Skip to main content

surge_network/network/
power_injection.rs

1// SPDX-License-Identifier: LicenseRef-PolyForm-Noncommercial-1.0.0
2//! Explicit fixed P/Q injections tied to physical equipment.
3
4use serde::{Deserialize, Serialize};
5
6/// High-level classification for fixed bus injections.
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
8pub enum PowerInjectionKind {
9    /// Boundary or external-network injection.
10    Boundary,
11    /// Equivalent-network injection.
12    Equivalent,
13    /// Converter-backed AC injection.
14    Converter,
15    /// Reactive compensation injection that is not voltage-regulating.
16    Compensator,
17    /// Fallback classification when no narrower category fits.
18    #[default]
19    Other,
20}
21
22/// A fixed P/Q injection at a bus.
23///
24/// Positive real/reactive values mean injection into the network. Bus demand is
25/// derived by subtracting these injections from the hosting bus aggregate.
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct PowerInjection {
28    /// Bus number where the equipment is connected.
29    pub bus: u32,
30    /// Stable equipment identifier.
31    pub id: String,
32    /// Injection classification.
33    pub kind: PowerInjectionKind,
34    /// Real power injection in MW. Positive = inject into the network.
35    pub active_power_injection_mw: f64,
36    /// Reactive power injection in MVAr. Positive = inject into the network.
37    pub reactive_power_injection_mvar: f64,
38    /// In-service status.
39    pub in_service: bool,
40}
41
42impl Default for PowerInjection {
43    fn default() -> Self {
44        Self {
45            bus: 0,
46            id: String::new(),
47            kind: PowerInjectionKind::Other,
48            active_power_injection_mw: 0.0,
49            reactive_power_injection_mvar: 0.0,
50            in_service: true,
51        }
52    }
53}
54
55impl PowerInjection {
56    /// Construct a fixed injection with positive values meaning net injection.
57    pub fn new(
58        bus: u32,
59        active_power_injection_mw: f64,
60        reactive_power_injection_mvar: f64,
61    ) -> Self {
62        Self {
63            bus,
64            active_power_injection_mw,
65            reactive_power_injection_mvar,
66            ..Default::default()
67        }
68    }
69}