pub struct Flowgate {
pub name: String,
pub monitored: Vec<WeightedBranchRef>,
pub contingency_branch: Option<BranchRef>,
pub limit_mw: f64,
pub limit_reverse_mw: f64,
pub in_service: bool,
pub limit_mw_schedule: Vec<f64>,
pub limit_reverse_mw_schedule: Vec<f64>,
pub hvdc_coefficients: Vec<(usize, f64)>,
pub hvdc_band_coefficients: Vec<(usize, usize, f64)>,
pub limit_mw_active_period: Option<u32>,
}Expand description
A flowgate: a monitored element under a specific contingency.
Fields§
§name: StringHuman-readable name (e.g. “FG_123”).
monitored: Vec<WeightedBranchRef>The monitored element(s) with signed coefficients.
contingency_branch: Option<BranchRef>The contingency element (branch that trips). None = base-case-only flowgate.
limit_mw: f64Forward MW limit (positive direction defined by monitored_coefficients).
limit_reverse_mw: f64Reverse MW limit (magnitude of allowable reverse flow). When zero (default), the forward limit is applied symmetrically.
in_service: boolWhether this flowgate is actively monitored.
limit_mw_schedule: Vec<f64>Per-timestep forward MW limit schedule (optional).
When non-empty, effective_limit_mw(t) returns schedule[t]
for timesteps within range, falling back to limit_mw otherwise.
Enables dynamic flowgate limits (ambient ratings, planned outage windows).
limit_reverse_mw_schedule: Vec<f64>Per-timestep reverse MW limit schedule (optional).
When non-empty, effective_limit_reverse_mw(t) returns schedule[t]
for timesteps within range, falling back to limit_reverse_mw otherwise.
hvdc_coefficients: Vec<(usize, f64)>HVDC link coefficients for N-1 HVDC contingency constraints.
Each entry: (hvdc_link_index, coefficient_pu).
When non-empty, the flowgate constraint includes HVDC dispatch variable terms:
Σ coeff_i·b_dc_i·(θ_from_i − θ_to_i) + Σ hvdc_coeff_k·P_hvdc[k] ∈ [-limit, limit]
hvdc_band_coefficients: Vec<(usize, usize, f64)>Per-band HVDC coefficients for banded N-1 HVDC contingency constraints.
Each entry: (hvdc_link_index, band_index, coefficient_pu).
limit_mw_active_period: Option<u32>Compact single-active-period marker. When Some(p),
Flowgate::effective_limit_mw returns limit_mw at timestep
p and the INACTIVE_FLOWGATE_LIMIT_MW sentinel for all
other timesteps — producing the same LP behaviour as a 18-slot
limit_mw_schedule with 17 sentinel entries but without the
per-flowgate Vec<f64> allocation (~1.2 GB savings on
617-bus explicit N-1 SCUC, where this is populated by
build_branch_security_flowgate). When None, the legacy
limit_mw_schedule / limit_mw lookup is used unchanged.
Implementations§
Source§impl Flowgate
impl Flowgate
Sourcepub fn effective_limit_mw(&self, t: usize) -> f64
pub fn effective_limit_mw(&self, t: usize) -> f64
Forward MW limit at timestep t.
Resolution order:
- If
limit_mw_active_periodisSome(p): returnlimit_mwatt == p, andINACTIVE_FLOWGATE_LIMIT_MWotherwise. This is the compact encoding used by explicit N-1 security flowgates (one period active, all others disabled). Avoids allocating ann_periods-lengthVec<f64>per flowgate. - Else if
limit_mw_schedule[t]exists: return it. - Else: fall back to
limit_mw.
Sourcepub fn effective_limit_reverse_mw(&self, t: usize) -> f64
pub fn effective_limit_reverse_mw(&self, t: usize) -> f64
Reverse MW limit at timestep t.
Returns limit_reverse_mw_schedule[t] when available, else
limit_reverse_mw. When the result is zero (or negative), callers
should fall back to the forward limit for symmetric enforcement.
Sourcepub fn effective_reverse_or_forward(&self, t: usize) -> f64
pub fn effective_reverse_or_forward(&self, t: usize) -> f64
Effective reverse limit, falling back to forward limit when zero.
This is the convenience method for constraint generation: returns the reverse limit if explicitly set (> 0), otherwise the forward limit for symmetric enforcement.