Skip to main content

cimstructs/
OverexcLimIEEE.rs

1/// The over excitation limiter model is intended to represent the significant features of OELs necessary for some large-scale system studies. It is the result of a pragmatic approach to obtain a model that can be widely applied with attainable data from generator owners. An attempt to include all variations in the functionality of OELs and duplicate how they interact with the rest of the excitation systems would likely result in a level of application insufficient for the studies for which they are intended. Reference: IEEE OEL 421.5-2005, 9.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct OverexcLimIEEE {
4    #[serde(flatten)]
5    pub base: super::OverexcitationLimiterDynamics,
6    /// OEL pickup/drop-out hysteresis (HYST). Typical value = 0,03.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub hyst: Option<f64>,
9    /// OEL timed field current limit (IFDLIM). Typical value = 1,05.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub ifdlim: Option<f64>,
12    /// OEL instantaneous field current limit (IFDMAX). Typical value = 1,5.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub ifdmax: Option<f64>,
15    /// OEL timed field current limiter pickup level (ITFPU). Typical value = 1,05.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub itfpu: Option<f64>,
18    /// OEL cooldown gain (KCD). Typical value = 1.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub kcd: Option<f64>,
21    /// OEL ramped limit rate (KRAMP). Unit = PU / s. Typical value = 10.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub kramp: Option<f64>,
24}
25impl crate::base::CimElement for OverexcLimIEEE {
26    fn mrid(&self) -> &str { &self.base.base.base.id }
27    fn type_name(&self) -> &'static str { "OverexcLimIEEE" }
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 = "OverexcLimIEEE".to_string();
35        if let Some(v) = self.hyst {
36            block.fields.insert("OverexcLimIEEE.hyst".into(), crate::base::FieldValue::Text(v.to_string()));
37        }
38        if let Some(v) = self.ifdlim {
39            block.fields.insert("OverexcLimIEEE.ifdlim".into(), crate::base::FieldValue::Text(v.to_string()));
40        }
41        if let Some(v) = self.ifdmax {
42            block.fields.insert("OverexcLimIEEE.ifdmax".into(), crate::base::FieldValue::Text(v.to_string()));
43        }
44        if let Some(v) = self.itfpu {
45            block.fields.insert("OverexcLimIEEE.itfpu".into(), crate::base::FieldValue::Text(v.to_string()));
46        }
47        if let Some(v) = self.kcd {
48            block.fields.insert("OverexcLimIEEE.kcd".into(), crate::base::FieldValue::Text(v.to_string()));
49        }
50        if let Some(v) = self.kramp {
51            block.fields.insert("OverexcLimIEEE.kramp".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        block
54    }
55}
56
57impl OverexcLimIEEE {
58    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
59        let mut obj = Self::default();
60        obj.base.base.base.id.clone_from(&b.mrid);
61        for (key, val) in &b.fields {
62            match key.as_str() {
63                "OverexcLimIEEE.hyst" => {
64                    match val {
65                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.hyst = Some(v); } }
66                        crate::base::FieldValue::TextList(svs) => {
67                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.hyst = Some(v); } }
68                        }
69                        _ => {}
70                    }
71                }
72                "OverexcLimIEEE.ifdlim" => {
73                    match val {
74                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ifdlim = Some(v); } }
75                        crate::base::FieldValue::TextList(svs) => {
76                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ifdlim = Some(v); } }
77                        }
78                        _ => {}
79                    }
80                }
81                "OverexcLimIEEE.ifdmax" => {
82                    match val {
83                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ifdmax = Some(v); } }
84                        crate::base::FieldValue::TextList(svs) => {
85                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ifdmax = Some(v); } }
86                        }
87                        _ => {}
88                    }
89                }
90                "OverexcLimIEEE.itfpu" => {
91                    match val {
92                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.itfpu = Some(v); } }
93                        crate::base::FieldValue::TextList(svs) => {
94                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.itfpu = Some(v); } }
95                        }
96                        _ => {}
97                    }
98                }
99                "OverexcLimIEEE.kcd" => {
100                    match val {
101                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kcd = Some(v); } }
102                        crate::base::FieldValue::TextList(svs) => {
103                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kcd = Some(v); } }
104                        }
105                        _ => {}
106                    }
107                }
108                "OverexcLimIEEE.kramp" => {
109                    match val {
110                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kramp = Some(v); } }
111                        crate::base::FieldValue::TextList(svs) => {
112                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kramp = Some(v); } }
113                        }
114                        _ => {}
115                    }
116                }
117                "OverexcitationLimiterDynamics.ExcitationSystemDynamics" => {
118                    if let crate::base::FieldValue::Resource(sv) = val {
119                        obj.base.excitation_system_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
120                    }
121                }
122                "DynamicsFunctionBlock.enabled" => {
123                    match val {
124                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
125                        crate::base::FieldValue::TextList(svs) => {
126                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
127                        }
128                        _ => {}
129                    }
130                }
131                "IdentifiedObject.description" => {
132                    match val {
133                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
134                        crate::base::FieldValue::TextList(svs) => {
135                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
136                        }
137                        _ => {}
138                    }
139                }
140                "IdentifiedObject.energyIdentCodeEic" => {
141                    match val {
142                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
143                        crate::base::FieldValue::TextList(svs) => {
144                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
145                        }
146                        _ => {}
147                    }
148                }
149                "IdentifiedObject.mRID" => {
150                    match val {
151                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
152                        crate::base::FieldValue::TextList(svs) => {
153                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
154                        }
155                        _ => {}
156                    }
157                }
158                "IdentifiedObject.name" => {
159                    match val {
160                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
161                        crate::base::FieldValue::TextList(svs) => {
162                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
163                        }
164                        _ => {}
165                    }
166                }
167                "IdentifiedObject.shortName" => {
168                    match val {
169                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
170                        crate::base::FieldValue::TextList(svs) => {
171                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
172                        }
173                        _ => {}
174                    }
175                }
176                _ => {}
177            }
178        }
179        obj
180    }
181}