Skip to content

Commit d9c63d2

Browse files
committed
[ModelicaSystemDoE] simplify definition; use a Modelicasystem instance as argument
1 parent 4f056f2 commit d9c63d2

1 file changed

Lines changed: 15 additions & 25 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,15 @@ def get_session(self) -> OMCSession:
461461
"""
462462
return self._session
463463

464+
def get_model_name(self) -> str:
465+
"""
466+
Return the defined model name.
467+
"""
468+
if not isinstance(self._model_name, str):
469+
raise ModelicaSystemError("No model name defined!")
470+
471+
return self._model_name
472+
464473
def set_command_line_options(self, command_line_option: str):
465474
"""
466475
Set the provided command line option via OMC setCommandLineOptions().
@@ -2080,15 +2089,8 @@ def run_doe():
20802089

20812090
def __init__(
20822091
self,
2083-
# data to be used for ModelicaSystem
2084-
model_file: Optional[str | os.PathLike] = None,
2085-
model_name: Optional[str] = None,
2086-
libraries: Optional[list[str | tuple[str, str]]] = None,
2087-
command_line_options: Optional[list[str]] = None,
2088-
variable_filter: Optional[str] = None,
2089-
work_directory: Optional[str | os.PathLike] = None,
2090-
omhome: Optional[str] = None,
2091-
session: Optional[OMCSession] = None,
2092+
# ModelicaSystem definition to use
2093+
mod: ModelicaSystem,
20922094
# simulation specific input
20932095
# TODO: add more settings (simulation options, input options, ...)
20942096
simargs: Optional[dict[str, Optional[str | dict[str, str] | numbers.Number]]] = None,
@@ -2101,23 +2103,11 @@ def __init__(
21012103
ModelicaSystem.simulate(). Additionally, the path to store the result files is needed (= resultpath) as well as
21022104
a list of parameters to vary for the Doe (= parameters). All possible combinations are considered.
21032105
"""
2104-
if model_name is None:
2105-
raise ModelicaSystemError("No model name provided!")
2106-
2107-
self._mod = ModelicaSystem(
2108-
command_line_options=command_line_options,
2109-
work_directory=work_directory,
2110-
omhome=omhome,
2111-
session=session,
2112-
)
2113-
self._mod.model(
2114-
model_file=model_file,
2115-
model_name=model_name,
2116-
libraries=libraries,
2117-
variable_filter=variable_filter,
2118-
)
2106+
if not isinstance(mod, ModelicaSystem):
2107+
raise ModelicaSystemError("Missing definition of ModelicaSystem!")
21192108

2120-
self._model_name = model_name
2109+
self._mod = mod
2110+
self._model_name = mod.get_model_name()
21212111

21222112
self._simargs = simargs
21232113

0 commit comments

Comments
 (0)