gemseo_fmu

Show inherited members

fmu_discipline module

Make a discipline from a Functional Mockup Unit (FMU) model.

class gemseo_fmu.fmu_discipline.FMUDiscipline(fmu_file_path, kind='auto', simulate_options=None, history_outputs=None, name=None)[source]

Bases: MDODiscipline

Generic wrapper for Functional Mock-Up Units (FMUs).

This discipline wraps a FMU model and computes some of its outputs from some of its inputs. It supports both model exchange (ME) and co-simulation (CS) models. This wrapper uses the PyFMI library for loading and simulating the FMU model.

Examples

>>> # Create a discipline considering PyFMI default simulation options
>>> discipline = FMUDiscipline(fmu_file_path, kind="CS")
>>> # Create a discipline considering user-defined simulation options
>>> options = {
>>>    "start_time": 0.0,
>>>    "final_time": 1.0,
>>>    "algorithm": "FMICSAlg",
>>>    "options": {"ncp": 510, "initialize": True},
>>>}
>>> discipline = FMUDiscipline(fmu_file_path, "CS", options)
>>> # To get the available simulation options
>>> discipline.simulation_options()
>>> # To see the discipline information
>>> print(discipline)

# noqa: D205,D212,D415

Parameters:
  • fmu_file_path (str | Path) – The path to the FMU file.

  • kind (str) –

    The kind of model. This is only needed if a FMU contains both a ME and CS model. Available options: ‘ME’, ‘CS’, ‘auto’

    By default it is set to “auto”.

  • simulate_options (dict[str, int | str | float] | None) –

    The PyFMI simulation options. The simulation method depends on which algorithm is used, this can be set with the function argument ‘algorithm’. Options for the algorithm are passed as option classes or as pure dicts. The default algorithm for this function is FMICSAlg.

    Simulation Options Parameters:

    • start_time –

      Start time for the simulation. Default: Start time defined in the default experiment from

      the ModelDescription file.

    • final_time –

      Final time for the simulation. Default: Stop time defined in the default experiment from

      the ModelDescription file.

    • input –

      Input signal for the simulation. The input should be a 2-tuple consisting of first the names of the input variable(s) and then the data matrix. Default: Empty tuple.

    • algorithm –

      The algorithm which will be used for the simulation is specified by passing the algorithm class as string or class object in this argument. ‘algorithm’ can be any class which implements the abstract class AlgorithmBase (found in algorithm_drivers.py). In this way it is possible to write own algorithms and use them with this function. Default: ‘FMICSAlg’

    • options –

      The available PyFMI options that should be used in the algorithm. See method ‘get_available_simulate_options()’ Default: Empty dict

  • history_outputs (Sequence[str] | None) – create a time history variable for the specified output. The name of each output variable is the output name followed by the suffix “_history”. This option is deactivated by default.

  • name (str | None) – The name of the discipline. If None, use the class name.

LOG_LEVEL: ClassVar[int] = 0

The log level of the model.

Available values: - NOTHING = 0 - FATAL = 1 - ERROR = 2 - WARNING = 3 - INFO = 4 - VERBOSE = 5 - DEBUG = 6 - ALL = 7

SILENT_PYFMI_CS: ClassVar[bool] = True

Whether to disable the PyFMI log on console.

The default is True.

cache: AbstractCache | None

The cache containing one or several executions of the discipline according to the cache policy.

data_processor: DataProcessor

A tool to pre- and post-process discipline data.

exec_for_lin: bool

Whether the last execution was due to a linearization.

input_grammar: BaseGrammar

The input grammar.

jac: dict[str, dict[str, ndarray]]

The Jacobians of the outputs wrt inputs.

The structure is {output: {input: matrix}}.

model: FMUModel

The PyFMI model.

name: str

The name of the discipline.

output_grammar: BaseGrammar

The output grammar.

re_exec_policy: ReExecutionPolicy

The policy to re-execute the same discipline.

residual_variables: Mapping[str, str]

The output variables mapping to their inputs, to be considered as residuals; they shall be equal to zero.

run_solves_residuals: bool

Whether the run method shall solve the residuals.

property simulation_options: dict[str, str | int | float]

The PyFMI simulation options.

property simulation_results: dict[str, float]

The history of simulation results.