1#[derive(Debug, Clone)]
8pub struct StateStore {
9 pub voltage_magnitude: Vec<f64>,
11 pub voltage_angle: Vec<f64>,
13 pub active_power: Vec<f64>,
15 pub reactive_power: Vec<f64>,
17}
18
19impl StateStore {
20 pub fn new(bus_count: usize) -> Self {
22 Self {
23 voltage_magnitude: vec![1.0; bus_count],
24 voltage_angle: vec![0.0; bus_count],
25 active_power: vec![0.0; bus_count],
26 reactive_power: vec![0.0; bus_count],
27 }
28 }
29
30 pub fn bus_count(&self) -> usize {
32 self.voltage_magnitude.len()
33 }
34
35 pub fn reset(&mut self) {
37 self.voltage_magnitude.fill(1.0);
38 self.voltage_angle.fill(0.0);
39 self.active_power.fill(0.0);
40 self.reactive_power.fill(0.0);
41 }
42}
43
44impl Default for StateStore {
45 fn default() -> Self {
46 Self::new(0)
47 }
48}