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
For each OMJulia session a temporary work directory is created and the results are published in that working directory, Inorder to get the workdirectory the users can
84
+
use the following API
85
+
86
+
>>> getWorkDirectory(mod)
87
+
"C:/Users/arupa54/AppData/Local/Temp/jl_5pbewl"
88
+
89
+
BuildModel
90
+
~~~~~~~~~~
91
+
The buildModel API can be used after ModelicaSystem(), in case the model needs to be updated or additional simulationflags needs to be set using sendExpression()
92
+
93
+
>>> buildModel(mod)
79
94
80
95
81
96
Standard get methods
@@ -99,45 +114,56 @@ Three calling possibilities are accepted using getXXX() where "XXX" can be any o
99
114
Usage of getMethods
100
115
~~~~~~~~~~~~~~~~~~~
101
116
102
-
>>> mod.getQuantities() // method-1, list of all variables from xml file
117
+
>>> getQuantities(mod) // method-1, list of all variables from xml file
>>> mod.getSolutions(["time","height"]) // method-2, returnlist of array
159
+
>>> getSolutions(mod,["time","height"]) //returnlist of array
160
+
161
+
>>> getSolutions(mod,resultfile="c:/tmpbouncingBall.mat") // method-2 returns list of simulation variables for which results are available , the resulfile location is provided by user
An example of how to do advanced simulation to set parameter values using set methods and finally simulate the "BouncingBall.mo" model is given below .
171
197
172
-
>>> mod.getParameters()
198
+
>>> getParameters(mod)
173
199
{"c": "0.9", "radius": "0.1"}
174
200
175
-
>>> mod.setParameters(["radius=14","c=0.5"])
201
+
>>> setParameters(mod,["radius=14","c=0.5"])
176
202
177
203
To check whether new values are updated to model , we can again query the getParameters().
178
204
179
-
>>> mod.getParameters()
205
+
>>> getParameters(mod)
180
206
{"c": "0.5", "radius": "14"}
181
207
182
208
Similary we can also use setInputs() to set a value for the inputs during various time interval can also be done using the following.
183
209
184
-
>>> mod.setInputs("cAi=1")
210
+
>>> setInputs(mod,"cAi=1")
211
+
212
+
And then finally we can simulate the model using, The simulate() API can be used in two methods
213
+
1) without any arguments
214
+
2) resultfile names provided by user (only filename is allowed and not the location)
185
215
186
-
And then finally we can simulate the model using.
216
+
>>> simulate(mod) // method-1 default result file name will be used
217
+
>>> simulate(mod,resultfile="tmpbouncingBall.mat") // method-2 resultfile name provided by users
187
218
188
-
>>> mod.simulate()
189
219
190
220
Linearization
191
221
~~~~~~~~~~~~~
@@ -201,21 +231,21 @@ The following methods are available for linearization of a modelica model
The buildModel API can be used after ModelicaSystem(), in case the model needs to be updated or additional simulationflags needs to be set using sendExpression()
Copy file name to clipboardExpand all lines: doc/UsersGuide/source/ompython.rst
+24-3Lines changed: 24 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -184,6 +184,13 @@ The object constructor requires a minimum of 2 input arguments which are strings
184
184
- By default ModelicaSystem uses OMCSessionZMQ but if you want to use OMCSession
185
185
then pass the argument `useCorba=True` to the constructor.
186
186
187
+
BuildModel
188
+
~~~~~~~~~~
189
+
The buildModel API can be used after ModelicaSystem(), in case the model needs to be updated or additional simulationflags needs to be set using sendExpression()
>>> mod.getSolutions("time","height") // method-2, returnlist of numpy arrays
256
+
>>> mod.getSolutions("time","height") //returnlist of numpy arrays
257
+
258
+
>>> mod.getSolutions(resultfile="c:/tmpbouncingBall.mat") // method-2 returns list of simulation variables for which results are available , the resulfile location is provided by user
259
+
260
+
>>> mod.getSolutions(["time","height"],resultfile="c:/tmpbouncingBall.mat") //returnlist of array
261
+
244
262
245
263
Standard set methods
246
264
~~~~~~~~~~~~~~~~~~~~
@@ -279,9 +297,12 @@ To check whether new values are updated to model , we can again query the getPar
279
297
>>> mod.getParameters()
280
298
{'c': 0.5, 'radius': 14}
281
299
282
-
And then finally we can simulate the model using.
300
+
And then finally we can simulate the model using, The simulate() API can be used in two methods
301
+
1) without any arguments
302
+
2) resultfile names provided by user (only filename is allowed and not the location)
283
303
284
-
>>> mod.simulate()
304
+
>>> mod.simulate() // method-1 default result file name will be used
305
+
>>> mod.simulate(resultfile="tmpbouncingBall.mat") // method-2 resultfile name provided by users
0 commit comments