1use caseformat::Bus;
2use num_complex::Complex64;
3
4pub fn make_sdzip(
11 base_mva: f64,
12 bus: &[Bus],
13 pw: Option<[f64; 3]>,
14 qw: Option<[f64; 3]>,
15) -> (Vec<Complex64>, Vec<Complex64>, Vec<Complex64>) {
16 let pw = pw.unwrap_or([1.0, 0.0, 0.0]);
17 let qw = qw.unwrap_or(pw);
18
19 let base_mva = Complex64::new(base_mva, 0.0);
20
21 let mut sd_z = Vec::with_capacity(bus.len());
22 let mut sd_i = Vec::with_capacity(bus.len());
23 let mut sd_p = Vec::with_capacity(bus.len());
24 for b in bus {
25 sd_z.push(Complex64::new(b.pd * pw[2], b.qd * qw[2]) / base_mva);
26 sd_i.push(Complex64::new(b.pd * pw[1], b.qd * qw[1]) / base_mva);
27 sd_p.push(Complex64::new(b.pd * pw[0], b.qd * qw[0]) / base_mva);
28 }
29 (sd_z, sd_i, sd_p)
30}