Skip to content

Commit 7cfe79c

Browse files
committed
[ModelicaSystem] add ModelicaDoERunner
1 parent a22ad1c commit 7cfe79c

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
@@ -2624,3 +2624,41 @@ def setup(
26242624
# read XML file
26252625
xml_file = self._session.omcpath(self.getWorkDirectory()) / f"{self._model_name}_init.xml"
26262626
self._xmlparse(xml_file=xml_file)
2627+
2628+
2629+
class ModelicaDoERunner(ModelicaDoEABC):
2630+
"""
2631+
Class to run DoEs based on a (Open)Modelica model using ModelicaSystemRunner
2632+
2633+
The example is the same as defined for ModelicaDoEABC
2634+
"""
2635+
2636+
def __init__(
2637+
self,
2638+
# ModelicaSystem definition to use
2639+
mod: ModelicaSystemOMC,
2640+
# simulation specific input
2641+
# TODO: add more settings (simulation options, input options, ...)
2642+
simargs: Optional[dict[str, Optional[str | dict[str, str] | numbers.Number]]] = None,
2643+
# DoE specific inputs
2644+
resultpath: Optional[str | os.PathLike] = None,
2645+
parameters: Optional[dict[str, list[str] | list[int] | list[float]]] = None,
2646+
) -> None:
2647+
if not isinstance(mod, ModelicaSystemRunner):
2648+
raise ModelicaSystemError(f"Invalid definition for mod: {type(mod)} - expect ModelicaSystemOMC!")
2649+
2650+
super().__init__(
2651+
mod=mod,
2652+
simargs=simargs,
2653+
resultpath=resultpath,
2654+
parameters=parameters,
2655+
)
2656+
2657+
def _prepare_structure_parameters(
2658+
self,
2659+
idx_pc_structure: int,
2660+
pc_structure: Tuple,
2661+
param_structure: dict[str, list[str] | list[int] | list[float]],
2662+
) -> dict[str, str | int | float]:
2663+
raise ModelicaSystemError(f"{self.__class__.__name__} can not handle structure parameters as it uses a "
2664+
"pre-compiled binary of model.")

0 commit comments

Comments
 (0)