Flows

A flow transports a material from one stock to another. As a designer, you must enter the rate of the flow by specifying both the magnitude of the flow and the time period over which that magnitude operates. So, for instance, in our river example the magnitude of the flow could be a million gallons of water and the period over which it flows could be one day: in effect a million gallons per day. Flows may connect two stocks together. Alternatively, a flow can lack a start or an end. In this case, the unconnected end acts as an unlimited stock of material.

As with the initial value of a stock, the rate of a flow can be a simple number or a more complex equation. The equation can be based on many factors including the values of the stocks the flow is connected to and the current time. For example, if we had a stock representing the population of rabbits (called Rabbit Population), we could make the flow into the stock be the number of rabbits times a constant birthrate. This equation would result in geometric growth in the rabbit population:

[Rabbit Population]*0.01

Alternatively, if we had a flow representing rainfall, we could set the flow rate to be based on the current time of the year. Rainfall over the course of a year can be approximated using a sinusoidal function like the following:

 sin(2*pi*(weeks+10)/52)*30+35

Where weeks is a Simgua function that automatically takes on the value of the current simulation time measured in weeks, pi is the constant 3.14159…, and sin is another Simgua function that applies the trigonometric sine function to an angle inputted using radians.

A flow can be restricted to positive flows only.  In this case, the flow will only be applied if the calculated magnitude of the flow rate is positive. This restriction would be applicable for both our rabbit and rain examples. We know that neither of the flows should ever be negative (you cannot have negative births or negative rain) so we might want to set them to only allow positive flows just to insure that such an impossible event never happens (though it never will in any event given the equations we specified). Additionally, a flow can be designated as time-independent. Such a flow’s magnitude is not scaled by the time step of the model. This can prove useful in the design of flow splitters or aggregators (such as a fork in a river).

Every flow has two special properties that may be referenced in its equations. The first is Alpha which refers to the stock at the start of the flow. The second is Omega which refers to the stock at the end of the flow. In your equations you may use either of these instead of needing to know the actual names of a flow’s start or end stocks. For instance if you wanted 5% of the water from a lake to evaporate out of it each time period, you could use the following statement for the rate of a flow whose beginning was the lake:

[Alpha]*0.05

There is one very powerful feature of flows we have not yet covered. Almost all of the time you will want the amount of material withdrawn from the flow’s Alpha to be the same as the amount deposited into the flow’s Omega. For some specific applications however, you will want these two quantities to differ. For instance if your flow is to represent a pipe, the outflow should have a slightly lower hydraulic head (or energy) due to friction losses within the pipe. You can implement this type of case using what is known as a Transformer flow with one inflow rate, and a separate outflow rate with a slightly reduced hydraulic head. It is possible to reproduce features like this without transformers, but transformers make the task much easier.

When using transformers, you must specify two separate rate equations, one for the inflow to the flow and one for the outflow. Additionally, one of these equations is called the Primary equation and the other is called the Secondary equation and is derived from the primary. The primary rate is calculated before the secondary rate and the secondary rate is passed a variable called Primary that refers to the primary rate and may be used in the equation. For instance, the following could be used as the outflow equation to simulate 10% head-loss in a pipe:

Dim out as Material = Primary

out.head = out.head * 0.9

Return out

Back to the overview of all primitives.