FMU

class pathsim.blocks.fmu.CoSimulationFMU(fmu_path, instance_name='fmu_instance', start_values=None, dt=None, verbose=False)[source]

Bases: Block

Co-Simulation FMU block using FMPy with support for FMI 2.0 and FMI 3.0.

This block wraps an FMU (Functional Mock-up Unit) for co-simulation. The FMU encapsulates a simulation model that can be executed independently and synchronized with the main simulation.

Parameters:
  • fmu_path (str) – path to the FMU file (.fmu)

  • instance_name (str, optional) – name for the FMU instance (default: ‘fmu_instance’)

  • start_values (dict, optional) – dictionary of variable names and their initial values

  • dt (float, optional) – communication step size for co-simulation. If None, uses the FMU’s default experiment step size if available.

fmu_path

path to the FMU file

Type:

str

instance_name

name of the FMU instance

Type:

str

start_values

initial values for FMU variables

Type:

dict

model_description

FMI model description from FMPy

Type:

ModelDescription

fmu

FMPy FMU instance for co-simulation

Type:

FMU2Slave or FMU3Slave

fmi_version

FMI version (‘2.0’ or ‘3.0’)

Type:

str

_input_refs

reference map for input variables

Type:

dict

_output_refs

reference map for output variables

Type:

dict

FMU Capabilities
----------------
can_interpolate_inputs

whether FMU can interpolate inputs between communication points

Type:

bool

can_handle_variable_step

whether FMU supports variable communication step sizes

Type:

bool

default_step_size

recommended default step size from FMU

Type:

float or None

max_output_derivative_order

maximum order of output derivatives available

Type:

int

update(t)[source]

Update FMU inputs/outputs between scheduled steps if interpolation supported.

reset()[source]

Reset the FMU instance.

class pathsim.blocks.fmu.ModelExchangeFMU(fmu_path, instance_name='fmu_instance', start_values=None, tolerance=1e-10, verbose=False)[source]

Bases: DynamicalSystem

Model Exchange FMU block using FMPy with support for FMI 2.0 and FMI 3.0.

This block wraps an FMU (Functional Mock-up Unit) for model exchange. The FMU provides the right-hand side of an ODE system that is integrated by PathSim’s numerical solvers. Internal FMU events (state events, time events, and step completion events) are translated to PathSim events.

Parameters:
  • fmu_path (str) – path to the FMU file (.fmu)

  • instance_name (str, optional) – name for the FMU instance (default: ‘fmu_instance’)

  • start_values (dict, optional) – dictionary of variable names and their initial values

  • tolerance (float, optional) – tolerance for event detection (default: 1e-10)

  • verbose (bool, optional) – enable verbose output (default: False)

fmu_path

path to the FMU file

Type:

str

instance_name

name of the FMU instance

Type:

str

start_values

initial values for FMU variables

Type:

dict

model_description

FMI model description from FMPy

Type:

ModelDescription

fmu

FMPy FMU instance for model exchange

Type:

FMU2Model or FMU3Model

fmi_version

FMI version (‘2.0’ or ‘3.0’)

Type:

str

_input_refs

reference map for input variables

Type:

dict

_output_refs

reference map for output variables

Type:

dict

n_states

number of continuous states

Type:

int

n_event_indicators

number of event indicators

Type:

int

time_event

dynamic time event for FMU-scheduled events

Type:

ScheduleList or None

sample(t, dt)[source]

Sample block after successful timestep and handle FMU step completion events.

This is called by the simulation after a complete timestep (all RK stages finished). It’s the proper place to call completedIntegratorStep() per FMI standard.

Parameters:
  • t (float) – evaluation time for sampling

  • dt (float) – integration timestep

reset()[source]

Reset the FMU instance.