Skip to main content

cimstructs/
ExcIEEEAC5A.rs

1/// IEEE 421.5-2005 type AC5A model. The model represents a simplified model for brushless excitation systems. The regulator is supplied from a source, such as a permanent magnet generator, which is not affected by system disturbances. Unlike other AC models, this model uses loaded rather than open circuit exciter saturation data in the same way as it is used for the DC models. Because the model has been widely implemented by the industry, it is sometimes used to represent other types of systems when either detailed data for them are not available or simplified models are required. Reference: IEEE 421.5-2005, 6.5.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcIEEEAC5A {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Exciter voltage at which exciter saturation is defined (EFD1) (> 0). Typical value = 5,6.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub efd1: Option<f64>,
9    /// Exciter voltage at which exciter saturation is defined (EFD2) (> 0). Typical value = 4,2.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub efd2: Option<f64>,
12    /// Voltage regulator gain (KA) (> 0). Typical value = 400.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub ka: Option<f64>,
15    /// Exciter constant related to self-excited field (KE). Typical value = 1.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub ke: Option<f64>,
18    /// Excitation control system stabilizer gains (KF) (>= 0). Typical value = 0,03.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub kf: Option<f64>,
21    /// Exciter saturation function value at the corresponding exciter voltage, EFD1 (SE[EFD1]) (>= 0). Typical value = 0,86.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub seefd1: Option<f64>,
24    /// Exciter saturation function value at the corresponding exciter voltage, EFD2 (SE[EFD2]) (>= 0). Typical value = 0,5.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub seefd2: Option<f64>,
27    /// Voltage regulator time constant (TA) (> 0). Typical value = 0,02.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub ta: Option<f64>,
30    /// Exciter time constant, integration rate associated with exciter control (TE) (> 0). Typical value = 0,8.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub te: Option<f64>,
33    /// Excitation control system stabilizer time constant (TF1) (> 0). Typical value = 1.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub tf1: Option<f64>,
36    /// Excitation control system stabilizer time constant (TF2) (>= 0). Typical value = 1.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub tf2: Option<f64>,
39    /// Excitation control system stabilizer time constant (TF3) (>= 0). Typical value = 1.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub tf3: Option<f64>,
42    /// Maximum voltage regulator output (VRMAX) (> 0). Typical value = 7,3.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub vrmax: Option<f64>,
45    /// Minimum voltage regulator output (VRMIN) (< 0). Typical value = -7,3.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub vrmin: Option<f64>,
48}
49impl crate::base::CimElement for ExcIEEEAC5A {
50    fn mrid(&self) -> &str { &self.base.base.base.id }
51    fn type_name(&self) -> &'static str { "ExcIEEEAC5A" }
52    fn as_any(&self) -> &dyn std::any::Any { self }
53    fn to_json_value(&self) -> serde_json::Value {
54        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
55    }
56    fn to_block(&self) -> crate::base::RdfBlock {
57        let mut block = self.base.to_block();
58        block.type_name = "ExcIEEEAC5A".to_string();
59        if let Some(v) = self.efd1 {
60            block.fields.insert("ExcIEEEAC5A.efd1".into(), crate::base::FieldValue::Text(v.to_string()));
61        }
62        if let Some(v) = self.efd2 {
63            block.fields.insert("ExcIEEEAC5A.efd2".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.ka {
66            block.fields.insert("ExcIEEEAC5A.ka".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.ke {
69            block.fields.insert("ExcIEEEAC5A.ke".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.kf {
72            block.fields.insert("ExcIEEEAC5A.kf".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.seefd1 {
75            block.fields.insert("ExcIEEEAC5A.seefd1".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.seefd2 {
78            block.fields.insert("ExcIEEEAC5A.seefd2".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.ta {
81            block.fields.insert("ExcIEEEAC5A.ta".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.te {
84            block.fields.insert("ExcIEEEAC5A.te".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.tf1 {
87            block.fields.insert("ExcIEEEAC5A.tf1".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.tf2 {
90            block.fields.insert("ExcIEEEAC5A.tf2".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.tf3 {
93            block.fields.insert("ExcIEEEAC5A.tf3".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.vrmax {
96            block.fields.insert("ExcIEEEAC5A.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.vrmin {
99            block.fields.insert("ExcIEEEAC5A.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        block
102    }
103}
104
105impl ExcIEEEAC5A {
106    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
107        let mut obj = Self::default();
108        obj.base.base.base.id.clone_from(&b.mrid);
109        for (key, val) in &b.fields {
110            match key.as_str() {
111                "ExcIEEEAC5A.efd1" => {
112                    match val {
113                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efd1 = Some(v); } }
114                        crate::base::FieldValue::TextList(svs) => {
115                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efd1 = Some(v); } }
116                        }
117                        _ => {}
118                    }
119                }
120                "ExcIEEEAC5A.efd2" => {
121                    match val {
122                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efd2 = Some(v); } }
123                        crate::base::FieldValue::TextList(svs) => {
124                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efd2 = Some(v); } }
125                        }
126                        _ => {}
127                    }
128                }
129                "ExcIEEEAC5A.ka" => {
130                    match val {
131                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
132                        crate::base::FieldValue::TextList(svs) => {
133                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
134                        }
135                        _ => {}
136                    }
137                }
138                "ExcIEEEAC5A.ke" => {
139                    match val {
140                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ke = Some(v); } }
141                        crate::base::FieldValue::TextList(svs) => {
142                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ke = Some(v); } }
143                        }
144                        _ => {}
145                    }
146                }
147                "ExcIEEEAC5A.kf" => {
148                    match val {
149                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kf = Some(v); } }
150                        crate::base::FieldValue::TextList(svs) => {
151                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kf = Some(v); } }
152                        }
153                        _ => {}
154                    }
155                }
156                "ExcIEEEAC5A.seefd1" => {
157                    match val {
158                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.seefd1 = Some(v); } }
159                        crate::base::FieldValue::TextList(svs) => {
160                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.seefd1 = Some(v); } }
161                        }
162                        _ => {}
163                    }
164                }
165                "ExcIEEEAC5A.seefd2" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.seefd2 = Some(v); } }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.seefd2 = Some(v); } }
170                        }
171                        _ => {}
172                    }
173                }
174                "ExcIEEEAC5A.ta" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
179                        }
180                        _ => {}
181                    }
182                }
183                "ExcIEEEAC5A.te" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.te = Some(v); } }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.te = Some(v); } }
188                        }
189                        _ => {}
190                    }
191                }
192                "ExcIEEEAC5A.tf1" => {
193                    match val {
194                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tf1 = Some(v); } }
195                        crate::base::FieldValue::TextList(svs) => {
196                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tf1 = Some(v); } }
197                        }
198                        _ => {}
199                    }
200                }
201                "ExcIEEEAC5A.tf2" => {
202                    match val {
203                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tf2 = Some(v); } }
204                        crate::base::FieldValue::TextList(svs) => {
205                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tf2 = Some(v); } }
206                        }
207                        _ => {}
208                    }
209                }
210                "ExcIEEEAC5A.tf3" => {
211                    match val {
212                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tf3 = Some(v); } }
213                        crate::base::FieldValue::TextList(svs) => {
214                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tf3 = Some(v); } }
215                        }
216                        _ => {}
217                    }
218                }
219                "ExcIEEEAC5A.vrmax" => {
220                    match val {
221                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
222                        crate::base::FieldValue::TextList(svs) => {
223                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
224                        }
225                        _ => {}
226                    }
227                }
228                "ExcIEEEAC5A.vrmin" => {
229                    match val {
230                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
231                        crate::base::FieldValue::TextList(svs) => {
232                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
233                        }
234                        _ => {}
235                    }
236                }
237                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
238                    if let crate::base::FieldValue::Resource(sv) = val {
239                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
240                    }
241                }
242                "DynamicsFunctionBlock.enabled" => {
243                    match val {
244                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
245                        crate::base::FieldValue::TextList(svs) => {
246                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
247                        }
248                        _ => {}
249                    }
250                }
251                "IdentifiedObject.description" => {
252                    match val {
253                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
254                        crate::base::FieldValue::TextList(svs) => {
255                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
256                        }
257                        _ => {}
258                    }
259                }
260                "IdentifiedObject.energyIdentCodeEic" => {
261                    match val {
262                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
263                        crate::base::FieldValue::TextList(svs) => {
264                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
265                        }
266                        _ => {}
267                    }
268                }
269                "IdentifiedObject.mRID" => {
270                    match val {
271                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
272                        crate::base::FieldValue::TextList(svs) => {
273                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
274                        }
275                        _ => {}
276                    }
277                }
278                "IdentifiedObject.name" => {
279                    match val {
280                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
281                        crate::base::FieldValue::TextList(svs) => {
282                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
283                        }
284                        _ => {}
285                    }
286                }
287                "IdentifiedObject.shortName" => {
288                    match val {
289                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
290                        crate::base::FieldValue::TextList(svs) => {
291                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
292                        }
293                        _ => {}
294                    }
295                }
296                _ => {}
297            }
298        }
299        obj
300    }
301}