24.05.2014 Views

pdf: 600KB - Potsdam Institute for Climate Impact Research

pdf: 600KB - Potsdam Institute for Climate Impact Research

pdf: 600KB - Potsdam Institute for Climate Impact Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

27<br />

6.4 Representation of the model in a simulation language<br />

A simulation language enables the mathematical relationships of a model to be expressed without<br />

having to program the procedures <strong>for</strong> numerical integration, input/output, etc.<br />

There are simulation languages <strong>for</strong> a variety of modelling approaches. We will restrict our<br />

attention here to those designed <strong>for</strong> handling systems of ordinary differential/difference equations,<br />

since they are by far the most widely used in the ecological field.<br />

Box 6.4 shows the model implemented using ACSL, an industrial-strength simulation language<br />

used in some ecosystem modelling projects (e.g. Thornley, 1998).<br />

Box 6.4 Implementation of the model in ACSL<br />

PROGRAM Simple grass-water model<br />

CINTERVAL cint = 0.1<br />

NSTEPS nstep = 1<br />

CONSTANT rain = 100, k1 = 0.1, k2 = 0.1<br />

CONSTANT grass_init = 100, water_init = 100<br />

growth = k1*grass*water<br />

transpiration = k2*grass*water<br />

grass_rate_of_change = growth<br />

water_rate_of_change = rain-transpiration<br />

grass = INTEG(grass_rate_of_change, grass_init)<br />

water = INTEG(water_rate_of_change, water_init)<br />

TERMT(t .GE. 20)<br />

END<br />

We note strong similarities with both the representation of the model in terms of differential<br />

equations (Box 6.2), and indeed with parts of the implementation of the model as a computer<br />

program (Box 6.3). The simulation language enables one to concentrate on expressing the<br />

mathematical relationships in the model, and leave the procedural bits - such as how to undertake<br />

numerical integration - to the software package.<br />

The programming approach (Section 6.3) is an example of a procedural approach to modelling.<br />

The use of a simulation language, on the other hand, exemplifies a declarative approach, in which<br />

we simply express the mathematical relationships that apply, and leave it up to some modellingaware<br />

interpreter to process these in the correct way. You may well be thinking that there is not a<br />

lot of difference between these: after all, the model equations are expressed in identical syntax,<br />

and both require learning some <strong>for</strong>m of text-based computer language. However, there are<br />

several key differences:<br />

In the procedural program, the statements must be read in order, starting from the first. In the<br />

simulation language, the statements can be entered in any order: they are sorted into the correct<br />

order <strong>for</strong> evaluation by the simulation language interpreter.<br />

In the procedural computer program, each equation is actually an instruction, called an<br />

'assignment statement'. The correct way of reading it is: Work out the expression on the right of<br />

the equals sign, then assign this value to the variable on the left. In the simulation language, on<br />

the other hand, the equation is a statement of the mathematical equality between the left-hand and<br />

right-hand sides. One consequence of this is that it is not an error in the programming language<br />

to have two separate statements with the same variable on the left-hand side, though this would be<br />

an error in the simulation language.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!