Page 97 - ExtendSim User Guide
P. 97

Tutorial 71
Simplifying the model
Specifying input variables
Open the Equation block dialog.
In the Input Variables table at the left of the dialog, note that by default Connec- tor 0 is selected from the popup menu in the Variable Type column. This is the option you want, because the equation will get its values from the top input connector. To give the input a more rel- evant name:
Type Contents in the Variable Name field to the right of Connector 0.
Specifying output variables
In the Output Variables (results) table at
the right of the dialog, note that by default
Connector 0 is selected from the popup
menu in the Variable Type column. This indicates that the results of the equation will be sent to the top output connector, which is the option you want for this example. To give the output a more relevant name:
Type Overflow as the Variable Name.
Entering the equation
Click the Open Equation Editor button, delete the default equation, and enter the following code and comments. (You can edit the equation in the equation pane, but the Equation Edi- tor window has advantages such as code completion, syntax colorization, brace matching, and tab support):
       real reservoirDepth; // define a new variable as a real number
       reservoirDepth = 50.0; // set its value
       if (contents >= reservoirDepth) // if contents is >= depth...
         overflow = contents - reservoirDepth; // then calculate outflow.
       else
         overflow = 0.0;    // If the contents is too low, outflow = 0.
☞ Comments, which are preceded by //, are optional but helpful for documentation.
Equation block dialog
Continuous


































































































   95   96   97   98   99