Skip to main content

cimstructs/
ACDCConverter.rs

1/// A unit with valves for three phases, together with unit control equipment, essential protective and switching devices, DC storage capacitors, phase reactors and auxiliaries, if any, used for conversion.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ACDCConverter {
4    #[serde(flatten)]
5    pub base: super::ConductingEquipment,
6    /// Point of common coupling terminal for this converter DC side. It is typically the terminal on the power transformer (or switch) closest to the AC network.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub pcc_terminal: Option<super::base::MridRef>,
9    /// Base apparent power of the converter pole. The attribute shall be a positive value.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub base_s: Option<f64>,
12    /// Converter DC current, also called Id. It is converter’s state variable, result from power flow.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub idc: Option<f64>,
15    /// Active power loss in pole at no power transfer. It is converter’s configuration data used in power flow. The attribute shall be a positive value.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub idle_loss: Option<f64>,
18    /// Maximum active power limit. The value is overwritten by values of VsCapabilityCurve, if present.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub max_p: Option<f64>,
21    /// The maximum voltage on the DC side at which the converter should operate. It is converter’s configuration data used in power flow. The attribute shall be a positive value.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub max_udc: Option<f64>,
24    /// Minimum active power limit. The value is overwritten by values of VsCapabilityCurve, if present.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub min_p: Option<f64>,
27    /// The minimum voltage on the DC side at which the converter should operate. It is converter’s configuration data used in power flow. The attribute shall be a positive value.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub min_udc: Option<f64>,
30    /// Number of valves in the converter. Used in loss calculations.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub number_of_valves: Option<i64>,
33    /// Active power at the point of common coupling. Load sign convention is used, i.e. positive sign means flow out from a node. Starting value for a steady state solution in the case a simplified power flow model is used.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub p: Option<f64>,
36    /// The active power loss at a DC Pole = idleLoss + switchingLoss*|Idc| + resitiveLoss*Idc^2. For lossless operation Pdc=Pac. For rectifier operation with losses Pdc=Pac-lossP. For inverter operation with losses Pdc=Pac+lossP. It is converter’s state variable used in power flow. The attribute shall be a positive value.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub pole_loss_p: Option<f64>,
39    /// Reactive power at the point of common coupling. Load sign convention is used, i.e. positive sign means flow out from a node. Starting value for a steady state solution in the case a simplified power flow model is used.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub q: Option<f64>,
42    /// Rated converter DC voltage, also called UdN. The attribute shall be a positive value. It is converter’s configuration data used in power flow. For instance a bipolar HVDC link with value 200 kV has a 400kV difference between the dc lines.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub rated_udc: Option<f64>,
45    /// It is converter’s configuration data used in power flow. Refer to poleLossP. The attribute shall be a positive value.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub resistive_loss: Option<f64>,
48    /// Switching losses, relative to the base apparent power 'baseS'. Refer to poleLossP. The attribute shall be a positive value.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub switching_loss: Option<f64>,
51    /// Real power injection target in AC grid, at point of common coupling. Load sign convention is used, i.e. positive sign means flow out from a node.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub target_ppcc: Option<f64>,
54    /// Target value for DC voltage magnitude. The attribute shall be a positive value.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub target_udc: Option<f64>,
57    /// Line-to-line converter voltage, the voltage at the AC side of the valve. It is converter’s state variable, result from power flow. The attribute shall be a positive value.
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub uc: Option<f64>,
60    /// Converter voltage at the DC side, also called Ud. It is converter’s state variable, result from power flow. The attribute shall be a positive value.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub udc: Option<f64>,
63    /// Valve threshold voltage, also called Uvalve. Forward voltage drop when the valve is conducting. Used in loss calculations, i.e. the switchLoss depend on numberOfValves * valveU0.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub valve_u0: Option<f64>,
66}
67impl crate::base::CimElement for ACDCConverter {
68    fn mrid(&self) -> &str { &self.base.base.base.base.id }
69    fn type_name(&self) -> &'static str { "ACDCConverter" }
70    fn as_any(&self) -> &dyn std::any::Any { self }
71    fn to_json_value(&self) -> serde_json::Value {
72        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
73    }
74    fn to_block(&self) -> crate::base::RdfBlock {
75        let mut block = self.base.to_block();
76        block.type_name = "ACDCConverter".to_string();
77        if let Some(ref v) = self.pcc_terminal {
78            block.fields.insert("ACDCConverter.PccTerminal".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
79        }
80        if let Some(v) = self.base_s {
81            block.fields.insert("ACDCConverter.baseS".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.idc {
84            block.fields.insert("ACDCConverter.idc".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.idle_loss {
87            block.fields.insert("ACDCConverter.idleLoss".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.max_p {
90            block.fields.insert("ACDCConverter.maxP".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.max_udc {
93            block.fields.insert("ACDCConverter.maxUdc".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.min_p {
96            block.fields.insert("ACDCConverter.minP".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.min_udc {
99            block.fields.insert("ACDCConverter.minUdc".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.number_of_valves {
102            block.fields.insert("ACDCConverter.numberOfValves".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.p {
105            block.fields.insert("ACDCConverter.p".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        if let Some(v) = self.pole_loss_p {
108            block.fields.insert("ACDCConverter.poleLossP".into(), crate::base::FieldValue::Text(v.to_string()));
109        }
110        if let Some(v) = self.q {
111            block.fields.insert("ACDCConverter.q".into(), crate::base::FieldValue::Text(v.to_string()));
112        }
113        if let Some(v) = self.rated_udc {
114            block.fields.insert("ACDCConverter.ratedUdc".into(), crate::base::FieldValue::Text(v.to_string()));
115        }
116        if let Some(v) = self.resistive_loss {
117            block.fields.insert("ACDCConverter.resistiveLoss".into(), crate::base::FieldValue::Text(v.to_string()));
118        }
119        if let Some(v) = self.switching_loss {
120            block.fields.insert("ACDCConverter.switchingLoss".into(), crate::base::FieldValue::Text(v.to_string()));
121        }
122        if let Some(v) = self.target_ppcc {
123            block.fields.insert("ACDCConverter.targetPpcc".into(), crate::base::FieldValue::Text(v.to_string()));
124        }
125        if let Some(v) = self.target_udc {
126            block.fields.insert("ACDCConverter.targetUdc".into(), crate::base::FieldValue::Text(v.to_string()));
127        }
128        if let Some(v) = self.uc {
129            block.fields.insert("ACDCConverter.uc".into(), crate::base::FieldValue::Text(v.to_string()));
130        }
131        if let Some(v) = self.udc {
132            block.fields.insert("ACDCConverter.udc".into(), crate::base::FieldValue::Text(v.to_string()));
133        }
134        if let Some(v) = self.valve_u0 {
135            block.fields.insert("ACDCConverter.valveU0".into(), crate::base::FieldValue::Text(v.to_string()));
136        }
137        block
138    }
139}
140
141impl ACDCConverter {
142    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
143        let mut obj = Self::default();
144        obj.base.base.base.base.id.clone_from(&b.mrid);
145        for (key, val) in &b.fields {
146            match key.as_str() {
147                "ACDCConverter.PccTerminal" => {
148                    if let crate::base::FieldValue::Resource(sv) = val {
149                        obj.pcc_terminal = Some(crate::base::MridRef { mrid: sv.clone() });
150                    }
151                }
152                "ACDCConverter.baseS" => {
153                    match val {
154                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base_s = Some(v); } }
155                        crate::base::FieldValue::TextList(svs) => {
156                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base_s = Some(v); } }
157                        }
158                        _ => {}
159                    }
160                }
161                "ACDCConverter.idc" => {
162                    match val {
163                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.idc = Some(v); } }
164                        crate::base::FieldValue::TextList(svs) => {
165                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.idc = Some(v); } }
166                        }
167                        _ => {}
168                    }
169                }
170                "ACDCConverter.idleLoss" => {
171                    match val {
172                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.idle_loss = Some(v); } }
173                        crate::base::FieldValue::TextList(svs) => {
174                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.idle_loss = Some(v); } }
175                        }
176                        _ => {}
177                    }
178                }
179                "ACDCConverter.maxP" => {
180                    match val {
181                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.max_p = Some(v); } }
182                        crate::base::FieldValue::TextList(svs) => {
183                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.max_p = Some(v); } }
184                        }
185                        _ => {}
186                    }
187                }
188                "ACDCConverter.maxUdc" => {
189                    match val {
190                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.max_udc = Some(v); } }
191                        crate::base::FieldValue::TextList(svs) => {
192                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.max_udc = Some(v); } }
193                        }
194                        _ => {}
195                    }
196                }
197                "ACDCConverter.minP" => {
198                    match val {
199                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.min_p = Some(v); } }
200                        crate::base::FieldValue::TextList(svs) => {
201                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.min_p = Some(v); } }
202                        }
203                        _ => {}
204                    }
205                }
206                "ACDCConverter.minUdc" => {
207                    match val {
208                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.min_udc = Some(v); } }
209                        crate::base::FieldValue::TextList(svs) => {
210                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.min_udc = Some(v); } }
211                        }
212                        _ => {}
213                    }
214                }
215                "ACDCConverter.numberOfValves" => {
216                    match val {
217                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.number_of_valves = Some(v); } }
218                        crate::base::FieldValue::TextList(svs) => {
219                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.number_of_valves = Some(v); } }
220                        }
221                        _ => {}
222                    }
223                }
224                "ACDCConverter.p" => {
225                    match val {
226                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.p = Some(v); } }
227                        crate::base::FieldValue::TextList(svs) => {
228                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.p = Some(v); } }
229                        }
230                        _ => {}
231                    }
232                }
233                "ACDCConverter.poleLossP" => {
234                    match val {
235                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.pole_loss_p = Some(v); } }
236                        crate::base::FieldValue::TextList(svs) => {
237                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.pole_loss_p = Some(v); } }
238                        }
239                        _ => {}
240                    }
241                }
242                "ACDCConverter.q" => {
243                    match val {
244                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.q = Some(v); } }
245                        crate::base::FieldValue::TextList(svs) => {
246                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.q = Some(v); } }
247                        }
248                        _ => {}
249                    }
250                }
251                "ACDCConverter.ratedUdc" => {
252                    match val {
253                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.rated_udc = Some(v); } }
254                        crate::base::FieldValue::TextList(svs) => {
255                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.rated_udc = Some(v); } }
256                        }
257                        _ => {}
258                    }
259                }
260                "ACDCConverter.resistiveLoss" => {
261                    match val {
262                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.resistive_loss = Some(v); } }
263                        crate::base::FieldValue::TextList(svs) => {
264                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.resistive_loss = Some(v); } }
265                        }
266                        _ => {}
267                    }
268                }
269                "ACDCConverter.switchingLoss" => {
270                    match val {
271                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.switching_loss = Some(v); } }
272                        crate::base::FieldValue::TextList(svs) => {
273                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.switching_loss = Some(v); } }
274                        }
275                        _ => {}
276                    }
277                }
278                "ACDCConverter.targetPpcc" => {
279                    match val {
280                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.target_ppcc = Some(v); } }
281                        crate::base::FieldValue::TextList(svs) => {
282                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.target_ppcc = Some(v); } }
283                        }
284                        _ => {}
285                    }
286                }
287                "ACDCConverter.targetUdc" => {
288                    match val {
289                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.target_udc = Some(v); } }
290                        crate::base::FieldValue::TextList(svs) => {
291                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.target_udc = Some(v); } }
292                        }
293                        _ => {}
294                    }
295                }
296                "ACDCConverter.uc" => {
297                    match val {
298                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.uc = Some(v); } }
299                        crate::base::FieldValue::TextList(svs) => {
300                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.uc = Some(v); } }
301                        }
302                        _ => {}
303                    }
304                }
305                "ACDCConverter.udc" => {
306                    match val {
307                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.udc = Some(v); } }
308                        crate::base::FieldValue::TextList(svs) => {
309                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.udc = Some(v); } }
310                        }
311                        _ => {}
312                    }
313                }
314                "ACDCConverter.valveU0" => {
315                    match val {
316                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.valve_u0 = Some(v); } }
317                        crate::base::FieldValue::TextList(svs) => {
318                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.valve_u0 = Some(v); } }
319                        }
320                        _ => {}
321                    }
322                }
323                "ConductingEquipment.BaseVoltage" => {
324                    if let crate::base::FieldValue::Resource(sv) = val {
325                        obj.base.base_voltage = Some(crate::base::MridRef { mrid: sv.clone() });
326                    }
327                }
328                "Equipment.EquipmentContainer" => {
329                    if let crate::base::FieldValue::Resource(sv) = val {
330                        obj.base.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
331                    }
332                }
333                "Equipment.aggregate" => {
334                    match val {
335                        crate::base::FieldValue::Text(sv) => { obj.base.base.aggregate = Some(sv.trim() == "true"); }
336                        crate::base::FieldValue::TextList(svs) => {
337                            if let Some(sv) = svs.last() { obj.base.base.aggregate = Some(sv.trim() == "true"); }
338                        }
339                        _ => {}
340                    }
341                }
342                "Equipment.inService" => {
343                    match val {
344                        crate::base::FieldValue::Text(sv) => { obj.base.base.in_service = Some(sv.trim() == "true"); }
345                        crate::base::FieldValue::TextList(svs) => {
346                            if let Some(sv) = svs.last() { obj.base.base.in_service = Some(sv.trim() == "true"); }
347                        }
348                        _ => {}
349                    }
350                }
351                "Equipment.normallyInService" => {
352                    match val {
353                        crate::base::FieldValue::Text(sv) => { obj.base.base.normally_in_service = Some(sv.trim() == "true"); }
354                        crate::base::FieldValue::TextList(svs) => {
355                            if let Some(sv) = svs.last() { obj.base.base.normally_in_service = Some(sv.trim() == "true"); }
356                        }
357                        _ => {}
358                    }
359                }
360                "IdentifiedObject.description" => {
361                    match val {
362                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.description = sv.clone(); }
363                        crate::base::FieldValue::TextList(svs) => {
364                            if let Some(sv) = svs.last() { obj.base.base.base.base.description = sv.clone(); }
365                        }
366                        _ => {}
367                    }
368                }
369                "IdentifiedObject.energyIdentCodeEic" => {
370                    match val {
371                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
372                        crate::base::FieldValue::TextList(svs) => {
373                            if let Some(sv) = svs.last() { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
374                        }
375                        _ => {}
376                    }
377                }
378                "IdentifiedObject.mRID" => {
379                    match val {
380                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.m_rid = sv.clone(); }
381                        crate::base::FieldValue::TextList(svs) => {
382                            if let Some(sv) = svs.last() { obj.base.base.base.base.m_rid = sv.clone(); }
383                        }
384                        _ => {}
385                    }
386                }
387                "IdentifiedObject.name" => {
388                    match val {
389                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.name = sv.clone(); }
390                        crate::base::FieldValue::TextList(svs) => {
391                            if let Some(sv) = svs.last() { obj.base.base.base.base.name = sv.clone(); }
392                        }
393                        _ => {}
394                    }
395                }
396                "IdentifiedObject.shortName" => {
397                    match val {
398                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.short_name = sv.clone(); }
399                        crate::base::FieldValue::TextList(svs) => {
400                            if let Some(sv) = svs.last() { obj.base.base.base.base.short_name = sv.clone(); }
401                        }
402                        _ => {}
403                    }
404                }
405                _ => {}
406            }
407        }
408        obj
409    }
410}