Skip to main content

cimstructs/
ShuntCompensator.rs

1/// A shunt capacitor or reactor or switchable bank of shunt capacitors or reactors. A section of a shunt compensator is an individual capacitor or reactor. A negative value for bPerSection indicates that the compensator is a reactor. ShuntCompensator is a single terminal device. Ground is implied.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ShuntCompensator {
4    #[serde(flatten)]
5    pub base: super::RegulatingCondEq,
6    /// An automatic voltage regulation delay (AVRDelay) which is the time delay from a change in voltage to when the capacitor is allowed to change state. This filters out temporary changes in voltage.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub a_vr_delay: Option<f64>,
9    /// Used for Yn and Zn connections. True if the neutral is solidly grounded.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub grounded: Option<bool>,
12    /// The maximum number of sections that may be switched in.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub maximum_sections: Option<i64>,
15    /// The voltage at which the nominal reactive power may be calculated. This should normally be within 10% of the voltage at which the capacitor is connected to the network.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub nom_u: Option<f64>,
18    /// The normal number of sections switched in. The value shall be between zero and ShuntCompensator.maximumSections.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub normal_sections: Option<i64>,
21    /// Shunt compensator sections in use. Starting value for steady state solution. The attribute shall be a positive value or zero. Non integer values are allowed to support continuous variables. The reasons for continuous value are to support study cases where no discrete shunt compensators has yet been designed, a solutions where a narrow voltage band force the sections to oscillate or accommodate for a continuous solution as input. For LinearShuntConpensator the value shall be between zero and ShuntCompensator.maximumSections. At value zero the shunt compensator conductance and admittance is zero. Linear interpolation of conductance and admittance between the previous and next integer section is applied in case of non-integer values. For NonlinearShuntCompensator-s shall only be set to one of the NonlinearShuntCompenstorPoint.sectionNumber. There is no interpolation between NonlinearShuntCompenstorPoint-s.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub sections: Option<f64>,
24    /// Voltage sensitivity required for the device to regulate the bus voltage, in voltage/reactive power.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub voltage_sensitivity: Option<f64>,
27}
28impl crate::base::CimElement for ShuntCompensator {
29    fn mrid(&self) -> &str { &self.base.base.base.base.base.base.id }
30    fn type_name(&self) -> &'static str { "ShuntCompensator" }
31    fn as_any(&self) -> &dyn std::any::Any { self }
32    fn to_json_value(&self) -> serde_json::Value {
33        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
34    }
35    fn to_block(&self) -> crate::base::RdfBlock {
36        let mut block = self.base.to_block();
37        block.type_name = "ShuntCompensator".to_string();
38        if let Some(v) = self.a_vr_delay {
39            block.fields.insert("ShuntCompensator.aVRDelay".into(), crate::base::FieldValue::Text(v.to_string()));
40        }
41        if let Some(v) = self.grounded {
42            block.fields.insert("ShuntCompensator.grounded".into(), crate::base::FieldValue::Text(v.to_string()));
43        }
44        if let Some(v) = self.maximum_sections {
45            block.fields.insert("ShuntCompensator.maximumSections".into(), crate::base::FieldValue::Text(v.to_string()));
46        }
47        if let Some(v) = self.nom_u {
48            block.fields.insert("ShuntCompensator.nomU".into(), crate::base::FieldValue::Text(v.to_string()));
49        }
50        if let Some(v) = self.normal_sections {
51            block.fields.insert("ShuntCompensator.normalSections".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.sections {
54            block.fields.insert("ShuntCompensator.sections".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        if let Some(v) = self.voltage_sensitivity {
57            block.fields.insert("ShuntCompensator.voltageSensitivity".into(), crate::base::FieldValue::Text(v.to_string()));
58        }
59        block
60    }
61}
62
63impl ShuntCompensator {
64    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
65        let mut obj = Self::default();
66        obj.base.base.base.base.base.base.id.clone_from(&b.mrid);
67        for (key, val) in &b.fields {
68            match key.as_str() {
69                "ShuntCompensator.aVRDelay" => {
70                    match val {
71                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.a_vr_delay = Some(v); } }
72                        crate::base::FieldValue::TextList(svs) => {
73                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.a_vr_delay = Some(v); } }
74                        }
75                        _ => {}
76                    }
77                }
78                "ShuntCompensator.grounded" => {
79                    match val {
80                        crate::base::FieldValue::Text(sv) => { obj.grounded = Some(sv.trim() == "true"); }
81                        crate::base::FieldValue::TextList(svs) => {
82                            if let Some(sv) = svs.last() { obj.grounded = Some(sv.trim() == "true"); }
83                        }
84                        _ => {}
85                    }
86                }
87                "ShuntCompensator.maximumSections" => {
88                    match val {
89                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.maximum_sections = Some(v); } }
90                        crate::base::FieldValue::TextList(svs) => {
91                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.maximum_sections = Some(v); } }
92                        }
93                        _ => {}
94                    }
95                }
96                "ShuntCompensator.nomU" => {
97                    match val {
98                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.nom_u = Some(v); } }
99                        crate::base::FieldValue::TextList(svs) => {
100                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.nom_u = Some(v); } }
101                        }
102                        _ => {}
103                    }
104                }
105                "ShuntCompensator.normalSections" => {
106                    match val {
107                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.normal_sections = Some(v); } }
108                        crate::base::FieldValue::TextList(svs) => {
109                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.normal_sections = Some(v); } }
110                        }
111                        _ => {}
112                    }
113                }
114                "ShuntCompensator.sections" => {
115                    match val {
116                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.sections = Some(v); } }
117                        crate::base::FieldValue::TextList(svs) => {
118                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.sections = Some(v); } }
119                        }
120                        _ => {}
121                    }
122                }
123                "ShuntCompensator.voltageSensitivity" => {
124                    match val {
125                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.voltage_sensitivity = Some(v); } }
126                        crate::base::FieldValue::TextList(svs) => {
127                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.voltage_sensitivity = Some(v); } }
128                        }
129                        _ => {}
130                    }
131                }
132                "RegulatingCondEq.RegulatingControl" => {
133                    if let crate::base::FieldValue::Resource(sv) = val {
134                        obj.base.regulating_control = Some(crate::base::MridRef { mrid: sv.clone() });
135                    }
136                }
137                "RegulatingCondEq.controlEnabled" => {
138                    match val {
139                        crate::base::FieldValue::Text(sv) => { obj.base.control_enabled = Some(sv.trim() == "true"); }
140                        crate::base::FieldValue::TextList(svs) => {
141                            if let Some(sv) = svs.last() { obj.base.control_enabled = Some(sv.trim() == "true"); }
142                        }
143                        _ => {}
144                    }
145                }
146                "ConductingEquipment.BaseVoltage" => {
147                    if let crate::base::FieldValue::Resource(sv) = val {
148                        obj.base.base.base.base_voltage = Some(crate::base::MridRef { mrid: sv.clone() });
149                    }
150                }
151                "Equipment.EquipmentContainer" => {
152                    if let crate::base::FieldValue::Resource(sv) = val {
153                        obj.base.base.base.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
154                    }
155                }
156                "Equipment.aggregate" => {
157                    match val {
158                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.aggregate = Some(sv.trim() == "true"); }
159                        crate::base::FieldValue::TextList(svs) => {
160                            if let Some(sv) = svs.last() { obj.base.base.base.base.aggregate = Some(sv.trim() == "true"); }
161                        }
162                        _ => {}
163                    }
164                }
165                "Equipment.inService" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.in_service = Some(sv.trim() == "true"); }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { obj.base.base.base.base.in_service = Some(sv.trim() == "true"); }
170                        }
171                        _ => {}
172                    }
173                }
174                "Equipment.normallyInService" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { obj.base.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
179                        }
180                        _ => {}
181                    }
182                }
183                "IdentifiedObject.description" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.description = sv.clone(); }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.description = sv.clone(); }
188                        }
189                        _ => {}
190                    }
191                }
192                "IdentifiedObject.energyIdentCodeEic" => {
193                    match val {
194                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
195                        crate::base::FieldValue::TextList(svs) => {
196                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
197                        }
198                        _ => {}
199                    }
200                }
201                "IdentifiedObject.mRID" => {
202                    match val {
203                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.m_rid = sv.clone(); }
204                        crate::base::FieldValue::TextList(svs) => {
205                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.m_rid = sv.clone(); }
206                        }
207                        _ => {}
208                    }
209                }
210                "IdentifiedObject.name" => {
211                    match val {
212                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.name = sv.clone(); }
213                        crate::base::FieldValue::TextList(svs) => {
214                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.name = sv.clone(); }
215                        }
216                        _ => {}
217                    }
218                }
219                "IdentifiedObject.shortName" => {
220                    match val {
221                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.short_name = sv.clone(); }
222                        crate::base::FieldValue::TextList(svs) => {
223                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.short_name = sv.clone(); }
224                        }
225                        _ => {}
226                    }
227                }
228                _ => {}
229            }
230        }
231        obj
232    }
233}