From 2065a94b428e0b213e58835a880aa0fda21ed5c2 Mon Sep 17 00:00:00 2001 From: syntron Date: Fri, 31 Oct 2025 17:40:29 +0100 Subject: [PATCH 1/9] [ModelicaSystem] rename variables --- OMPython/ModelicaSystem.py | 24 +++++++++++----------- tests/test_FMIExport.py | 4 ++-- tests/test_FMIImport.py | 2 +- tests/test_ModelicaSystem.py | 36 ++++++++++++++++----------------- tests/test_ModelicaSystemCmd.py | 4 ++-- tests/test_ModelicaSystemDoE.py | 4 ++-- tests/test_OMSessionCmd.py | 2 +- tests/test_linearization.py | 8 ++++---- tests/test_optimization.py | 4 ++-- 9 files changed, 44 insertions(+), 44 deletions(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index e08f6532..d01543b1 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -400,8 +400,8 @@ def __init__( def model( self, - name: Optional[str] = None, - file: Optional[str | os.PathLike] = None, + model_name: Optional[str] = None, + model_file: Optional[str | os.PathLike] = None, libraries: Optional[list[str | tuple[str, str]]] = None, variable_filter: Optional[str] = None, build: bool = True, @@ -411,9 +411,9 @@ def model( This method loads the model file and builds it if requested (build == True). Args: - file: Path to the model file. Either absolute or relative to + model_file: Path to the model file. Either absolute or relative to the current working directory. - name: The name of the model class. If it is contained within + model_name: The name of the model class. If it is contained within a package, "PackageName.ModelName" should be used. libraries: List of libraries to be loaded before the model itself is loaded. Two formats are supported for the list elements: @@ -439,7 +439,7 @@ def model( raise ModelicaSystemError("Can not reuse this instance of ModelicaSystem " f"defined for {repr(self._model_name)}!") - if name is None or not isinstance(name, str): + if model_name is None or not isinstance(model_name, str): raise ModelicaSystemError("A model name must be provided!") if libraries is None: @@ -449,7 +449,7 @@ def model( raise ModelicaSystemError(f"Invalid input type for libraries: {type(libraries)} - list expected!") # set variables - self._model_name = name # Model class name + self._model_name = model_name # Model class name self._libraries = libraries # may be needed if model is derived from other model self._variable_filter = variable_filter @@ -457,8 +457,8 @@ def model( self._loadLibrary(libraries=self._libraries) self._file_name = None - if file is not None: - file_path = pathlib.Path(file) + if model_file is not None: + file_path = pathlib.Path(model_file) # special handling for OMCProcessLocal - consider a relative path if isinstance(self._session.omc_process, OMCProcessLocal) and not file_path.is_absolute(): file_path = pathlib.Path.cwd() / file_path @@ -1709,8 +1709,8 @@ def convertFmu2Mo( raise ModelicaSystemError(f"Missing file {filepath.as_posix()}") self.model( - name=f"{fmu_path.stem}_me_FMU", - file=filepath, + model_name=f"{fmu_path.stem}_me_FMU", + model_file=filepath, ) return filepath @@ -1984,8 +1984,8 @@ def __init__( omc_process=omc_process, ) self._mod.model( - file=fileName, - name=modelName, + model_file=fileName, + model_name=modelName, libraries=lmodel, variable_filter=variableFilter, ) diff --git a/tests/test_FMIExport.py b/tests/test_FMIExport.py index 5902e02a..0c504135 100644 --- a/tests/test_FMIExport.py +++ b/tests/test_FMIExport.py @@ -7,7 +7,7 @@ def test_CauerLowPassAnalog(): mod = OMPython.ModelicaSystem() mod.model( - name="Modelica.Electrical.Analog.Examples.CauerLowPassAnalog", + model_name="Modelica.Electrical.Analog.Examples.CauerLowPassAnalog", libraries=["Modelica"], ) tmp = pathlib.Path(mod.getWorkDirectory()) @@ -21,7 +21,7 @@ def test_CauerLowPassAnalog(): def test_DrumBoiler(): mod = OMPython.ModelicaSystem() mod.model( - name="Modelica.Fluid.Examples.DrumBoiler.DrumBoiler", + model_name="Modelica.Fluid.Examples.DrumBoiler.DrumBoiler", libraries=["Modelica"], ) tmp = pathlib.Path(mod.getWorkDirectory()) diff --git a/tests/test_FMIImport.py b/tests/test_FMIImport.py index 81167a9e..56a46115 100644 --- a/tests/test_FMIImport.py +++ b/tests/test_FMIImport.py @@ -24,7 +24,7 @@ def test_FMIImport(model_firstorder): # create model & simulate it mod1 = OMPython.ModelicaSystem() - mod1.model(file=filePath, name="M") + mod1.model(model_file=filePath, model_name="M") mod1.simulate() # create FMU & check diff --git a/tests/test_ModelicaSystem.py b/tests/test_ModelicaSystem.py index 79a94d61..ed2a821a 100644 --- a/tests/test_ModelicaSystem.py +++ b/tests/test_ModelicaSystem.py @@ -40,8 +40,8 @@ def worker(): filePath = model_firstorder.as_posix() mod = OMPython.ModelicaSystem() mod.model( - file=filePath, - name="M", + model_file=filePath, + model_name="M", ) mod.simulate() mod.convertMo2Fmu(fmuType="me") @@ -55,8 +55,8 @@ def test_setParameters(): model_path = omc.omcpath(model_path_str) mod = OMPython.ModelicaSystem() mod.model( - file=model_path / "BouncingBall.mo", - name="BouncingBall", + model_file=model_path / "BouncingBall.mo", + model_name="BouncingBall", ) # method 1 (test depreciated variants) @@ -90,8 +90,8 @@ def test_setSimulationOptions(): model_path = omc.omcpath(model_path_str) mod = OMPython.ModelicaSystem() mod.model( - file=model_path / "BouncingBall.mo", - name="BouncingBall", + model_file=model_path / "BouncingBall.mo", + model_name="BouncingBall", ) # method 1 @@ -127,8 +127,8 @@ def test_relative_path(model_firstorder): mod = OMPython.ModelicaSystem() mod.model( - file=model_relative, - name="M", + model_file=model_relative, + model_name="M", ) assert float(mod.getParameters("a")[0]) == -1 finally: @@ -141,8 +141,8 @@ def test_customBuildDirectory(tmp_path, model_firstorder): tmpdir.mkdir() mod = OMPython.ModelicaSystem(customBuildDirectory=tmpdir) mod.model( - file=filePath, - name="M", + model_file=filePath, + model_name="M", ) assert pathlib.Path(mod.getWorkDirectory()).resolve() == tmpdir.resolve() result_file = tmpdir / "a.mat" @@ -161,8 +161,8 @@ def test_getSolutions_docker(model_firstorder): omc_process=omc.omc_process, ) mod.model( - name="M", - file=model_firstorder.as_posix(), + model_file=model_firstorder, + model_name="M", ) _run_getSolutions(mod) @@ -171,8 +171,8 @@ def test_getSolutions_docker(model_firstorder): def test_getSolutions(model_firstorder): mod = OMPython.ModelicaSystem() mod.model( - file=model_firstorder.as_posix(), - name="M", + model_file=model_firstorder, + model_name="M", ) _run_getSolutions(mod) @@ -219,8 +219,8 @@ def test_getters(tmp_path): """) mod = OMPython.ModelicaSystem() mod.model( - file=model_file.as_posix(), - name="M_getters", + model_file=model_file.as_posix(), + model_name="M_getters", ) q = mod.getQuantities() @@ -415,8 +415,8 @@ def test_simulate_inputs(tmp_path): """) mod = OMPython.ModelicaSystem() mod.model( - file=model_file.as_posix(), - name="M_input", + model_file=model_file.as_posix(), + model_name="M_input", ) simOptions = {"stopTime": 1.0} diff --git a/tests/test_ModelicaSystemCmd.py b/tests/test_ModelicaSystemCmd.py index a177ad85..f1c25ab3 100644 --- a/tests/test_ModelicaSystemCmd.py +++ b/tests/test_ModelicaSystemCmd.py @@ -19,8 +19,8 @@ def model_firstorder(tmp_path): def mscmd_firstorder(model_firstorder): mod = OMPython.ModelicaSystem() mod.model( - file=model_firstorder.as_posix(), - name="M", + model_file=model_firstorder.as_posix(), + model_name="M", ) mscmd = OMPython.ModelicaSystemCmd( session=mod.session(), diff --git a/tests/test_ModelicaSystemDoE.py b/tests/test_ModelicaSystemDoE.py index 97b27e74..830bdb03 100644 --- a/tests/test_ModelicaSystemDoE.py +++ b/tests/test_ModelicaSystemDoE.py @@ -72,8 +72,8 @@ def test_ModelicaSystemDoE_docker(tmp_path, model_doe, param_doe): assert omc.sendExpression("getVersion()") == "OpenModelica 1.25.0" doe_mod = OMPython.ModelicaSystemDoE( - fileName=model_doe.as_posix(), - modelName="M", + model_file=model_doe.as_posix(), + model_name="M", parameters=param_doe, omc_process=omcp, simargs={"override": {'stopTime': 1.0}}, diff --git a/tests/test_OMSessionCmd.py b/tests/test_OMSessionCmd.py index 29993fdd..be02136a 100644 --- a/tests/test_OMSessionCmd.py +++ b/tests/test_OMSessionCmd.py @@ -10,7 +10,7 @@ def test_isPackage(): def test_isPackage2(): mod = OMPython.ModelicaSystem() mod.model( - name="Modelica.Electrical.Analog.Examples.CauerLowPassAnalog", + model_name="Modelica.Electrical.Analog.Examples.CauerLowPassAnalog", libraries=["Modelica"], ) omccmd = OMPython.OMCSessionCmd(session=mod.session()) diff --git a/tests/test_linearization.py b/tests/test_linearization.py index f0fc6dd7..7d596b03 100644 --- a/tests/test_linearization.py +++ b/tests/test_linearization.py @@ -26,8 +26,8 @@ def model_linearTest(tmp_path): def test_example(model_linearTest): mod = OMPython.ModelicaSystem() mod.model( - file=model_linearTest, - name="linearTest", + model_file=model_linearTest, + model_name="linearTest", ) [A, B, C, D] = mod.linearize() expected_matrixA = [[-3, 2, 0, 0], [-7, 0, -5, 1], [-1, 0, -1, 4], [0, 1, -1, 5]] @@ -61,8 +61,8 @@ def test_getters(tmp_path): """) mod = OMPython.ModelicaSystem() mod.model( - file=model_file.as_posix(), - name="Pendulum", + model_file=model_file.as_posix(), + model_name="Pendulum", libraries=["Modelica"], ) diff --git a/tests/test_optimization.py b/tests/test_optimization.py index cab78b49..ccc4011c 100644 --- a/tests/test_optimization.py +++ b/tests/test_optimization.py @@ -35,8 +35,8 @@ def test_optimization_example(tmp_path): mod = OMPython.ModelicaSystem() mod.model( - file=model_file.as_posix(), - name="BangBang2021", + model_file=model_file.as_posix(), + model_name="BangBang2021", ) optimizationOptions = { From 9cd0bab209d649513df9a579b0a8c322ee56fd3d Mon Sep 17 00:00:00 2001 From: syntron Date: Fri, 31 Oct 2025 17:36:41 +0100 Subject: [PATCH 2/9] [ModelicaSystemDoE] rename variables --- OMPython/ModelicaSystem.py | 24 +++++++++++++----------- tests/test_ModelicaSystemDoE.py | 8 ++++---- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index d01543b1..a57af83f 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -1926,8 +1926,8 @@ def run_doe(): resdir.mkdir(exist_ok=True) doe_mod = OMPython.ModelicaSystemDoE( - fileName=model.as_posix(), - modelName="M", + model_name="M", + model_file=model.as_posix(), parameters=param, resultpath=resdir, simargs={"override": {'stopTime': 1.0}}, @@ -1955,11 +1955,11 @@ def run_doe(): def __init__( self, # data to be used for ModelicaSystem - fileName: Optional[str | os.PathLike] = None, - modelName: Optional[str] = None, - lmodel: Optional[list[str | tuple[str, str]]] = None, + model_file: Optional[str | os.PathLike] = None, + model_name: Optional[str] = None, + libraries: Optional[list[str | tuple[str, str]]] = None, commandLineOptions: Optional[list[str]] = None, - variableFilter: Optional[str] = None, + variable_filter: Optional[str] = None, customBuildDirectory: Optional[str | os.PathLike] = None, omhome: Optional[str] = None, omc_process: Optional[OMCProcess] = None, @@ -1976,6 +1976,8 @@ def __init__( ModelicaSystem.simulate(). Additionally, the path to store the result files is needed (= resultpath) as well as a list of parameters to vary for the Doe (= parameters). All possible combinations are considered. """ + if model_name is None: + raise ModelicaSystemError("No model name provided!") self._mod = ModelicaSystem( commandLineOptions=commandLineOptions, @@ -1984,13 +1986,13 @@ def __init__( omc_process=omc_process, ) self._mod.model( - model_file=fileName, - model_name=modelName, - libraries=lmodel, - variable_filter=variableFilter, + model_file=model_file, + model_name=model_name, + libraries=libraries, + variable_filter=variable_filter, ) - self._model_name = modelName + self._model_name = model_name self._simargs = simargs self._timeout = timeout diff --git a/tests/test_ModelicaSystemDoE.py b/tests/test_ModelicaSystemDoE.py index 830bdb03..b028daae 100644 --- a/tests/test_ModelicaSystemDoE.py +++ b/tests/test_ModelicaSystemDoE.py @@ -54,8 +54,8 @@ def test_ModelicaSystemDoE_local(tmp_path, model_doe, param_doe): tmpdir.mkdir(exist_ok=True) doe_mod = OMPython.ModelicaSystemDoE( - fileName=model_doe.as_posix(), - modelName="M", + model_file=model_doe.as_posix(), + model_name="M", parameters=param_doe, resultpath=tmpdir, simargs={"override": {'stopTime': 1.0}}, @@ -89,8 +89,8 @@ def test_ModelicaSystemDoE_WSL(tmp_path, model_doe, param_doe): tmpdir.mkdir(exist_ok=True) doe_mod = OMPython.ModelicaSystemDoE( - fileName=model_doe.as_posix(), - modelName="M", + model_file=model_doe.as_posix(), + model_name="M", parameters=param_doe, resultpath=tmpdir, simargs={"override": {'stopTime': 1.0}}, From 7cdca619eb2938e70663b02b631aeac0de2544f1 Mon Sep 17 00:00:00 2001 From: syntron Date: Thu, 6 Nov 2025 19:31:50 +0100 Subject: [PATCH 3/9] [ModelicaSystem] rename variables: commandLineOptions => command_line --- OMPython/ModelicaSystem.py | 12 ++++++------ tests/test_FMIImport.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index a57af83f..33582e85 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -329,7 +329,7 @@ class ModelicaSystem: def __init__( self, - commandLineOptions: Optional[list[str]] = None, + command_line: Optional[list[str]] = None, customBuildDirectory: Optional[str | os.PathLike] = None, omhome: Optional[str] = None, omc_process: Optional[OMCProcess] = None, @@ -337,7 +337,7 @@ def __init__( """Create a ModelicaSystem instance. To define the model use model() or convertFmu2Mo(). Args: - commandLineOptions: List with extra command line options as elements. The list elements are + command_line: List with extra command line options as elements. The list elements are provided to omc via setCommandLineOptions(). If set, the default values will be overridden. To disable any command line options, use an empty list. customBuildDirectory: Path to a directory to be used for temporary @@ -378,14 +378,14 @@ def __init__( self._session = OMCSessionZMQ(omhome=omhome) # set commandLineOptions using default values or the user defined list - if commandLineOptions is None: + if command_line is None: # set default command line options to improve the performance of linearization and to avoid recompilation if # the simulation executable is reused in linearize() via the runtime flag '-l' - commandLineOptions = [ + command_line = [ "--linearizationDumpLanguage=python", "--generateSymbolicLinearization", ] - for opt in commandLineOptions: + for opt in command_line: self.setCommandLineOptions(commandLineOptions=opt) self._simulated = False # True if the model has already been simulated @@ -1980,7 +1980,7 @@ def __init__( raise ModelicaSystemError("No model name provided!") self._mod = ModelicaSystem( - commandLineOptions=commandLineOptions, + command_line=commandLineOptions, customBuildDirectory=customBuildDirectory, omhome=omhome, omc_process=omc_process, diff --git a/tests/test_FMIImport.py b/tests/test_FMIImport.py index 56a46115..486bcefc 100644 --- a/tests/test_FMIImport.py +++ b/tests/test_FMIImport.py @@ -33,7 +33,7 @@ def test_FMIImport(model_firstorder): # import FMU & check & simulate # TODO: why is '--allowNonStandardModelica=reinitInAlgorithms' needed? any example without this possible? - mod2 = OMPython.ModelicaSystem(commandLineOptions=['--allowNonStandardModelica=reinitInAlgorithms']) + mod2 = OMPython.ModelicaSystem(command_line=['--allowNonStandardModelica=reinitInAlgorithms']) mo = mod2.convertFmu2Mo(fmu=fmu) assert os.path.exists(mo) From 6f8dd84139aa803f0bc92070a500f6e56d9ce7c4 Mon Sep 17 00:00:00 2001 From: syntron Date: Thu, 6 Nov 2025 19:32:19 +0100 Subject: [PATCH 4/9] [ModelicaSystemDoE] rename variables: commandLineOptions => command_line --- OMPython/ModelicaSystem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index 33582e85..0df55b80 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -1958,7 +1958,7 @@ def __init__( model_file: Optional[str | os.PathLike] = None, model_name: Optional[str] = None, libraries: Optional[list[str | tuple[str, str]]] = None, - commandLineOptions: Optional[list[str]] = None, + command_line: Optional[list[str]] = None, variable_filter: Optional[str] = None, customBuildDirectory: Optional[str | os.PathLike] = None, omhome: Optional[str] = None, @@ -1980,7 +1980,7 @@ def __init__( raise ModelicaSystemError("No model name provided!") self._mod = ModelicaSystem( - command_line=commandLineOptions, + command_line=command_line, customBuildDirectory=customBuildDirectory, omhome=omhome, omc_process=omc_process, From 90b4ea0f08e9436f779245c36d6e316800c6cd89 Mon Sep 17 00:00:00 2001 From: syntron Date: Thu, 6 Nov 2025 19:33:13 +0100 Subject: [PATCH 5/9] [ModelicaSystem] rename variables: customBuildDirectory => work_directory --- OMPython/ModelicaSystem.py | 8 ++++---- tests/test_ModelicaSystem.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index 0df55b80..f56aa36a 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -330,7 +330,7 @@ class ModelicaSystem: def __init__( self, command_line: Optional[list[str]] = None, - customBuildDirectory: Optional[str | os.PathLike] = None, + work_directory: Optional[str | os.PathLike] = None, omhome: Optional[str] = None, omc_process: Optional[OMCProcess] = None, ) -> None: @@ -340,7 +340,7 @@ def __init__( command_line: List with extra command line options as elements. The list elements are provided to omc via setCommandLineOptions(). If set, the default values will be overridden. To disable any command line options, use an empty list. - customBuildDirectory: Path to a directory to be used for temporary + work_directory: Path to a directory to be used for temporary files like the model executable. If left unspecified, a tmp directory will be created. omhome: path to OMC to be used when creating the OMC session (see OMCSessionZMQ). @@ -391,7 +391,7 @@ def __init__( self._simulated = False # True if the model has already been simulated self._result_file: Optional[OMCPath] = None # for storing result file - self._work_dir: OMCPath = self.setWorkDirectory(customBuildDirectory) + self._work_dir: OMCPath = self.setWorkDirectory(work_directory) self._model_name: Optional[str] = None self._libraries: Optional[list[str | tuple[str, str]]] = None @@ -1981,7 +1981,7 @@ def __init__( self._mod = ModelicaSystem( command_line=command_line, - customBuildDirectory=customBuildDirectory, + work_directory=customBuildDirectory, omhome=omhome, omc_process=omc_process, ) diff --git a/tests/test_ModelicaSystem.py b/tests/test_ModelicaSystem.py index ed2a821a..d4cb155e 100644 --- a/tests/test_ModelicaSystem.py +++ b/tests/test_ModelicaSystem.py @@ -139,7 +139,7 @@ def test_customBuildDirectory(tmp_path, model_firstorder): filePath = model_firstorder.as_posix() tmpdir = tmp_path / "tmpdir1" tmpdir.mkdir() - mod = OMPython.ModelicaSystem(customBuildDirectory=tmpdir) + mod = OMPython.ModelicaSystem(work_directory=tmpdir) mod.model( model_file=filePath, model_name="M", From a66af41fe4a504dd98c0a37c035f8251b359b73b Mon Sep 17 00:00:00 2001 From: syntron Date: Thu, 6 Nov 2025 19:33:39 +0100 Subject: [PATCH 6/9] [ModelicaSystemDoE] rename variables: customBuildDirectory => work_directory --- OMPython/ModelicaSystem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index f56aa36a..cfb41409 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -1960,7 +1960,7 @@ def __init__( libraries: Optional[list[str | tuple[str, str]]] = None, command_line: Optional[list[str]] = None, variable_filter: Optional[str] = None, - customBuildDirectory: Optional[str | os.PathLike] = None, + work_directory: Optional[str | os.PathLike] = None, omhome: Optional[str] = None, omc_process: Optional[OMCProcess] = None, # simulation specific input @@ -1981,7 +1981,7 @@ def __init__( self._mod = ModelicaSystem( command_line=command_line, - work_directory=customBuildDirectory, + work_directory=work_directory, omhome=omhome, omc_process=omc_process, ) From 0694ae48da07df9765851bc2800e04387064aba2 Mon Sep 17 00:00:00 2001 From: syntron Date: Thu, 6 Nov 2025 19:40:08 +0100 Subject: [PATCH 7/9] [ModelicaSystem] rename variables: customBuildDirectory => work_directory (2) --- OMPython/ModelicaSystem.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index cfb41409..295e669b 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -522,15 +522,15 @@ def _loadLibrary(self, libraries: list): '1)["Modelica"]\n' '2)[("Modelica","3.2.3"), "PowerSystems"]\n') - def setWorkDirectory(self, customBuildDirectory: Optional[str | os.PathLike] = None) -> OMCPath: + def setWorkDirectory(self, work_directory: Optional[str | os.PathLike] = None) -> OMCPath: """ Define the work directory for the ModelicaSystem / OpenModelica session. The model is build within this directory. If no directory is defined a unique temporary directory is created. """ - if customBuildDirectory is not None: - workdir = self._session.omcpath(customBuildDirectory).absolute() + if work_directory is not None: + workdir = self._session.omcpath(work_directory).absolute() if not workdir.is_dir(): - raise IOError(f"Provided work directory does not exists: {customBuildDirectory}!") + raise IOError(f"Provided work directory does not exists: {work_directory}!") else: workdir = self._session.omcpath_tempdir().absolute() if not workdir.is_dir(): @@ -2048,7 +2048,7 @@ def prepare(self) -> int: build_dir = self._resultpath / f"DOE_{idx_pc_structure:09d}" build_dir.mkdir() - self._mod.setWorkDirectory(customBuildDirectory=build_dir) + self._mod.setWorkDirectory(work_directory=build_dir) sim_param_structure = {} for idx_structure, pk_structure in enumerate(param_structure.keys()): From 3eeb8a44ea701334cb14ef2600a0c5d110ec7bc8 Mon Sep 17 00:00:00 2001 From: syntron Date: Thu, 6 Nov 2025 19:59:36 +0100 Subject: [PATCH 8/9] [ModelicaSystem] rename variable / function setCommandLineOptions() => set_command_line_options() commandLineOptions => command_line_option --- OMPython/ModelicaSystem.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index 295e669b..6a27358d 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -386,7 +386,7 @@ def __init__( "--generateSymbolicLinearization", ] for opt in command_line: - self.setCommandLineOptions(commandLineOptions=opt) + self.set_command_line_options(command_line_option=opt) self._simulated = False # True if the model has already been simulated self._result_file: Optional[OMCPath] = None # for storing result file @@ -487,11 +487,11 @@ def session(self) -> OMCSessionZMQ: """ return self._session - def setCommandLineOptions(self, commandLineOptions: str): + def set_command_line_options(self, command_line_option: str): """ Set the provided command line option via OMC setCommandLineOptions(). """ - exp = f'setCommandLineOptions("{commandLineOptions}")' + exp = f'setCommandLineOptions("{command_line_option}")' self.sendExpression(exp) def _loadFile(self, fileName: OMCPath): @@ -1744,7 +1744,7 @@ def optimize(self) -> dict[str, Any]: """ cName = self._model_name properties = ','.join(f"{key}={val}" for key, val in self._optimization_options.items()) - self.setCommandLineOptions("-g=Optimica") + self.set_command_line_options("-g=Optimica") optimizeResult = self._requestApi(apiName='optimize', entity=cName, properties=properties) return optimizeResult From 51fa6c8fa06ccd4cf5a750dbbd7fcf3fbdaeda35 Mon Sep 17 00:00:00 2001 From: syntron Date: Wed, 19 Nov 2025 20:05:46 +0100 Subject: [PATCH 9/9] [MOdelicaSystem*] rename: command_line => command_line_options --- OMPython/ModelicaSystem.py | 14 +++++++------- tests/test_FMIImport.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index 6a27358d..776a641d 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -329,7 +329,7 @@ class ModelicaSystem: def __init__( self, - command_line: Optional[list[str]] = None, + command_line_options: Optional[list[str]] = None, work_directory: Optional[str | os.PathLike] = None, omhome: Optional[str] = None, omc_process: Optional[OMCProcess] = None, @@ -337,7 +337,7 @@ def __init__( """Create a ModelicaSystem instance. To define the model use model() or convertFmu2Mo(). Args: - command_line: List with extra command line options as elements. The list elements are + command_line_options: List with extra command line options as elements. The list elements are provided to omc via setCommandLineOptions(). If set, the default values will be overridden. To disable any command line options, use an empty list. work_directory: Path to a directory to be used for temporary @@ -378,14 +378,14 @@ def __init__( self._session = OMCSessionZMQ(omhome=omhome) # set commandLineOptions using default values or the user defined list - if command_line is None: + if command_line_options is None: # set default command line options to improve the performance of linearization and to avoid recompilation if # the simulation executable is reused in linearize() via the runtime flag '-l' - command_line = [ + command_line_options = [ "--linearizationDumpLanguage=python", "--generateSymbolicLinearization", ] - for opt in command_line: + for opt in command_line_options: self.set_command_line_options(command_line_option=opt) self._simulated = False # True if the model has already been simulated @@ -1958,7 +1958,7 @@ def __init__( model_file: Optional[str | os.PathLike] = None, model_name: Optional[str] = None, libraries: Optional[list[str | tuple[str, str]]] = None, - command_line: Optional[list[str]] = None, + command_line_options: Optional[list[str]] = None, variable_filter: Optional[str] = None, work_directory: Optional[str | os.PathLike] = None, omhome: Optional[str] = None, @@ -1980,7 +1980,7 @@ def __init__( raise ModelicaSystemError("No model name provided!") self._mod = ModelicaSystem( - command_line=command_line, + command_line_options=command_line_options, work_directory=work_directory, omhome=omhome, omc_process=omc_process, diff --git a/tests/test_FMIImport.py b/tests/test_FMIImport.py index 486bcefc..561352f8 100644 --- a/tests/test_FMIImport.py +++ b/tests/test_FMIImport.py @@ -33,7 +33,7 @@ def test_FMIImport(model_firstorder): # import FMU & check & simulate # TODO: why is '--allowNonStandardModelica=reinitInAlgorithms' needed? any example without this possible? - mod2 = OMPython.ModelicaSystem(command_line=['--allowNonStandardModelica=reinitInAlgorithms']) + mod2 = OMPython.ModelicaSystem(command_line_options=['--allowNonStandardModelica=reinitInAlgorithms']) mo = mod2.convertFmu2Mo(fmu=fmu) assert os.path.exists(mo)