Skip to main content

cimstructs/
WindContPType3IEC.rs

1/// P control model type 3. Reference: IEC 61400-27-1:2015, 5.6.5.4.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct WindContPType3IEC {
4    #[serde(flatten)]
5    pub base: super::IdentifiedObject,
6    /// Maximum wind turbine power ramp rate (dpmax). It is a type-dependent parameter.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub dpmax: Option<f64>,
9    /// Maximum ramp rate of wind turbine reference power (dprefmax). It is a project-dependent parameter.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub dprefmax: Option<f64>,
12    /// Minimum ramp rate of wind turbine reference power (dprefmin). It is a project-dependent parameter.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub dprefmin: Option<f64>,
15    /// Ramp limitation of torque, required in some grid codes (dtmax). It is a project-dependent parameter.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub dthetamax: Option<f64>,
18    /// Limitation of torque rise rate during UVRT (dthetamaxUVRT). It is a project-dependent parameter.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub dthetamaxuvrt: Option<f64>,
21    /// Gain for active drive train damping (KDTD). It is a type-dependent parameter.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub kdtd: Option<f64>,
24    /// PI controller integration parameter (KIp). It is a type-dependent parameter.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub kip: Option<f64>,
27    /// PI controller proportional gain (KPp). It is a type-dependent parameter.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub kpp: Option<f64>,
30    /// Enable UVRT power control mode (MpUVRT). It is a project-dependent parameter. true = voltage control (1 in the IEC model) false = reactive power control (0 in the IEC model).
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub mpuvrt: Option<bool>,
33    /// Active drive train damping frequency (omegaDTD). It can be calculated from two mass model parameters. It is a type-dependent parameter.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub omegadtd: Option<f64>,
36    /// Offset to reference value that limits controller action during rotor speed changes (omegaoffset). It is a case-dependent parameter.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub omegaoffset: Option<f64>,
39    /// Maximum active drive train damping power (pDTDmax). It is a type-dependent parameter.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub pdtdmax: Option<f64>,
42    /// Time delay after deep voltage sags (TDVS) (>= 0). It is a project-dependent parameter.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub tdvs: Option<f64>,
45    /// Minimum electrical generator torque (temin). It is a type-dependent parameter.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub thetaemin: Option<f64>,
48    /// Voltage scaling factor of reset-torque (tuscale). It is a project-dependent parameter.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub thetauscale: Option<f64>,
51    /// Filter time constant for generator speed measurement (Tomegafiltp3) (>= 0). It is a type-dependent parameter.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub tomegafiltp3: Option<f64>,
54    /// Time constant in speed reference filter (Tomega,ref) (>= 0). It is a type-dependent parameter.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub tomegaref: Option<f64>,
57    /// Filter time constant for power measurement (Tpfiltp3) (>= 0). It is a type-dependent parameter.
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub tpfiltp3: Option<f64>,
60    /// Time constant in power order lag (Tpord). It is a type-dependent parameter.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub tpord: Option<f64>,
63    /// Filter time constant for voltage measurement (Tufiltp3) (>= 0). It is a type-dependent parameter.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub tufiltp3: Option<f64>,
66    /// Voltage limit for hold UVRT status after deep voltage sags (uDVS). It is a project-dependent parameter.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub udvs: Option<f64>,
69    /// Voltage dip threshold for P-control (uPdip). Part of turbine control, often different (e.g 0.8) from converter thresholds. It is a project-dependent parameter.
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub updip: Option<f64>,
72    /// Coefficient for active drive train damping (zeta). It is a type-dependent parameter.
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub zeta: Option<f64>,
75}
76impl crate::base::CimElement for WindContPType3IEC {
77    fn mrid(&self) -> &str { &self.base.id }
78    fn type_name(&self) -> &'static str { "WindContPType3IEC" }
79    fn as_any(&self) -> &dyn std::any::Any { self }
80    fn to_json_value(&self) -> serde_json::Value {
81        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
82    }
83    fn to_block(&self) -> crate::base::RdfBlock {
84        let mut block = self.base.to_block();
85        block.type_name = "WindContPType3IEC".to_string();
86        if let Some(v) = self.dpmax {
87            block.fields.insert("WindContPType3IEC.dpmax".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.dprefmax {
90            block.fields.insert("WindContPType3IEC.dprefmax".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.dprefmin {
93            block.fields.insert("WindContPType3IEC.dprefmin".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.dthetamax {
96            block.fields.insert("WindContPType3IEC.dthetamax".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.dthetamaxuvrt {
99            block.fields.insert("WindContPType3IEC.dthetamaxuvrt".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.kdtd {
102            block.fields.insert("WindContPType3IEC.kdtd".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.kip {
105            block.fields.insert("WindContPType3IEC.kip".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        if let Some(v) = self.kpp {
108            block.fields.insert("WindContPType3IEC.kpp".into(), crate::base::FieldValue::Text(v.to_string()));
109        }
110        if let Some(v) = self.mpuvrt {
111            block.fields.insert("WindContPType3IEC.mpuvrt".into(), crate::base::FieldValue::Text(v.to_string()));
112        }
113        if let Some(v) = self.omegadtd {
114            block.fields.insert("WindContPType3IEC.omegadtd".into(), crate::base::FieldValue::Text(v.to_string()));
115        }
116        if let Some(v) = self.omegaoffset {
117            block.fields.insert("WindContPType3IEC.omegaoffset".into(), crate::base::FieldValue::Text(v.to_string()));
118        }
119        if let Some(v) = self.pdtdmax {
120            block.fields.insert("WindContPType3IEC.pdtdmax".into(), crate::base::FieldValue::Text(v.to_string()));
121        }
122        if let Some(v) = self.tdvs {
123            block.fields.insert("WindContPType3IEC.tdvs".into(), crate::base::FieldValue::Text(v.to_string()));
124        }
125        if let Some(v) = self.thetaemin {
126            block.fields.insert("WindContPType3IEC.thetaemin".into(), crate::base::FieldValue::Text(v.to_string()));
127        }
128        if let Some(v) = self.thetauscale {
129            block.fields.insert("WindContPType3IEC.thetauscale".into(), crate::base::FieldValue::Text(v.to_string()));
130        }
131        if let Some(v) = self.tomegafiltp3 {
132            block.fields.insert("WindContPType3IEC.tomegafiltp3".into(), crate::base::FieldValue::Text(v.to_string()));
133        }
134        if let Some(v) = self.tomegaref {
135            block.fields.insert("WindContPType3IEC.tomegaref".into(), crate::base::FieldValue::Text(v.to_string()));
136        }
137        if let Some(v) = self.tpfiltp3 {
138            block.fields.insert("WindContPType3IEC.tpfiltp3".into(), crate::base::FieldValue::Text(v.to_string()));
139        }
140        if let Some(v) = self.tpord {
141            block.fields.insert("WindContPType3IEC.tpord".into(), crate::base::FieldValue::Text(v.to_string()));
142        }
143        if let Some(v) = self.tufiltp3 {
144            block.fields.insert("WindContPType3IEC.tufiltp3".into(), crate::base::FieldValue::Text(v.to_string()));
145        }
146        if let Some(v) = self.udvs {
147            block.fields.insert("WindContPType3IEC.udvs".into(), crate::base::FieldValue::Text(v.to_string()));
148        }
149        if let Some(v) = self.updip {
150            block.fields.insert("WindContPType3IEC.updip".into(), crate::base::FieldValue::Text(v.to_string()));
151        }
152        if let Some(v) = self.zeta {
153            block.fields.insert("WindContPType3IEC.zeta".into(), crate::base::FieldValue::Text(v.to_string()));
154        }
155        block
156    }
157}
158
159impl WindContPType3IEC {
160    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
161        let mut obj = Self::default();
162        obj.base.id.clone_from(&b.mrid);
163        for (key, val) in &b.fields {
164            match key.as_str() {
165                "WindContPType3IEC.dpmax" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.dpmax = Some(v); } }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.dpmax = Some(v); } }
170                        }
171                        _ => {}
172                    }
173                }
174                "WindContPType3IEC.dprefmax" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.dprefmax = Some(v); } }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.dprefmax = Some(v); } }
179                        }
180                        _ => {}
181                    }
182                }
183                "WindContPType3IEC.dprefmin" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.dprefmin = Some(v); } }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.dprefmin = Some(v); } }
188                        }
189                        _ => {}
190                    }
191                }
192                "WindContPType3IEC.dthetamax" => {
193                    match val {
194                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.dthetamax = Some(v); } }
195                        crate::base::FieldValue::TextList(svs) => {
196                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.dthetamax = Some(v); } }
197                        }
198                        _ => {}
199                    }
200                }
201                "WindContPType3IEC.dthetamaxuvrt" => {
202                    match val {
203                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.dthetamaxuvrt = Some(v); } }
204                        crate::base::FieldValue::TextList(svs) => {
205                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.dthetamaxuvrt = Some(v); } }
206                        }
207                        _ => {}
208                    }
209                }
210                "WindContPType3IEC.kdtd" => {
211                    match val {
212                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kdtd = Some(v); } }
213                        crate::base::FieldValue::TextList(svs) => {
214                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kdtd = Some(v); } }
215                        }
216                        _ => {}
217                    }
218                }
219                "WindContPType3IEC.kip" => {
220                    match val {
221                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kip = Some(v); } }
222                        crate::base::FieldValue::TextList(svs) => {
223                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kip = Some(v); } }
224                        }
225                        _ => {}
226                    }
227                }
228                "WindContPType3IEC.kpp" => {
229                    match val {
230                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kpp = Some(v); } }
231                        crate::base::FieldValue::TextList(svs) => {
232                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kpp = Some(v); } }
233                        }
234                        _ => {}
235                    }
236                }
237                "WindContPType3IEC.mpuvrt" => {
238                    match val {
239                        crate::base::FieldValue::Text(sv) => { obj.mpuvrt = Some(sv.trim() == "true"); }
240                        crate::base::FieldValue::TextList(svs) => {
241                            if let Some(sv) = svs.last() { obj.mpuvrt = Some(sv.trim() == "true"); }
242                        }
243                        _ => {}
244                    }
245                }
246                "WindContPType3IEC.omegadtd" => {
247                    match val {
248                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.omegadtd = Some(v); } }
249                        crate::base::FieldValue::TextList(svs) => {
250                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.omegadtd = Some(v); } }
251                        }
252                        _ => {}
253                    }
254                }
255                "WindContPType3IEC.omegaoffset" => {
256                    match val {
257                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.omegaoffset = Some(v); } }
258                        crate::base::FieldValue::TextList(svs) => {
259                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.omegaoffset = Some(v); } }
260                        }
261                        _ => {}
262                    }
263                }
264                "WindContPType3IEC.pdtdmax" => {
265                    match val {
266                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.pdtdmax = Some(v); } }
267                        crate::base::FieldValue::TextList(svs) => {
268                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.pdtdmax = Some(v); } }
269                        }
270                        _ => {}
271                    }
272                }
273                "WindContPType3IEC.tdvs" => {
274                    match val {
275                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tdvs = Some(v); } }
276                        crate::base::FieldValue::TextList(svs) => {
277                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tdvs = Some(v); } }
278                        }
279                        _ => {}
280                    }
281                }
282                "WindContPType3IEC.thetaemin" => {
283                    match val {
284                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.thetaemin = Some(v); } }
285                        crate::base::FieldValue::TextList(svs) => {
286                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.thetaemin = Some(v); } }
287                        }
288                        _ => {}
289                    }
290                }
291                "WindContPType3IEC.thetauscale" => {
292                    match val {
293                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.thetauscale = Some(v); } }
294                        crate::base::FieldValue::TextList(svs) => {
295                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.thetauscale = Some(v); } }
296                        }
297                        _ => {}
298                    }
299                }
300                "WindContPType3IEC.tomegafiltp3" => {
301                    match val {
302                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tomegafiltp3 = Some(v); } }
303                        crate::base::FieldValue::TextList(svs) => {
304                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tomegafiltp3 = Some(v); } }
305                        }
306                        _ => {}
307                    }
308                }
309                "WindContPType3IEC.tomegaref" => {
310                    match val {
311                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tomegaref = Some(v); } }
312                        crate::base::FieldValue::TextList(svs) => {
313                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tomegaref = Some(v); } }
314                        }
315                        _ => {}
316                    }
317                }
318                "WindContPType3IEC.tpfiltp3" => {
319                    match val {
320                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tpfiltp3 = Some(v); } }
321                        crate::base::FieldValue::TextList(svs) => {
322                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tpfiltp3 = Some(v); } }
323                        }
324                        _ => {}
325                    }
326                }
327                "WindContPType3IEC.tpord" => {
328                    match val {
329                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tpord = Some(v); } }
330                        crate::base::FieldValue::TextList(svs) => {
331                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tpord = Some(v); } }
332                        }
333                        _ => {}
334                    }
335                }
336                "WindContPType3IEC.tufiltp3" => {
337                    match val {
338                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tufiltp3 = Some(v); } }
339                        crate::base::FieldValue::TextList(svs) => {
340                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tufiltp3 = Some(v); } }
341                        }
342                        _ => {}
343                    }
344                }
345                "WindContPType3IEC.udvs" => {
346                    match val {
347                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.udvs = Some(v); } }
348                        crate::base::FieldValue::TextList(svs) => {
349                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.udvs = Some(v); } }
350                        }
351                        _ => {}
352                    }
353                }
354                "WindContPType3IEC.updip" => {
355                    match val {
356                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.updip = Some(v); } }
357                        crate::base::FieldValue::TextList(svs) => {
358                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.updip = Some(v); } }
359                        }
360                        _ => {}
361                    }
362                }
363                "WindContPType3IEC.zeta" => {
364                    match val {
365                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.zeta = Some(v); } }
366                        crate::base::FieldValue::TextList(svs) => {
367                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.zeta = Some(v); } }
368                        }
369                        _ => {}
370                    }
371                }
372                "IdentifiedObject.description" => {
373                    match val {
374                        crate::base::FieldValue::Text(sv) => { obj.base.description = sv.clone(); }
375                        crate::base::FieldValue::TextList(svs) => {
376                            if let Some(sv) = svs.last() { obj.base.description = sv.clone(); }
377                        }
378                        _ => {}
379                    }
380                }
381                "IdentifiedObject.energyIdentCodeEic" => {
382                    match val {
383                        crate::base::FieldValue::Text(sv) => { obj.base.energy_ident_code_eic = sv.clone(); }
384                        crate::base::FieldValue::TextList(svs) => {
385                            if let Some(sv) = svs.last() { obj.base.energy_ident_code_eic = sv.clone(); }
386                        }
387                        _ => {}
388                    }
389                }
390                "IdentifiedObject.mRID" => {
391                    match val {
392                        crate::base::FieldValue::Text(sv) => { obj.base.m_rid = sv.clone(); }
393                        crate::base::FieldValue::TextList(svs) => {
394                            if let Some(sv) = svs.last() { obj.base.m_rid = sv.clone(); }
395                        }
396                        _ => {}
397                    }
398                }
399                "IdentifiedObject.name" => {
400                    match val {
401                        crate::base::FieldValue::Text(sv) => { obj.base.name = sv.clone(); }
402                        crate::base::FieldValue::TextList(svs) => {
403                            if let Some(sv) = svs.last() { obj.base.name = sv.clone(); }
404                        }
405                        _ => {}
406                    }
407                }
408                "IdentifiedObject.shortName" => {
409                    match val {
410                        crate::base::FieldValue::Text(sv) => { obj.base.short_name = sv.clone(); }
411                        crate::base::FieldValue::TextList(svs) => {
412                            if let Some(sv) = svs.last() { obj.base.short_name = sv.clone(); }
413                        }
414                        _ => {}
415                    }
416                }
417                _ => {}
418            }
419        }
420        obj
421    }
422}