Skip to content
Open
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
2,443 changes: 17 additions & 2,426 deletions OMPython/ModelicaSystem.py

Large diffs are not rendered by default.

1,817 changes: 16 additions & 1,801 deletions OMPython/OMCSession.py

Large diffs are not rendered by default.

110 changes: 66 additions & 44 deletions OMPython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,67 @@
```
import OMPython
omc = OMPython.OMCSessionLocal()
omc.sendExpression("command")
omc.sendExpression("getVersion()")
```

"""

from OMPython.model_execution import (
ModelExecutionCmd,
ModelExecutionData,
ModelExecutionConfig,
ModelExecutionRun,
ModelExecutionException,
)

from OMPython.ModelicaSystem import (
LinearizationResult,
ModelicaSystem,
ModelicaSystemOMC,
ModelicaSystemDoE,
ModelicaDoEOMC,
ModelicaSystemError,
ModelicaSystemRunner,
ModelicaDoERunner,

doe_get_solutions,

ModelicaSystemCmd,
)
from OMPython.OMCSession import (
from OMPython.om_session_abc import (
OMPathABC,
OMCPath,

OMSessionABC,
OMSessionRunner,

OMSessionException,
)
from OMPython.om_session_omc import (
OMCPath,
OMCSessionABC,
OMCSessionCmd,
OMCSessionDocker,
OMCSessionDockerContainer,
OMCSessionException,
OMCSessionLocal,
OMCSessionPort,

OMCSessionWSL,
)
from OMPython.om_session_runner import (
OMPathRunnerBash,
OMPathRunnerLocal,
OMSessionRunner,
)
from OMPython.modelica_system_abc import (
LinearizationResult,
ModelicaSystemABC,
ModelicaSystemError,
)
from OMPython.modelica_system_omc import (
ModelicaSystemOMC,
)
from OMPython.modelica_system_runner import (
ModelicaSystemRunner,
)
from OMPython.modelica_doe_abc import (
ModelicaDoEABC,
)
from OMPython.modelica_doe_omc import (
doe_get_solutions,

OMCSessionWSL,
ModelicaDoEOMC,
)
from OMPython.modelica_doe_runner import (
ModelicaDoERunner,
)

# the imports below are compatibility functionality (OMPython v4.0.0)
from OMPython.ModelicaSystem import (
ModelicaSystem,
ModelicaSystemCmd,
ModelicaSystemDoE,
)
from OMPython.OMCSession import (
OMCSessionCmd,
OMCSessionException,
OMCSessionZMQ,

OMCProcessLocal,
Expand All @@ -60,42 +77,47 @@

# global names imported if import 'from OMPython import *' is used
__all__ = [
'doe_get_solutions',

'LinearizationResult',

'ModelExecutionCmd',
'ModelExecutionData',
'ModelExecutionConfig',
'ModelExecutionRun',
'ModelExecutionException',

'ModelicaSystem',
'ModelicaSystemOMC',
'ModelicaSystemCmd',
'ModelicaSystemDoE',
'ModelicaDoEABC',
'ModelicaDoEOMC',
'ModelicaDoERunner',
'ModelicaSystemABC',
'ModelicaSystemDoE',
'ModelicaSystemError',

'ModelicaSystemOMC',
'ModelicaSystemRunner',
'ModelicaDoERunner',

'OMPathABC',
'OMCPath',

'OMSessionABC',
'OMSessionRunner',

'doe_get_solutions',
'OMSessionException',

'OMCPath',
'OMCSessionABC',
'OMCSessionCmd',
'OMCSessionDocker',
'OMCSessionDockerContainer',
'OMCSessionException',
'OMCSessionPort',
'OMCSessionLocal',
'OMCSessionPort',
'OMCSessionWSL',

'OMPathRunnerBash',
'OMPathRunnerLocal',
'OMSessionRunner',

'ModelicaSystemCmd',
'ModelicaSystem',

'OMCSessionABC',
'OMCSessionCmd',

'OMCSessionException',

'OMCSessionWSL',
'OMCSessionZMQ',

'OMCProcessLocal',
Expand Down
24 changes: 12 additions & 12 deletions OMPython/model_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ class ModelExecutionException(Exception):


@dataclasses.dataclass
class ModelExecutionData:
class ModelExecutionRun:
"""
Data class to store the command line data for running a model executable in the OMC environment.
Data class to store the command line data for running a model executable. This definition is independent of the OMC
environment as only the executable is needed.

All data should be defined for the environment, where OMC is running (local, docker or WSL)

To use this as a definition of an OMC simulation run, it has to be processed within
OMCProcess*.self_update(). This defines the attribute cmd_model_executable.
All data should be defined for the environment, where the executable was defined / is located. This is especially
important if OMPython and the executable are defined in different environments (docker or WSL).
"""
# cmd_path is the expected working directory
cmd_path: str
Expand Down Expand Up @@ -105,11 +104,12 @@ def run(self) -> int:
return returncode


class ModelExecutionCmd:
class ModelExecutionConfig:
"""
All information about a compiled model executable. This should include data about all structured parameters, i.e.
parameters which need a recompilation of the model. All non-structured parameters can be easily changed without
the need for recompilation.
This class collects all information about a compiled model executable. This includes data about all structured
parameters, i.e. parameters which need a recompilation of the model. All non-structured parameters can be easily
changed without the need for recompilation. The final result is an instance of class ModelExecutionRun - a
definition to run one simulation based on the compiled model executable.
"""

def __init__(
Expand Down Expand Up @@ -261,7 +261,7 @@ def get_cmd_args(self) -> list[str]:

return cmdl

def definition(self) -> ModelExecutionData:
def definition(self) -> ModelExecutionRun:
"""
Define all needed data to run the model executable. The data is stored in an OMCSessionRunData object.
"""
Expand Down Expand Up @@ -301,7 +301,7 @@ def definition(self) -> ModelExecutionData:
if self._cmd_local:
cmd_cwd_local = cmd_path.as_posix()

omc_run_data = ModelExecutionData(
omc_run_data = ModelExecutionRun(
cmd_path=cmd_path.as_posix(),
cmd_model_name=self._model_name,
cmd_args=self.get_cmd_args(),
Expand Down
Loading
Loading