@@ -38,17 +38,25 @@ def model_firstorder(tmp_path, model_firstorder_content):
3838def test_ModelicaSystem_loop (model_firstorder ):
3939 def worker ():
4040 filePath = model_firstorder .as_posix ()
41- m = OMPython .ModelicaSystem (filePath , "M" )
42- m .simulate ()
43- m .convertMo2Fmu (fmuType = "me" )
41+ mod = OMPython .ModelicaSystem ()
42+ mod .model_definition (
43+ file = filePath ,
44+ model = "M" ,
45+ )
46+ mod .simulate ()
47+ mod .convertMo2Fmu (fmuType = "me" )
4448 for _ in range (10 ):
4549 worker ()
4650
4751
4852def test_setParameters ():
4953 omc = OMPython .OMCSessionZMQ ()
5054 model_path = omc .sendExpression ("getInstallationDirectoryPath()" ) + "/share/doc/omc/testmodels/"
51- mod = OMPython .ModelicaSystem (model_path + "BouncingBall.mo" , "BouncingBall" )
55+ mod = OMPython .ModelicaSystem ()
56+ mod .model_definition (
57+ file = model_path + "BouncingBall.mo" ,
58+ model = "BouncingBall" ,
59+ )
5260
5361 # method 1 (test depreciated variants)
5462 mod .setParameters ("e=1.234" )
@@ -78,7 +86,11 @@ def test_setParameters():
7886def test_setSimulationOptions ():
7987 omc = OMPython .OMCSessionZMQ ()
8088 model_path = omc .sendExpression ("getInstallationDirectoryPath()" ) + "/share/doc/omc/testmodels/"
81- mod = OMPython .ModelicaSystem (fileName = model_path + "BouncingBall.mo" , modelName = "BouncingBall" )
89+ mod = OMPython .ModelicaSystem ()
90+ mod .model_definition (
91+ file = model_path + "BouncingBall.mo" ,
92+ model = "BouncingBall" ,
93+ )
8294
8395 # method 1
8496 mod .setSimulationOptions (stopTime = 1.234 )
@@ -111,7 +123,11 @@ def test_relative_path(model_firstorder):
111123 model_relative = str (model_file )
112124 assert "/" not in model_relative
113125
114- mod = OMPython .ModelicaSystem (fileName = model_relative , modelName = "M" )
126+ mod = OMPython .ModelicaSystem ()
127+ mod .model_definition (
128+ file = model_relative ,
129+ model = "M" ,
130+ )
115131 assert float (mod .getParameters ("a" )[0 ]) == - 1
116132 finally :
117133 model_file .unlink () # clean up the temporary file
@@ -121,11 +137,15 @@ def test_customBuildDirectory(tmp_path, model_firstorder):
121137 filePath = model_firstorder .as_posix ()
122138 tmpdir = tmp_path / "tmpdir1"
123139 tmpdir .mkdir ()
124- m = OMPython .ModelicaSystem (filePath , "M" , customBuildDirectory = tmpdir )
125- assert pathlib .Path (m .getWorkDirectory ()).resolve () == tmpdir .resolve ()
140+ mod = OMPython .ModelicaSystem (customBuildDirectory = tmpdir )
141+ mod .model_definition (
142+ file = filePath ,
143+ model = "M" ,
144+ )
145+ assert pathlib .Path (mod .getWorkDirectory ()).resolve () == tmpdir .resolve ()
126146 result_file = tmpdir / "a.mat"
127147 assert not result_file .exists ()
128- m .simulate (resultfile = "a.mat" )
148+ mod .simulate (resultfile = "a.mat" )
129149 assert result_file .is_file ()
130150
131151
@@ -150,7 +170,11 @@ def test_getSolutions_docker(model_firstorder_content):
150170
151171def test_getSolutions (model_firstorder ):
152172 filePath = model_firstorder .as_posix ()
153- mod = OMPython .ModelicaSystem (filePath , "M" )
173+ mod = OMPython .ModelicaSystem ()
174+ mod .model_definition (
175+ file = filePath ,
176+ model = "M" ,
177+ )
154178
155179 _run_getSolutions (mod )
156180
@@ -194,7 +218,11 @@ def test_getters(tmp_path):
194218y = der(x);
195219end M_getters;
196220""" )
197- mod = OMPython .ModelicaSystem (fileName = model_file .as_posix (), modelName = "M_getters" )
221+ mod = OMPython .ModelicaSystem ()
222+ mod .model_definition (
223+ file = model_file .as_posix (),
224+ model = "M_getters" ,
225+ )
198226
199227 q = mod .getQuantities ()
200228 assert isinstance (q , list )
@@ -386,7 +414,11 @@ def test_simulate_inputs(tmp_path):
386414y = x;
387415end M_input;
388416""" )
389- mod = OMPython .ModelicaSystem (fileName = model_file .as_posix (), modelName = "M_input" )
417+ mod = OMPython .ModelicaSystem ()
418+ mod .model_definition (
419+ file = model_file .as_posix (),
420+ model = "M_input" ,
421+ )
390422
391423 simOptions = {"stopTime" : 1.0 }
392424 mod .setSimulationOptions (** simOptions )
0 commit comments