Step 3: Defining conditional components

 

Up to this point, all the components we have created have had only one equation, which has been evaluated throughout the model run. This is fine for most continuous models, but often things change as the model progresses.

For our model, for example, let's assume that when the level of pollutant in Lake2 reaches 250 units, the discharge in the lake is reduced to a value defined as Discharge = 10*sin(t*π/365).

To deal with this, we can make Discharge a conditional component. Instead of having a single equation, a conditional component has a list of conditions with associated equations. ModelMaker evaluates each condition in turn until it finds a condition which is true and uses the associated equation to evaluate the component.

To follow this example load the model "tutor2.mod"

In our new model, the value of Discharge will be influenced by the value of Lake2, so we must insert a new influence between Lake2 and Discharge.

  • Add an influence from Lake2 to Discharge
Now we can define Discharge as a conditional component.
  • Double click Discharge to open its definition dialog box
  • Click Conditional…
The Conditional Variable Definition dialog box opens. Initially, the conditional component is defined with a single default condition. Default or empty conditions are always defined as true.
  • Click New
The Conditional Equation dialog box opens.
  • Enter Lake2>250 in the Condition edit box and 10*sin(t*pi/365) in the Equation edit box
  • Click OK
The new conditional equation is inserted into the Condition and Equation list boxes.
  • Click OK to close the definition dialog box

Select the graph of Lake1 and Lake2 and re-run the model. The graph now shows the effect of switching the rate of discharge as the amount of pollutant in Lake2 changes. Create a new graph of the value of Discharge to see how the conditional component changes during the model run.

The completed model for this step is "tutor3.mod"

Return to the main tutorial page
  
ModelKinetix is a trade name of FamilyGenetix, managed by AP Benson.
© FamilyGenetix 2001-2003