sim_explorer.utils.osp¶
Functions
|
Prepare a OspSystemStructure xml file according to OSP configuration specification. |
|
Make a OspSystemStructure file from a js5 specification. |
Read the system structure in xml format and return as js5 dict, similar to ..._from_js5. |
- sim_explorer.utils.osp.make_osp_system_structure(name: str = 'OspSystemStructure', version: str = '0.1', start: float = 0.0, base_step: float = 0.01, algorithm: str = 'fixedStep', simulators: dict[str, Any] | None = None, functions_linear: dict[str, Any] | None = None, functions_sum: dict[str, Any] | None = None, functions_vectorsum: dict[str, Any] | None = None, connections_variable: Sequence[tuple[str, str, str, str]] | None = None, connections_signal: Sequence[tuple[str, str, str, str]] | None = None, connections_group: Sequence[tuple[str, str, str, str]] | None = None, connections_signalgroup: Sequence[tuple[str, str, str, str]] | None = None, path: Path | str = '.') Path ¶
Prepare a OspSystemStructure xml file according to OSP configuration specification.
- Parameters:
name (str) – the name of the system model, used also as file name
version (str) – The version of the OspSystemConfiguration xmlns
start (float) – The simulation start time
base_step (float) – The base stepSize of the simulation. The exact usage depends on the algorithm chosen
algorithm (str) – The name of the algorithm
simulators (dict) – dict of models (in OSP called ‘simulators’). Per simulator: <instance> : {source: , stepSize: , <var-name>: value, …} (values as python types)
functions_linear (dict) – dict of LinearTransformation function. Per function: <name> : {factor: , offset: }
functions_sum (dict) – dict of Sum functions. Per function: <name> : {inputCount: } (number of inputs to sum over)
functions_vectorsum (dict) – dict of VectorSum functions. Per function: <name> : {inputCount: , numericType: , dimension: }
connections_variable (tuple)=() – tuple of model connections. Each connection is defined through (model, out-variable, model, in-variable)
connections_signal (tuple)=() – tuple of signal connections: Each connection is defined through (model, variable, function, signal)
connections_group (tuple)=() – tuple of group connections: Each connection is defined through (model, group, model, group)
connections_signalgroup (tuple)=() – tuple of signal group connections: Each connection is defined through (model, group, function, signal-group)
dest (Path,str) – the path where the file should be saved
- Returns:
The absolute path of the file as Path object
.. todo:: better stepSize control in dependence on algorithm selected, e.g. with fixedStep we should probably set all step sizes to the minimum of everything?
- sim_explorer.utils.osp.osp_system_structure_from_js5(file: Path, dest: Path | None = None) Path ¶
Make a OspSystemStructure file from a js5 specification. The js5 specification is closely related to the make_osp_systemStructure() function (and uses it).
- sim_explorer.utils.osp.read_system_structure_xml(file: Path) dict[str, Any] ¶
Read the system structure in xml format and return as js5 dict, similar to …_from_js5.