@@ -22,17 +22,25 @@ def model_firstorder(tmp_path):
2222def test_ModelicaSystem_loop (model_firstorder ):
2323 def worker ():
2424 filePath = model_firstorder .as_posix ()
25- m = OMPython .ModelicaSystem (filePath , "M" )
26- m .simulate ()
27- m .convertMo2Fmu (fmuType = "me" )
25+ mod = OMPython .ModelicaSystem ()
26+ mod .model_definition (
27+ file = filePath ,
28+ model = "M" ,
29+ )
30+ mod .simulate ()
31+ mod .convertMo2Fmu (fmuType = "me" )
2832 for _ in range (10 ):
2933 worker ()
3034
3135
3236def test_setParameters ():
3337 omc = OMPython .OMCSessionZMQ ()
3438 model_path = omc .sendExpression ("getInstallationDirectoryPath()" ) + "/share/doc/omc/testmodels/"
35- mod = OMPython .ModelicaSystem (model_path + "BouncingBall.mo" , "BouncingBall" )
39+ mod = OMPython .ModelicaSystem ()
40+ mod .model_definition (
41+ file = model_path + "BouncingBall.mo" ,
42+ model = "BouncingBall" ,
43+ )
3644
3745 # method 1
3846 mod .setParameters (pvals = {"e" : 1.234 })
@@ -61,7 +69,11 @@ def test_setParameters():
6169def test_setSimulationOptions ():
6270 omc = OMPython .OMCSessionZMQ ()
6371 model_path = omc .sendExpression ("getInstallationDirectoryPath()" ) + "/share/doc/omc/testmodels/"
64- mod = OMPython .ModelicaSystem (fileName = model_path + "BouncingBall.mo" , modelName = "BouncingBall" )
72+ mod = OMPython .ModelicaSystem ()
73+ mod .model_definition (
74+ file = model_path + "BouncingBall.mo" ,
75+ model = "BouncingBall" ,
76+ )
6577
6678 # method 1
6779 mod .setSimulationOptions (simOptions = {"stopTime" : 1.234 })
@@ -94,7 +106,11 @@ def test_relative_path(model_firstorder):
94106 model_relative = str (model_file )
95107 assert "/" not in model_relative
96108
97- mod = OMPython .ModelicaSystem (fileName = model_relative , modelName = "M" )
109+ mod = OMPython .ModelicaSystem ()
110+ mod .model_definition (
111+ file = model_relative ,
112+ model = "M" ,
113+ )
98114 assert float (mod .getParameters ("a" )[0 ]) == - 1
99115 finally :
100116 model_file .unlink () # clean up the temporary file
@@ -104,17 +120,25 @@ def test_customBuildDirectory(tmp_path, model_firstorder):
104120 filePath = model_firstorder .as_posix ()
105121 tmpdir = tmp_path / "tmpdir1"
106122 tmpdir .mkdir ()
107- m = OMPython .ModelicaSystem (filePath , "M" , customBuildDirectory = tmpdir )
108- assert m .getWorkDirectory ().resolve () == tmpdir .resolve ()
123+ mod = OMPython .ModelicaSystem (customBuildDirectory = tmpdir )
124+ mod .model_definition (
125+ file = filePath ,
126+ model = "M" ,
127+ )
128+ assert mod .getWorkDirectory ().resolve () == tmpdir .resolve ()
109129 result_file = tmpdir / "a.mat"
110130 assert not result_file .exists ()
111- m .simulate (resultfile = "a.mat" )
131+ mod .simulate (resultfile = "a.mat" )
112132 assert result_file .is_file ()
113133
114134
115135def test_getSolutions (model_firstorder ):
116136 filePath = model_firstorder .as_posix ()
117- mod = OMPython .ModelicaSystem (filePath , "M" )
137+ mod = OMPython .ModelicaSystem ()
138+ mod .model_definition (
139+ file = filePath ,
140+ model = "M" ,
141+ )
118142 x0 = 1
119143 a = - 1
120144 tau = - 1 / a
@@ -151,7 +175,11 @@ def test_getters(tmp_path):
151175y = der(x);
152176end M_getters;
153177""" )
154- mod = OMPython .ModelicaSystem (fileName = model_file .as_posix (), modelName = "M_getters" )
178+ mod = OMPython .ModelicaSystem ()
179+ mod .model_definition (
180+ file = model_file .as_posix (),
181+ model = "M_getters" ,
182+ )
155183
156184 q = mod .getQuantities ()
157185 assert isinstance (q , list )
@@ -343,7 +371,11 @@ def test_simulate_inputs(tmp_path):
343371y = x;
344372end M_input;
345373""" )
346- mod = OMPython .ModelicaSystem (fileName = model_file .as_posix (), modelName = "M_input" )
374+ mod = OMPython .ModelicaSystem ()
375+ mod .model_definition (
376+ file = model_file .as_posix (),
377+ model = "M_input" ,
378+ )
347379
348380 mod .setSimulationOptions (simOptions = {"stopTime" : 1.0 })
349381
0 commit comments