Skip to main content

cimstructs/
ExcST2A.rs

1/// Modified IEEE ST2A static excitation system with another lead-lag block added to match the model defined by WECC.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcST2A {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Maximum field voltage (Efdmax) (>= 0). Typical value = 99.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub efdmax: Option<f64>,
9    /// Voltage regulator gain (Ka) (> 0). Typical value = 120.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub ka: Option<f64>,
12    /// Rectifier loading factor proportional to commutating reactance (Kc) (>= 0). Typical value = 1,82.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub kc: 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,05.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub kf: Option<f64>,
21    /// Potential circuit gain coefficient (Ki) (>= 0). Typical value = 8.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub ki: Option<f64>,
24    /// Potential circuit gain coefficient (Kp) (>= 0). Typical value = 4,88.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub kp: Option<f64>,
27    /// Voltage regulator time constant (Ta) (> 0). Typical value = 0,15.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub ta: Option<f64>,
30    /// Voltage regulator time constant (Tb) (>= 0). Typical value = 0.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub tb: Option<f64>,
33    /// Voltage regulator time constant (Tc) (>= 0). Typical value = 0.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub tc: Option<f64>,
36    /// Exciter time constant, integration rate associated with exciter control (Te) (> 0). Typical value = 0,5.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub te: Option<f64>,
39    /// Excitation control system stabilizer time constant (Tf) (>= 0). Typical value = 0,7.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub tf: Option<f64>,
42    /// UEL input (UELin). true = HV gate false = add to error signal. Typical value = false.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub uelin: Option<bool>,
45    /// Maximum voltage regulator outputs (Vrmax) (> 0). Typical value = 1.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub vrmax: Option<f64>,
48    /// Minimum voltage regulator outputs (Vrmin) (< 0). Typical value = -1.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub vrmin: Option<f64>,
51}
52impl crate::base::CimElement for ExcST2A {
53    fn mrid(&self) -> &str { &self.base.base.base.id }
54    fn type_name(&self) -> &'static str { "ExcST2A" }
55    fn as_any(&self) -> &dyn std::any::Any { self }
56    fn to_json_value(&self) -> serde_json::Value {
57        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
58    }
59    fn to_block(&self) -> crate::base::RdfBlock {
60        let mut block = self.base.to_block();
61        block.type_name = "ExcST2A".to_string();
62        if let Some(v) = self.efdmax {
63            block.fields.insert("ExcST2A.efdmax".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.ka {
66            block.fields.insert("ExcST2A.ka".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.kc {
69            block.fields.insert("ExcST2A.kc".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.ke {
72            block.fields.insert("ExcST2A.ke".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.kf {
75            block.fields.insert("ExcST2A.kf".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.ki {
78            block.fields.insert("ExcST2A.ki".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.kp {
81            block.fields.insert("ExcST2A.kp".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.ta {
84            block.fields.insert("ExcST2A.ta".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.tb {
87            block.fields.insert("ExcST2A.tb".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.tc {
90            block.fields.insert("ExcST2A.tc".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.te {
93            block.fields.insert("ExcST2A.te".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.tf {
96            block.fields.insert("ExcST2A.tf".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.uelin {
99            block.fields.insert("ExcST2A.uelin".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.vrmax {
102            block.fields.insert("ExcST2A.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.vrmin {
105            block.fields.insert("ExcST2A.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        block
108    }
109}
110
111impl ExcST2A {
112    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
113        let mut obj = Self::default();
114        obj.base.base.base.id.clone_from(&b.mrid);
115        for (key, val) in &b.fields {
116            match key.as_str() {
117                "ExcST2A.efdmax" => {
118                    match val {
119                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efdmax = Some(v); } }
120                        crate::base::FieldValue::TextList(svs) => {
121                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efdmax = Some(v); } }
122                        }
123                        _ => {}
124                    }
125                }
126                "ExcST2A.ka" => {
127                    match val {
128                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
129                        crate::base::FieldValue::TextList(svs) => {
130                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
131                        }
132                        _ => {}
133                    }
134                }
135                "ExcST2A.kc" => {
136                    match val {
137                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
138                        crate::base::FieldValue::TextList(svs) => {
139                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
140                        }
141                        _ => {}
142                    }
143                }
144                "ExcST2A.ke" => {
145                    match val {
146                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ke = Some(v); } }
147                        crate::base::FieldValue::TextList(svs) => {
148                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ke = Some(v); } }
149                        }
150                        _ => {}
151                    }
152                }
153                "ExcST2A.kf" => {
154                    match val {
155                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kf = Some(v); } }
156                        crate::base::FieldValue::TextList(svs) => {
157                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kf = Some(v); } }
158                        }
159                        _ => {}
160                    }
161                }
162                "ExcST2A.ki" => {
163                    match val {
164                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
165                        crate::base::FieldValue::TextList(svs) => {
166                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
167                        }
168                        _ => {}
169                    }
170                }
171                "ExcST2A.kp" => {
172                    match val {
173                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
174                        crate::base::FieldValue::TextList(svs) => {
175                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
176                        }
177                        _ => {}
178                    }
179                }
180                "ExcST2A.ta" => {
181                    match val {
182                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
183                        crate::base::FieldValue::TextList(svs) => {
184                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
185                        }
186                        _ => {}
187                    }
188                }
189                "ExcST2A.tb" => {
190                    match val {
191                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tb = Some(v); } }
192                        crate::base::FieldValue::TextList(svs) => {
193                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tb = Some(v); } }
194                        }
195                        _ => {}
196                    }
197                }
198                "ExcST2A.tc" => {
199                    match val {
200                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tc = Some(v); } }
201                        crate::base::FieldValue::TextList(svs) => {
202                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tc = Some(v); } }
203                        }
204                        _ => {}
205                    }
206                }
207                "ExcST2A.te" => {
208                    match val {
209                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.te = Some(v); } }
210                        crate::base::FieldValue::TextList(svs) => {
211                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.te = Some(v); } }
212                        }
213                        _ => {}
214                    }
215                }
216                "ExcST2A.tf" => {
217                    match val {
218                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tf = Some(v); } }
219                        crate::base::FieldValue::TextList(svs) => {
220                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tf = Some(v); } }
221                        }
222                        _ => {}
223                    }
224                }
225                "ExcST2A.uelin" => {
226                    match val {
227                        crate::base::FieldValue::Text(sv) => { obj.uelin = Some(sv.trim() == "true"); }
228                        crate::base::FieldValue::TextList(svs) => {
229                            if let Some(sv) = svs.last() { obj.uelin = Some(sv.trim() == "true"); }
230                        }
231                        _ => {}
232                    }
233                }
234                "ExcST2A.vrmax" => {
235                    match val {
236                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
237                        crate::base::FieldValue::TextList(svs) => {
238                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
239                        }
240                        _ => {}
241                    }
242                }
243                "ExcST2A.vrmin" => {
244                    match val {
245                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
246                        crate::base::FieldValue::TextList(svs) => {
247                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
248                        }
249                        _ => {}
250                    }
251                }
252                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
253                    if let crate::base::FieldValue::Resource(sv) = val {
254                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
255                    }
256                }
257                "DynamicsFunctionBlock.enabled" => {
258                    match val {
259                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
260                        crate::base::FieldValue::TextList(svs) => {
261                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
262                        }
263                        _ => {}
264                    }
265                }
266                "IdentifiedObject.description" => {
267                    match val {
268                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
269                        crate::base::FieldValue::TextList(svs) => {
270                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
271                        }
272                        _ => {}
273                    }
274                }
275                "IdentifiedObject.energyIdentCodeEic" => {
276                    match val {
277                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
278                        crate::base::FieldValue::TextList(svs) => {
279                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
280                        }
281                        _ => {}
282                    }
283                }
284                "IdentifiedObject.mRID" => {
285                    match val {
286                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
287                        crate::base::FieldValue::TextList(svs) => {
288                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
289                        }
290                        _ => {}
291                    }
292                }
293                "IdentifiedObject.name" => {
294                    match val {
295                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
296                        crate::base::FieldValue::TextList(svs) => {
297                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
298                        }
299                        _ => {}
300                    }
301                }
302                "IdentifiedObject.shortName" => {
303                    match val {
304                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
305                        crate::base::FieldValue::TextList(svs) => {
306                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
307                        }
308                        _ => {}
309                    }
310                }
311                _ => {}
312            }
313        }
314        obj
315    }
316}