Skip to main content

Common

Trait Common 

Source
pub trait Common: FmiInstance {
Show 17 methods // Required methods fn get_version(&self) -> &str; fn get_types_platform(&self) -> &str; fn set_debug_logging( &mut self, logging_on: bool, categories: &[&str], ) -> Result<Fmi2Res, Fmi2Error>; fn setup_experiment( &mut self, tolerance: Option<f64>, start_time: f64, stop_time: Option<f64>, ) -> Result<Fmi2Res, Fmi2Error>; fn enter_initialization_mode(&mut self) -> Result<Fmi2Res, Fmi2Error>; fn exit_initialization_mode(&mut self) -> Result<Fmi2Res, Fmi2Error>; fn terminate(&mut self) -> Result<Fmi2Res, Fmi2Error>; fn reset(&mut self) -> Result<Fmi2Res, Fmi2Error>; fn get_real( &mut self, sv: &[fmi2ValueReference], v: &mut [fmi2Real], ) -> Result<Fmi2Res, Fmi2Error>; fn get_integer( &mut self, sv: &[fmi2ValueReference], v: &mut [fmi2Integer], ) -> Result<Fmi2Res, Fmi2Error>; fn get_boolean( &mut self, sv: &[fmi2ValueReference], v: &mut [fmi2Boolean], ) -> Result<Fmi2Res, Fmi2Error>; fn get_string( &mut self, sv: &[fmi2ValueReference], v: &mut [CString], ) -> Result<(), Fmi2Error>; fn set_real( &mut self, vrs: &[fmi2ValueReference], values: &[fmi2Real], ) -> Result<Fmi2Res, Fmi2Error>; fn set_integer( &mut self, vrs: &[fmi2ValueReference], values: &[fmi2Integer], ) -> Result<Fmi2Res, Fmi2Error>; fn set_boolean( &mut self, vrs: &[fmi2ValueReference], values: &[fmi2Boolean], ) -> Result<Fmi2Res, Fmi2Error>; fn set_string( &mut self, vrs: &[fmi2ValueReference], values: &[CString], ) -> Result<(), Fmi2Error>; fn get_directional_derivative( &self, unknown_vrs: &[fmi2ValueReference], known_vrs: &[fmi2ValueReference], dv_known_values: &[fmi2Real], dv_unknown_values: &mut [fmi2Real], ) -> Result<Fmi2Res, Fmi2Error>;
}
Available on crate feature fmi2 only.
Expand description

Interface common to both ModelExchange and CoSimulation

Required Methods§

Source

fn get_version(&self) -> &str

The FMI-standard version string

Source

fn get_types_platform(&self) -> &str

Source

fn set_debug_logging( &mut self, logging_on: bool, categories: &[&str], ) -> Result<Fmi2Res, Fmi2Error>

Source

fn setup_experiment( &mut self, tolerance: Option<f64>, start_time: f64, stop_time: Option<f64>, ) -> Result<Fmi2Res, Fmi2Error>

Informs the FMU to setup the experiment. This function can be called after instantiate() and before enter_initialization_mode() is called.

§Tolerance control
  • Under ModelExchange: If tolerance = Some(..) then the model is called with a numerical integration scheme where the step size is controlled by using tolerance for error estimation (usually as relative tolerance). In such a case, all numerical algorithms used inside the model (for example to solve non-linear algebraic equations) should also operate with an error estimation of an appropriate smaller relative tolerance.
  • Under CoSimulation: If tolerance = Some(..) then the communication interval of the slave is controlled by error estimation. In case the slave utilizes a numerical integrator with variable step size and error estimation, it is suggested to use tolerance for the error estimation of the internal integrator (usually as relative tolerance). An FMU for Co-Simulation might ignore this argument.
§Start and Stop times

The arguments start_time and stop_time can be used to check whether the model is valid within the given boundaries. Argument start_timeis the fixed initial value of the independent variable [if the independent variable is "time",start_timeis the starting time of initializaton]. Ifstop_timeisSome(..), then stop_timeis the defined final value of the independent variable [if the independent variable is "time",stop_timeis the stop time of the simulation] and if the environment tries to compute paststop_timethe FMU has to returnError. If stop_timeisNone()`, then no final value of the independent variable is defined.

Source

fn enter_initialization_mode(&mut self) -> Result<Fmi2Res, Fmi2Error>

Informs the FMU to enter Initialization Mode.

Before calling this function, all variables with attribute <ScalarVariable initial = "exact" or "approx"> can be set with the set() function. Setting other variables is not allowed. Furthermore, setup_experiment() must be called at least once before calling enter_initialization_mode(), in order that start_time is defined.

Source

fn exit_initialization_mode(&mut self) -> Result<Fmi2Res, Fmi2Error>

Informs the FMU to exit Initialization Mode.

Under ModelExchange this function switches off all initialization equations and the FMU enters implicitely Event Mode, that is all continuous-time and active discrete-time equations are available.

Source

fn terminate(&mut self) -> Result<Fmi2Res, Fmi2Error>

Informs the FMU that the simulation run is terminated.

After calling this function, the final values of all variables can be inquired with the fmi2GetXXX(..) functions. It is not allowed to call this function after one of the functions returned with a status flag of fmi2Error or fmi2Fatal.

Source

fn reset(&mut self) -> Result<Fmi2Res, Fmi2Error>

Is called by the environment to reset the FMU after a simulation run.

The FMU goes into the same state as if fmi2Instantiate would have been called. All variables have their default values. Before starting a new run, fmi2SetupExperiment and fmi2EnterInitializationMode have to be called.

Source

fn get_real( &mut self, sv: &[fmi2ValueReference], v: &mut [fmi2Real], ) -> Result<Fmi2Res, Fmi2Error>

Source

fn get_integer( &mut self, sv: &[fmi2ValueReference], v: &mut [fmi2Integer], ) -> Result<Fmi2Res, Fmi2Error>

Source

fn get_boolean( &mut self, sv: &[fmi2ValueReference], v: &mut [fmi2Boolean], ) -> Result<Fmi2Res, Fmi2Error>

Source

fn get_string( &mut self, sv: &[fmi2ValueReference], v: &mut [CString], ) -> Result<(), Fmi2Error>

Source

fn set_real( &mut self, vrs: &[fmi2ValueReference], values: &[fmi2Real], ) -> Result<Fmi2Res, Fmi2Error>

Set real values

§Arguments
  • vrs - a slice of fmi::fmi2ValueReference ValueReferences
  • values - a slice of fmi::fmi2Real values to set
Source

fn set_integer( &mut self, vrs: &[fmi2ValueReference], values: &[fmi2Integer], ) -> Result<Fmi2Res, Fmi2Error>

Set integer values

§Arguments
  • vrs - a slice of fmi::fmi2ValueReference ValueReferences
  • values - a slice of fmi::fmi2Integer values to set
Source

fn set_boolean( &mut self, vrs: &[fmi2ValueReference], values: &[fmi2Boolean], ) -> Result<Fmi2Res, Fmi2Error>

Source

fn set_string( &mut self, vrs: &[fmi2ValueReference], values: &[CString], ) -> Result<(), Fmi2Error>

Source

fn get_directional_derivative( &self, unknown_vrs: &[fmi2ValueReference], known_vrs: &[fmi2ValueReference], dv_known_values: &[fmi2Real], dv_unknown_values: &mut [fmi2Real], ) -> Result<Fmi2Res, Fmi2Error>

It is optionally possible to provide evaluation of partial derivatives for an FMU. For Model Exchange, this means computing the partial derivatives at a particular time instant. For Co-Simulation, this means to compute the partial derivatives at a particular communication point. One function is provided to compute directional derivatives. This function can be used to construct the desired partial derivative matrices.

Implementors§

Source§

impl<Tag: InstanceTag> Common for Instance<Tag>