Skip to content

Commit e766959

Browse files
authored
B001 ModelicaSystem split (#426)
* (B001) split ModelicaSystem [ModelicaSystem] split ModelicaSystem into ModelicaSystemABC and ModelicaSystem [ModelicaSystem] rename ModelicaSystem => ModelicaSystemOMC * add compatibility variable for ModelicaSystem [test_ModelicaSystemOMC] rename from ModelicaSystem and update [test_*] use ModelicaSystemOMC [ModelicaSystem*] fix last usages of ModelicaSystem() in comments & docstrings * chore: trigger CI
1 parent 5b05821 commit e766959

10 files changed

+716
-676
lines changed

OMPython/ModelicaSystem.py

Lines changed: 689 additions & 655 deletions
Large diffs are not rendered by default.

OMPython/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from OMPython.ModelicaSystem import (
1515
LinearizationResult,
1616
ModelicaSystem,
17+
ModelicaSystemOMC,
1718
ModelExecutionCmd,
1819
ModelicaSystemDoE,
1920
ModelicaSystemError,
@@ -43,6 +44,7 @@
4344
'ModelExecutionException',
4445

4546
'ModelicaSystem',
47+
'ModelicaSystemOMC',
4648
'ModelExecutionCmd',
4749
'ModelicaSystemDoE',
4850
'ModelicaSystemError',

tests/test_FMIExport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def test_CauerLowPassAnalog():
9-
mod = OMPython.ModelicaSystem()
9+
mod = OMPython.ModelicaSystemOMC()
1010
mod.model(
1111
model_name="Modelica.Electrical.Analog.Examples.CauerLowPassAnalog",
1212
libraries=["Modelica"],
@@ -20,7 +20,7 @@ def test_CauerLowPassAnalog():
2020

2121

2222
def test_DrumBoiler():
23-
mod = OMPython.ModelicaSystem()
23+
mod = OMPython.ModelicaSystemOMC()
2424
mod.model(
2525
model_name="Modelica.Fluid.Examples.DrumBoiler.DrumBoiler",
2626
libraries=["Modelica"],

tests/test_FMIImport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def model_firstorder(tmp_path):
2222

2323
def test_FMIImport(model_firstorder):
2424
# create model & simulate it
25-
mod1 = OMPython.ModelicaSystem()
25+
mod1 = OMPython.ModelicaSystemOMC()
2626
mod1.model(
2727
model_file=model_firstorder,
2828
model_name="M",
@@ -35,7 +35,7 @@ def test_FMIImport(model_firstorder):
3535

3636
# import FMU & check & simulate
3737
# TODO: why is '--allowNonStandardModelica=reinitInAlgorithms' needed? any example without this possible?
38-
mod2 = OMPython.ModelicaSystem(command_line_options=['--allowNonStandardModelica=reinitInAlgorithms'])
38+
mod2 = OMPython.ModelicaSystemOMC(command_line_options=['--allowNonStandardModelica=reinitInAlgorithms'])
3939
mo = mod2.convertFmu2Mo(fmu=fmu)
4040
assert os.path.exists(mo)
4141

tests/test_ModelicaSystemCmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def model_firstorder(tmp_path):
1818

1919
@pytest.fixture
2020
def mscmd_firstorder(model_firstorder):
21-
mod = OMPython.ModelicaSystem()
21+
mod = OMPython.ModelicaSystemOMC()
2222
mod.model(
2323
model_file=model_firstorder,
2424
model_name="M",

tests/test_ModelicaSystemDoE.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_ModelicaSystemDoE_local(tmp_path, model_doe, param_doe):
5555
tmpdir = tmp_path / 'DoE'
5656
tmpdir.mkdir(exist_ok=True)
5757

58-
mod = OMPython.ModelicaSystem()
58+
mod = OMPython.ModelicaSystemOMC()
5959
mod.model(
6060
model_file=model_doe,
6161
model_name="M",
@@ -78,7 +78,7 @@ def test_ModelicaSystemDoE_docker(tmp_path, model_doe, param_doe):
7878
omversion = omcs.sendExpression("getVersion()")
7979
assert isinstance(omversion, str) and omversion.startswith("OpenModelica")
8080

81-
mod = OMPython.ModelicaSystem(
81+
mod = OMPython.ModelicaSystemOMC(
8282
session=omcs,
8383
)
8484
mod.model(
@@ -102,7 +102,7 @@ def test_ModelicaSystemDoE_WSL(tmp_path, model_doe, param_doe):
102102
omversion = omcs.sendExpression("getVersion()")
103103
assert isinstance(omversion, str) and omversion.startswith("OpenModelica")
104104

105-
mod = OMPython.ModelicaSystem(
105+
mod = OMPython.ModelicaSystemOMC(
106106
session=omcs,
107107
)
108108
mod.model(
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def model_firstorder(tmp_path, model_firstorder_content):
4040

4141
def test_ModelicaSystem_loop(model_firstorder):
4242
def worker():
43-
mod = OMPython.ModelicaSystem()
43+
mod = OMPython.ModelicaSystemOMC()
4444
mod.model(
4545
model_file=model_firstorder,
4646
model_name="M",
@@ -56,7 +56,9 @@ def test_setParameters():
5656
omcs = OMPython.OMCSessionLocal()
5757
model_path_str = omcs.sendExpression("getInstallationDirectoryPath()") + "/share/doc/omc/testmodels"
5858
model_path = omcs.omcpath(model_path_str)
59-
mod = OMPython.ModelicaSystem()
59+
mod = OMPython.ModelicaSystemOMC(
60+
session=omcs,
61+
)
6062
mod.model(
6163
model_file=model_path / "BouncingBall.mo",
6264
model_name="BouncingBall",
@@ -91,7 +93,9 @@ def test_setSimulationOptions():
9193
omcs = OMPython.OMCSessionLocal()
9294
model_path_str = omcs.sendExpression("getInstallationDirectoryPath()") + "/share/doc/omc/testmodels"
9395
model_path = omcs.omcpath(model_path_str)
94-
mod = OMPython.ModelicaSystem()
96+
mod = OMPython.ModelicaSystemOMC(
97+
session=omcs,
98+
)
9599
mod.model(
96100
model_file=model_path / "BouncingBall.mo",
97101
model_name="BouncingBall",
@@ -128,7 +132,7 @@ def test_relative_path(model_firstorder):
128132
model_relative = str(model_file)
129133
assert "/" not in model_relative
130134

131-
mod = OMPython.ModelicaSystem()
135+
mod = OMPython.ModelicaSystemOMC()
132136
mod.model(
133137
model_file=model_relative,
134138
model_name="M",
@@ -141,7 +145,7 @@ def test_relative_path(model_firstorder):
141145
def test_customBuildDirectory(tmp_path, model_firstorder):
142146
tmpdir = tmp_path / "tmpdir1"
143147
tmpdir.mkdir()
144-
mod = OMPython.ModelicaSystem(work_directory=tmpdir)
148+
mod = OMPython.ModelicaSystemOMC(work_directory=tmpdir)
145149
mod.model(
146150
model_file=model_firstorder,
147151
model_name="M",
@@ -157,7 +161,7 @@ def test_customBuildDirectory(tmp_path, model_firstorder):
157161
@skip_python_older_312
158162
def test_getSolutions_docker(model_firstorder):
159163
omcs = OMPython.OMCSessionDocker(docker="openmodelica/openmodelica:v1.25.0-minimal")
160-
mod = OMPython.ModelicaSystem(
164+
mod = OMPython.ModelicaSystemOMC(
161165
session=omcs,
162166
)
163167
mod.model(
@@ -169,7 +173,7 @@ def test_getSolutions_docker(model_firstorder):
169173

170174

171175
def test_getSolutions(model_firstorder):
172-
mod = OMPython.ModelicaSystem()
176+
mod = OMPython.ModelicaSystemOMC()
173177
mod.model(
174178
model_file=model_firstorder,
175179
model_name="M",
@@ -217,7 +221,7 @@ def test_getters(tmp_path):
217221
y = der(x);
218222
end M_getters;
219223
""")
220-
mod = OMPython.ModelicaSystem()
224+
mod = OMPython.ModelicaSystemOMC()
221225
mod.model(
222226
model_file=model_file,
223227
model_name="M_getters",
@@ -426,7 +430,7 @@ def test_simulate_inputs(tmp_path):
426430
y = x;
427431
end M_input;
428432
""")
429-
mod = OMPython.ModelicaSystem()
433+
mod = OMPython.ModelicaSystemOMC()
430434
mod.model(
431435
model_file=model_file,
432436
model_name="M_input",

tests/test_OMSessionCmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def test_isPackage():
88

99

1010
def test_isPackage2():
11-
mod = OMPython.ModelicaSystem()
11+
mod = OMPython.ModelicaSystemOMC()
1212
mod.model(
1313
model_name="Modelica.Electrical.Analog.Examples.CauerLowPassAnalog",
1414
libraries=["Modelica"],

tests/test_linearization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def model_linearTest(tmp_path):
2525

2626

2727
def test_example(model_linearTest):
28-
mod = OMPython.ModelicaSystem()
28+
mod = OMPython.ModelicaSystemOMC()
2929
mod.model(
3030
model_file=model_linearTest,
3131
model_name="linearTest",
@@ -60,7 +60,7 @@ def test_getters(tmp_path):
6060
y2 = phi + u1;
6161
end Pendulum;
6262
""")
63-
mod = OMPython.ModelicaSystem()
63+
mod = OMPython.ModelicaSystemOMC()
6464
mod.model(
6565
model_file=model_file,
6666
model_name="Pendulum",

tests/test_optimization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_optimization_example(tmp_path):
3434
end BangBang2021;
3535
""")
3636

37-
mod = OMPython.ModelicaSystem()
37+
mod = OMPython.ModelicaSystemOMC()
3838
mod.model(
3939
model_file=model_file,
4040
model_name="BangBang2021",

0 commit comments

Comments
 (0)