Skip to main content

cimstructs/
AsynchronousMachineTimeConstantReactance.rs

1/// Parameter details: If X'' = X', a single cage (one equivalent rotor winding per axis) is modelled. The “p” in the attribute names is a substitution for a “prime” in the usual parameter notation, e.g. tpo refers to T'o. The parameters used for models expressed in time constant reactance form include: - RotatingMachine.ratedS (MVAbase); - RotatingMachineDynamics.damping (D); - RotatingMachineDynamics.inertia (H); - RotatingMachineDynamics.saturationFactor (S1); - RotatingMachineDynamics.saturationFactor120 (S12); - RotatingMachineDynamics.statorLeakageReactance (Xl); - RotatingMachineDynamics.statorResistance (Rs); - .xs (Xs); - .xp (X'); - .xpp (X''); - .tpo (T'o); - .tppo (T''o).
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct AsynchronousMachineTimeConstantReactance {
4    #[serde(flatten)]
5    pub base: super::AsynchronousMachineDynamics,
6    /// Transient rotor time constant (T'o) (> AsynchronousMachineTimeConstantReactance.tppo). Typical value = 5.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub tpo: Option<f64>,
9    /// Subtransient rotor time constant (T''o) (> 0). Typical value = 0,03.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub tppo: Option<f64>,
12    /// Transient reactance (unsaturated) (X') (>= AsynchronousMachineTimeConstantReactance.xpp). Typical value = 0,5.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub xp: Option<f64>,
15    /// Subtransient reactance (unsaturated) (X'') (> RotatingMachineDynamics.statorLeakageReactance). Typical value = 0,2.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub xpp: Option<f64>,
18    /// Synchronous reactance (Xs) (>= AsynchronousMachineTimeConstantReactance.xp). Typical value = 1,8.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub xs: Option<f64>,
21}
22impl crate::base::CimElement for AsynchronousMachineTimeConstantReactance {
23    fn mrid(&self) -> &str { &self.base.base.base.base.id }
24    fn type_name(&self) -> &'static str { "AsynchronousMachineTimeConstantReactance" }
25    fn as_any(&self) -> &dyn std::any::Any { self }
26    fn to_json_value(&self) -> serde_json::Value {
27        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
28    }
29    fn to_block(&self) -> crate::base::RdfBlock {
30        let mut block = self.base.to_block();
31        block.type_name = "AsynchronousMachineTimeConstantReactance".to_string();
32        if let Some(v) = self.tpo {
33            block.fields.insert("AsynchronousMachineTimeConstantReactance.tpo".into(), crate::base::FieldValue::Text(v.to_string()));
34        }
35        if let Some(v) = self.tppo {
36            block.fields.insert("AsynchronousMachineTimeConstantReactance.tppo".into(), crate::base::FieldValue::Text(v.to_string()));
37        }
38        if let Some(v) = self.xp {
39            block.fields.insert("AsynchronousMachineTimeConstantReactance.xp".into(), crate::base::FieldValue::Text(v.to_string()));
40        }
41        if let Some(v) = self.xpp {
42            block.fields.insert("AsynchronousMachineTimeConstantReactance.xpp".into(), crate::base::FieldValue::Text(v.to_string()));
43        }
44        if let Some(v) = self.xs {
45            block.fields.insert("AsynchronousMachineTimeConstantReactance.xs".into(), crate::base::FieldValue::Text(v.to_string()));
46        }
47        block
48    }
49}
50
51impl AsynchronousMachineTimeConstantReactance {
52    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
53        let mut obj = Self::default();
54        obj.base.base.base.base.id.clone_from(&b.mrid);
55        for (key, val) in &b.fields {
56            match key.as_str() {
57                "AsynchronousMachineTimeConstantReactance.tpo" => {
58                    match val {
59                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tpo = Some(v); } }
60                        crate::base::FieldValue::TextList(svs) => {
61                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tpo = Some(v); } }
62                        }
63                        _ => {}
64                    }
65                }
66                "AsynchronousMachineTimeConstantReactance.tppo" => {
67                    match val {
68                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tppo = Some(v); } }
69                        crate::base::FieldValue::TextList(svs) => {
70                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tppo = Some(v); } }
71                        }
72                        _ => {}
73                    }
74                }
75                "AsynchronousMachineTimeConstantReactance.xp" => {
76                    match val {
77                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.xp = Some(v); } }
78                        crate::base::FieldValue::TextList(svs) => {
79                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.xp = Some(v); } }
80                        }
81                        _ => {}
82                    }
83                }
84                "AsynchronousMachineTimeConstantReactance.xpp" => {
85                    match val {
86                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.xpp = Some(v); } }
87                        crate::base::FieldValue::TextList(svs) => {
88                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.xpp = Some(v); } }
89                        }
90                        _ => {}
91                    }
92                }
93                "AsynchronousMachineTimeConstantReactance.xs" => {
94                    match val {
95                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.xs = Some(v); } }
96                        crate::base::FieldValue::TextList(svs) => {
97                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.xs = Some(v); } }
98                        }
99                        _ => {}
100                    }
101                }
102                "AsynchronousMachineDynamics.AsynchronousMachine" => {
103                    if let crate::base::FieldValue::Resource(sv) = val {
104                        obj.base.asynchronous_machine = Some(crate::base::MridRef { mrid: sv.clone() });
105                    }
106                }
107                "RotatingMachineDynamics.damping" => {
108                    match val {
109                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.damping = Some(v); } }
110                        crate::base::FieldValue::TextList(svs) => {
111                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.damping = Some(v); } }
112                        }
113                        _ => {}
114                    }
115                }
116                "RotatingMachineDynamics.inertia" => {
117                    match val {
118                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.inertia = Some(v); } }
119                        crate::base::FieldValue::TextList(svs) => {
120                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.inertia = Some(v); } }
121                        }
122                        _ => {}
123                    }
124                }
125                "RotatingMachineDynamics.saturationFactor" => {
126                    match val {
127                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.saturation_factor = Some(v); } }
128                        crate::base::FieldValue::TextList(svs) => {
129                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.saturation_factor = Some(v); } }
130                        }
131                        _ => {}
132                    }
133                }
134                "RotatingMachineDynamics.saturationFactor120" => {
135                    match val {
136                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.saturation_factor120 = Some(v); } }
137                        crate::base::FieldValue::TextList(svs) => {
138                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.saturation_factor120 = Some(v); } }
139                        }
140                        _ => {}
141                    }
142                }
143                "RotatingMachineDynamics.statorLeakageReactance" => {
144                    match val {
145                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.stator_leakage_reactance = Some(v); } }
146                        crate::base::FieldValue::TextList(svs) => {
147                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.stator_leakage_reactance = Some(v); } }
148                        }
149                        _ => {}
150                    }
151                }
152                "RotatingMachineDynamics.statorResistance" => {
153                    match val {
154                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.stator_resistance = Some(v); } }
155                        crate::base::FieldValue::TextList(svs) => {
156                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.stator_resistance = Some(v); } }
157                        }
158                        _ => {}
159                    }
160                }
161                "DynamicsFunctionBlock.enabled" => {
162                    match val {
163                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.enabled = Some(sv.trim() == "true"); }
164                        crate::base::FieldValue::TextList(svs) => {
165                            if let Some(sv) = svs.last() { obj.base.base.base.enabled = Some(sv.trim() == "true"); }
166                        }
167                        _ => {}
168                    }
169                }
170                "IdentifiedObject.description" => {
171                    match val {
172                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.description = sv.clone(); }
173                        crate::base::FieldValue::TextList(svs) => {
174                            if let Some(sv) = svs.last() { obj.base.base.base.base.description = sv.clone(); }
175                        }
176                        _ => {}
177                    }
178                }
179                "IdentifiedObject.energyIdentCodeEic" => {
180                    match val {
181                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
182                        crate::base::FieldValue::TextList(svs) => {
183                            if let Some(sv) = svs.last() { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
184                        }
185                        _ => {}
186                    }
187                }
188                "IdentifiedObject.mRID" => {
189                    match val {
190                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.m_rid = sv.clone(); }
191                        crate::base::FieldValue::TextList(svs) => {
192                            if let Some(sv) = svs.last() { obj.base.base.base.base.m_rid = sv.clone(); }
193                        }
194                        _ => {}
195                    }
196                }
197                "IdentifiedObject.name" => {
198                    match val {
199                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.name = sv.clone(); }
200                        crate::base::FieldValue::TextList(svs) => {
201                            if let Some(sv) = svs.last() { obj.base.base.base.base.name = sv.clone(); }
202                        }
203                        _ => {}
204                    }
205                }
206                "IdentifiedObject.shortName" => {
207                    match val {
208                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.short_name = sv.clone(); }
209                        crate::base::FieldValue::TextList(svs) => {
210                            if let Some(sv) = svs.last() { obj.base.base.base.base.short_name = sv.clone(); }
211                        }
212                        _ => {}
213                    }
214                }
215                _ => {}
216            }
217        }
218        obj
219    }
220}