fmi_schema/fmi2/
variable_dependency.rs

1use yaserde_derive::{YaDeserialize, YaSerialize};
2
3/// Dependency of scalar Unknown from Knowns in Continuous-Time and Event Mode (ModelExchange), and
4/// at Communication Points (CoSimulation): Unknown=f(Known_1, Known_2, ...).
5/// The Knowns are "inputs", "continuous states" and "independent variable" (usually time)".
6#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
7pub struct Fmi2VariableDependency {
8    /// ScalarVariable index of Unknown
9    #[yaserde(attribute = true)]
10    pub index: u32,
11
12    /// Defines the dependency of the Unknown (directly or indirectly via auxiliary variables) on
13    /// the Knowns in Continuous-Time and Event Mode ([`super::ModelExchange`]) and at
14    /// Communication Points ([`super::CoSimulation`]).
15    ///
16    /// If not present, it must be assumed that the Unknown depends on all Knowns. If present as
17    /// empty list, the Unknown depends on none of the Knowns. Otherwise the Unknown depends on
18    /// the Knowns defined by the given [`super::ScalarVariable`] indices. The indices are
19    /// ordered according to size, starting with the smallest index.
20    #[yaserde(attribute = true, rename = "dependencies")]
21    pub dependencies: Vec<u32>,
22
23    /// If not present, it must be assumed that the Unknown depends on the Knowns without a
24    /// particular structure. Otherwise, the corresponding Known v enters the equation as:
25    ///
26    /// * [`DependenciesKind::Dependent`]:  no particular structure, f(v)
27    /// * [`DependenciesKind::Constant`]:   constant factor, c*v (only for Real variablse)
28    /// * [`DependenciesKind::Fixed`]:      fixed factor, p*v (only for Real variables)
29    /// * [`DependenciesKind::Tunable`]:    tunable factor, p*v (only for Real variables)
30    /// * [`DependenciesKind::Discrete`]:   discrete factor, d*v (only for Real variables)
31    ///
32    /// If [`Self::dependencies_kind`] is present, [`Self::dependencies`] must be present and must
33    /// have the same number of list elements.
34    #[yaserde(attribute = true, rename = "dependenciesKind")]
35    pub dependencies_kind: Vec<DependenciesKind>,
36}
37
38#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
39pub enum DependenciesKind {
40    #[yaserde(rename = "dependent")]
41    #[default]
42    Dependent,
43    #[yaserde(rename = "constant")]
44    Constant,
45    #[yaserde(rename = "fixed")]
46    Fixed,
47    #[yaserde(rename = "tunable")]
48    Tunable,
49    #[yaserde(rename = "discrete")]
50    Discrete,
51}