Skip to main content

cimstructs/
WindAeroTwoDimIEC.rs

1/// Two-dimensional aerodynamic model. Reference: IEC 61400-27-1:2015, 5.6.1.3.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct WindAeroTwoDimIEC {
4    #[serde(flatten)]
5    pub base: super::IdentifiedObject,
6    /// Partial derivative of aerodynamic power with respect to changes in WTR speed (dpomega). It is a type-dependent parameter.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub dpomega: Option<f64>,
9    /// Partial derivative of aerodynamic power with respect to changes in pitch angle (dptheta). It is a type-dependent parameter.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub dptheta: Option<f64>,
12    /// Partial derivative (dpv1). It is a type-dependent parameter.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub dpv1: Option<f64>,
15    /// Rotor speed if the wind turbine is not derated (omega0). It is a type-dependent parameter.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub omegazero: Option<f64>,
18    /// Available aerodynamic power (pavail). It is a case-dependent parameter.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub pavail: Option<f64>,
21    /// Blade angle at twice rated wind speed (thetav2). It is a type-dependent parameter.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub thetav2: Option<f64>,
24    /// Pitch angle if the wind turbine is not derated (theta0). It is a case-dependent parameter.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub thetazero: Option<f64>,
27}
28impl crate::base::CimElement for WindAeroTwoDimIEC {
29    fn mrid(&self) -> &str { &self.base.id }
30    fn type_name(&self) -> &'static str { "WindAeroTwoDimIEC" }
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 = "WindAeroTwoDimIEC".to_string();
38        if let Some(v) = self.dpomega {
39            block.fields.insert("WindAeroTwoDimIEC.dpomega".into(), crate::base::FieldValue::Text(v.to_string()));
40        }
41        if let Some(v) = self.dptheta {
42            block.fields.insert("WindAeroTwoDimIEC.dptheta".into(), crate::base::FieldValue::Text(v.to_string()));
43        }
44        if let Some(v) = self.dpv1 {
45            block.fields.insert("WindAeroTwoDimIEC.dpv1".into(), crate::base::FieldValue::Text(v.to_string()));
46        }
47        if let Some(v) = self.omegazero {
48            block.fields.insert("WindAeroTwoDimIEC.omegazero".into(), crate::base::FieldValue::Text(v.to_string()));
49        }
50        if let Some(v) = self.pavail {
51            block.fields.insert("WindAeroTwoDimIEC.pavail".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.thetav2 {
54            block.fields.insert("WindAeroTwoDimIEC.thetav2".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        if let Some(v) = self.thetazero {
57            block.fields.insert("WindAeroTwoDimIEC.thetazero".into(), crate::base::FieldValue::Text(v.to_string()));
58        }
59        block
60    }
61}
62
63impl WindAeroTwoDimIEC {
64    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
65        let mut obj = Self::default();
66        obj.base.id.clone_from(&b.mrid);
67        for (key, val) in &b.fields {
68            match key.as_str() {
69                "WindAeroTwoDimIEC.dpomega" => {
70                    match val {
71                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.dpomega = Some(v); } }
72                        crate::base::FieldValue::TextList(svs) => {
73                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.dpomega = Some(v); } }
74                        }
75                        _ => {}
76                    }
77                }
78                "WindAeroTwoDimIEC.dptheta" => {
79                    match val {
80                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.dptheta = Some(v); } }
81                        crate::base::FieldValue::TextList(svs) => {
82                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.dptheta = Some(v); } }
83                        }
84                        _ => {}
85                    }
86                }
87                "WindAeroTwoDimIEC.dpv1" => {
88                    match val {
89                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.dpv1 = Some(v); } }
90                        crate::base::FieldValue::TextList(svs) => {
91                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.dpv1 = Some(v); } }
92                        }
93                        _ => {}
94                    }
95                }
96                "WindAeroTwoDimIEC.omegazero" => {
97                    match val {
98                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.omegazero = Some(v); } }
99                        crate::base::FieldValue::TextList(svs) => {
100                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.omegazero = Some(v); } }
101                        }
102                        _ => {}
103                    }
104                }
105                "WindAeroTwoDimIEC.pavail" => {
106                    match val {
107                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.pavail = Some(v); } }
108                        crate::base::FieldValue::TextList(svs) => {
109                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.pavail = Some(v); } }
110                        }
111                        _ => {}
112                    }
113                }
114                "WindAeroTwoDimIEC.thetav2" => {
115                    match val {
116                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.thetav2 = Some(v); } }
117                        crate::base::FieldValue::TextList(svs) => {
118                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.thetav2 = Some(v); } }
119                        }
120                        _ => {}
121                    }
122                }
123                "WindAeroTwoDimIEC.thetazero" => {
124                    match val {
125                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.thetazero = Some(v); } }
126                        crate::base::FieldValue::TextList(svs) => {
127                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.thetazero = Some(v); } }
128                        }
129                        _ => {}
130                    }
131                }
132                "IdentifiedObject.description" => {
133                    match val {
134                        crate::base::FieldValue::Text(sv) => { obj.base.description = sv.clone(); }
135                        crate::base::FieldValue::TextList(svs) => {
136                            if let Some(sv) = svs.last() { obj.base.description = sv.clone(); }
137                        }
138                        _ => {}
139                    }
140                }
141                "IdentifiedObject.energyIdentCodeEic" => {
142                    match val {
143                        crate::base::FieldValue::Text(sv) => { obj.base.energy_ident_code_eic = sv.clone(); }
144                        crate::base::FieldValue::TextList(svs) => {
145                            if let Some(sv) = svs.last() { obj.base.energy_ident_code_eic = sv.clone(); }
146                        }
147                        _ => {}
148                    }
149                }
150                "IdentifiedObject.mRID" => {
151                    match val {
152                        crate::base::FieldValue::Text(sv) => { obj.base.m_rid = sv.clone(); }
153                        crate::base::FieldValue::TextList(svs) => {
154                            if let Some(sv) = svs.last() { obj.base.m_rid = sv.clone(); }
155                        }
156                        _ => {}
157                    }
158                }
159                "IdentifiedObject.name" => {
160                    match val {
161                        crate::base::FieldValue::Text(sv) => { obj.base.name = sv.clone(); }
162                        crate::base::FieldValue::TextList(svs) => {
163                            if let Some(sv) = svs.last() { obj.base.name = sv.clone(); }
164                        }
165                        _ => {}
166                    }
167                }
168                "IdentifiedObject.shortName" => {
169                    match val {
170                        crate::base::FieldValue::Text(sv) => { obj.base.short_name = sv.clone(); }
171                        crate::base::FieldValue::TextList(svs) => {
172                            if let Some(sv) = svs.last() { obj.base.short_name = sv.clone(); }
173                        }
174                        _ => {}
175                    }
176                }
177                _ => {}
178            }
179        }
180        obj
181    }
182}