Skip to content

Commit edc1408

Browse files
committed
[ModelicaSystem] add ModelicaDoERunner
1 parent e301ddf commit edc1408

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

0 commit comments

Comments
 (0)