You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The object constructor requires a minimum of 2 input arguments which are strings, and may need a third string input argument.
67
+
68
+
- The first input argument must be a string with the file name of the Modelica code, with Modelica file extension ".mo"
69
+
If the Modelica file is not in the current directory of Python, then the file path must also be included
70
+
71
+
- The second input argument must be a string with the name of the Modelica model
72
+
including the namespace if the model is wrapped within a Modelica package
73
+
74
+
- A third input argument is used if the Modelica model builds on other Modelica code, e.g. the Modelica Standard Library.
75
+
76
+
Standard get methods API
77
+
~~~~~~~~~~~~~~~~~~~~~~~~~
78
+
79
+
>>> mod.getQuantities()
80
+
>>> mod.getContinuous()
81
+
>>> mod.getInputs()
82
+
>>> mod.getOutputs()
83
+
>>> mod.getParameters()
84
+
>>> mod.getSimulationOptions()
85
+
86
+
Two calling possibilities are accepted using getXXX() where "XXX" can be any of the above functions (eg:) getParameters().
87
+
88
+
- getXXX() without input argument, returns a dictionary with names as keys and values as values.
89
+
- getXXX(S), where S is a sequence of strings of names, returns a tuple of values for the specified names.
90
+
91
+
92
+
Standard set methods API
93
+
~~~~~~~~~~~~~~~~~~~~~~~~~
94
+
95
+
>>> mod.setInputs()
96
+
>>> mod.setParameters()
97
+
>>> mod.setSimulationOptions()
98
+
99
+
Two calling possibilities are accepted using setXXXs(),where "XXX" can be any of above functions.
100
+
101
+
- setXXX(k) with K being a sequence of keyword assignments of type quantity name = value Here, the quantity name could be
102
+
a parameter name (i.e., not a string), an input name, etc.
103
+
- setXXXs(**D), with D being a dictionary with quantity names as keywords and values as described with the alternative
104
+
input argument K.
105
+
106
+
Example usage of Above API
107
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
108
+
An example of how to get parameter names and change the value of parameters using set methods and finally simulate the "BouncingBall.mo" model is given below.
109
+
110
+
>>> mod.getParameters()
111
+
{'c': 0.9, 'radius': 0.1}
112
+
113
+
>>> mod.setParameters(radius=14,c=0.5) //setting parameter value using first option
114
+
>>> mod.setParameters(**{"radius":14,"c":0.5}) // setting parameter value using second option
115
+
116
+
To check whether new values are updated to model , we can again query the getParameters().
117
+
118
+
>>> mod.getParameters()
119
+
{'c': 0.5, 'radius': 14}
120
+
121
+
And then finally we can simulate the model using.
122
+
123
+
>>> mod.simulate()
124
+
125
+
Test Commands using old OMPython features
126
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57
127
58
128
To test the command outputs, simply create an OMCSession object by
59
129
importing from the OMPython library within Python interepreter. The
0 commit comments