Simulate a Model Using EKL Scripting
You can simulate Modelica models using Enterprise Knowledge
Language (EKL) scripts. You use the global function
SimulateBehaviorModel
.
In this task, you create an action to simulate the model, and you test that the simulation was performed.
- From the Compass, click 3D Modeling Apps , and select Engineering Rules Capture.
-
From the
action bar,
click
Action
.
For full information about actions, see Engineering Rules Capture Users Guide: Working with Actions: Creating an Action.
-
In the
Action Editor, do the following:
- Click the text pane to enter it.
- Press Enter to go to a new line.
-
From the
tree,
double-click
MyModelTest.
Important: Use double-click here, avoid entering this part of the line. `MyTestLib\MyModelTest`
is inserted in the text pane. - Click Language Browser.
-
In the Language Browser, the
Search field, start entering
simulate.
The hits are displayed dynamically as you type.
- You can see that three functions with the same name SimulateBehaviorModel are available.
-
Click each function to display the documentation window to
decide which function to use, depending on if you want to simulate a functional
behavior, a logical behavior, or a free-standing Modelica model.
In this scenario, you simulate a free-standing Modelica model.
-
Double-click the search result
SimulateBehaviorModel that is specified
for "all Modelica models" in the documentation window.
->SimulateBehaviorModel(,)
is added in the Action Editor pane. -
Click in the bracket of the above function and enter the start time
and stop time, with comma sign between them.
Use the start time
0
and the stop time6
in this scenario.Note: You can select to use the start time and stop time defined for the model in the simulation setup in Dymola Behavior Modeling. See General Tab.Important: To select the start time and stop time defined in the simulation setup, you must manually remove the comma sign in the bracket of the function. The full text for this task is now:`MyTestLib\MyModelTest`->SimulateBehaviorModel(0,6)
- Click OK.
The result is:- The action is created.
- In the tree, under the Relations.1 node, the action is displayed with an icon .
- In the tree, under the Relations.1 node, right-click Action.1 and select Action.1 object > Run.
-
In the
Insert Object dialog box, click
OK.
The result is:
- The action is executed. MyModelTest is simulated with start time 0 and stop time 6.
- The Variable Browser appears to display the result of the simulation.
- To check the result, in the Variable Browser, right-click a signal and select Add to Plot > New Plot.
- From the Compass, click 3D Modeling Apps , and select Behavior Modeling.
Note:
You can now edit and run the action directly without changing app. You can edit the action by double-clicking the action in the tree.