In the software, the equation structure underlying the model diagram is of vital importance. The equations created behind the scenes as you hook together stocks and flows are known as "Finite Difference Equations." The equations window of the cooling model, for example, would yield a set of equations that look like the ones below.
Temperature(t) = Temperature(t-dt) + (-Cooling)*dt
INIT Temperature = 100
Cooling = Temperature * Constant
Constant = 0.5
In a model, each stock equation (in this case, the equation for Temperature) is a finite difference equation. Conceptually, solving finite difference equations is straightforward. It involves a two step initialization phase, and a three step iterative evaluation phase:
Step 1. Create a list of all equations in required order of evaluation.
Step 2. Calculate initial values for all stocks, flows and converters (in order of evaluation).
Step 1. Estimate the change in stocks over the interval DT. Calculate new values for stocks based on this estimate.
Step 2. Use new values of stocks to calculate new values for flows and converters.
Step 3. Update simulation time by an increment of DT. Stop iterating when Time >= simulation To Time.
Step 1 of the iteration phase is a critical one: How does one estimate the change in the value of stocks over the interval DT? The software provides three algorithms for doing this estimation - Euler's, 2nd-order Runge-Kutta, and 4th-order Runge-Kutta. (To change the integration method, open the Run Specs... dialog under the Run menu.) We'll deal with each in turn.