Skip to main content

cimstructs/
SynchronousMachineDetailed.rs

1/// All synchronous machine detailed types use a subset of the same data parameters and input/output variables. The several variations differ in the following ways: - the number of equivalent windings that are included; - the way in which saturation is incorporated into the model; - whether or not “subtransient saliency” (X''q not = X''d) is represented. It is not necessary for each simulation tool to have separate models for each of the model types. The same model can often be used for several types by alternative logic within the model. Also, differences in saturation representation might not result in significant model performance differences so model substitutions are often acceptable.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct SynchronousMachineDetailed {
4    #[serde(flatten)]
5    pub base: super::SynchronousMachineDynamics,
6    /// Ratio (exciter voltage/generator voltage) of Efd bases of exciter and generator models (> 0). Typical value = 1.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub efd_base_ratio: Option<f64>,
9    /// Excitation base system mode. It should be equal to the value of WLMDV given by the user. WLMDV is the PU ratio between the field voltage and the excitation current: Efd = WLMDV x Ifd. Typical value = ifag.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub ifd_base_type: Option<super::base::UriRef>,
12    /// Quadrature-axis saturation factor at 120% of rated terminal voltage (S12q) (>= SynchonousMachineDetailed.saturationFactorQAxis). Typical value = 0,12.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub saturation_factor120q_axis: Option<f64>,
15    /// Quadrature-axis saturation factor at rated terminal voltage (S1q) (>= 0). Typical value = 0,02.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub saturation_factor_q_axis: Option<f64>,
18}
19impl crate::base::CimElement for SynchronousMachineDetailed {
20    fn mrid(&self) -> &str { &self.base.base.base.base.id }
21    fn type_name(&self) -> &'static str { "SynchronousMachineDetailed" }
22    fn as_any(&self) -> &dyn std::any::Any { self }
23    fn to_json_value(&self) -> serde_json::Value {
24        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
25    }
26    fn to_block(&self) -> crate::base::RdfBlock {
27        let mut block = self.base.to_block();
28        block.type_name = "SynchronousMachineDetailed".to_string();
29        if let Some(v) = self.efd_base_ratio {
30            block.fields.insert("SynchronousMachineDetailed.efdBaseRatio".into(), crate::base::FieldValue::Text(v.to_string()));
31        }
32        if let Some(ref v) = self.ifd_base_type {
33            block.fields.insert("SynchronousMachineDetailed.ifdBaseType".into(), crate::base::FieldValue::Resource(v.uri.clone()));
34        }
35        if let Some(v) = self.saturation_factor120q_axis {
36            block.fields.insert("SynchronousMachineDetailed.saturationFactor120QAxis".into(), crate::base::FieldValue::Text(v.to_string()));
37        }
38        if let Some(v) = self.saturation_factor_q_axis {
39            block.fields.insert("SynchronousMachineDetailed.saturationFactorQAxis".into(), crate::base::FieldValue::Text(v.to_string()));
40        }
41        block
42    }
43}
44
45impl SynchronousMachineDetailed {
46    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
47        let mut obj = Self::default();
48        obj.base.base.base.base.id.clone_from(&b.mrid);
49        for (key, val) in &b.fields {
50            match key.as_str() {
51                "SynchronousMachineDetailed.efdBaseRatio" => {
52                    match val {
53                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efd_base_ratio = Some(v); } }
54                        crate::base::FieldValue::TextList(svs) => {
55                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efd_base_ratio = Some(v); } }
56                        }
57                        _ => {}
58                    }
59                }
60                "SynchronousMachineDetailed.ifdBaseType" => {
61                    if let crate::base::FieldValue::Resource(sv) = val {
62                        obj.ifd_base_type = Some(crate::base::UriRef { uri: sv.clone() });
63                    }
64                }
65                "SynchronousMachineDetailed.saturationFactor120QAxis" => {
66                    match val {
67                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.saturation_factor120q_axis = Some(v); } }
68                        crate::base::FieldValue::TextList(svs) => {
69                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.saturation_factor120q_axis = Some(v); } }
70                        }
71                        _ => {}
72                    }
73                }
74                "SynchronousMachineDetailed.saturationFactorQAxis" => {
75                    match val {
76                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.saturation_factor_q_axis = Some(v); } }
77                        crate::base::FieldValue::TextList(svs) => {
78                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.saturation_factor_q_axis = Some(v); } }
79                        }
80                        _ => {}
81                    }
82                }
83                "SynchronousMachineDynamics.SynchronousMachine" => {
84                    if let crate::base::FieldValue::Resource(sv) = val {
85                        obj.base.synchronous_machine = Some(crate::base::MridRef { mrid: sv.clone() });
86                    }
87                }
88                "RotatingMachineDynamics.damping" => {
89                    match val {
90                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.damping = Some(v); } }
91                        crate::base::FieldValue::TextList(svs) => {
92                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.damping = Some(v); } }
93                        }
94                        _ => {}
95                    }
96                }
97                "RotatingMachineDynamics.inertia" => {
98                    match val {
99                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.inertia = Some(v); } }
100                        crate::base::FieldValue::TextList(svs) => {
101                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.inertia = Some(v); } }
102                        }
103                        _ => {}
104                    }
105                }
106                "RotatingMachineDynamics.saturationFactor" => {
107                    match val {
108                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.saturation_factor = Some(v); } }
109                        crate::base::FieldValue::TextList(svs) => {
110                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.saturation_factor = Some(v); } }
111                        }
112                        _ => {}
113                    }
114                }
115                "RotatingMachineDynamics.saturationFactor120" => {
116                    match val {
117                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.saturation_factor120 = Some(v); } }
118                        crate::base::FieldValue::TextList(svs) => {
119                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.saturation_factor120 = Some(v); } }
120                        }
121                        _ => {}
122                    }
123                }
124                "RotatingMachineDynamics.statorLeakageReactance" => {
125                    match val {
126                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.stator_leakage_reactance = Some(v); } }
127                        crate::base::FieldValue::TextList(svs) => {
128                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.stator_leakage_reactance = Some(v); } }
129                        }
130                        _ => {}
131                    }
132                }
133                "RotatingMachineDynamics.statorResistance" => {
134                    match val {
135                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.stator_resistance = Some(v); } }
136                        crate::base::FieldValue::TextList(svs) => {
137                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.stator_resistance = Some(v); } }
138                        }
139                        _ => {}
140                    }
141                }
142                "DynamicsFunctionBlock.enabled" => {
143                    match val {
144                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.enabled = Some(sv.trim() == "true"); }
145                        crate::base::FieldValue::TextList(svs) => {
146                            if let Some(sv) = svs.last() { obj.base.base.base.enabled = Some(sv.trim() == "true"); }
147                        }
148                        _ => {}
149                    }
150                }
151                "IdentifiedObject.description" => {
152                    match val {
153                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.description = sv.clone(); }
154                        crate::base::FieldValue::TextList(svs) => {
155                            if let Some(sv) = svs.last() { obj.base.base.base.base.description = sv.clone(); }
156                        }
157                        _ => {}
158                    }
159                }
160                "IdentifiedObject.energyIdentCodeEic" => {
161                    match val {
162                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
163                        crate::base::FieldValue::TextList(svs) => {
164                            if let Some(sv) = svs.last() { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
165                        }
166                        _ => {}
167                    }
168                }
169                "IdentifiedObject.mRID" => {
170                    match val {
171                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.m_rid = sv.clone(); }
172                        crate::base::FieldValue::TextList(svs) => {
173                            if let Some(sv) = svs.last() { obj.base.base.base.base.m_rid = sv.clone(); }
174                        }
175                        _ => {}
176                    }
177                }
178                "IdentifiedObject.name" => {
179                    match val {
180                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.name = sv.clone(); }
181                        crate::base::FieldValue::TextList(svs) => {
182                            if let Some(sv) = svs.last() { obj.base.base.base.base.name = sv.clone(); }
183                        }
184                        _ => {}
185                    }
186                }
187                "IdentifiedObject.shortName" => {
188                    match val {
189                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.short_name = sv.clone(); }
190                        crate::base::FieldValue::TextList(svs) => {
191                            if let Some(sv) = svs.last() { obj.base.base.base.base.short_name = sv.clone(); }
192                        }
193                        _ => {}
194                    }
195                }
196                _ => {}
197            }
198        }
199        obj
200    }
201}