Skip to content

Commit 5234743

Browse files
committed
[ModelicaSystem] add ModelicaDoERunner
1 parent 3353a4a commit 5234743

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,3 +2633,41 @@ def setup(
26332633
# read XML file
26342634
xml_file = self._session.omcpath(self.getWorkDirectory()) / f"{self._model_name}_init.xml"
26352635
self._xmlparse(xml_file=xml_file)
2636+
2637+
2638+
class ModelicaDoERunner(ModelicaDoEABC):
2639+
"""
2640+
Class to run DoEs based on a (Open)Modelica model using ModelicaSystemRunner
2641+
2642+
The example is the same as defined for ModelicaDoEABC
2643+
"""
2644+
2645+
def __init__(
2646+
self,
2647+
# ModelicaSystem definition to use
2648+
mod: ModelicaSystemOMC,
2649+
# simulation specific input
2650+
# TODO: add more settings (simulation options, input options, ...)
2651+
simargs: Optional[dict[str, Optional[str | dict[str, str] | numbers.Number]]] = None,
2652+
# DoE specific inputs
2653+
resultpath: Optional[str | os.PathLike] = None,
2654+
parameters: Optional[dict[str, list[str] | list[int] | list[float]]] = None,
2655+
) -> None:
2656+
if not isinstance(mod, ModelicaSystemRunner):
2657+
raise ModelicaSystemError(f"Invalid definition for mod: {type(mod)} - expect ModelicaSystemOMC!")
2658+
2659+
super().__init__(
2660+
mod=mod,
2661+
simargs=simargs,
2662+
resultpath=resultpath,
2663+
parameters=parameters,
2664+
)
2665+
2666+
def _prepare_structure_parameters(
2667+
self,
2668+
idx_pc_structure: int,
2669+
pc_structure: Tuple,
2670+
param_structure: dict[str, list[str] | list[int] | list[float]],
2671+
) -> dict[str, str | int | float]:
2672+
raise ModelicaSystemError(f"{self.__class__.__name__} can not handle structure parameters as it uses a "
2673+
"pre-compiled binary of model.")

0 commit comments

Comments
 (0)