[][src]Trait fmi::instance::ModelExchange

pub trait ModelExchange: Common {
    fn enter_event_mode(&self) -> Result<()>;
fn new_discrete_states(&self, event_info: &mut EventInfo) -> Result<()>;
fn enter_continuous_time_mode(&self) -> Result<()>;
fn completed_integrator_step(
        &self,
        no_set_fmu_state_prior_to_current_point: bool
    ) -> Result<(bool, bool)>;
fn set_time(&self, time: f64) -> Result<()>;
fn set_continuous_states(&self, states: &[f64]) -> Result<()>;
fn get_derivatives(&self, dx: &mut Vec<f64>) -> Result<()>;
fn get_event_indicators(&self, events: &mut Vec<f64>) -> Result<()>;
fn get_continuous_states(&self, x: &mut Vec<f64>) -> Result<()>;
fn get_nominals_of_continuous_states(&self) -> Result<&[f64]>; }

Required methods

fn enter_event_mode(&self) -> Result<()>

The model enters Event Mode from the Continuous-Time Mode and discrete-time equations may become active (and relations are not "frozen").

fn new_discrete_states(&self, event_info: &mut EventInfo) -> Result<()>

The FMU is in Event Mode and the super dense time is incremented by this call. If the super dense time before a call to new_discrete_states was (tR,tI) then the time instant after the call is (tR,tI + 1).

If returned EventInfo.new_discrete_states_needed = true, the FMU should stay in Event Mode and the FMU requires to set new inputs to the FMU (set_XXX on inputs), to compute and get the outputs (get_XXX on outputs) and to call new_discrete_states again. Depending on the connection with other FMUs, the environment shall * call terminate, if terminate_simulation = true is returned by at least one FMU, * call enter_continuous_time_mode if all FMUs return new_discrete_states_needed = false. * stay in Event Mode otherwise.

fn enter_continuous_time_mode(&self) -> Result<()>

The model enters Continuous-Time Mode and all discrete-time equations become inactive and all relations are "frozen".

This function has to be called when changing from Event Mode (after the global event iteration in Event Mode over all involved FMUs and other models has converged) into Continuous-Time Mode.

fn completed_integrator_step(
    &self,
    no_set_fmu_state_prior_to_current_point: bool
) -> Result<(bool, bool)>

Complete integrator step and return enterEventMode.

This function must be called by the environment after every completed step of the integrator provided the capability flag completedIntegratorStepNotNeeded = false. Argument no_set_fmu_state_prior_to_current_point is true if set_fmu_state will no longer be called for time instants prior to current time in this simulation run [the FMU can use this flag to flush a result buffer].

The returned tuple are the flags (enter_event_mode, terminate_simulation)

fn set_time(&self, time: f64) -> Result<()>

Set a new time instant and re-initialize caching of variables that depend on time, provided the newly provided time value is different to the previously set time value (variables that depend solely on constants or parameters need not to be newly computed in the sequel, but the previously computed values can be reused).

fn set_continuous_states(&self, states: &[f64]) -> Result<()>

Set a new (continuous) state vector and re-initialize caching of variables that depend on the states. Argument nx is the length of vector x and is provided for checking purposes (variables that depend solely on constants, parameters, time, and inputs do not need to be newly computed in the sequel, but the previously computed values can be reused). Note, the continuous states might also be changed in Event Mode. Note: fmi2Status = fmi2Discard is possible.

fn get_derivatives(&self, dx: &mut Vec<f64>) -> Result<()>

Compute state derivatives and event indicators at the current time instant and for the current states. The derivatives are returned as a vector with “nx” elements.

fn get_event_indicators(&self, events: &mut Vec<f64>) -> Result<()>

A state event is triggered when the domain of an event indicator changes from zj > 0 to zj ≤ 0 or vice versa. The FMU must guarantee that at an event restart zj ≠ 0, for example by shifting zj with a small value. Furthermore, zj should be scaled in the FMU with its nominal value (so all elements of the returned vector “eventIndicators” should be in the order of “one”). The event indicators are returned as a vector with “ni” elements.

fn get_continuous_states(&self, x: &mut Vec<f64>) -> Result<()>

Return the new (continuous) state vector x. This function has to be called directly after calling function enter_continuous_time_mode if it returns with eventInfo->valuesOfContinuousStatesChanged = true (indicating that the (continuous-time) state vector has changed).

fn get_nominals_of_continuous_states(&self) -> Result<&[f64]>

Return the nominal values of the continuous states. This function should always be called after calling function new_discrete_states if it returns with eventInfo->nominals_of_continuous_states = true since then the nominal values of the continuous states have changed [e.g. because the association of the continuous states to variables has changed due to internal dynamic state selection].

If the FMU does not have information about the nominal value of a continuous state i, a nominal value x_nominal[i] = 1.0 should be returned.

Note, it is required that x_nominal[i] > 0.0 [Typically, the nominal values of the continuous states are used to compute the absolute tolerance required by the integrator. Example: absoluteTolerance[i] = 0.01tolerancex_nominal[i];]

Loading content...

Implementors

impl ModelExchange for InstanceME[src]

Loading content...