Step 4: Adding defined values and independent events

 

A defined value is calculated only at the start of a model run, or in response to the actions of an event. This means that they are very useful for holding values which do not change very often, or which change only in a discontinuous manner.

We shall use a defined value to hold the discharge level which is changed by an event.

ModelMaker provides two types of event to cater for discontinuous models - independent and component events; events can adjust model component values.

Let's assume that the pollutant discharge rate in our model follows a regular pattern: every week it switches between 25 kgd-1 and 10 kgd-1. To model this behavior we will replace the variable Discharge with a defined value (also called Discharge) and an independent event.

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

  • Select the Discharge variable and press the Delete key
Discharge and the influences connecting it to Lake1 and Lake2 are deleted.
  • Add a defined value, D1
  • Double click D1 to open its definition dialog box
  • Enter Discharge in the Symbol edit box and 25 in the Equation edit box
  • Click OK
  • Add an independent event, E1
  • Insert three new influences between Discharge and Lake1, Discharge and E1, and E1 and Discharge
Independent events are triggered at pre-determined values of the independent variable. Such triggers can be periodic or non-periodic.
  • Double click E1 to open its definition dialog box
  • In the Definition tab, enter Switch in the Symbol edit box, set Initial Status to Active and set Event Class to Reactivate
  • Select the Triggers tab
  • The Triggers tab defines when the event will be triggered.
    • Select Periodic Trigger
    • Enter 7 in the Period edit box and 7 in the Starting At edit box
    • Select the Actions tab
    The Actions tab defines what will happen when the event is triggered. We want to say:

    If the value of Discharge is 25
    Set Discharge to 10
    Otherwise
    Set Discharge to 25


    To define this action, we can use the if…else statement.
    • Define the action as shown:

    Everything to the right of a double slash '//' is a comment and is ignored by ModelMaker.
    • Click OK to close the dialog

    This completes the definition of the independent event. Re-running the model results in a zigzag pattern of pollutant discharge as the initial dumping fades away.

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

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