Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions OMPython/ModelicaSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2276,12 +2276,12 @@ def get_doe_solutions(
continue

if var_list is None:
var_list_row = list(self._mod.getSolutions(resultfile=resultfile.as_posix()))
var_list_row = list(self._mod.getSolutions(resultfile=resultfile))
else:
var_list_row = var_list

try:
sol = self._mod.getSolutions(varList=var_list_row, resultfile=resultfile.as_posix())
sol = self._mod.getSolutions(varList=var_list_row, resultfile=resultfile)
sol_data = {var: sol[idx] for idx, var in enumerate(var_list_row)}
sol_dict[resultfilename]['msg'] = 'Simulation available'
sol_dict[resultfilename]['data'] = sol_data
Expand Down
7 changes: 4 additions & 3 deletions tests/test_FMIImport.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ def model_firstorder(tmp_path):


def test_FMIImport(model_firstorder):
filePath = model_firstorder.as_posix()

# create model & simulate it
mod1 = OMPython.ModelicaSystem()
mod1.model(model_file=filePath, model_name="M")
mod1.model(
model_file=model_firstorder,
model_name="M",
)
mod1.simulate()

# create FMU & check
Expand Down
10 changes: 4 additions & 6 deletions tests/test_ModelicaSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ def model_firstorder(tmp_path, model_firstorder_content):

def test_ModelicaSystem_loop(model_firstorder):
def worker():
filePath = model_firstorder.as_posix()
mod = OMPython.ModelicaSystem()
mod.model(
model_file=filePath,
model_file=model_firstorder,
model_name="M",
)
mod.simulate()
Expand Down Expand Up @@ -139,12 +138,11 @@ def test_relative_path(model_firstorder):


def test_customBuildDirectory(tmp_path, model_firstorder):
filePath = model_firstorder.as_posix()
tmpdir = tmp_path / "tmpdir1"
tmpdir.mkdir()
mod = OMPython.ModelicaSystem(work_directory=tmpdir)
mod.model(
model_file=filePath,
model_file=model_firstorder,
model_name="M",
)
assert pathlib.Path(mod.getWorkDirectory()).resolve() == tmpdir.resolve()
Expand Down Expand Up @@ -222,7 +220,7 @@ def test_getters(tmp_path):
""")
mod = OMPython.ModelicaSystem()
mod.model(
model_file=model_file.as_posix(),
model_file=model_file,
model_name="M_getters",
)

Expand Down Expand Up @@ -418,7 +416,7 @@ def test_simulate_inputs(tmp_path):
""")
mod = OMPython.ModelicaSystem()
mod.model(
model_file=model_file.as_posix(),
model_file=model_file,
model_name="M_input",
)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_ModelicaSystemCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def model_firstorder(tmp_path):
def mscmd_firstorder(model_firstorder):
mod = OMPython.ModelicaSystem()
mod.model(
model_file=model_firstorder.as_posix(),
model_file=model_firstorder,
model_name="M",
)
mscmd = OMPython.ModelicaSystemCmd(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_ModelicaSystemDoE.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_ModelicaSystemDoE_local(tmp_path, model_doe, param_doe):
tmpdir.mkdir(exist_ok=True)

doe_mod = OMPython.ModelicaSystemDoE(
model_file=model_doe.as_posix(),
model_file=model_doe,
model_name="M",
parameters=param_doe,
resultpath=tmpdir,
Expand All @@ -74,7 +74,7 @@ def test_ModelicaSystemDoE_docker(tmp_path, model_doe, param_doe):
assert omc.sendExpression("getVersion()") == "OpenModelica 1.25.0"

doe_mod = OMPython.ModelicaSystemDoE(
model_file=model_doe.as_posix(),
model_file=model_doe,
model_name="M",
parameters=param_doe,
omc_process=omcp,
Expand All @@ -91,7 +91,7 @@ def test_ModelicaSystemDoE_WSL(tmp_path, model_doe, param_doe):
tmpdir.mkdir(exist_ok=True)

doe_mod = OMPython.ModelicaSystemDoE(
model_file=model_doe.as_posix(),
model_file=model_doe,
model_name="M",
parameters=param_doe,
resultpath=tmpdir,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_linearization.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_getters(tmp_path):
""")
mod = OMPython.ModelicaSystem()
mod.model(
model_file=model_file.as_posix(),
model_file=model_file,
model_name="Pendulum",
libraries=["Modelica"],
)
Expand Down
7 changes: 5 additions & 2 deletions tests/test_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_optimization_example(tmp_path):

mod = OMPython.ModelicaSystem()
mod.model(
model_file=model_file.as_posix(),
model_file=model_file,
model_name="BangBang2021",
)

Expand All @@ -57,7 +57,10 @@ def test_optimization_example(tmp_path):
# it is necessary to specify resultfile, otherwise it wouldn't find it.
resultfile_str = r["resultFile"]
resultfile_omcpath = mod.session().omcpath(resultfile_str)
time, f, v = mod.getSolutions(["time", "f", "v"], resultfile=resultfile_omcpath.as_posix())
time, f, v = mod.getSolutions(
varList=["time", "f", "v"],
resultfile=resultfile_omcpath,
)
assert np.isclose(f[0], 10)
assert np.isclose(f[-1], -10)

Expand Down