Skip to main content

cimstructs/
ExcELIN1.rs

1/// Static PI transformer fed excitation system ELIN (VATECH) - simplified model. This model represents an all-static excitation system. A PI voltage controller establishes a desired field current set point for a proportional current controller. The integrator of the PI controller has a follow-up input to match its signal to the present field current. A power system stabilizer with power input is included in the model.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcELIN1 {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Controller follow up deadband (Dpnf). Typical value = 0.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub dpnf: Option<f64>,
9    /// Maximum open circuit excitation voltage (Efmax) (> ExcELIN1.efmin). Typical value = 5.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub efmax: Option<f64>,
12    /// Minimum open circuit excitation voltage (Efmin) (< ExcELIN1.efmax). Typical value = -5.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub efmin: Option<f64>,
15    /// Stabilizer gain 1 (Ks1). Typical value = 0.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub ks1: Option<f64>,
18    /// Stabilizer gain 2 (Ks2). Typical value = 0.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub ks2: Option<f64>,
21    /// Stabilizer limit output (smax). Typical value = 0,1.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub smax: Option<f64>,
24    /// Current transducer time constant (Tfi) (>= 0). Typical value = 0.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub tfi: Option<f64>,
27    /// Controller reset time constant (Tnu) (>= 0). Typical value = 2.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub tnu: Option<f64>,
30    /// Stabilizer phase lag time constant (Ts1) (>= 0). Typical value = 1.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub ts1: Option<f64>,
33    /// Stabilizer filter time constant (Ts2) (>= 0). Typical value = 1.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub ts2: Option<f64>,
36    /// Stabilizer parameters (Tsw) (>= 0). Typical value = 3.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub tsw: Option<f64>,
39    /// Current controller gain (Vpi). Typical value = 12,45.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub vpi: Option<f64>,
42    /// Controller follow up gain (Vpnf). Typical value = 2.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub vpnf: Option<f64>,
45    /// Voltage controller proportional gain (Vpu). Typical value = 34,5.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub vpu: Option<f64>,
48    /// Excitation transformer effective reactance (Xe) (>= 0). Xe represents the regulation of the transformer/rectifier unit. Typical value = 0,06.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub xe: Option<f64>,
51}
52impl crate::base::CimElement for ExcELIN1 {
53    fn mrid(&self) -> &str { &self.base.base.base.id }
54    fn type_name(&self) -> &'static str { "ExcELIN1" }
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 = "ExcELIN1".to_string();
62        if let Some(v) = self.dpnf {
63            block.fields.insert("ExcELIN1.dpnf".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.efmax {
66            block.fields.insert("ExcELIN1.efmax".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.efmin {
69            block.fields.insert("ExcELIN1.efmin".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.ks1 {
72            block.fields.insert("ExcELIN1.ks1".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.ks2 {
75            block.fields.insert("ExcELIN1.ks2".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.smax {
78            block.fields.insert("ExcELIN1.smax".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.tfi {
81            block.fields.insert("ExcELIN1.tfi".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.tnu {
84            block.fields.insert("ExcELIN1.tnu".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.ts1 {
87            block.fields.insert("ExcELIN1.ts1".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.ts2 {
90            block.fields.insert("ExcELIN1.ts2".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.tsw {
93            block.fields.insert("ExcELIN1.tsw".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.vpi {
96            block.fields.insert("ExcELIN1.vpi".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.vpnf {
99            block.fields.insert("ExcELIN1.vpnf".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.vpu {
102            block.fields.insert("ExcELIN1.vpu".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.xe {
105            block.fields.insert("ExcELIN1.xe".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        block
108    }
109}
110
111impl ExcELIN1 {
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                "ExcELIN1.dpnf" => {
118                    match val {
119                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.dpnf = Some(v); } }
120                        crate::base::FieldValue::TextList(svs) => {
121                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.dpnf = Some(v); } }
122                        }
123                        _ => {}
124                    }
125                }
126                "ExcELIN1.efmax" => {
127                    match val {
128                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efmax = Some(v); } }
129                        crate::base::FieldValue::TextList(svs) => {
130                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efmax = Some(v); } }
131                        }
132                        _ => {}
133                    }
134                }
135                "ExcELIN1.efmin" => {
136                    match val {
137                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efmin = Some(v); } }
138                        crate::base::FieldValue::TextList(svs) => {
139                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efmin = Some(v); } }
140                        }
141                        _ => {}
142                    }
143                }
144                "ExcELIN1.ks1" => {
145                    match val {
146                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ks1 = Some(v); } }
147                        crate::base::FieldValue::TextList(svs) => {
148                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ks1 = Some(v); } }
149                        }
150                        _ => {}
151                    }
152                }
153                "ExcELIN1.ks2" => {
154                    match val {
155                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ks2 = Some(v); } }
156                        crate::base::FieldValue::TextList(svs) => {
157                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ks2 = Some(v); } }
158                        }
159                        _ => {}
160                    }
161                }
162                "ExcELIN1.smax" => {
163                    match val {
164                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.smax = Some(v); } }
165                        crate::base::FieldValue::TextList(svs) => {
166                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.smax = Some(v); } }
167                        }
168                        _ => {}
169                    }
170                }
171                "ExcELIN1.tfi" => {
172                    match val {
173                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tfi = Some(v); } }
174                        crate::base::FieldValue::TextList(svs) => {
175                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tfi = Some(v); } }
176                        }
177                        _ => {}
178                    }
179                }
180                "ExcELIN1.tnu" => {
181                    match val {
182                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tnu = Some(v); } }
183                        crate::base::FieldValue::TextList(svs) => {
184                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tnu = Some(v); } }
185                        }
186                        _ => {}
187                    }
188                }
189                "ExcELIN1.ts1" => {
190                    match val {
191                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ts1 = Some(v); } }
192                        crate::base::FieldValue::TextList(svs) => {
193                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ts1 = Some(v); } }
194                        }
195                        _ => {}
196                    }
197                }
198                "ExcELIN1.ts2" => {
199                    match val {
200                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ts2 = Some(v); } }
201                        crate::base::FieldValue::TextList(svs) => {
202                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ts2 = Some(v); } }
203                        }
204                        _ => {}
205                    }
206                }
207                "ExcELIN1.tsw" => {
208                    match val {
209                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tsw = Some(v); } }
210                        crate::base::FieldValue::TextList(svs) => {
211                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tsw = Some(v); } }
212                        }
213                        _ => {}
214                    }
215                }
216                "ExcELIN1.vpi" => {
217                    match val {
218                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vpi = Some(v); } }
219                        crate::base::FieldValue::TextList(svs) => {
220                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vpi = Some(v); } }
221                        }
222                        _ => {}
223                    }
224                }
225                "ExcELIN1.vpnf" => {
226                    match val {
227                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vpnf = Some(v); } }
228                        crate::base::FieldValue::TextList(svs) => {
229                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vpnf = Some(v); } }
230                        }
231                        _ => {}
232                    }
233                }
234                "ExcELIN1.vpu" => {
235                    match val {
236                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vpu = Some(v); } }
237                        crate::base::FieldValue::TextList(svs) => {
238                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vpu = Some(v); } }
239                        }
240                        _ => {}
241                    }
242                }
243                "ExcELIN1.xe" => {
244                    match val {
245                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.xe = Some(v); } }
246                        crate::base::FieldValue::TextList(svs) => {
247                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.xe = 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}