Skip to main content

cimstructs/
ExcIEEEST4B.rs

1/// IEEE 421.5-2005 type ST4B model. This model is a variation of the type ST3A model, with a proportional plus integral (PI) regulator block replacing the lag-lead regulator characteristic that is in the ST3A model. Both potential and compound source rectifier excitation systems are modelled. The PI regulator blocks have non-windup limits that are represented. The voltage regulator of this model is typically implemented digitally. Reference: IEEE 421.5-2005, 7.4.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcIEEEST4B {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Rectifier loading factor proportional to commutating reactance (KC) (>= 0). Typical value = 0,113.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub kc: Option<f64>,
9    /// Feedback gain constant of the inner loop field regulator (KG) (>= 0). Typical value = 0.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub kg: Option<f64>,
12    /// Potential circuit gain coefficient (KI) (>= 0). Typical value = 0.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub ki: Option<f64>,
15    /// Voltage regulator integral gain output (KIM). Typical value = 0.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub kim: Option<f64>,
18    /// Voltage regulator integral gain (KIR). Typical value = 10,75.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub kir: Option<f64>,
21    /// Potential circuit gain coefficient (KP) (> 0). Typical value = 9,3.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub kp: Option<f64>,
24    /// Voltage regulator proportional gain output (KPM). Typical value = 1.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub kpm: Option<f64>,
27    /// Voltage regulator proportional gain (KPR). Typical value = 10,75.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub kpr: Option<f64>,
30    /// Voltage regulator time constant (TA) (>= 0). Typical value = 0,02.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub ta: Option<f64>,
33    /// Potential circuit phase angle (thetap). Typical value = 0.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub thetap: Option<f64>,
36    /// Maximum excitation voltage (VBMax) (> 0). Typical value = 11,63.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub vbmax: Option<f64>,
39    /// Maximum inner loop output (VMMax) (> ExcIEEEST4B.vmmin). Typical value = 99.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub vmmax: Option<f64>,
42    /// Minimum inner loop output (VMMin) (< ExcIEEEST4B.vmmax). Typical value = -99.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub vmmin: Option<f64>,
45    /// Maximum voltage regulator output (VRMAX) (> 0). Typical value = 1.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub vrmax: Option<f64>,
48    /// Minimum voltage regulator output (VRMIN) (< 0). Typical value = -0,87.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub vrmin: Option<f64>,
51    /// Reactance associated with potential source (XL) (>= 0). Typical value = 0,124.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub xl: Option<f64>,
54}
55impl crate::base::CimElement for ExcIEEEST4B {
56    fn mrid(&self) -> &str { &self.base.base.base.id }
57    fn type_name(&self) -> &'static str { "ExcIEEEST4B" }
58    fn as_any(&self) -> &dyn std::any::Any { self }
59    fn to_json_value(&self) -> serde_json::Value {
60        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
61    }
62    fn to_block(&self) -> crate::base::RdfBlock {
63        let mut block = self.base.to_block();
64        block.type_name = "ExcIEEEST4B".to_string();
65        if let Some(v) = self.kc {
66            block.fields.insert("ExcIEEEST4B.kc".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.kg {
69            block.fields.insert("ExcIEEEST4B.kg".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.ki {
72            block.fields.insert("ExcIEEEST4B.ki".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.kim {
75            block.fields.insert("ExcIEEEST4B.kim".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.kir {
78            block.fields.insert("ExcIEEEST4B.kir".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.kp {
81            block.fields.insert("ExcIEEEST4B.kp".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.kpm {
84            block.fields.insert("ExcIEEEST4B.kpm".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.kpr {
87            block.fields.insert("ExcIEEEST4B.kpr".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.ta {
90            block.fields.insert("ExcIEEEST4B.ta".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.thetap {
93            block.fields.insert("ExcIEEEST4B.thetap".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.vbmax {
96            block.fields.insert("ExcIEEEST4B.vbmax".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.vmmax {
99            block.fields.insert("ExcIEEEST4B.vmmax".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.vmmin {
102            block.fields.insert("ExcIEEEST4B.vmmin".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.vrmax {
105            block.fields.insert("ExcIEEEST4B.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        if let Some(v) = self.vrmin {
108            block.fields.insert("ExcIEEEST4B.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
109        }
110        if let Some(v) = self.xl {
111            block.fields.insert("ExcIEEEST4B.xl".into(), crate::base::FieldValue::Text(v.to_string()));
112        }
113        block
114    }
115}
116
117impl ExcIEEEST4B {
118    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
119        let mut obj = Self::default();
120        obj.base.base.base.id.clone_from(&b.mrid);
121        for (key, val) in &b.fields {
122            match key.as_str() {
123                "ExcIEEEST4B.kc" => {
124                    match val {
125                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
126                        crate::base::FieldValue::TextList(svs) => {
127                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
128                        }
129                        _ => {}
130                    }
131                }
132                "ExcIEEEST4B.kg" => {
133                    match val {
134                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kg = Some(v); } }
135                        crate::base::FieldValue::TextList(svs) => {
136                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kg = Some(v); } }
137                        }
138                        _ => {}
139                    }
140                }
141                "ExcIEEEST4B.ki" => {
142                    match val {
143                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
144                        crate::base::FieldValue::TextList(svs) => {
145                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
146                        }
147                        _ => {}
148                    }
149                }
150                "ExcIEEEST4B.kim" => {
151                    match val {
152                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kim = Some(v); } }
153                        crate::base::FieldValue::TextList(svs) => {
154                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kim = Some(v); } }
155                        }
156                        _ => {}
157                    }
158                }
159                "ExcIEEEST4B.kir" => {
160                    match val {
161                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kir = Some(v); } }
162                        crate::base::FieldValue::TextList(svs) => {
163                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kir = Some(v); } }
164                        }
165                        _ => {}
166                    }
167                }
168                "ExcIEEEST4B.kp" => {
169                    match val {
170                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
171                        crate::base::FieldValue::TextList(svs) => {
172                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
173                        }
174                        _ => {}
175                    }
176                }
177                "ExcIEEEST4B.kpm" => {
178                    match val {
179                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kpm = Some(v); } }
180                        crate::base::FieldValue::TextList(svs) => {
181                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kpm = Some(v); } }
182                        }
183                        _ => {}
184                    }
185                }
186                "ExcIEEEST4B.kpr" => {
187                    match val {
188                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kpr = Some(v); } }
189                        crate::base::FieldValue::TextList(svs) => {
190                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kpr = Some(v); } }
191                        }
192                        _ => {}
193                    }
194                }
195                "ExcIEEEST4B.ta" => {
196                    match val {
197                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
198                        crate::base::FieldValue::TextList(svs) => {
199                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
200                        }
201                        _ => {}
202                    }
203                }
204                "ExcIEEEST4B.thetap" => {
205                    match val {
206                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.thetap = Some(v); } }
207                        crate::base::FieldValue::TextList(svs) => {
208                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.thetap = Some(v); } }
209                        }
210                        _ => {}
211                    }
212                }
213                "ExcIEEEST4B.vbmax" => {
214                    match val {
215                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vbmax = Some(v); } }
216                        crate::base::FieldValue::TextList(svs) => {
217                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vbmax = Some(v); } }
218                        }
219                        _ => {}
220                    }
221                }
222                "ExcIEEEST4B.vmmax" => {
223                    match val {
224                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vmmax = Some(v); } }
225                        crate::base::FieldValue::TextList(svs) => {
226                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vmmax = Some(v); } }
227                        }
228                        _ => {}
229                    }
230                }
231                "ExcIEEEST4B.vmmin" => {
232                    match val {
233                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vmmin = Some(v); } }
234                        crate::base::FieldValue::TextList(svs) => {
235                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vmmin = Some(v); } }
236                        }
237                        _ => {}
238                    }
239                }
240                "ExcIEEEST4B.vrmax" => {
241                    match val {
242                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
243                        crate::base::FieldValue::TextList(svs) => {
244                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
245                        }
246                        _ => {}
247                    }
248                }
249                "ExcIEEEST4B.vrmin" => {
250                    match val {
251                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
252                        crate::base::FieldValue::TextList(svs) => {
253                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
254                        }
255                        _ => {}
256                    }
257                }
258                "ExcIEEEST4B.xl" => {
259                    match val {
260                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.xl = Some(v); } }
261                        crate::base::FieldValue::TextList(svs) => {
262                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.xl = Some(v); } }
263                        }
264                        _ => {}
265                    }
266                }
267                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
268                    if let crate::base::FieldValue::Resource(sv) = val {
269                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
270                    }
271                }
272                "DynamicsFunctionBlock.enabled" => {
273                    match val {
274                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
275                        crate::base::FieldValue::TextList(svs) => {
276                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
277                        }
278                        _ => {}
279                    }
280                }
281                "IdentifiedObject.description" => {
282                    match val {
283                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
284                        crate::base::FieldValue::TextList(svs) => {
285                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
286                        }
287                        _ => {}
288                    }
289                }
290                "IdentifiedObject.energyIdentCodeEic" => {
291                    match val {
292                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
293                        crate::base::FieldValue::TextList(svs) => {
294                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
295                        }
296                        _ => {}
297                    }
298                }
299                "IdentifiedObject.mRID" => {
300                    match val {
301                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
302                        crate::base::FieldValue::TextList(svs) => {
303                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
304                        }
305                        _ => {}
306                    }
307                }
308                "IdentifiedObject.name" => {
309                    match val {
310                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
311                        crate::base::FieldValue::TextList(svs) => {
312                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
313                        }
314                        _ => {}
315                    }
316                }
317                "IdentifiedObject.shortName" => {
318                    match val {
319                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
320                        crate::base::FieldValue::TextList(svs) => {
321                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
322                        }
323                        _ => {}
324                    }
325                }
326                _ => {}
327            }
328        }
329        obj
330    }
331}