use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DynamicModel {
pub generators: Vec<GeneratorDyn>,
pub exciters: Vec<ExciterDyn>,
pub governors: Vec<GovernorDyn>,
pub pss: Vec<PssDyn>,
#[serde(default)]
pub loads: Vec<LoadDyn>,
#[serde(default)]
pub facts: Vec<FACTSDyn>,
pub unknown_records: Vec<UnknownDyrRecord>,
#[serde(default)]
pub oels: Vec<OelDyn>,
#[serde(default)]
pub uels: Vec<UelDyn>,
#[serde(default)]
pub shafts: Vec<ShaftDyn>,
}
impl DynamicModel {
pub fn n_generators(&self) -> usize {
self.generators.len()
}
pub fn n_exciters(&self) -> usize {
self.exciters.len()
}
pub fn n_governors(&self) -> usize {
self.governors.len()
}
pub fn n_pss(&self) -> usize {
self.pss.len()
}
pub fn n_loads(&self) -> usize {
self.loads.len()
}
pub fn total(&self) -> usize {
self.n_generators()
+ self.n_exciters()
+ self.n_governors()
+ self.n_pss()
+ self.n_loads()
+ self.n_facts()
+ self.oels.len()
+ self.uels.len()
+ self.shafts.len()
}
pub fn coverage(&self) -> (usize, usize, f64) {
let n_supported = self.total();
let n_unknown = self.unknown_records.len();
let n_total = n_supported + n_unknown;
let pct = if n_total > 0 {
n_supported as f64 / n_total as f64 * 100.0
} else {
100.0
};
(n_supported, n_total, pct)
}
pub fn n_facts(&self) -> usize {
self.facts.len()
}
pub fn find_facts(&self, bus: u32, device_id: &str) -> Option<&FACTSDyn> {
self.facts
.iter()
.find(|f| f.bus == bus && f.device_id == device_id)
}
pub fn find_load(&self, bus: u32, load_id: &str) -> Option<&LoadDyn> {
self.loads
.iter()
.find(|l| l.bus == bus && l.load_id == load_id)
}
pub fn find_generator(&self, bus: u32, machine_id: &str) -> Option<&GeneratorDyn> {
self.generators
.iter()
.find(|g| g.bus == bus && g.machine_id == machine_id)
}
pub fn find_exciter(&self, bus: u32, machine_id: &str) -> Option<&ExciterDyn> {
self.exciters
.iter()
.find(|e| e.bus == bus && e.machine_id == machine_id)
}
pub fn find_governor(&self, bus: u32, machine_id: &str) -> Option<&GovernorDyn> {
self.governors
.iter()
.find(|g| g.bus == bus && g.machine_id == machine_id)
}
pub fn find_pss(&self, bus: u32, machine_id: &str) -> Option<&PssDyn> {
self.pss
.iter()
.find(|p| p.bus == bus && p.machine_id == machine_id)
}
pub fn find_shaft(&self, bus: u32, machine_id: &str) -> Option<&ShaftDyn> {
self.shafts
.iter()
.find(|s| s.bus == bus && s.machine_id == machine_id)
}
pub fn unknown_model_summary(&self) -> Vec<UnknownModelGroup> {
use std::collections::BTreeMap;
let mut groups: BTreeMap<String, UnknownModelGroup> = BTreeMap::new();
for rec in &self.unknown_records {
let entry = groups.entry(rec.model_name.clone()).or_insert_with(|| {
let equiv = crate::dynamics::usrmdl_equiv::suggest_equivalent(&rec.model_name);
let category = crate::dynamics::usrmdl_equiv::guess_category(&rec.model_name);
UnknownModelGroup {
model_name: rec.model_name.clone(),
count: 0,
buses: Vec::new(),
category: category.label().to_string(),
suggested_equivalent: equiv.map(|e| e.suggested.to_string()),
suggestion_notes: equiv.map(|e| e.notes.to_string()),
}
});
entry.count += 1;
if !entry.buses.contains(&rec.bus) {
entry.buses.push(rec.bus);
}
}
groups.into_values().collect()
}
pub fn incomplete_machines(&self) -> Vec<IncompleteMachine> {
self.generators
.iter()
.filter_map(|g| {
let has_exc = self.find_exciter(g.bus, &g.machine_id).is_some();
let has_gov = self.find_governor(g.bus, &g.machine_id).is_some();
let has_pss = self.find_pss(g.bus, &g.machine_id).is_some();
if !has_exc || !has_gov || !has_pss {
Some(IncompleteMachine {
bus: g.bus,
machine_id: g.machine_id.clone(),
has_exciter: has_exc,
has_governor: has_gov,
has_pss,
})
} else {
None
}
})
.collect()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UnknownModelGroup {
pub model_name: String,
pub count: usize,
pub buses: Vec<u32>,
pub category: String,
pub suggested_equivalent: Option<String>,
pub suggestion_notes: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IncompleteMachine {
pub bus: u32,
pub machine_id: String,
pub has_exciter: bool,
pub has_governor: bool,
pub has_pss: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GeneratorDyn {
pub bus: u32,
pub machine_id: String,
pub model: GeneratorModel,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum GeneratorModel {
Gencls(GenclsParams),
Genrou(GenrouParams),
Gensal(GensalParams),
Regca(RegcaParams),
Gentpj(GentpjParams),
Genqec(GenqecParams),
Regcb(RegcbParams),
Wt3g2u(Wt3g2uParams),
Wt4g1(Wt4g1Params),
RegfmA1(RegfmA1Params),
RegfmB1(RegfmB1Params),
Dera(DeraParams),
Gentra(GentraParams),
Gentpf(GentpjParams),
Regcc(RegccParams),
Wt4g2(Wt4g2Params),
Derc(DercParams),
Genroa(GenrouParams),
Gensaa(GensalParams),
RegfmC1(RegfmC1Params),
Pvgu1(Pvgu1Params),
Pvdg(PvdgParams),
Wt3g3(Wt3g2uParams),
Regco1(Regco1Params),
Genwtg(GenrouParams),
Genroe(GenrouParams),
Gensal3(Gensal3Params),
Derp(DerpParams),
RegfmD1(Regfmd1Params),
Gensae(GensalParams),
Wt1g1(Wt1g1Params),
Wt2g1(Wt1g1Params),
Pvd1(PvdgParams),
Pvdu1(Pvgu1Params),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GenclsParams {
pub h: f64,
pub d: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GenrouParams {
pub td0_prime: f64,
pub td0_pprime: f64,
pub tq0_prime: f64,
pub tq0_pprime: f64,
pub h: f64,
pub d: f64,
pub xd: f64,
pub xq: f64,
pub xd_prime: f64,
pub xq_prime: f64,
pub xd_pprime: f64,
pub xl: f64,
pub s1: f64,
pub s12: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ra: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GensalParams {
pub td0_prime: f64,
pub td0_pprime: f64,
pub tq0_pprime: f64,
pub h: f64,
pub d: f64,
pub xd: f64,
pub xq: f64,
pub xd_prime: f64,
pub xd_pprime: f64,
pub xl: f64,
pub s1: f64,
pub s12: f64,
pub xtran: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RegcaParams {
pub tg: f64,
pub x_eq: f64,
pub imax: f64,
pub tfltr: f64,
pub kp_pll: f64,
pub ki_pll: f64,
pub rrpwr: f64,
pub vdip: f64,
pub vup: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RegcbParams {
pub tg: f64,
pub x_eq: f64,
pub imax: f64,
pub tfltr: f64,
pub tip: f64,
pub kp_pll: f64,
pub ki_pll: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wt3g2uParams {
pub tg: f64,
pub x_eq: f64,
pub imax: f64,
pub tfltr: f64,
pub kpll: f64,
pub kipll: f64,
pub h_rotor: f64,
pub d_rotor: f64,
pub t_rotor: f64,
pub lm_over_ls: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wt4g1Params {
pub tg: f64,
pub x_eq: f64,
pub imax: f64,
pub kp_pll: f64,
pub ki_pll: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RegfmA1Params {
pub x_eq: f64,
pub h: f64,
pub d: f64,
pub imax: f64,
pub tg: f64,
#[serde(default = "default_gfm_tv")]
pub tv: f64,
#[serde(default = "default_gfm_tpll")]
pub tpll: f64,
#[serde(default = "default_gfm_tvi")]
pub tvi: f64,
#[serde(default = "default_gfm_kp_droop")]
pub kp_droop: f64,
#[serde(default)]
pub ki_droop: f64,
#[serde(default = "default_gfm_kq_droop")]
pub kq_droop: f64,
#[serde(default)]
pub ki_q: f64,
#[serde(default)]
pub r_vi: f64,
#[serde(default = "default_gfm_x_vi")]
pub x_vi: f64,
}
fn default_gfm_tv() -> f64 {
0.02
}
fn default_gfm_tpll() -> f64 {
0.02
}
fn default_gfm_tvi() -> f64 {
0.05
}
fn default_gfm_kp_droop() -> f64 {
20.0
}
fn default_gfm_kq_droop() -> f64 {
20.0
}
fn default_gfm_x_vi() -> f64 {
0.1
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RegfmB1Params {
pub x_eq: f64,
pub h: f64,
pub d: f64,
pub imax: f64,
pub tg: f64,
#[serde(default = "default_gfm_tv")]
pub tv: f64,
#[serde(default = "default_gfm_tpll")]
pub tpll: f64,
#[serde(default = "default_gfm_tvi")]
pub tvi: f64,
#[serde(default = "default_gfm_kp_droop")]
pub kp_droop: f64,
#[serde(default)]
pub ki_droop: f64,
#[serde(default = "default_gfm_kq_droop")]
pub kq_droop: f64,
#[serde(default)]
pub ki_q: f64,
#[serde(default)]
pub r_vi: f64,
#[serde(default = "default_gfm_x_vi")]
pub x_vi: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeraParams {
pub x_eq: f64,
pub trf: f64,
pub imax: f64,
pub trv: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GentraParams {
pub h: f64,
pub d: f64,
pub ra: f64,
pub xd: f64,
pub xd_prime: f64,
pub td0_prime: f64,
pub xq: f64,
pub s1: f64,
pub s12: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RegccParams {
pub tg: f64,
pub x_eq: f64,
pub imax: f64,
pub tfltr: f64,
pub t_pll: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wt4g2Params {
pub tg: f64,
pub x_eq: f64,
pub imax: f64,
pub kp_pll: f64,
pub ki_pll: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DercParams {
pub tp: f64,
pub tq: f64,
pub tv: f64,
pub mbase: f64,
pub lfac: f64,
pub x_eq: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExciterDyn {
pub bus: u32,
pub machine_id: String,
pub model: ExciterModel,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReecdParams {
pub dbd1: f64,
pub dbd2: f64,
pub kqv: f64,
pub kqi: f64,
pub trv: f64,
pub tp: f64,
pub iqmax: f64,
pub iqmin: f64,
pub ipmax: f64,
pub rrpwr: f64,
pub ddn: f64,
pub dup: f64,
pub fdbd1: f64,
pub fdbd2: f64,
pub vdip: f64,
pub vup: f64,
pub pref: f64,
pub pmax: f64,
pub pmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReeccuParams {
pub dbd1: f64,
pub kqv: f64,
pub kqi: f64,
pub trv: f64,
pub tp: f64,
pub rrpwr: f64,
pub vdip: f64,
pub vup: f64,
pub pref: f64,
pub pmax: f64,
pub pmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RexsParams {
pub te: f64,
pub tf: f64,
pub ke: f64,
pub kf: f64,
pub efd1: f64,
pub efd2: f64,
pub sefd1: f64,
pub sefd2: f64,
pub tc: f64,
pub tb: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum ExciterModel {
Exst1(Exst1Params),
Esst3a(Esst3aParams),
Esdc2a(Esdc2aParams),
Exdc2(Exdc2Params),
Ieeex1(Ieeex1Params),
Sexs(SexsParams),
Ieeet1(Ieeet1Params),
Scrx(ScrxParams),
Reeca(ReecaParams),
Esst1a(Esst1aParams),
Exac1(Exac1Params),
Esac1a(Exac1Params),
Esac7b(Esac7bParams),
Esst4b(Esst4bParams),
Reecd(ReecdParams),
Reeccu(ReeccuParams),
Rexs(RexsParams),
Esac2a(Esac2aParams),
Esac5a(Esac5aParams),
Esst5b(Esst5bParams),
Exac4(Exac4Params),
Esst6b(Esst6bParams),
Esst7b(Esst7bParams),
Esac6a(Esac6aParams),
Esdc1a(Esdc1aParams),
Exst2(Exst2Params),
Ac8b(Ac8bParams),
Bbsex1(Bbsex1Params),
Ieeet3(Ieeet3Params),
Wt3e1(Wt3e1Params),
Wt3e2(Wt3e2Params),
Wt4e1(Wt4e1Params),
Wt4e2(Wt4e1Params),
Repcb(RepcbParams),
Repcc(RepcbParams),
Exst3(Exst3Params),
Cbufr(CbufrParams),
Cbufd(CbufdParams),
Pveu1(Pveu1Params),
Ieeet2(Ieeet2Params),
Exac2(Exac2Params),
Exac3(Exac3Params),
Esac3a(Esac3aParams),
Esst8c(Esst8cParams),
Esst9b(Esst9bParams),
Esst10c(Esst10cParams),
Esdc3a(Esdc3aParams),
Exdc1(Exdc1Params),
Esst2a(Esst2aParams),
Exdc3(Exdc3Params),
Wt3c2(Wt3e1Params),
Esac7c(Esac7cParams),
Esdc4c(Esdc4cParams),
Reecbu1(ReeccuParams),
Reece(ReecaParams),
Reeceu1(ReeccuParams),
Esac8c(Ac8bParams),
Esac9c(Esac7bParams),
Esac10c(Esac7cParams),
Esac11c(Ac8bParams),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Exst1Params {
pub tr: f64,
pub vimax: f64,
pub vimin: f64,
pub tc: f64,
pub tb: f64,
pub ka: f64,
pub ta: f64,
pub vrmax: f64,
pub vrmin: f64,
pub kc: f64,
pub kf: f64,
pub tf: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub klr: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ilr: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esst3aParams {
pub tr: f64,
pub vimax: f64,
pub vimin: f64,
pub km: f64,
pub tc: f64,
pub tb: f64,
pub ka: f64,
pub ta: f64,
pub vrmax: f64,
pub vrmin: f64,
pub kg: f64,
pub kp: f64,
pub ki: f64,
pub vbmax: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esdc2aParams {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub tb: f64,
pub tc: f64,
pub vrmax: f64,
pub vrmin: f64,
pub ke: f64,
pub te: f64,
pub kf: f64,
pub tf1: f64,
pub switch_: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Exdc2Params {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub tb: f64,
pub tc: f64,
pub vrmax: f64,
pub vrmin: f64,
pub ke: f64,
pub te: f64,
pub kf: f64,
pub tf1: f64,
pub switch_: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub e1: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub se1: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub e2: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub se2: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ieeex1Params {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub tb: f64,
pub tc: f64,
pub vrmax: f64,
pub vrmin: f64,
pub ke: f64,
pub te: f64,
pub kf: f64,
pub tf: f64,
pub aex: f64,
pub bex: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub e1: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub se1: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub e2: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub se2: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SexsParams {
pub tb: f64,
pub tc: f64,
pub k: f64,
pub te: f64,
pub emin: f64,
pub emax: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ieeet1Params {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub ke: f64,
pub te: f64,
pub kf: f64,
pub tf: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub vrmax: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub vrmin: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScrxParams {
pub tr: f64,
pub k: f64,
pub te: f64,
pub emin: f64,
pub emax: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub rcrfd: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReecaParams {
pub trv: f64,
pub kqv: f64,
pub tp: f64,
pub kqp: f64,
pub kqi: f64,
pub vref0: f64,
pub dbd1: f64,
pub dbd2: f64,
pub vdip: f64,
pub vup: f64,
pub iqh1: f64,
pub iql1: f64,
pub qmax: f64,
pub qmin: f64,
pub tpfilt: f64,
pub tqfilt: f64,
pub rrpwr: f64,
pub rrpwr_dn: f64,
pub pqflag: i32,
pub imax: f64,
pub ipmax: f64,
pub vdl1: [(f64, f64); 4],
pub vdl2: [(f64, f64); 4],
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GovernorDyn {
pub bus: u32,
pub machine_id: String,
pub model: GovernorModel,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepdcParams {
pub tp: f64,
pub kpg: f64,
pub kig: f64,
pub pmax: f64,
pub pmin: f64,
pub tlag: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wt3t1Params {
pub h: f64,
pub damp: f64,
pub ka: f64,
pub theta: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wt3p1Params {
pub tp: f64,
pub kpp: f64,
pub kip: f64,
pub pmax: f64,
pub pmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ggov1dParams {
pub r: f64,
pub t_pelec: f64,
pub maxerr: f64,
pub minerr: f64,
pub kpgov: f64,
pub kigov: f64,
pub kdgov: f64,
pub fdbd1: f64,
pub fdbd2: f64,
pub pmax: f64,
pub pmin: f64,
pub tact: f64,
pub kturb: f64,
pub wfnl: f64,
pub tb: f64,
pub tc: f64,
pub flag: f64,
pub teng: f64,
pub tfload: f64,
pub kpload: f64,
pub kiload: f64,
pub ldref: f64,
pub dm: f64,
pub ropen: f64,
pub rclose: f64,
pub kimw: f64,
pub pmwset: f64,
pub aset: f64,
pub ka: f64,
pub ta: f64,
pub db: f64,
pub tsa: f64,
pub tsb: f64,
pub rup: f64,
pub rdown: f64,
pub load_ref: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Tgov1nParams {
pub r: f64,
pub dt: f64,
pub t1: f64,
pub vmax: f64,
pub vmin: f64,
pub t2: f64,
pub t3: f64,
pub d: f64,
pub db: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum GovernorModel {
Tgov1(Tgov1Params),
Ieeeg1(Ieeeg1Params),
Ggov1(Ggov1Params),
Gast(GastParams),
Repca(RepcaParams),
Hygov(HygovParams),
Hygovd(HygovdParams),
Tgov1d(Tgov1dParams),
Ieeeg1d(Ieeeg1dParams),
Wsieg1(Ieeeg1Params),
Ieeeg2(Ieeeg2Params),
Repcd(RepdcParams),
Wt3t1(Wt3t1Params),
Wt3p1(Wt3p1Params),
Ggov1d(Ggov1dParams),
Tgov1n(Tgov1nParams),
Cbest(CbestParams),
Chaaut(ChaautParams),
Pidgov(PidgovParams),
Degov1(Degov1Params),
Tgov5(Tgov5Params),
Gast2a(Gast2aParams),
H6e(H6eParams),
Wshygp(WshygpParams),
Ggov2(Ggov2Params),
Ggov3(Ggov3Params),
Wpidhy(WpidhyParams),
H6b(H6bParams),
Wshydd(WshyddParams),
Repcgfmc1(Repcgfmc1Params),
Wtdta1(Wtdta1Params),
Wtara1(Wtara1Params),
Wtpta1(Wtpta1Params),
Ieesgo(IeesgoParams),
Wttqa1(Wttqa1Params),
Hygov4(Hygov4Params),
Wehgov(WehgovParams),
Ieeeg3(Ieeeg3Params),
Ieeeg4(Ieeeg4Params),
Govct1(Govct1Params),
Govct2(Govct2Params),
Tgov3(Tgov3Params),
Tgov4(Tgov3Params),
Wt2e1(Wt2e1Params),
Wt12t1(Wt3t1Params),
Wt12a1(Wt3p1Params),
Wtaero(WtaeroParams),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Tgov1Params {
pub r: f64,
pub t1: f64,
pub vmax: f64,
pub vmin: f64,
pub t2: f64,
pub t3: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub dt: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ieeeg1Params {
pub k: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub uo: f64,
pub uc: f64,
pub pmax: f64,
pub pmin: f64,
pub t4: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k1: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k2: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub t5: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k3: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k4: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub t6: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k5: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k6: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub t7: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k7: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k8: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PssDyn {
pub bus: u32,
pub machine_id: String,
pub model: PssModel,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum PssModel {
Ieeest(IeeestParams),
St2cut(St2cutParams),
Pss2a(Pss2aParams),
Pss2b(Pss2bParams),
Stab1(Stab1Params),
Pss1a(Pss1aParams),
Stab2a(Stab2aParams),
Pss4b(Pss4bParams),
Stab3(Stab3Params),
Pss3b(Pss3bParams),
Pss2c(Pss2cParams),
Pss5(Pss5Params),
Pss6c(Pss6cParams),
Psssb(PsssbParams),
Stab4(Stab4Params),
Stab5(Stab5Params),
Pss3c(Pss3bParams),
Pss4c(Pss4bParams),
Pss5c(Pss5Params),
Pss7c(Pss7cParams),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IeeestParams {
pub a1: f64,
pub a2: f64,
pub a3: f64,
pub a4: f64,
pub a5: f64,
pub a6: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub t6: f64,
pub ks: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub lsmax: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub lsmin: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub vcu: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub vcl: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ggov1Params {
pub r: f64,
pub tpelec: f64,
pub vmax: f64,
pub vmin: f64,
pub kpgov: f64,
pub kigov: f64,
pub kturb: f64,
pub wfnl: f64,
pub tb: f64,
pub tc: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub trate: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ldref: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub dm: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GastParams {
pub r: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub at: f64,
pub kt: f64,
pub vmin: f64,
pub vmax: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepcaParams {
pub vrflag: f64,
pub rc: f64,
pub tfltr: f64,
pub kp: f64,
pub ki: f64,
pub vmax: f64,
pub vmin: f64,
pub vref: f64,
pub qref: f64,
pub qmax: f64,
pub qmin: f64,
pub fdbd1: f64,
pub fdbd2: f64,
pub ddn: f64,
pub dup: f64,
pub tp: f64,
pub kpg: f64,
pub kig: f64,
pub pref: f64,
pub pmax: f64,
pub pmin: f64,
pub rrpwr: f64,
pub tlag: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct St2cutParams {
pub k1: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub k2: f64,
pub t5: f64,
pub t6: f64,
pub t7: f64,
pub t8: f64,
pub lsmax: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub lsmin: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub vcu: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub vcl: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GentpjParams {
pub td0_prime: f64,
pub td0_pprime: f64,
pub tq0_prime: f64,
pub tq0_pprime: f64,
pub h: f64,
pub d: f64,
pub xd: f64,
pub xq: f64,
pub xd_prime: f64,
pub xq_prime: f64,
pub xd_pprime: f64,
pub xl: f64,
pub s1: f64,
pub s12: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub kii: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ra: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GenqecParams {
pub td0_prime: f64,
pub td0_pprime: f64,
pub tq0_prime: f64,
pub tq0_pprime: f64,
pub h: f64,
pub d: f64,
pub xd: f64,
pub xq: f64,
pub xd_prime: f64,
pub xq_prime: f64,
pub xd_pprime: f64,
pub xl: f64,
pub s1: f64,
pub s12: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ra: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esst1aParams {
pub tr: f64,
pub vimax: f64,
pub vimin: f64,
pub tc: f64,
pub tb: f64,
pub tc1: f64,
pub tb1: f64,
pub ka: f64,
pub ta: f64,
pub vamax: f64,
pub vamin: f64,
pub vrmax: f64,
pub vrmin: f64,
pub kc: f64,
pub kf: f64,
pub tf: f64,
pub klr: f64,
pub ilr: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Exac1Params {
pub tr: f64,
pub tb: f64,
pub tc: f64,
pub ka: f64,
pub ta: f64,
pub vrmax: f64,
pub vrmin: f64,
pub te: f64,
pub kf: f64,
pub tf: f64,
pub kc: f64,
pub kd: f64,
pub ke: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esac7bParams {
pub tr: f64,
pub kpa: f64,
pub kia: f64,
pub vrh: f64,
pub vrl: f64,
pub kpf: f64,
pub vfh: f64,
pub tf: f64,
pub te: f64,
pub ke: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
pub kd: f64,
pub kc: f64,
pub kl: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esst4bParams {
pub tr: f64,
pub kpr: f64,
pub kir: f64,
pub vrmax: f64,
pub vrmin: f64,
pub kpm: f64,
pub kim: f64,
pub vmmax: f64,
pub vmmin: f64,
pub kg: f64,
pub kp: f64,
pub ki: f64,
pub vbmax: f64,
pub vgmax: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HygovParams {
pub r: f64,
pub tp: f64,
pub velm: f64,
pub tg: f64,
pub gmax: f64,
pub gmin: f64,
pub tw: f64,
pub at: f64,
pub dturb: f64,
pub qnl: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HygovdParams {
pub r: f64,
pub tp: f64,
pub velm: f64,
pub tg: f64,
pub gmax: f64,
pub gmin: f64,
pub tw: f64,
pub at: f64,
pub dturb: f64,
pub qnl: f64,
pub db1: f64,
pub db2: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Tgov1dParams {
pub r: f64,
pub t1: f64,
pub vmax: f64,
pub vmin: f64,
pub t2: f64,
pub t3: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub dt: Option<f64>,
pub db1: f64,
pub db2: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ieeeg1dParams {
pub k: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub uo: f64,
pub uc: f64,
pub pmax: f64,
pub pmin: f64,
pub t4: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k1: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k2: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub t5: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k3: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k4: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub t6: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k5: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k6: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub t7: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k7: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub k8: Option<f64>,
pub db1: f64,
pub db2: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ieeeg2Params {
pub k: f64,
pub t1: f64,
pub t2: f64,
#[serde(default)]
pub t3: f64,
#[serde(default)]
pub rt: f64,
#[serde(default)]
pub pmin: f64,
#[serde(default = "Ieeeg2Params::default_pmax")]
pub pmax: f64,
#[serde(default = "Ieeeg2Params::default_at")]
pub at: f64,
#[serde(default)]
pub dturb: f64,
#[serde(default)]
pub qnl: f64,
}
impl Ieeeg2Params {
fn default_pmax() -> f64 {
1.0
}
fn default_at() -> f64 {
1.0
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pss2aParams {
pub m1: f64,
pub t6: f64,
pub t7: f64,
pub ks2: f64,
pub t8: f64,
pub t9: f64,
pub m2: f64,
pub tw1: f64,
pub tw2: f64,
pub tw3: f64,
pub tw4: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub ks1: f64,
pub ks3: f64,
pub vstmax: f64,
pub vstmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pss2bParams {
pub m1: f64,
pub t6: f64,
pub t7: f64,
pub ks2: f64,
pub t8: f64,
pub t9: f64,
pub m2: f64,
pub tw1: f64,
pub tw2: f64,
pub tw3: f64,
pub tw4: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub ks1: f64,
pub ks3: f64,
pub vstmax: f64,
pub vstmin: f64,
pub t10: f64,
pub t11: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Stab1Params {
pub ks: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub hlim: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CbestParams {
pub p_max: f64,
pub p_min: f64,
pub q_max: f64,
pub q_min: f64,
pub tp: f64,
pub tq: f64,
pub e_cap: f64,
pub mbase: f64,
pub soc_init: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChaautParams {
pub kf: f64,
pub tf: f64,
pub p_max: f64,
pub p_min: f64,
pub tp: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esac2aParams {
pub tr: f64,
pub tb: f64,
pub tc: f64,
pub ka: f64,
pub ta: f64,
pub vamax: f64,
pub vamin: f64,
pub ke: f64,
pub te: f64,
pub kf: f64,
pub tf: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
pub vrmax: f64,
pub vrmin: f64,
pub kb: f64,
pub kc: f64,
pub kd: f64,
pub kh: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esac5aParams {
pub ka: f64,
pub ta: f64,
pub ke: f64,
pub te: f64,
pub kf: f64,
pub tf: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
pub vrmax: f64,
pub vrmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pss1aParams {
pub ks: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub vstmax: f64,
pub vstmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PidgovParams {
pub pmax: f64,
pub pmin: f64,
pub kp: f64,
pub ki: f64,
pub kd: f64,
pub td: f64,
pub tf: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Degov1Params {
pub r: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
#[serde(default = "default_degov1_t4")]
pub t4: f64,
#[serde(default = "default_degov1_t5")]
pub t5: f64,
#[serde(default = "default_degov1_t6")]
pub t6: f64,
pub td: f64,
#[serde(default = "default_degov1_k")]
pub k: f64,
pub vmax: f64,
pub vmin: f64,
#[serde(default = "default_degov1_velm")]
pub velm: f64,
pub at: f64,
pub kt: f64,
}
fn default_degov1_t4() -> f64 {
0.0
}
fn default_degov1_t5() -> f64 {
0.01
}
fn default_degov1_t6() -> f64 {
0.01
}
fn default_degov1_k() -> f64 {
1.0
}
fn default_degov1_velm() -> f64 {
99.0
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FACTSDyn {
pub bus: u32,
pub device_id: String,
pub model: FACTSModel,
#[serde(default)]
pub to_bus: Option<u32>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum FACTSModel {
Csvgn1(Csvgn1Params),
Cstcon(CstconParams),
Tcsc(TcscParams),
Cdc4t(Cdc4tParams),
Vscdct(VscdctParams),
Csvgn3(Csvgn3Params),
Cdc7t(Cdc7tParams),
Csvgn4(Csvgn4Params),
Csvgn5(Csvgn5Params),
Cdc6t(Cdc6tParams),
Cstcnt(CstcntParams),
Mmc1(Mmc1Params),
Hvdcplu1(HvdcPlu1Params),
Csvgn6(Csvgn6Params),
Stcon1(Stcon1Params),
Gcsc(GcscParams),
Sssc(SsscParams),
Upfc(UpfcParams),
Cdc3t(Cdc3tParams),
Svsmo1(Svsmo1Params),
Svsmo2(Svsmo2Params),
Svsmo3(Svsmo3Params),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Csvgn1Params {
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub k: f64,
pub vmax: f64,
pub vmin: f64,
pub bmax: f64,
pub bmin: f64,
pub mbase: f64,
#[serde(default)]
pub b_l: Option<f64>,
#[serde(default)]
pub b_c: Option<f64>,
#[serde(default)]
pub t_alpha: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CstconParams {
pub tr: f64,
pub k: f64,
pub tiq: f64,
pub imax: f64,
pub imin: f64,
pub mbase: f64,
#[serde(default)]
pub c_dc: Option<f64>,
#[serde(default)]
pub vdc_ref: Option<f64>,
#[serde(default)]
pub kp_vdc: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TcscParams {
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub xmax: f64,
pub xmin: f64,
pub k: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Cdc4tParams {
pub setvl: f64,
pub vschd: f64,
pub mbase: f64,
pub tr: f64,
pub td: f64,
pub alpha_min: f64,
pub alpha_max: f64,
pub gamma_min: f64,
pub gamma_ref: Option<f64>,
pub ramp: Option<f64>,
#[serde(default)]
pub kp_alpha: Option<f64>,
#[serde(default)]
pub ki_alpha: Option<f64>,
#[serde(default)]
pub ki_gamma: Option<f64>,
pub rectifier_bus: u32,
pub inverter_bus: u32,
#[serde(default)]
pub vdcol_v1: Option<f64>,
#[serde(default)]
pub vdcol_v2: Option<f64>,
#[serde(default)]
pub vdcol_i1: Option<f64>,
#[serde(default)]
pub vdcol_i2: Option<f64>,
#[serde(default)]
pub t_iord: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VscdctParams {
pub p_order: f64,
pub vdc_ref: f64,
pub t_dc: f64,
pub t_ac: f64,
pub imax: f64,
pub q_order: Option<f64>,
#[serde(default)]
pub kp_vdc: Option<f64>,
#[serde(default)]
pub ki_vdc: Option<f64>,
#[serde(default)]
pub kp_q: Option<f64>,
#[serde(default)]
pub ki_q: Option<f64>,
#[serde(default)]
pub t_vdc_filt: Option<f64>,
#[serde(default)]
pub kp_id: Option<f64>,
#[serde(default)]
pub ki_id: Option<f64>,
#[serde(default)]
pub kp_iq: Option<f64>,
#[serde(default)]
pub ki_iq: Option<f64>,
pub mbase: f64,
pub rectifier_bus: u32,
pub inverter_bus: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LoadDyn {
pub bus: u32,
pub load_id: String,
pub model: LoadModel,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum LoadModel {
Clod(ClodParams),
Indmot(IndmotParams),
Motor(MotorParams),
Cmpldw(CmpldwParams),
Cmpldwg(CmpldwgParams),
Cmldblu2(Cmldblu2Params),
Cmldaru2(Cmldblu2Params),
Motorw(MotorwParams),
Cim5(Cim5Params),
Lcfb1(Lcfb1Params),
Ldfral(LdfralParams),
Frqtplt(FrqtpltParams),
Lvshbl(LvshblParams),
Cim6(Cim6Params),
Cimw(IndmotParams),
Extl(ExtlParams),
Ieelar(ExtlParams),
Cmldowu2(CmpldwParams),
Cmldxnu2(CmpldwParams),
Cmldalu2(CmpldwParams),
Cmldblu2w(Cmldblu2Params),
Cmldaru2w(Cmldblu2Params),
Vtgtpat(VtgtpatParams),
Vtgdcat(VtgtpatParams),
Frqtpat(FrqtpatParams),
Frqdcat(FrqtpatParams),
Distr1(Distr1Params),
Bfr50(Bfr50Params),
Lvshc1(LvshblParams),
TransDiff87(TransDiff87Params),
LineDiff87l(LineDiff87lParams),
Recloser79(Recloser79Params),
Cmlddgu2(CmpldwParams),
Cmlddggu2(CmpldwgParams),
Cmldowdgu2(CmpldwParams),
Cmldxndgu2(CmpldwParams),
Uvls1(Uvls1Params),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClodParams {
pub mbase: f64,
pub lfac: f64,
pub rfrac: f64,
pub xfrac: f64,
pub lfrac_dl: f64,
pub nfrac: f64,
pub dsli: f64,
pub tv: f64,
pub tf: f64,
pub vtd: f64,
pub vtu: f64,
pub ftd: f64,
pub ftu: f64,
pub td: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IndmotParams {
pub h: f64,
pub d: f64,
pub ra: f64,
pub xs: f64,
pub xr: f64,
pub xm: f64,
pub rr: f64,
pub t0p: f64,
pub x0p: f64,
pub mbase: f64,
pub lfac: f64,
pub slip0: f64,
pub te0: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MotorParams {
pub h: f64,
pub ra: f64,
pub xs: f64,
pub x0p: f64,
pub t0p: f64,
pub mbase: f64,
pub lfac: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esst5bParams {
pub tr: f64,
pub kc: f64,
pub kf: f64,
pub tf: f64,
pub ka: f64,
pub tb: f64,
pub tc: f64,
pub vrmax: f64,
pub vrmin: f64,
pub t1: f64,
pub t2: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Exac4Params {
pub tr: f64,
pub tc: f64,
pub tb: f64,
pub ka: f64,
pub ta: f64,
pub vrmax: f64,
pub vrmin: f64,
pub kc: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Tgov5Params {
pub r: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub k1: f64,
pub k2: f64,
pub k3: f64,
pub pmax: f64,
pub pmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Gast2aParams {
pub r: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub at: f64,
pub kt: f64,
pub vmin: f64,
pub vmax: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Stab2aParams {
pub ks: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub hlim: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pss4bParams {
pub kl: f64,
pub kh: f64,
pub tw1: f64,
pub tw2: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub vstmax: f64,
pub vstmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Csvgn3Params {
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub k: f64,
pub slope: f64,
pub vmax: f64,
pub vmin: f64,
pub bmax: f64,
pub bmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Cdc7tParams {
pub setvl: f64,
pub vschd: f64,
pub mbase: f64,
pub tr: f64,
pub td: f64,
pub alpha_min: f64,
pub alpha_max: f64,
pub gamma_min: f64,
pub rectifier_bus: u32,
pub inverter_bus: u32,
pub runback_rate: f64,
pub current_order_max: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CmpldwMotorParams {
pub ra: f64,
pub xm: f64,
pub r1: f64,
pub x1: f64,
pub r2: f64,
pub x2: f64,
pub h: f64,
pub vtr: f64,
pub etrq: f64,
}
impl Default for CmpldwMotorParams {
fn default() -> Self {
Self {
ra: 0.0,
xm: 3.0,
r1: 0.04,
x1: 0.1,
r2: 0.04,
x2: 0.1,
h: 0.5,
vtr: 0.0,
etrq: 0.0,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CmpldwParams {
pub lfma: f64,
pub lfmb: f64,
pub lfmc: f64,
pub kp1: f64,
pub np1: f64,
pub kp2: f64,
pub np2: f64,
pub kq1: f64,
pub nq1: f64,
pub kq2: f64,
pub nq2: f64,
pub ra: f64,
pub xm: f64,
pub r1: f64,
pub x1: f64,
pub r2: f64,
pub x2: f64,
pub vtr1: f64,
pub vtr2: f64,
pub mbase: f64,
#[serde(default)]
pub motor_a: Option<CmpldwMotorParams>,
#[serde(default)]
pub motor_b: Option<CmpldwMotorParams>,
#[serde(default)]
pub motor_c: Option<CmpldwMotorParams>,
#[serde(default = "default_tv")]
pub tv: f64,
#[serde(default)]
pub fel: f64,
#[serde(default)]
pub pfreq: f64,
}
fn default_tv() -> f64 {
0.02
}
impl CmpldwParams {
pub fn motor_a_params(&self) -> CmpldwMotorParams {
self.motor_a.clone().unwrap_or(CmpldwMotorParams {
ra: self.ra,
xm: self.xm,
r1: self.r1,
x1: self.x1,
r2: self.r2,
x2: self.x2,
h: 0.5,
vtr: self.vtr1,
etrq: 0.0,
})
}
pub fn motor_b_params(&self) -> CmpldwMotorParams {
self.motor_b.clone().unwrap_or(CmpldwMotorParams {
ra: self.ra,
xm: self.xm * 1.5, r1: self.r1 * 1.2,
x1: self.x1 * 1.2,
r2: self.r2 * 1.2,
x2: self.x2 * 1.2,
h: 0.3, vtr: self.vtr2,
etrq: 0.0,
})
}
pub fn motor_c_params(&self) -> CmpldwMotorParams {
self.motor_c.clone().unwrap_or(CmpldwMotorParams {
ra: self.ra * 0.8,
xm: self.xm * 2.0, r1: self.r1 * 0.8,
x1: self.x1 * 0.8,
r2: self.r2 * 0.8,
x2: self.x2 * 0.8,
h: 0.1, vtr: self.vtr2,
etrq: 2.0, })
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CmpldwgParams {
pub lfma: f64,
pub lfmb: f64,
pub lfmc: f64,
pub kp1: f64,
pub np1: f64,
pub kp2: f64,
pub np2: f64,
pub kq1: f64,
pub nq1: f64,
pub kq2: f64,
pub nq2: f64,
pub ra: f64,
pub xm: f64,
pub r1: f64,
pub x1: f64,
pub r2: f64,
pub x2: f64,
pub vtr1: f64,
pub vtr2: f64,
pub mbase: f64,
pub gen_mw: f64,
#[serde(default)]
pub motor_a: Option<CmpldwMotorParams>,
#[serde(default)]
pub motor_b: Option<CmpldwMotorParams>,
#[serde(default)]
pub motor_c: Option<CmpldwMotorParams>,
#[serde(default = "default_tv")]
pub tv: f64,
#[serde(default)]
pub fel: f64,
#[serde(default)]
pub pfreq: f64,
}
impl CmpldwgParams {
pub fn motor_a_params(&self) -> CmpldwMotorParams {
self.motor_a.clone().unwrap_or(CmpldwMotorParams {
ra: self.ra,
xm: self.xm,
r1: self.r1,
x1: self.x1,
r2: self.r2,
x2: self.x2,
h: 0.5,
vtr: self.vtr1,
etrq: 0.0,
})
}
pub fn motor_b_params(&self) -> CmpldwMotorParams {
self.motor_b.clone().unwrap_or(CmpldwMotorParams {
ra: self.ra,
xm: self.xm * 1.5,
r1: self.r1 * 1.2,
x1: self.x1 * 1.2,
r2: self.r2 * 1.2,
x2: self.x2 * 1.2,
h: 0.3,
vtr: self.vtr2,
etrq: 0.0,
})
}
pub fn motor_c_params(&self) -> CmpldwMotorParams {
self.motor_c.clone().unwrap_or(CmpldwMotorParams {
ra: self.ra * 0.8,
xm: self.xm * 2.0,
r1: self.r1 * 0.8,
x1: self.x1 * 0.8,
r2: self.r2 * 0.8,
x2: self.x2 * 0.8,
h: 0.1,
vtr: self.vtr2,
etrq: 2.0,
})
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Cmldblu2Params {
pub t1: f64,
pub t2: f64,
pub k1: f64,
pub k2: f64,
pub pf: f64,
pub kp: f64,
pub kq: f64,
pub vmin: f64,
pub vmax: f64,
pub mbase: f64,
}
pub type Cmldaru2Params = Cmldblu2Params;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MotorwParams {
pub ra: f64,
pub xm: f64,
pub r1: f64,
pub x1: f64,
pub r2: f64,
pub x2: f64,
pub h: f64,
pub vtr1: f64,
pub vtr2: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Cim5Params {
pub ra: f64,
pub xs: f64,
pub xm: f64,
pub xr1: f64,
pub xr2: f64,
pub rr1: f64,
pub rr2: f64,
pub h: f64,
pub e1: f64,
pub s1: f64,
pub e2: f64,
pub s2: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esst6bParams {
pub tr: f64,
pub ilr: f64,
pub klr: f64,
pub ka: f64,
pub ta: f64,
pub kc: f64,
pub vrmax: f64,
pub vrmin: f64,
pub kff: f64,
pub kgff: f64,
pub t1: f64,
pub t2: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esst7bParams {
pub tr: f64,
pub kpa: f64,
pub kia: f64,
pub vrmax: f64,
pub vrmin: f64,
pub kpff: f64,
pub kh: f64,
pub vmax: f64,
pub vmin: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub kl: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esac6aParams {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub tk: f64,
pub tb: f64,
pub tc: f64,
pub vamax: f64,
pub vamin: f64,
pub vrmax: f64,
pub vrmin: f64,
pub te: f64,
pub kh: f64,
pub kf: f64,
pub tf: f64,
pub kc: f64,
pub kd: f64,
pub ke: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esdc1aParams {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub kf: f64,
pub tf: f64,
pub ke: f64,
pub te: f64,
pub se1: f64,
pub e1: f64,
pub se2: f64,
pub e2: f64,
pub vrmax: f64,
pub vrmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Exst2Params {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub vrmax: f64,
pub vrmin: f64,
pub kc: f64,
pub ki: f64,
pub ke: f64,
pub te: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ac8bParams {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub kc: f64,
pub vrmax: f64,
pub vrmin: f64,
pub kd: f64,
pub ke: f64,
pub te: f64,
pub pid_kp: f64,
pub pid_ki: f64,
pub pid_kd: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Bbsex1Params {
pub t1r: f64,
pub t2r: f64,
pub t3r: f64,
pub t4r: f64,
pub t1i: f64,
pub t2i: f64,
pub ka: f64,
pub ta: f64,
pub vrmax: f64,
pub vrmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ieeet3Params {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub vrmax: f64,
pub vrmin: f64,
pub kf: f64,
pub tf: f64,
pub ke: f64,
pub te: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
pub kp: f64,
pub ki: f64,
pub kc: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct H6eParams {
pub r: f64,
pub tr: f64,
pub tf: f64,
pub tg: f64,
pub tw: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub dt: f64,
pub pmax: f64,
pub pmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WshygpParams {
pub r: f64,
pub tf: f64,
pub tg: f64,
pub tw: f64,
pub kd: f64,
pub pmax: f64,
pub pmin: f64,
pub kp: f64,
pub ki: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Stab3Params {
pub ks: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub t6: f64,
pub vstmax: f64,
pub vstmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pss3bParams {
pub a1: f64,
pub a2: f64,
pub a3: f64,
pub a4: f64,
pub a5: f64,
pub a6: f64,
pub a7: f64,
pub a8: f64,
pub vsi1max: f64,
pub vsi1min: f64,
pub vsi2max: f64,
pub vsi2min: f64,
pub vstmax: f64,
pub vstmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wt3e1Params {
pub kpv: f64,
pub kiv: f64,
pub kqv: f64,
pub xd: f64,
pub kpq: f64,
pub kiq: f64,
pub tpe: f64,
pub pmin: f64,
pub pmax: f64,
pub qmin: f64,
pub qmax: f64,
pub imax: f64,
pub tv: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wt3e2Params {
pub kpv: f64,
pub kiv: f64,
pub kqv: f64,
pub xd: f64,
pub kpq: f64,
pub kiq: f64,
pub tpe: f64,
pub pmin: f64,
pub pmax: f64,
pub qmin: f64,
pub qmax: f64,
pub imax: f64,
pub tiq: f64,
pub tv: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wt4e1Params {
pub kpv: f64,
pub kiv: f64,
pub tpe: f64,
pub pmin: f64,
pub pmax: f64,
pub qmin: f64,
pub qmax: f64,
pub imax: f64,
}
pub type Wt4e2Params = Wt4e1Params;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepcbParams {
pub tp: f64,
pub tfltr: f64,
pub kp: f64,
pub ki: f64,
pub tft: f64,
pub tfv: f64,
pub qmax: f64,
pub qmin: f64,
pub vmax: f64,
pub vmin: f64,
pub kc: f64,
pub refs: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Csvgn4Params {
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub k: f64,
pub slope: f64,
pub kpod: f64,
pub tpod: f64,
pub vmax: f64,
pub vmin: f64,
pub bmax: f64,
pub bmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Csvgn5Params {
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub k: f64,
pub kv: f64,
pub kpod: f64,
pub tpod: f64,
pub vmax: f64,
pub vmin: f64,
pub bmax: f64,
pub bmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Cdc6tParams {
pub setvl: f64,
pub vschd: f64,
pub mbase: f64,
pub tr: f64,
pub td: f64,
pub alpha_min: f64,
pub alpha_max: f64,
pub gamma_min: f64,
pub rectifier_bus: u32,
pub inverter_bus: u32,
pub i_limit: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CstcntParams {
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub ka: f64,
pub ta: f64,
pub iqmax: f64,
pub iqmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Mmc1Params {
pub tr: f64,
pub kp_v: f64,
pub ki_v: f64,
pub kp_i: f64,
pub ki_i: f64,
pub vdc: f64,
pub larm: f64,
pub pmax: f64,
pub pmin: f64,
pub qmax: f64,
pub qmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Exst3Params {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub tb: f64,
pub tc: f64,
pub vrmax: f64,
pub vrmin: f64,
pub kc: f64,
pub ki: f64,
pub km: f64,
pub vmmax: f64,
pub vmmin: f64,
pub xm: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CbufrParams {
pub kf: f64,
pub tf: f64,
pub tp: f64,
pub p_base: f64,
pub p_min: f64,
pub p_max: f64,
pub e_cap: f64,
pub soc_init: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CbufdParams {
pub kf: f64,
pub tf: f64,
pub tp: f64,
pub tq: f64,
pub p_base: f64,
pub p_min: f64,
pub p_max: f64,
pub q_base: f64,
pub q_min: f64,
pub q_max: f64,
pub e_cap: f64,
pub soc_init: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RegfmC1Params {
pub kd: f64,
pub ki: f64,
pub kq: f64,
pub tg: f64,
pub ddn: f64,
pub dup: f64,
pub pmax: f64,
pub pmin: f64,
pub qmax: f64,
pub qmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pvgu1Params {
pub lvplsw: f64,
pub rrpwr: f64,
pub brkpt: f64,
pub zerox: f64,
pub lvpl1: f64,
pub volim: f64,
pub lvpnt1: f64,
pub lvpnt0: f64,
pub iolim: f64,
pub tfltr: f64,
pub khv: f64,
pub iqrmax: f64,
pub iqrmin: f64,
pub accel: f64,
pub vsmax: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pveu1Params {
pub tiq: f64,
pub dflag: f64,
pub vref0: f64,
pub tv: f64,
pub dbd: f64,
pub kqv: f64,
pub iqhl: f64,
pub iqll: f64,
pub pmax: f64,
pub pmin: f64,
pub qmax: f64,
pub qmin: f64,
pub vmax: f64,
pub vmin: f64,
pub tpord: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PvdgParams {
pub tp: f64,
pub tq: f64,
pub vtrip1: f64,
pub vtrip2: f64,
pub vtrip3: f64,
pub ftrip1: f64,
pub ftrip2: f64,
pub pmax: f64,
pub qmax: f64,
pub qmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ieeet2Params {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub vrmax: f64,
pub vrmin: f64,
pub ke: f64,
pub te: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
pub kf: f64,
pub tf: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Exac2Params {
pub tr: f64,
pub tb: f64,
pub tc: f64,
pub ka: f64,
pub ta: f64,
pub vamax: f64,
pub vamin: f64,
pub te: f64,
pub kf: f64,
pub tf: f64,
pub ke: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
pub kc: f64,
pub kd: f64,
pub kh: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Exac3Params {
pub tr: f64,
pub kc: f64,
pub ki: f64,
pub vmin: f64,
pub vmax: f64,
pub ke: f64,
pub te: f64,
pub kf: f64,
pub tf: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
pub ka: f64,
pub ta: f64,
pub efdn: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esac3aParams {
pub tr: f64,
pub tb: f64,
pub tc: f64,
pub ka: f64,
pub ta: f64,
pub vamax: f64,
pub vamin: f64,
pub te: f64,
pub ke: f64,
pub kf1: f64,
pub tf: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
pub kc: f64,
pub kd: f64,
pub ki: f64,
pub efdn: f64,
pub kn: f64,
pub vfemax: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esst8cParams {
pub tr: f64,
pub kpr: f64,
pub kir: f64,
pub vrmax: f64,
pub vrmin: f64,
pub ka: f64,
pub ta: f64,
pub kc: f64,
pub vbmax: f64,
pub xl: f64,
pub kf: f64,
pub tf: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esst9bParams {
pub tr: f64,
pub kpa: f64,
pub kia: f64,
pub vrmax: f64,
pub vrmin: f64,
pub ka: f64,
pub ta: f64,
pub vbmax: f64,
pub kc: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esst10cParams {
pub tr: f64,
pub kpa: f64,
pub kia: f64,
pub kpb: f64,
pub kib: f64,
pub vrmax: f64,
pub vrmin: f64,
pub ka: f64,
pub ta: f64,
pub vbmax: f64,
pub kc: f64,
pub t1: f64,
pub t2: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esdc3aParams {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub vrmax: f64,
pub vrmin: f64,
pub te: f64,
pub ke: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
pub kp: f64,
pub ki: f64,
pub kf: f64,
pub tf: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Exdc1Params {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub vrmax: f64,
pub vrmin: f64,
pub ke: f64,
pub te: f64,
pub kf: f64,
pub tf: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esst2aParams {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub tb: f64,
pub tc: f64,
pub ke: f64,
pub te: f64,
pub kf: f64,
pub tf: f64,
pub vrmax: f64,
pub vrmin: f64,
pub e1: f64, pub se1: f64, pub e2: f64, pub se2: f64, pub kc: f64, pub kp: f64, pub ki: f64, pub tp: f64, }
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Exdc3Params {
pub tr: f64,
pub kv: f64, pub tstall: f64, pub tcon: f64, pub tb: f64,
pub tc: f64,
pub vrmax: f64,
pub vrmin: f64,
pub veff: f64,
pub tlim: f64,
pub vlim: f64,
pub ke: f64,
pub te: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pss2cParams {
pub m1: f64,
pub t6: f64,
pub m2: f64,
pub t7: f64,
pub tw1: f64,
pub tw2: f64,
pub tw3: f64,
pub tw4: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t8: f64,
pub t9: f64,
pub n: i32,
pub ks1: f64,
pub ks2: f64,
pub ks3: f64,
pub vstmax: f64,
pub vstmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pss5Params {
pub kl: f64,
pub km: f64,
pub kh: f64,
pub tw1: f64,
pub tw2: f64,
pub tw3: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub t6: f64,
pub vstmax: f64,
pub vstmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pss6cParams {
pub kl: f64,
pub km: f64,
pub kh: f64,
pub kl2: f64,
pub km2: f64,
pub kh2: f64,
pub tw1: f64,
pub tw2: f64,
pub tw3: f64,
pub tw4: f64,
pub tw5: f64,
pub tw6: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub vstmax: f64,
pub vstmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PsssbParams {
pub ks: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub t6: f64,
pub tw: f64,
pub vstmax: f64,
pub vstmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Stab4Params {
pub ks: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub t6: f64,
pub t7: f64,
pub t8: f64,
pub hlim: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Stab5Params {
pub ks: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub t6: f64,
pub t7: f64,
pub t8: f64,
pub t9: f64,
pub t10: f64,
pub hlim: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ggov2Params {
pub r: f64,
pub rselect: f64,
pub tpelec: f64,
pub maxerr: f64,
pub minerr: f64,
pub kpgov: f64,
pub kigov: f64,
pub kdgov: f64,
pub tdgov: f64,
pub vmax: f64,
pub vmin: f64,
pub tact: f64,
pub kturb: f64,
pub wfnl: f64,
pub tb: f64,
pub tc: f64,
pub flag: f64,
pub teng: f64,
pub tfload: f64,
pub kpload: f64,
pub kiload: f64,
pub ldref: f64,
pub dm: f64,
pub ropen: f64,
pub rclose: f64,
pub kimw: f64,
pub pmwset: f64,
pub aset: f64,
pub ka: f64,
pub ta: f64,
pub db: f64,
pub tsa: f64,
pub tsb: f64,
pub rup: f64,
pub rdown: f64,
pub pmax: f64,
pub pmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ggov3Params {
pub r: f64,
pub rselect: f64,
pub tpelec: f64,
pub maxerr: f64,
pub minerr: f64,
pub kpgov: f64,
pub kigov: f64,
pub kdgov: f64,
pub tdgov: f64,
pub vmax: f64,
pub vmin: f64,
pub tact: f64,
pub kturb: f64,
pub wfnl: f64,
pub tb: f64,
pub tc: f64,
pub flag: f64,
pub teng: f64,
pub tfload: f64,
pub kpload: f64,
pub kiload: f64,
pub ldref: f64,
pub dm: f64,
pub ropen: f64,
pub rclose: f64,
pub kimw: f64,
pub pmwset: f64,
pub aset: f64,
pub ka: f64,
pub ta: f64,
pub db: f64,
pub tsa: f64,
pub tsb: f64,
pub tw: f64,
pub rup: f64,
pub rdown: f64,
pub pmax: f64,
pub pmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WpidhyParams {
pub gatmax: f64,
pub gatmin: f64,
pub reg: f64,
pub kp: f64,
pub ki: f64,
pub kd: f64,
pub ta: f64,
pub tb: f64,
pub tw: f64,
pub at: f64,
pub dturb: f64,
pub gmax: f64,
pub gmin: f64,
pub pmax: f64,
pub pmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct H6bParams {
pub tg: f64, pub tp: f64, pub uo: f64, pub uc: f64, pub pmax: f64,
pub pmin: f64,
pub beta: f64, pub tw: f64, pub dbinf: f64, pub dbsup: f64, }
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WshyddParams {
pub r: f64,
pub tf: f64,
pub tg: f64,
pub tw: f64,
pub db: f64, pub kd: f64,
pub pmax: f64,
pub pmin: f64,
pub kp: f64,
pub ki: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HvdcPlu1Params {
pub setvl: f64,
pub vschd: f64,
pub mbase: f64,
pub xcr: f64,
pub xci: f64,
pub rdc: f64,
pub td: f64,
pub tr: f64,
pub alpha_min: f64,
pub alpha_max: f64,
pub gamma_min: f64,
pub kp_id: f64,
pub ki_id: f64,
pub t_ramp: f64,
pub pmax: f64,
pub pmin: f64,
pub rectifier_bus: u32,
pub inverter_bus: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Csvgn6Params {
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub k: f64,
pub k_aux: f64,
pub t_aux: f64,
pub vmax: f64,
pub vmin: f64,
pub bmax: f64,
pub bmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Stcon1Params {
pub tr: f64,
pub kp: f64,
pub ki: f64,
pub kp_i: f64,
pub ki_i: f64,
pub vmax: f64,
pub vmin: f64,
pub iqmax: f64,
pub iqmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GcscParams {
pub tr: f64,
pub kp: f64,
pub ki: f64,
pub xmax: f64,
pub xmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SsscParams {
pub tr: f64,
pub kp: f64,
pub ki: f64,
pub kp_i: f64,
pub ki_i: f64,
pub vqmax: f64,
pub vqmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UpfcParams {
pub tr: f64,
pub kp_p: f64,
pub ki_p: f64,
pub kp_q: f64,
pub ki_q: f64,
pub kp_v: f64,
pub ki_v: f64,
pub pmax: f64,
pub pmin: f64,
pub qmax: f64,
pub qmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Cdc3tParams {
pub tr: f64,
pub kp1: f64,
pub ki1: f64,
pub kp2: f64,
pub ki2: f64,
pub kp3: f64,
pub ki3: f64,
pub pmax: f64,
pub pmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Regco1Params {
pub tr: f64,
pub kp_v: f64,
pub ki_v: f64,
pub kp_i: f64,
pub ki_i: f64,
pub vmax: f64,
pub vmin: f64,
pub iqmax: f64,
pub iqmin: f64,
pub pmax: f64,
pub pmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Gensal3Params {
pub td0_prime: f64,
pub h: f64,
pub d: f64,
pub xd: f64,
pub xq: f64,
pub xd_prime: f64,
pub xl: f64,
pub s1: f64,
pub s12: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Lcfb1Params {
pub tc: f64,
pub tb: f64,
pub kf: f64,
pub pmax: f64,
pub pmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LdfralParams {
pub tc: f64,
pub tb: f64,
pub kf: f64,
pub kp: f64,
pub pmax: f64,
pub pmin: f64,
pub mbase: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FrqtpltParams {
pub tf: f64,
pub fmin: f64,
pub fmax: f64,
pub p_trip: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LvshblParams {
pub tv: f64,
pub vmin: f64,
pub p_block: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Uvls1Params {
pub tv: f64,
pub vmin: f64,
pub t_delay: f64,
pub p_shed: f64,
pub v_reconnect: f64,
pub t_reconnect: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UnknownDyrRecord {
pub bus: u32,
pub model_name: String,
pub machine_id: String,
pub params: Vec<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Repcgfmc1Params {
pub kp_v: f64,
pub ki_v: f64,
pub vmax: f64,
pub vmin: f64,
pub kp_q: f64,
pub ki_q: f64,
pub qmax: f64,
pub qmin: f64,
pub tlag: f64,
pub fdroop: f64,
pub dbd1: f64,
pub dbd2: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DerpParams {
pub x_eq: f64,
pub trf: f64,
pub imax: f64,
pub trv: f64,
pub tpll: f64,
pub flow: f64,
pub fhigh: f64,
pub vlow: f64,
pub vhigh: f64,
pub trip: f64,
pub treconnect: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Regfmd1Params {
pub rrv: f64,
pub lrv: f64,
pub kpv: f64,
pub kiv: f64,
pub kpg: f64,
pub kig: f64,
pub kdroop: f64,
pub kvir: f64,
pub kfir: f64,
pub imax: f64,
pub dpf: f64,
pub dqf: f64,
pub x_eq: f64,
pub mbase: f64,
pub tpll: f64,
pub tv: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wtdta1Params {
pub h: f64,
pub dshaft: f64,
pub kshaft: f64,
pub d2: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wtara1Params {
pub ka: f64,
pub ta: f64,
pub km: f64,
pub tm: f64,
pub pmax: f64,
pub pmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wtpta1Params {
pub kpp: f64,
pub kip: f64,
pub theta_max: f64,
pub theta_min: f64,
pub rate_max: f64,
pub rate_min: f64,
pub te: f64,
pub kp_pitch: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CpTable {
pub lambda_bp: Vec<f64>,
pub beta_bp: Vec<f64>,
pub cp_values: Vec<f64>,
}
impl CpTable {
pub fn interpolate(&self, lambda: f64, beta: f64) -> f64 {
let (il, il1, fl) = Self::find_bracket(&self.lambda_bp, lambda);
let (ib, ib1, fb) = Self::find_bracket(&self.beta_bp, beta);
let nb = self.beta_bp.len();
let c00 = self.cp_values[il * nb + ib];
let c01 = self.cp_values[il * nb + ib1];
let c10 = self.cp_values[il1 * nb + ib];
let c11 = self.cp_values[il1 * nb + ib1];
let c0 = c00 + fb * (c01 - c00);
let c1 = c10 + fb * (c11 - c10);
(c0 + fl * (c1 - c0)).max(0.0)
}
pub fn nrel_5mw() -> Self {
let lambda_bp = vec![2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0];
let beta_bp = vec![0.0, 5.0, 10.0, 15.0, 20.0, 25.0];
#[rustfmt::skip]
let cp_values = vec![
0.10, 0.06, 0.02, 0.01, 0.00, 0.00, 0.30, 0.20, 0.10, 0.04, 0.01, 0.00, 0.42, 0.32, 0.18, 0.08, 0.03, 0.01, 0.48, 0.38, 0.22, 0.11, 0.04, 0.01, 0.44, 0.34, 0.20, 0.10, 0.04, 0.01, 0.35, 0.26, 0.15, 0.07, 0.03, 0.01, 0.22, 0.16, 0.09, 0.04, 0.02, 0.01, 0.10, 0.07, 0.04, 0.02, 0.01, 0.00, ];
Self {
lambda_bp,
beta_bp,
cp_values,
}
}
fn find_bracket(bp: &[f64], val: f64) -> (usize, usize, f64) {
if bp.len() < 2 {
return (0, 0, 0.0);
}
if val <= bp[0] {
return (0, 0, 0.0);
}
if val >= bp[bp.len() - 1] {
let n = bp.len() - 1;
return (n, n, 0.0);
}
let pos = bp.partition_point(|&x| x <= val);
let i = if pos > 0 { pos - 1 } else { 0 };
let i1 = (i + 1).min(bp.len() - 1);
let span = bp[i1] - bp[i];
let frac = if span.abs() > 1e-15 {
(val - bp[i]) / span
} else {
0.0
};
(i, i1, frac)
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WtaeroParams {
pub rho: f64,
pub r_rotor: f64,
pub gear_ratio: f64,
pub cp_table: CpTable,
pub v_wind_base: f64,
pub mbase_mw: f64,
pub h_rotor: Option<f64>,
pub k_shaft: Option<f64>,
pub d_shaft: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IeesgoParams {
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub t4: f64,
pub t5: f64,
pub t6: f64,
pub k1: f64,
pub k2: f64,
pub k3: f64,
pub pmax: f64,
pub pmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wttqa1Params {
pub kp: f64,
pub ki: f64,
pub tp: f64,
pub pmax: f64,
pub pmin: f64,
pub tflag: i32,
pub twref: f64,
pub temax: f64,
pub temin: f64,
pub spl: [(f64, f64); 4],
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Cim6Params {
pub ra: f64,
pub xs: f64,
pub xm: f64,
pub xr1: f64,
pub xr2: f64,
pub rr1: f64,
pub rr2: f64,
pub h: f64,
pub e1: f64,
pub s1: f64,
pub e2: f64,
pub s2: f64,
pub mbase: f64,
pub tq0p: f64,
pub xq_prime: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExtlParams {
pub tp: f64,
pub tq: f64,
pub kpv: f64,
pub kqv: f64,
pub kpf: f64,
pub kqf: f64,
pub mbase: f64,
pub lfac: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Svsmo1Params {
pub tr: f64,
pub k: f64,
pub ta: f64,
pub b_min: f64,
pub b_max: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Svsmo2Params {
pub tr: f64,
pub k: f64,
pub ta: f64,
pub iq_min: f64,
pub iq_max: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Svsmo3Params {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub tb: f64,
pub b_min: f64,
pub b_max: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VtgtpatParams {
pub tv: f64,
pub vtrip: f64,
pub vreset: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FrqtpatParams {
pub tf: f64,
pub ftrip_hi: f64,
pub ftrip_lo: f64,
pub freset: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Hygov4Params {
pub tr: f64,
pub tf: f64,
pub dturb: f64,
pub hdam: f64,
pub tw: f64,
pub qnl: f64,
pub at: f64,
pub dg: f64,
pub gmax: f64,
pub gmin: f64,
pub ts: f64,
pub ks: f64,
pub pmax: f64,
pub pmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WehgovParams {
pub r: f64,
pub tr: f64,
pub tf: f64,
pub tg: f64,
pub tw: f64,
pub at: f64,
pub dturb: f64,
pub qnl: f64,
pub gmax: f64,
pub gmin: f64,
pub dbd1: f64,
pub dbd2: f64,
pub pmax: f64,
pub pmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ieeeg3Params {
pub tg: f64,
pub tp: f64,
pub uo: f64,
pub uc: f64,
pub pmax: f64,
pub pmin: f64,
pub tw: f64,
pub at: f64,
pub dturb: f64,
pub qnl: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ieeeg4Params {
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub ki: f64,
pub pmax: f64,
pub pmin: f64,
pub tw: f64,
pub at: f64,
pub dturb: f64,
pub qnl: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esac7cParams {
pub tr: f64,
pub kpr: f64,
pub kir: f64,
pub kdr: f64,
pub tdr: f64,
pub vrmax: f64,
pub vrmin: f64,
pub ka: f64,
pub ta: f64,
pub kp: f64,
pub kl: f64,
pub te: f64,
pub ke: f64,
pub vfemax: f64,
pub vemin: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Esdc4cParams {
pub tr: f64,
pub ka: f64,
pub ta: f64,
pub kpr: f64,
pub kir: f64,
pub kdr: f64,
pub tdr: f64,
pub vrmax: f64,
pub vrmin: f64,
pub ke: f64,
pub te: f64,
pub kf: f64,
pub tf: f64,
pub e1: f64,
pub se1: f64,
pub e2: f64,
pub se2: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pss7cParams {
#[serde(default)]
pub kss: f64,
#[serde(default)]
pub tw1: f64,
#[serde(default)]
pub tw2: f64,
#[serde(default)]
pub t1: f64,
#[serde(default)]
pub t2: f64,
#[serde(default)]
pub t3: f64,
#[serde(default)]
pub t4: f64,
#[serde(default = "default_vsmax")]
pub vsmax: f64,
#[serde(default = "default_vsmin")]
pub vsmin: f64,
#[serde(default)]
pub kl: f64,
#[serde(default = "default_tw")]
pub tw_l: f64,
#[serde(default)]
pub t1_l: f64,
#[serde(default = "default_tlag")]
pub t2_l: f64,
#[serde(default)]
pub ki: f64,
#[serde(default = "default_tw")]
pub tw_i: f64,
#[serde(default)]
pub t1_i: f64,
#[serde(default = "default_tlag")]
pub t2_i: f64,
#[serde(default)]
pub kh: f64,
#[serde(default = "default_tw")]
pub tw_h: f64,
#[serde(default)]
pub t1_h: f64,
#[serde(default = "default_tlag")]
pub t2_h: f64,
#[serde(default = "default_vsmax")]
pub vstmax: f64,
#[serde(default = "default_vsmin")]
pub vstmin: f64,
}
fn default_vsmax() -> f64 {
0.1
}
fn default_vsmin() -> f64 {
-0.1
}
fn default_tw() -> f64 {
10.0
}
fn default_tlag() -> f64 {
0.04
}
impl Pss7cParams {
pub fn effective_bands(&self) -> Pss7cBands {
if self.kl == 0.0 && self.ki == 0.0 && self.kh == 0.0 && self.kss != 0.0 {
Pss7cBands {
kl: 0.0,
tw_l: self.tw1,
t1_l: 0.0,
t2_l: 0.04,
ki: self.kss,
tw_i: self.tw1,
t1_i: self.t1,
t2_i: self.t2,
kh: 0.0,
tw_h: self.tw2,
t1_h: 0.0,
t2_h: 0.04,
vstmax: self.vsmax,
vstmin: self.vsmin,
}
} else {
Pss7cBands {
kl: self.kl,
tw_l: self.tw_l,
t1_l: self.t1_l,
t2_l: self.t2_l,
ki: self.ki,
tw_i: self.tw_i,
t1_i: self.t1_i,
t2_i: self.t2_i,
kh: self.kh,
tw_h: self.tw_h,
t1_h: self.t1_h,
t2_h: self.t2_h,
vstmax: self.vstmax,
vstmin: self.vstmin,
}
}
}
}
#[derive(Debug, Clone)]
pub struct Pss7cBands {
pub kl: f64,
pub tw_l: f64,
pub t1_l: f64,
pub t2_l: f64,
pub ki: f64,
pub tw_i: f64,
pub t1_i: f64,
pub t2_i: f64,
pub kh: f64,
pub tw_h: f64,
pub t1_h: f64,
pub t2_h: f64,
pub vstmax: f64,
pub vstmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Govct1Params {
pub r: f64,
pub t1: f64,
pub vmax: f64,
pub vmin: f64,
pub t2: f64,
pub t3: f64,
pub k1: f64,
pub k2: f64,
pub k3: f64,
pub t4: f64,
pub t5: f64,
pub t6: f64,
pub k7: f64,
pub k8: f64,
pub pmax: f64,
pub pmin: f64,
#[serde(default)]
pub td: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Govct2Params {
pub r: f64,
pub t1: f64,
pub vmax: f64,
pub vmin: f64,
pub t2: f64,
pub t3: f64,
pub k1: f64,
pub k2: f64,
pub k3: f64,
pub t4: f64,
pub t5: f64,
pub t6: f64,
pub k7: f64,
pub k8: f64,
pub pmax: f64,
pub pmin: f64,
#[serde(default)]
pub td: f64,
pub t_hrsg: f64,
pub k_st: f64,
pub t_st: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Tgov3Params {
pub r: f64,
pub t1: f64,
pub vmax: f64,
pub vmin: f64,
pub t2: f64,
pub t3: f64,
pub dt: f64,
pub kd: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wt1g1Params {
pub h: f64,
pub d: f64,
pub ra: f64,
pub x_eq: f64,
pub imax: f64,
pub xs: f64,
pub xm: f64,
pub xr: f64,
pub rr: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wt2e1Params {
pub kp: f64,
pub ki: f64,
pub pmax: f64,
pub pmin: f64,
pub te: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Distr1Params {
pub z1: f64,
pub z2: f64,
pub z3: f64,
pub t1: f64,
pub t2: f64,
pub t3: f64,
pub reach_angle_deg: f64,
pub mbase: f64,
pub lfac: f64,
pub branch_from: u32,
pub branch_to: u32,
pub branch_r: f64,
pub branch_x: f64,
pub tf: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Bfr50Params {
pub t_bfr: f64,
pub i_sup: f64,
pub branch_idx: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TransDiff87Params {
pub slope1: f64,
pub slope2: f64,
pub i_pickup: f64,
pub harmonic_restraint: f64,
pub from_bus: u32,
pub to_bus: u32,
pub circuit: String,
pub turns_ratio: f64,
pub tf: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LineDiff87lParams {
pub slope1: f64,
pub slope2: f64,
pub i_pickup: f64,
pub from_bus: u32,
pub to_bus: u32,
pub circuit: String,
pub tf: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Recloser79Params {
pub dead_time_1: f64,
pub dead_time_2: f64,
pub dead_time_3: f64,
pub max_attempts: u32,
pub from_bus: u32,
pub to_bus: u32,
pub circuit: String,
pub reset_time: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Oel1bParams {
pub ifdmax: f64,
pub ifdlim: f64,
pub vrmax: f64,
pub vamin: f64,
pub kramp: f64,
pub tff: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Oel2cParams {
pub ifdmax: f64,
pub t_oel: f64,
pub vamin: f64,
pub vrmax: f64,
pub k_oel: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Scl1cParams {
pub irated: f64,
pub kr: f64,
pub tr: f64,
pub vclmax: f64,
pub vclmin: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Uel1Params {
pub kul: f64,
pub tu1: f64,
pub vucmax: f64,
pub vucmin: f64,
pub kur: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Uel2cParams {
pub kul: f64,
pub tu1: f64,
pub tu2: f64,
pub tu3: f64,
pub tu4: f64,
pub vuimax: f64,
pub vuimin: f64,
pub p0: f64,
pub q0: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OelDyn {
pub bus: u32,
pub machine_id: String,
pub model: OelModel,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UelDyn {
pub bus: u32,
pub machine_id: String,
pub model: UelModel,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum OelModel {
Oel1b(Oel1bParams),
Oel2c(Oel2cParams),
Oel3c(Oel2cParams),
Oel4c(Oel2cParams),
Oel5c(Oel2cParams),
Scl1c(Scl1cParams),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum UelModel {
Uel1(Uel1Params),
Uel2c(Uel2cParams),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ShaftDyn {
pub bus: u32,
pub machine_id: String,
pub model: crate::dynamics::shaft::ShaftModel,
}
#[cfg(test)]
mod tests {
use super::*;
fn empty_dm() -> DynamicModel {
DynamicModel::default()
}
#[test]
fn test_coverage_all_supported() {
let mut dm = empty_dm();
dm.generators.push(GeneratorDyn {
bus: 1,
machine_id: "1".into(),
model: GeneratorModel::Gencls(GenclsParams { h: 3.0, d: 0.0 }),
});
let (n_sup, n_tot, pct) = dm.coverage();
assert_eq!(n_sup, 1);
assert_eq!(n_tot, 1);
assert!((pct - 100.0).abs() < 1e-10);
}
#[test]
fn test_coverage_with_unknown() {
let mut dm = empty_dm();
dm.generators.push(GeneratorDyn {
bus: 1,
machine_id: "1".into(),
model: GeneratorModel::Gencls(GenclsParams { h: 3.0, d: 0.0 }),
});
dm.unknown_records.push(UnknownDyrRecord {
bus: 2,
model_name: "GENCC".into(),
machine_id: "1".into(),
params: vec![1.0, 2.0],
});
let (n_sup, n_tot, pct) = dm.coverage();
assert_eq!(n_sup, 1);
assert_eq!(n_tot, 2);
assert!((pct - 50.0).abs() < 1e-10);
}
#[test]
fn test_coverage_empty() {
let dm = empty_dm();
let (n_sup, n_tot, pct) = dm.coverage();
assert_eq!(n_sup, 0);
assert_eq!(n_tot, 0);
assert!((pct - 100.0).abs() < 1e-10);
}
}