@@ -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 (test depreciated variants)
3846 mod .setParameters ("e=1.234" )
@@ -62,7 +70,11 @@ def test_setParameters():
6270def test_setSimulationOptions ():
6371 omc = OMPython .OMCSessionZMQ ()
6472 model_path = omc .sendExpression ("getInstallationDirectoryPath()" ) + "/share/doc/omc/testmodels/"
65- mod = OMPython .ModelicaSystem (fileName = model_path + "BouncingBall.mo" , modelName = "BouncingBall" )
73+ mod = OMPython .ModelicaSystem ()
74+ mod .model_definition (
75+ file = model_path + "BouncingBall.mo" ,
76+ model = "BouncingBall" ,
77+ )
6678
6779 # method 1
6880 mod .setSimulationOptions (stopTime = 1.234 )
@@ -95,7 +107,11 @@ def test_relative_path(model_firstorder):
95107 model_relative = str (model_file )
96108 assert "/" not in model_relative
97109
98- mod = OMPython .ModelicaSystem (fileName = model_relative , modelName = "M" )
110+ mod = OMPython .ModelicaSystem ()
111+ mod .model_definition (
112+ file = model_relative ,
113+ model = "M" ,
114+ )
99115 assert float (mod .getParameters ("a" )[0 ]) == - 1
100116 finally :
101117 model_file .unlink () # clean up the temporary file
@@ -105,17 +121,25 @@ def test_customBuildDirectory(tmp_path, model_firstorder):
105121 filePath = model_firstorder .as_posix ()
106122 tmpdir = tmp_path / "tmpdir1"
107123 tmpdir .mkdir ()
108- m = OMPython .ModelicaSystem (filePath , "M" , customBuildDirectory = tmpdir )
109- assert pathlib .Path (m .getWorkDirectory ()).resolve () == tmpdir .resolve ()
124+ mod = OMPython .ModelicaSystem (customBuildDirectory = tmpdir )
125+ mod .model_definition (
126+ file = filePath ,
127+ model = "M" ,
128+ )
129+ assert pathlib .Path (mod .getWorkDirectory ()).resolve () == tmpdir .resolve ()
110130 result_file = tmpdir / "a.mat"
111131 assert not result_file .exists ()
112- m .simulate (resultfile = "a.mat" )
132+ mod .simulate (resultfile = "a.mat" )
113133 assert result_file .is_file ()
114134
115135
116136def test_getSolutions (model_firstorder ):
117137 filePath = model_firstorder .as_posix ()
118- mod = OMPython .ModelicaSystem (filePath , "M" )
138+ mod = OMPython .ModelicaSystem ()
139+ mod .model_definition (
140+ file = filePath ,
141+ model = "M" ,
142+ )
119143 x0 = 1
120144 a = - 1
121145 tau = - 1 / a
@@ -154,7 +178,11 @@ def test_getters(tmp_path):
154178y = der(x);
155179end M_getters;
156180""" )
157- mod = OMPython .ModelicaSystem (fileName = model_file .as_posix (), modelName = "M_getters" )
181+ mod = OMPython .ModelicaSystem ()
182+ mod .model_definition (
183+ file = model_file .as_posix (),
184+ model = "M_getters" ,
185+ )
158186
159187 q = mod .getQuantities ()
160188 assert isinstance (q , list )
@@ -346,7 +374,11 @@ def test_simulate_inputs(tmp_path):
346374y = x;
347375end M_input;
348376""" )
349- mod = OMPython .ModelicaSystem (fileName = model_file .as_posix (), modelName = "M_input" )
377+ mod = OMPython .ModelicaSystem ()
378+ mod .model_definition (
379+ file = model_file .as_posix (),
380+ model = "M_input" ,
381+ )
350382
351383 simOptions = {"stopTime" : 1.0 }
352384 mod .setSimulationOptions (** simOptions )
0 commit comments