Skip to main content

CoSimulation

Trait CoSimulation 

Source
pub trait CoSimulation: Common {
    // Required methods
    fn enter_step_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>;
    fn get_output_derivatives(
        &mut self,
        vrs: &[fmi3ValueReference],
        orders: &[i32],
        values: &mut [f64],
    ) -> Result<Fmi3Res, Fmi3Error>;
    fn do_step(
        &mut self,
        current_communication_point: f64,
        communication_step_size: f64,
        no_set_fmu_state_prior_to_current_point: bool,
        event_handling_needed: &mut bool,
        terminate_simulation: &mut bool,
        early_return: &mut bool,
        last_successful_time: &mut f64,
    ) -> Result<Fmi3Res, Fmi3Error>;
}
Available on crate feature fmi3 only.
Expand description

Interface for Co-Simulation instances

Required Methods§

Source

fn enter_step_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

This function must be called to change from Event Mode into Step Mode in Co-Simulation.

Source

fn get_output_derivatives( &mut self, vrs: &[fmi3ValueReference], orders: &[i32], values: &mut [f64], ) -> Result<Fmi3Res, Fmi3Error>

The returned values correspond to the derivatives at the current time of the FMU. For example, after a successful call to CoSimulation::do_step, the returned values are related to the end of the communication step.

Arguments:

  • vrs: the variables whose derivatives shall be retrieved. If multiple derivatives of a variable shall be retrieved, list the value reference multiple times.
  • orders: the orders of the respective derivative (1 means the first derivative, 2 means the second derivative, …​, 0 is not allowed). If multiple derivatives of a variable shall be retrieved, its value reference must occur multiple times in valueReferences aligned with the corresponding orders array.
  • values: the values of the derivatives are returned in this array. The order of the values corresponds to the order of the value references. Array elements are laid out contiguously.

See https://fmi-standard.org/docs/3.0.1/#fmi3GetOutputDerivatives

Source

fn do_step( &mut self, current_communication_point: f64, communication_step_size: f64, no_set_fmu_state_prior_to_current_point: bool, event_handling_needed: &mut bool, terminate_simulation: &mut bool, early_return: &mut bool, last_successful_time: &mut f64, ) -> Result<Fmi3Res, Fmi3Error>

The importer requests the computation of the next time step.

Arguments:

  • current_communication_point: the current communication point of the importer (t_i). At the first call of do_step, must be equal to the argument start_time of enter_initialization_mode.
  • communication_step_size: the communication step size (h_i). Must be >0.0. The FMU is expected to compute until time t_i+1 = t_i + h_i.

See: https://fmi-standard.org/docs/3.0.1/#fmi3DoStep

Implementors§