Skip to content

[ModelicaSystem] prepare OMCPath #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 19, 2025
Merged
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
25 changes: 13 additions & 12 deletions OMPython/ModelicaSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"""

import ast
import csv
from dataclasses import dataclass
import logging
import numbers
Expand Down Expand Up @@ -965,16 +964,17 @@ def simulate_cmd(
if simargs:
om_cmd.args_set(args=simargs)

overrideFile = self._tempdir / f"{self._model_name}_override.txt"
if self._override_variables or self._simulate_options_override:
tmpdict = self._override_variables.copy()
tmpdict.update(self._simulate_options_override)
# write to override file
with open(file=overrideFile, mode="w", encoding="utf-8") as fh:
for key, value in tmpdict.items():
fh.write(f"{key}={value}\n")
override_file = result_file.parent / f"{result_file.stem}_override.txt"

om_cmd.arg_set(key="overrideFile", val=overrideFile.as_posix())
override_content = (
"\n".join([f"{key}={value}" for key, value in self._override_variables.items()])
+ "\n".join([f"{key}={value}" for key, value in self._simulate_options_override.items()])
+ "\n"
)

override_file.write_text(override_content)
om_cmd.arg_set(key="overrideFile", val=override_file.as_posix())

if self._inputs: # if model has input quantities
for key in self._inputs:
Expand Down Expand Up @@ -1432,9 +1432,10 @@ def _createCSVData(self, csvfile: Optional[pathlib.Path] = None) -> pathlib.Path
if csvfile is None:
csvfile = self._tempdir / f'{self._model_name}.csv'

with open(file=csvfile, mode="w", encoding="utf-8", newline="") as fh:
writer = csv.writer(fh)
writer.writerows(csv_rows)
# basic definition of a CSV file using csv_rows as input
csv_content = "\n".join([",".join(map(str, row)) for row in csv_rows]) + "\n"

csvfile.write_text(csv_content)

return csvfile

Expand Down
Loading