Skip to main content

cimstructs/
ExcIEEEAC4A.rs

1/// IEEE 421.5-2005 type AC4A model. The model represents type AC4A alternator-supplied controlled-rectifier excitation system which is quite different from the other types of AC systems. This high initial response excitation system utilizes a full thyristor bridge in the exciter output circuit. The voltage regulator controls the firing of the thyristor bridges. The exciter alternator uses an independent voltage regulator to control its output voltage to a constant value. These effects are not modelled; however, transient loading effects on the exciter alternator are included. Reference: IEEE 421.5-2005, 6.4.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcIEEEAC4A {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Voltage regulator gain (KA) (> 0). Typical value = 200.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub ka: Option<f64>,
9    /// Rectifier loading factor proportional to commutating reactance (KC) (>= 0). Typical value = 0.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub kc: Option<f64>,
12    /// Voltage regulator time constant (TA) (> 0). Typical value = 0,015.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub ta: Option<f64>,
15    /// Voltage regulator time constant (TB) (>= 0). Typical value = 10.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub tb: Option<f64>,
18    /// Voltage regulator time constant (TC) (>= 0). Typical value = 1.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub tc: Option<f64>,
21    /// Maximum voltage regulator input limit (VIMAX) (> 0). Typical value = 10.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub vimax: Option<f64>,
24    /// Minimum voltage regulator input limit (VIMIN) (< 0). Typical value = -10.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub vimin: Option<f64>,
27    /// Maximum voltage regulator output (VRMAX) (> 0). Typical value = 5,64.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub vrmax: Option<f64>,
30    /// Minimum voltage regulator output (VRMIN) (< 0). Typical value = -4,53.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub vrmin: Option<f64>,
33}
34impl crate::base::CimElement for ExcIEEEAC4A {
35    fn mrid(&self) -> &str { &self.base.base.base.id }
36    fn type_name(&self) -> &'static str { "ExcIEEEAC4A" }
37    fn as_any(&self) -> &dyn std::any::Any { self }
38    fn to_json_value(&self) -> serde_json::Value {
39        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
40    }
41    fn to_block(&self) -> crate::base::RdfBlock {
42        let mut block = self.base.to_block();
43        block.type_name = "ExcIEEEAC4A".to_string();
44        if let Some(v) = self.ka {
45            block.fields.insert("ExcIEEEAC4A.ka".into(), crate::base::FieldValue::Text(v.to_string()));
46        }
47        if let Some(v) = self.kc {
48            block.fields.insert("ExcIEEEAC4A.kc".into(), crate::base::FieldValue::Text(v.to_string()));
49        }
50        if let Some(v) = self.ta {
51            block.fields.insert("ExcIEEEAC4A.ta".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.tb {
54            block.fields.insert("ExcIEEEAC4A.tb".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        if let Some(v) = self.tc {
57            block.fields.insert("ExcIEEEAC4A.tc".into(), crate::base::FieldValue::Text(v.to_string()));
58        }
59        if let Some(v) = self.vimax {
60            block.fields.insert("ExcIEEEAC4A.vimax".into(), crate::base::FieldValue::Text(v.to_string()));
61        }
62        if let Some(v) = self.vimin {
63            block.fields.insert("ExcIEEEAC4A.vimin".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.vrmax {
66            block.fields.insert("ExcIEEEAC4A.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.vrmin {
69            block.fields.insert("ExcIEEEAC4A.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        block
72    }
73}
74
75impl ExcIEEEAC4A {
76    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
77        let mut obj = Self::default();
78        obj.base.base.base.id.clone_from(&b.mrid);
79        for (key, val) in &b.fields {
80            match key.as_str() {
81                "ExcIEEEAC4A.ka" => {
82                    match val {
83                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
84                        crate::base::FieldValue::TextList(svs) => {
85                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
86                        }
87                        _ => {}
88                    }
89                }
90                "ExcIEEEAC4A.kc" => {
91                    match val {
92                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
93                        crate::base::FieldValue::TextList(svs) => {
94                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
95                        }
96                        _ => {}
97                    }
98                }
99                "ExcIEEEAC4A.ta" => {
100                    match val {
101                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
102                        crate::base::FieldValue::TextList(svs) => {
103                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
104                        }
105                        _ => {}
106                    }
107                }
108                "ExcIEEEAC4A.tb" => {
109                    match val {
110                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tb = Some(v); } }
111                        crate::base::FieldValue::TextList(svs) => {
112                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tb = Some(v); } }
113                        }
114                        _ => {}
115                    }
116                }
117                "ExcIEEEAC4A.tc" => {
118                    match val {
119                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tc = Some(v); } }
120                        crate::base::FieldValue::TextList(svs) => {
121                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tc = Some(v); } }
122                        }
123                        _ => {}
124                    }
125                }
126                "ExcIEEEAC4A.vimax" => {
127                    match val {
128                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vimax = Some(v); } }
129                        crate::base::FieldValue::TextList(svs) => {
130                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vimax = Some(v); } }
131                        }
132                        _ => {}
133                    }
134                }
135                "ExcIEEEAC4A.vimin" => {
136                    match val {
137                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vimin = Some(v); } }
138                        crate::base::FieldValue::TextList(svs) => {
139                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vimin = Some(v); } }
140                        }
141                        _ => {}
142                    }
143                }
144                "ExcIEEEAC4A.vrmax" => {
145                    match val {
146                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
147                        crate::base::FieldValue::TextList(svs) => {
148                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
149                        }
150                        _ => {}
151                    }
152                }
153                "ExcIEEEAC4A.vrmin" => {
154                    match val {
155                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
156                        crate::base::FieldValue::TextList(svs) => {
157                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
158                        }
159                        _ => {}
160                    }
161                }
162                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
163                    if let crate::base::FieldValue::Resource(sv) = val {
164                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
165                    }
166                }
167                "DynamicsFunctionBlock.enabled" => {
168                    match val {
169                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
170                        crate::base::FieldValue::TextList(svs) => {
171                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
172                        }
173                        _ => {}
174                    }
175                }
176                "IdentifiedObject.description" => {
177                    match val {
178                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
179                        crate::base::FieldValue::TextList(svs) => {
180                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
181                        }
182                        _ => {}
183                    }
184                }
185                "IdentifiedObject.energyIdentCodeEic" => {
186                    match val {
187                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
188                        crate::base::FieldValue::TextList(svs) => {
189                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
190                        }
191                        _ => {}
192                    }
193                }
194                "IdentifiedObject.mRID" => {
195                    match val {
196                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
197                        crate::base::FieldValue::TextList(svs) => {
198                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
199                        }
200                        _ => {}
201                    }
202                }
203                "IdentifiedObject.name" => {
204                    match val {
205                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
206                        crate::base::FieldValue::TextList(svs) => {
207                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
208                        }
209                        _ => {}
210                    }
211                }
212                "IdentifiedObject.shortName" => {
213                    match val {
214                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
215                        crate::base::FieldValue::TextList(svs) => {
216                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
217                        }
218                        _ => {}
219                    }
220                }
221                _ => {}
222            }
223        }
224        obj
225    }
226}