You are here

Cycles

Many environmental factors vary on a daily or an annual basis: e.g. temperature, radiation, evapotranspiration. It is desirable to be able to capture this if you want to capture the effect of the factor on the behaviour of your modelled system, and if the time-scale is appropriate.

Let’s assume that your time unit is the month (i.e. all your rates are expressed per month, and that simulation time is shown in month).

The function fmod is used to calculate remainders when doing division. For example, dividing 28 by 12, gives two with a remainder of four. This gives us a mathematical means to create a cycle. Dividing the time function by 12 and looking only at the remainder will give a series of numbers from zero to 11 in sequence again and again. We can use these as the month number (0=January, 1=February, 2=March and so on).

To return to the example used in illustrating the sketch graph, rainfall patterns repeat year after year. So we can modify the expression used in the equation for the sketch graph to use the fmod function as well as the time function. This looks like this: “graph(fmod(time(),12))”

In fact there are now easier ways to get data into a Simile model and have it repeat after a certain period of time. The sketch graph dialogue includes a pulldown menu with the caption "Out of range:" which gives a series of options for how to pick a value when the input value is outside the range covered by the graph. The options are:

  • Truncate, which means return the value at the nearest side of the graph,
  • Extrapolate, which means extend the last (or first) section of the sketch graph in a straight line to the required datapoint, or
  • Wraparound, which means that the range of values given by the graph repeats after the given input range to cover any input value.

Using the Wraparound option has the same effect as placing an "fmod()" function around the expression supplied to the graph function.