SystemInterfaceOSP

class sim_explorer.system_interface_osp.SystemInterfaceOSP(structure_file: Path | str = '', name: str | None = None, description: str = '', log_level: str = 'fatal', **kwargs: Any)

Bases: SystemInterface

Implements the SystemInterface as a OSP.

Parameters:
  • structure_file (Path) – Path to system model definition file

  • name (str) – Possibility to provide an explicit system name (if not provided by system file)

  • description (str) – Optional possibility to provide a system description

  • log_level (str) – Per default the level is set to ‘fatal’, but it can be set to ‘trace’, ‘debug’, ‘info’, ‘warning’, ‘error’ or ‘fatal’ (e.g. for debugging purposes)

  • **kwargs – Optional possibility to supply additional keyword arguments:

Note: This class sets full_simulator_available=True , in contrast to the superclass where it is by default value set to False.

__init__(structure_file: Path | str = '', name: str | None = None, description: str = '', log_level: str = 'fatal', **kwargs: Any) None

Methods

__init__([structure_file, name, ...])

action_step(act_info, typ)

Pre-compile the step action and return the partial function so that it can be called at communication points.

add_actions(actions, act_type, cvar, ...[, rng])

Add specified actions to the provided action dict.

allowed_action(action, comp, var, time)

Check whether the action would be allowed according to FMI2 rules, see FMI2.01, p.49.

comp_model_var(cref, vref)

Find the component name and the variable names from the provided reference(s).

component_id_from_name(name)

Get the component id from the name.

component_name_from_id(idx)

Retrieve the component name from the given index.

do_action(time, act_info, typ)

Do the action described by the tuple using OSP functions.

init_simulator()

Instantiate and initialize the simulator, so that simulations can be run.

match_components(comps)

Identify component (instances) based on 'comps' (component alias or tuple of aliases).

match_variables(component, varname)

Based on an example component (instance), identify unique variables starting with 'varname'.

model_from_component(comp)

Find the model name from the component name or index.

pytype(fmu_type[, val])

Return the python type of the FMU type provided as string.

read_system_structure(file, *[, fmus_exist])

Read the systemStructure file and perform checks.

run_until(time)

Instruct the simulator to simulate until the given time.

update_refs_values(allrefs, baserefs, ...)

Update baserefs and basevals with refs and values according to all possible refs.

valid_initial(causality, variability)

Return valid initial setting as tuple of str.

variable_iter(variables, flt)

Get the variable dicts of the variables refered to by ids.

variable_name_from_ref(comp, ref)

Get the variable name from its component instant (id or name) and its valueReference.

variables(comp)

Get the registered variables for a given component from the system.

Attributes

models

path

action_step(act_info: tuple[str, str, tuple[int, ...]] | tuple[str, str, tuple[int, ...], tuple[int | float | bool | str, ...]], typ: type) Callable[[...], Any]

Pre-compile the step action and return the partial function so that it can be called at communication points.

do_action(time: int | float, act_info: tuple[str, str, tuple[int, ...]] | tuple[str, str, tuple[int, ...], tuple[int | float | bool | str, ...]], typ: type) bool

Do the action described by the tuple using OSP functions.

init_simulator() bool

Instantiate and initialize the simulator, so that simulations can be run. Perforemd separately from __init__ so that it can be repeated before simulation runs.

run_until(time: int | float) bool

Instruct the simulator to simulate until the given time.