| |
Adding compartments
We shall start the model by adding compartments to the Diagram view (Main). A compartment is a container in a model and is defined in terms of what is entering and leaving it. Compartments appear in model diagrams as rectangular boxes.
- Click the Compartment icon on the toolbar

- Add a compartment (C1) by moving the cursor to the desired location in the model diagram and clicking with the Left Mouse Button (LMB)
- Repeat the above steps to add two more compartments (C2 and C3)
The three compartments are filled with blue lines, indicating that the compartment equations are undefined.
The properties of a model component are defined in its component definition dialog box.
- Double click C1 with the LMB to open its definition dialog box
- Enter Lake1 in the Symbol edit box and 1000 in the Initial Value edit box
- Click OK to close the dialog
- Double click C2
- Enter Lake2 in the Symbol edit box
- Click OK
- Repeat for C3, entering Sea in the Symbol edit box
Adding flows
Flows represent the transport of a quantity from one compartment to another, and are used in conjunction with compartments to build up systems of differential equations.
We shall add two flows to our model to represent the river and the estuary.
- Click the Flow icon on the toolbar

- Click Lake1 with the LMB followed by Lake2
- Repeat to create a flow between Lake2 and Sea
The equations of the compartments are automatically updated to reflect the presence of the flow. Thus, the blue shading of the compartments is removed, but now the flow is shaded red to indicate an equation error. This is because flow is defined as being proportional to the value of its source compartment:
F1 = ? * Lake1
F2 = ? * Lake2
? represents an as yet unknown value. We shall define ? as a parameter and then complete the flow definition.
Adding parameters
Parameters represent constant values within a model. Their values cannot be changed from within a model but can be adjusted during certain model analysis procedures.
Parameters are added to a model from the Parameters view.
- Click the Parameters icon

The Parameters view is created and activated. This view is divided into six columns - Name, Value, Optimize, Minimize, Monte Carlo and Dist Type.
- Click the Parameter icon on the Parameters toolbar

A new parameter, p1, is added to the Parameters view.
- Repeat to add a second parameter, p2
- Double click p1 to open its definition dialog
- Enter river_rate in the Symbol edit box and 0.1 in the Value edit box
- Click OK
- Repeat for p2, entering estuary_rate and 0.05 in the Symbol and Value edit boxes
Now we can complete the flow definition:
- Activate the Diagram view (Main) by selecting it in the Model Explorer

- Double click F1 to open its definition dialog box
- Enter River in the Symbol edit box and river_rate * Lake1 in the Equation edit box (i.e. select ? and double click river_rate in the Available Components list box)
- Click OK
- Repeat for F2, entering Estuary in the Symbol edit box and estuary_rate * Lake2 in the Equation edit box
Once the flows have been updated, the model diagram should not contain any blue or red shading, indicating that ModelMaker can find no errors in the model definition and that the model is ready to run.
Running your model
The model is now ready to run. This is the process of solving the equations over the desired range of the model's independent variable. By default, ModelMaker's independent variable is time, t. All equations are solved over a range of values for t, and all equations are written with respect to t.
- Click the Integrate icon

The Run dialog box opens. ModelMaker runs a model from t = 0 to t = 100 by default, and calculates values 100 times during the model run.
The model is run with the default options. When the calculations are complete a message appears stating how long the calculation has taken. This simple model should only take a fraction of a second. Click OK to dismiss this dialog.
Displaying tables
Tables provide access to the values calculated by ModelMaker during a model run. We shall create a table of Lake1 and Lake2 against time.
- Click the Table icon

The Table Selection dialog box opens.
- Select Lake1 and Lake2 in the Components list box (i.e. use or to make multiple component selections)
- Click >> to move Lake1 and Lake2 into the Selected list box
The independent variable, t, is selected by default.
The Results view is created and activated with a sub-view Table1 which contains your model's data. Tables can be customized using the Table Series dialog box. To open this dialog:
- Click the Series icon on the Tables toolbar

This dialog is used to change column titles and apply different numeric formats. Click OK to close the dialog.
Displaying graphs
Graphs represent a useful way of examining data trends. We shall plot a graph of Lake1 and Lake2 against time.
- Click the Graph icon

The Graph Selection dialog box opens.
- Select Lake1 and Lake2 in the Components list box
- Click >> to move Lake1 and Lake2 into the Vertical Axis list box
By default, ModelMaker plots the graph against the independent variable.
A new graph is added to the Results view as Graph1. Many of the graph's properties can be customized in the Graph Series Options, Graph Attributes Configuration, X-Axis Configuration and Y-Axis Configuration dialog boxes. These dialogs can all be accessed from the Graph toolbar by clicking the Series, Attributes, X-Axis and Y-Axis icons respectively.
The completed model for this step is "tutor1.mod"
Return to the main tutorial page
|