Skip to main content

cimstructs/
PowerTransformer.rs

1/// An electrical device consisting of two or more coupled windings, with or without a magnetic core, for introducing mutual coupling between electric circuits. Transformers can be used to control voltage and phase shift (active power flow). A power transformer may be composed of separate transformer tanks that need not be identical. A power transformer can be modelled with or without tanks and is intended for use in both balanced and unbalanced representations. A power transformer typically has two terminals, but may have one (grounding), three or more terminals. The inherited association ConductingEquipment.BaseVoltage should not be used. The association from TransformerEnd to BaseVoltage should be used instead.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct PowerTransformer {
4    #[serde(flatten)]
5    pub base: super::ConductingEquipment,
6    /// The highest operating current (Ib in IEC 60909-0) before short circuit (depends on network configuration and relevant reliability philosophy). It is used for calculation of the impedance correction factor KT defined in IEC 60909-0.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub before_sh_circuit_highest_operating_current: Option<f64>,
9    /// The highest operating voltage (Ub in IEC 60909-0) before short circuit. It is used for calculation of the impedance correction factor KT defined in IEC 60909-0. This is worst case voltage on the low side winding (3.7.1 of IEC 60909:2001). Used to define operating conditions.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub before_sh_circuit_highest_operating_voltage: Option<f64>,
12    /// The angle of power factor before short circuit (phib in IEC 60909-0). It is used for calculation of the impedance correction factor KT defined in IEC 60909-0. This is the worst case power factor. Used to define operating conditions.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub before_short_circuit_angle_pf: Option<f64>,
15    /// The minimum operating voltage (uQmin in IEC 60909-0) at the high voltage side (Q side) of the unit transformer of the power station unit. A value well established from long-term operating experience of the system. It is used for calculation of the impedance correction factor KG defined in IEC 60909-0.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub high_side_min_operating_u: Option<f64>,
18    /// Indicates whether the machine is part of a power station unit. Used for short circuit data exchange according to IEC 60909. It has an impact on how the correction factors are calculated for transformers, since the transformer is not necessarily part of a synchronous machine and generating unit. It is not always possible to derive this information from the model. This is why the attribute is necessary.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub is_part_of_generator_unit: Option<bool>,
21    /// It is used to define if the data (other attributes related to short circuit data exchange) defines long term operational conditions or not. Used for short circuit data exchange according to IEC 60909.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub operational_values_considered: Option<bool>,
24}
25impl crate::base::CimElement for PowerTransformer {
26    fn mrid(&self) -> &str { &self.base.base.base.base.id }
27    fn type_name(&self) -> &'static str { "PowerTransformer" }
28    fn as_any(&self) -> &dyn std::any::Any { self }
29    fn to_json_value(&self) -> serde_json::Value {
30        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
31    }
32    fn to_block(&self) -> crate::base::RdfBlock {
33        let mut block = self.base.to_block();
34        block.type_name = "PowerTransformer".to_string();
35        if let Some(v) = self.before_sh_circuit_highest_operating_current {
36            block.fields.insert("PowerTransformer.beforeShCircuitHighestOperatingCurrent".into(), crate::base::FieldValue::Text(v.to_string()));
37        }
38        if let Some(v) = self.before_sh_circuit_highest_operating_voltage {
39            block.fields.insert("PowerTransformer.beforeShCircuitHighestOperatingVoltage".into(), crate::base::FieldValue::Text(v.to_string()));
40        }
41        if let Some(v) = self.before_short_circuit_angle_pf {
42            block.fields.insert("PowerTransformer.beforeShortCircuitAnglePf".into(), crate::base::FieldValue::Text(v.to_string()));
43        }
44        if let Some(v) = self.high_side_min_operating_u {
45            block.fields.insert("PowerTransformer.highSideMinOperatingU".into(), crate::base::FieldValue::Text(v.to_string()));
46        }
47        if let Some(v) = self.is_part_of_generator_unit {
48            block.fields.insert("PowerTransformer.isPartOfGeneratorUnit".into(), crate::base::FieldValue::Text(v.to_string()));
49        }
50        if let Some(v) = self.operational_values_considered {
51            block.fields.insert("PowerTransformer.operationalValuesConsidered".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        block
54    }
55}
56
57impl PowerTransformer {
58    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
59        let mut obj = Self::default();
60        obj.base.base.base.base.id.clone_from(&b.mrid);
61        for (key, val) in &b.fields {
62            match key.as_str() {
63                "PowerTransformer.beforeShCircuitHighestOperatingCurrent" => {
64                    match val {
65                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.before_sh_circuit_highest_operating_current = Some(v); } }
66                        crate::base::FieldValue::TextList(svs) => {
67                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.before_sh_circuit_highest_operating_current = Some(v); } }
68                        }
69                        _ => {}
70                    }
71                }
72                "PowerTransformer.beforeShCircuitHighestOperatingVoltage" => {
73                    match val {
74                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.before_sh_circuit_highest_operating_voltage = Some(v); } }
75                        crate::base::FieldValue::TextList(svs) => {
76                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.before_sh_circuit_highest_operating_voltage = Some(v); } }
77                        }
78                        _ => {}
79                    }
80                }
81                "PowerTransformer.beforeShortCircuitAnglePf" => {
82                    match val {
83                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.before_short_circuit_angle_pf = Some(v); } }
84                        crate::base::FieldValue::TextList(svs) => {
85                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.before_short_circuit_angle_pf = Some(v); } }
86                        }
87                        _ => {}
88                    }
89                }
90                "PowerTransformer.highSideMinOperatingU" => {
91                    match val {
92                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.high_side_min_operating_u = Some(v); } }
93                        crate::base::FieldValue::TextList(svs) => {
94                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.high_side_min_operating_u = Some(v); } }
95                        }
96                        _ => {}
97                    }
98                }
99                "PowerTransformer.isPartOfGeneratorUnit" => {
100                    match val {
101                        crate::base::FieldValue::Text(sv) => { obj.is_part_of_generator_unit = Some(sv.trim() == "true"); }
102                        crate::base::FieldValue::TextList(svs) => {
103                            if let Some(sv) = svs.last() { obj.is_part_of_generator_unit = Some(sv.trim() == "true"); }
104                        }
105                        _ => {}
106                    }
107                }
108                "PowerTransformer.operationalValuesConsidered" => {
109                    match val {
110                        crate::base::FieldValue::Text(sv) => { obj.operational_values_considered = Some(sv.trim() == "true"); }
111                        crate::base::FieldValue::TextList(svs) => {
112                            if let Some(sv) = svs.last() { obj.operational_values_considered = Some(sv.trim() == "true"); }
113                        }
114                        _ => {}
115                    }
116                }
117                "ConductingEquipment.BaseVoltage" => {
118                    if let crate::base::FieldValue::Resource(sv) = val {
119                        obj.base.base_voltage = Some(crate::base::MridRef { mrid: sv.clone() });
120                    }
121                }
122                "Equipment.EquipmentContainer" => {
123                    if let crate::base::FieldValue::Resource(sv) = val {
124                        obj.base.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
125                    }
126                }
127                "Equipment.aggregate" => {
128                    match val {
129                        crate::base::FieldValue::Text(sv) => { obj.base.base.aggregate = Some(sv.trim() == "true"); }
130                        crate::base::FieldValue::TextList(svs) => {
131                            if let Some(sv) = svs.last() { obj.base.base.aggregate = Some(sv.trim() == "true"); }
132                        }
133                        _ => {}
134                    }
135                }
136                "Equipment.inService" => {
137                    match val {
138                        crate::base::FieldValue::Text(sv) => { obj.base.base.in_service = Some(sv.trim() == "true"); }
139                        crate::base::FieldValue::TextList(svs) => {
140                            if let Some(sv) = svs.last() { obj.base.base.in_service = Some(sv.trim() == "true"); }
141                        }
142                        _ => {}
143                    }
144                }
145                "Equipment.normallyInService" => {
146                    match val {
147                        crate::base::FieldValue::Text(sv) => { obj.base.base.normally_in_service = Some(sv.trim() == "true"); }
148                        crate::base::FieldValue::TextList(svs) => {
149                            if let Some(sv) = svs.last() { obj.base.base.normally_in_service = Some(sv.trim() == "true"); }
150                        }
151                        _ => {}
152                    }
153                }
154                "IdentifiedObject.description" => {
155                    match val {
156                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.description = sv.clone(); }
157                        crate::base::FieldValue::TextList(svs) => {
158                            if let Some(sv) = svs.last() { obj.base.base.base.base.description = sv.clone(); }
159                        }
160                        _ => {}
161                    }
162                }
163                "IdentifiedObject.energyIdentCodeEic" => {
164                    match val {
165                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
166                        crate::base::FieldValue::TextList(svs) => {
167                            if let Some(sv) = svs.last() { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
168                        }
169                        _ => {}
170                    }
171                }
172                "IdentifiedObject.mRID" => {
173                    match val {
174                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.m_rid = sv.clone(); }
175                        crate::base::FieldValue::TextList(svs) => {
176                            if let Some(sv) = svs.last() { obj.base.base.base.base.m_rid = sv.clone(); }
177                        }
178                        _ => {}
179                    }
180                }
181                "IdentifiedObject.name" => {
182                    match val {
183                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.name = sv.clone(); }
184                        crate::base::FieldValue::TextList(svs) => {
185                            if let Some(sv) = svs.last() { obj.base.base.base.base.name = sv.clone(); }
186                        }
187                        _ => {}
188                    }
189                }
190                "IdentifiedObject.shortName" => {
191                    match val {
192                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.short_name = sv.clone(); }
193                        crate::base::FieldValue::TextList(svs) => {
194                            if let Some(sv) = svs.last() { obj.base.base.base.base.short_name = sv.clone(); }
195                        }
196                        _ => {}
197                    }
198                }
199                _ => {}
200            }
201        }
202        obj
203    }
204}