Skip to main content

cimstructs/
ExcST3A.rs

1/// Modified IEEE ST3A static excitation system with added speed multiplier.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcST3A {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Maximum AVR output (Efdmax) (>= 0). Typical value = 6,9.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub efdmax: Option<f64>,
9    /// Rectifier loading factor proportional to commutating reactance (Kc) (>= 0). Typical value = 1,1.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub kc: Option<f64>,
12    /// Feedback gain constant of the inner loop field regulator (Kg) (>= 0). Typical value = 1.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub kg: Option<f64>,
15    /// Potential circuit gain coefficient (Ki) (>= 0). Typical value = 4,83.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub ki: Option<f64>,
18    /// AVR gain (Kj) (> 0). Typical value = 200.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub kj: Option<f64>,
21    /// Forward gain constant of the inner loop field regulator (Km) (> 0). Typical value = 7,04.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub km: Option<f64>,
24    /// Potential source gain (Kp) (> 0). Typical value = 4,37.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub kp: Option<f64>,
27    /// Coefficient to allow different usage of the model-speed coefficient (Ks). Typical value = 0.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub ks: Option<f64>,
30    /// Coefficient to allow different usage of the model-speed coefficient (Ks1). Typical value = 0.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub ks1: Option<f64>,
33    /// Voltage regulator time constant (Tb) (>= 0). Typical value = 6,67.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub tb: Option<f64>,
36    /// Voltage regulator time constant (Tc) (>= 0). Typical value = 1.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub tc: Option<f64>,
39    /// Potential circuit phase angle (thetap). Typical value = 20.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub thetap: Option<f64>,
42    /// Forward time constant of inner loop field regulator (Tm) (> 0). Typical value = 1.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub tm: Option<f64>,
45    /// Maximum excitation voltage (Vbmax) (> 0). Typical value = 8,63.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub vbmax: Option<f64>,
48    /// Maximum inner loop feedback voltage (Vgmax) (>= 0). Typical value = 6,53.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub vgmax: Option<f64>,
51    /// Maximum voltage regulator input limit (Vimax) (> 0). Typical value = 0,2.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub vimax: Option<f64>,
54    /// Minimum voltage regulator input limit (Vimin) (< 0). Typical value = -0,2.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub vimin: Option<f64>,
57    /// Maximum voltage regulator output (Vrmax) (> 0). Typical value = 1.
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub vrmax: Option<f64>,
60    /// Minimum voltage regulator output (Vrmin) (< 0). Typical value = -1.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub vrmin: Option<f64>,
63    /// Reactance associated with potential source (Xl) (>= 0). Typical value = 0,09.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub xl: Option<f64>,
66}
67impl crate::base::CimElement for ExcST3A {
68    fn mrid(&self) -> &str { &self.base.base.base.id }
69    fn type_name(&self) -> &'static str { "ExcST3A" }
70    fn as_any(&self) -> &dyn std::any::Any { self }
71    fn to_json_value(&self) -> serde_json::Value {
72        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
73    }
74    fn to_block(&self) -> crate::base::RdfBlock {
75        let mut block = self.base.to_block();
76        block.type_name = "ExcST3A".to_string();
77        if let Some(v) = self.efdmax {
78            block.fields.insert("ExcST3A.efdmax".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.kc {
81            block.fields.insert("ExcST3A.kc".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.kg {
84            block.fields.insert("ExcST3A.kg".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.ki {
87            block.fields.insert("ExcST3A.ki".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.kj {
90            block.fields.insert("ExcST3A.kj".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.km {
93            block.fields.insert("ExcST3A.km".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.kp {
96            block.fields.insert("ExcST3A.kp".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.ks {
99            block.fields.insert("ExcST3A.ks".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.ks1 {
102            block.fields.insert("ExcST3A.ks1".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.tb {
105            block.fields.insert("ExcST3A.tb".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        if let Some(v) = self.tc {
108            block.fields.insert("ExcST3A.tc".into(), crate::base::FieldValue::Text(v.to_string()));
109        }
110        if let Some(v) = self.thetap {
111            block.fields.insert("ExcST3A.thetap".into(), crate::base::FieldValue::Text(v.to_string()));
112        }
113        if let Some(v) = self.tm {
114            block.fields.insert("ExcST3A.tm".into(), crate::base::FieldValue::Text(v.to_string()));
115        }
116        if let Some(v) = self.vbmax {
117            block.fields.insert("ExcST3A.vbmax".into(), crate::base::FieldValue::Text(v.to_string()));
118        }
119        if let Some(v) = self.vgmax {
120            block.fields.insert("ExcST3A.vgmax".into(), crate::base::FieldValue::Text(v.to_string()));
121        }
122        if let Some(v) = self.vimax {
123            block.fields.insert("ExcST3A.vimax".into(), crate::base::FieldValue::Text(v.to_string()));
124        }
125        if let Some(v) = self.vimin {
126            block.fields.insert("ExcST3A.vimin".into(), crate::base::FieldValue::Text(v.to_string()));
127        }
128        if let Some(v) = self.vrmax {
129            block.fields.insert("ExcST3A.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
130        }
131        if let Some(v) = self.vrmin {
132            block.fields.insert("ExcST3A.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
133        }
134        if let Some(v) = self.xl {
135            block.fields.insert("ExcST3A.xl".into(), crate::base::FieldValue::Text(v.to_string()));
136        }
137        block
138    }
139}
140
141impl ExcST3A {
142    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
143        let mut obj = Self::default();
144        obj.base.base.base.id.clone_from(&b.mrid);
145        for (key, val) in &b.fields {
146            match key.as_str() {
147                "ExcST3A.efdmax" => {
148                    match val {
149                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efdmax = Some(v); } }
150                        crate::base::FieldValue::TextList(svs) => {
151                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efdmax = Some(v); } }
152                        }
153                        _ => {}
154                    }
155                }
156                "ExcST3A.kc" => {
157                    match val {
158                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
159                        crate::base::FieldValue::TextList(svs) => {
160                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
161                        }
162                        _ => {}
163                    }
164                }
165                "ExcST3A.kg" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kg = Some(v); } }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kg = Some(v); } }
170                        }
171                        _ => {}
172                    }
173                }
174                "ExcST3A.ki" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
179                        }
180                        _ => {}
181                    }
182                }
183                "ExcST3A.kj" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kj = Some(v); } }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kj = Some(v); } }
188                        }
189                        _ => {}
190                    }
191                }
192                "ExcST3A.km" => {
193                    match val {
194                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.km = Some(v); } }
195                        crate::base::FieldValue::TextList(svs) => {
196                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.km = Some(v); } }
197                        }
198                        _ => {}
199                    }
200                }
201                "ExcST3A.kp" => {
202                    match val {
203                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
204                        crate::base::FieldValue::TextList(svs) => {
205                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
206                        }
207                        _ => {}
208                    }
209                }
210                "ExcST3A.ks" => {
211                    match val {
212                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ks = Some(v); } }
213                        crate::base::FieldValue::TextList(svs) => {
214                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ks = Some(v); } }
215                        }
216                        _ => {}
217                    }
218                }
219                "ExcST3A.ks1" => {
220                    match val {
221                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ks1 = Some(v); } }
222                        crate::base::FieldValue::TextList(svs) => {
223                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ks1 = Some(v); } }
224                        }
225                        _ => {}
226                    }
227                }
228                "ExcST3A.tb" => {
229                    match val {
230                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tb = Some(v); } }
231                        crate::base::FieldValue::TextList(svs) => {
232                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tb = Some(v); } }
233                        }
234                        _ => {}
235                    }
236                }
237                "ExcST3A.tc" => {
238                    match val {
239                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tc = Some(v); } }
240                        crate::base::FieldValue::TextList(svs) => {
241                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tc = Some(v); } }
242                        }
243                        _ => {}
244                    }
245                }
246                "ExcST3A.thetap" => {
247                    match val {
248                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.thetap = Some(v); } }
249                        crate::base::FieldValue::TextList(svs) => {
250                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.thetap = Some(v); } }
251                        }
252                        _ => {}
253                    }
254                }
255                "ExcST3A.tm" => {
256                    match val {
257                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tm = Some(v); } }
258                        crate::base::FieldValue::TextList(svs) => {
259                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tm = Some(v); } }
260                        }
261                        _ => {}
262                    }
263                }
264                "ExcST3A.vbmax" => {
265                    match val {
266                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vbmax = Some(v); } }
267                        crate::base::FieldValue::TextList(svs) => {
268                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vbmax = Some(v); } }
269                        }
270                        _ => {}
271                    }
272                }
273                "ExcST3A.vgmax" => {
274                    match val {
275                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vgmax = Some(v); } }
276                        crate::base::FieldValue::TextList(svs) => {
277                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vgmax = Some(v); } }
278                        }
279                        _ => {}
280                    }
281                }
282                "ExcST3A.vimax" => {
283                    match val {
284                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vimax = Some(v); } }
285                        crate::base::FieldValue::TextList(svs) => {
286                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vimax = Some(v); } }
287                        }
288                        _ => {}
289                    }
290                }
291                "ExcST3A.vimin" => {
292                    match val {
293                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vimin = Some(v); } }
294                        crate::base::FieldValue::TextList(svs) => {
295                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vimin = Some(v); } }
296                        }
297                        _ => {}
298                    }
299                }
300                "ExcST3A.vrmax" => {
301                    match val {
302                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
303                        crate::base::FieldValue::TextList(svs) => {
304                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
305                        }
306                        _ => {}
307                    }
308                }
309                "ExcST3A.vrmin" => {
310                    match val {
311                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
312                        crate::base::FieldValue::TextList(svs) => {
313                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
314                        }
315                        _ => {}
316                    }
317                }
318                "ExcST3A.xl" => {
319                    match val {
320                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.xl = Some(v); } }
321                        crate::base::FieldValue::TextList(svs) => {
322                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.xl = Some(v); } }
323                        }
324                        _ => {}
325                    }
326                }
327                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
328                    if let crate::base::FieldValue::Resource(sv) = val {
329                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
330                    }
331                }
332                "DynamicsFunctionBlock.enabled" => {
333                    match val {
334                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
335                        crate::base::FieldValue::TextList(svs) => {
336                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
337                        }
338                        _ => {}
339                    }
340                }
341                "IdentifiedObject.description" => {
342                    match val {
343                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
344                        crate::base::FieldValue::TextList(svs) => {
345                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
346                        }
347                        _ => {}
348                    }
349                }
350                "IdentifiedObject.energyIdentCodeEic" => {
351                    match val {
352                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
353                        crate::base::FieldValue::TextList(svs) => {
354                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
355                        }
356                        _ => {}
357                    }
358                }
359                "IdentifiedObject.mRID" => {
360                    match val {
361                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
362                        crate::base::FieldValue::TextList(svs) => {
363                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
364                        }
365                        _ => {}
366                    }
367                }
368                "IdentifiedObject.name" => {
369                    match val {
370                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
371                        crate::base::FieldValue::TextList(svs) => {
372                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
373                        }
374                        _ => {}
375                    }
376                }
377                "IdentifiedObject.shortName" => {
378                    match val {
379                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
380                        crate::base::FieldValue::TextList(svs) => {
381                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
382                        }
383                        _ => {}
384                    }
385                }
386                _ => {}
387            }
388        }
389        obj
390    }
391}