pub struct Generator {Show 32 fields
pub id: String,
pub bus: u32,
pub machine_id: Option<String>,
pub p: f64,
pub q: f64,
pub qmax: f64,
pub qmin: f64,
pub voltage_setpoint_pu: f64,
pub voltage_regulated: bool,
pub reg_bus: Option<u32>,
pub machine_base_mva: f64,
pub pmax: f64,
pub pmin: f64,
pub in_service: bool,
pub cost: Option<CostCurve>,
pub gen_type: GenType,
pub technology: Option<GeneratorTechnology>,
pub source_technology_code: Option<String>,
pub agc_participation_factor: Option<f64>,
pub h_inertia_s: Option<f64>,
pub pfr_eligible: bool,
pub quick_start: bool,
pub forced_outage_rate: Option<f64>,
pub storage: Option<StorageParams>,
pub owners: Vec<OwnershipEntry>,
pub commitment: Option<CommitmentParams>,
pub ramping: Option<RampingParams>,
pub inverter: Option<InverterParams>,
pub fault_data: Option<GenFaultData>,
pub reactive_capability: Option<ReactiveCapability>,
pub fuel: Option<FuelParams>,
pub market: Option<MarketParams>,
}Expand description
A generation unit connected to a bus in the transmission network.
Represents thermal, hydro, renewable, and storage resources. For storage
units (BESS, pumped hydro), set storage = Some(StorageParams) with
pmin = -charge_mw_max (negative) and pmax = discharge_mw_max.
All power quantities are in MW/MVAr (system base = 100 MVA for per-unit conversion). Voltage setpoint is in per-unit.
Fields§
§id: StringCanonical generator identifier.
This is the stable, crate-native identity for the generator and is used for replaying detached solutions, scenario application, and any other workflow that must survive generator reordering.
Auto-assigned by crate::network::Network::canonicalize_generator_ids
for generators that lack an explicit ID (format: gen_{bus}_{ordinal}).
bus: u32Bus number where the generator is connected.
machine_id: Option<String>PSS/E machine ID string (e.g. "1", "G1").
p: f64Real power output in MW.
q: f64Reactive power output in MVAr.
qmax: f64Maximum reactive power in MVAr.
qmin: f64Minimum reactive power in MVAr.
voltage_setpoint_pu: f64Voltage setpoint in per-unit.
voltage_regulated: boolWhether this generator participates in voltage regulation (PV bus). When false, the generator injects P/Q but does not control bus voltage. Default true — most generators regulate voltage.
reg_bus: Option<u32>Remote voltage regulated bus number (PSS/E IREG field).
machine_base_mva: f64Machine base MVA.
pmax: f64Maximum real power in MW.
pmin: f64Minimum real power in MW.
in_service: boolGenerator status (true = in service).
cost: Option<CostCurve>Cost curve for OPF (physical cost for planning).
gen_type: GenTypeGenerator electrical class.
technology: Option<GeneratorTechnology>Generator technology / prime mover classification.
source_technology_code: Option<String>Source-native technology code when available (e.g. MATPOWER gentype).
agc_participation_factor: Option<f64>AGC participation factor (dimensionless).
h_inertia_s: Option<f64>Inertia constant H in seconds (MVA·s / MVA).
pfr_eligible: boolEligible to provide primary frequency response.
quick_start: boolQuick-start flag: can reach full output in <=10 minutes.
forced_outage_rate: Option<f64>Forced outage rate [0, 1].
storage: Option<StorageParams>Storage parameters. Present iff this generator has energy storage capability (BESS, pumped hydro in storage mode, etc.). When Some: pmin = -charge_mw_max (negative), pmax = discharge_mw_max.
owners: Vec<OwnershipEntry>Ownership entries (PSS/E O1,F1..O4,F4). Up to 4 co-owners.
commitment: Option<CommitmentParams>Unit commitment parameters.
ramping: Option<RampingParams>Piecewise ramp curve parameters.
inverter: Option<InverterParams>Inverter-specific parameters.
fault_data: Option<GenFaultData>Generator fault/sequence data.
reactive_capability: Option<ReactiveCapability>Reactive capability curve data.
fuel: Option<FuelParams>Fuel-related parameters.
market: Option<MarketParams>Market offer/qualification parameters.
Implementations§
Source§impl Generator
impl Generator
Sourcepub fn new(bus: u32, p: f64, voltage_setpoint_pu: f64) -> Self
pub fn new(bus: u32, p: f64, voltage_setpoint_pu: f64) -> Self
Create a generator with the given bus, real power output, and voltage setpoint.
Sourcepub fn with_id(
id: impl Into<String>,
bus: u32,
p: f64,
voltage_setpoint_pu: f64,
) -> Self
pub fn with_id( id: impl Into<String>, bus: u32, p: f64, voltage_setpoint_pu: f64, ) -> Self
Create a generator with an explicit canonical ID.
Sourcepub fn has_reactive_power_range(&self, tolerance_mvar: f64) -> bool
pub fn has_reactive_power_range(&self, tolerance_mvar: f64) -> bool
Returns true when the generator can move reactive output enough to support a voltage target.
Sourcepub fn is_excluded_from_voltage_regulation(&self) -> bool
pub fn is_excluded_from_voltage_regulation(&self) -> bool
Returns true when this generator is explicitly excluded from acting as a voltage-regulating reference resource.
Sourcepub fn can_voltage_regulate(&self) -> bool
pub fn can_voltage_regulate(&self) -> bool
Returns true when the generator should participate in AC voltage control.
Q range is intentionally NOT required here: a generator with
qmin == qmax (e.g. Q pinned to a reference value for
diagnostic roundtrips or fixed-Q dispatch replays) is still a
legitimate voltage reference — V is the free variable at its bus,
Q just happens to be fixed rather than free. Requiring
has_reactive_power_range here breaks validate_for_solve
whenever the per-period dispatch profile collapses Q bounds to
a point (the bus then has no regulator count, slack-placement
check fails, AC-OPF preflight rejects the network).
Sourcepub fn ramp_up_at_mw(&self, p_mw: f64) -> Option<f64>
pub fn ramp_up_at_mw(&self, p_mw: f64) -> Option<f64>
Interpolate ramp-up rate at a given MW operating point. Below first breakpoint -> first segment’s rate. Above last breakpoint -> last segment’s rate. Returns None if curve is empty (unlimited ramp).
Sourcepub fn ramp_down_at_mw(&self, p_mw: f64) -> Option<f64>
pub fn ramp_down_at_mw(&self, p_mw: f64) -> Option<f64>
Interpolate ramp-down rate at a given MW operating point. Falls back to ramp_up_curve if ramp_down_curve is empty.
Sourcepub fn reg_ramp_up_at_mw(&self, p_mw: f64) -> Option<f64>
pub fn reg_ramp_up_at_mw(&self, p_mw: f64) -> Option<f64>
Interpolate regulation ramp-up rate at a given MW operating point. Falls back to ramp_up_curve if reg curve is empty.
Sourcepub fn reg_ramp_down_at_mw(&self, p_mw: f64) -> Option<f64>
pub fn reg_ramp_down_at_mw(&self, p_mw: f64) -> Option<f64>
Interpolate regulation ramp-down rate at a given MW operating point. Falls back to ramp_down_curve, then ramp_up_curve.
Sourcepub fn ramp_up_avg_mw_per_min(&self) -> Option<f64>
pub fn ramp_up_avg_mw_per_min(&self) -> Option<f64>
Weighted-average ramp-up rate over [Pmin, Pmax]. Returns None if curve is empty (unlimited ramp).
Sourcepub fn ramp_down_avg_mw_per_min(&self) -> Option<f64>
pub fn ramp_down_avg_mw_per_min(&self) -> Option<f64>
Weighted-average ramp-down rate over [Pmin, Pmax]. Falls back to ramp_up_curve if ramp_down_curve is empty.
Sourcepub fn ramp_up_mw_per_min(&self) -> Option<f64>
pub fn ramp_up_mw_per_min(&self) -> Option<f64>
Scalar ramp-up rate (MW/min) — first segment of ramp_up_curve.
Equivalent to ramp_up_at_mw(pmin). Returns None if curve is empty.
Sourcepub fn ramp_down_mw_per_min(&self) -> Option<f64>
pub fn ramp_down_mw_per_min(&self) -> Option<f64>
Scalar ramp-down rate (MW/min) — first segment, falls back to ramp_up.
Sourcepub fn ramp_agc_mw_per_min(&self) -> Option<f64>
pub fn ramp_agc_mw_per_min(&self) -> Option<f64>
AGC/regulation ramp rate (MW/min) — first segment, falls back to ramp_up.
Sourcepub fn is_storage(&self) -> bool
pub fn is_storage(&self) -> bool
Returns true if this generator has energy storage capability.
Sourcepub fn charge_mw_max(&self) -> f64
pub fn charge_mw_max(&self) -> f64
Maximum charge power (MW). Returns 0 for non-storage generators.
Sourcepub fn discharge_mw_max(&self) -> f64
pub fn discharge_mw_max(&self) -> f64
Maximum discharge power (MW). Alias for pmax for storage generators.
Sourcepub fn is_must_run(&self) -> bool
pub fn is_must_run(&self) -> bool
True if this generator is must-run.
Sourcepub fn reserve_offer(&self, product_id: &str) -> Option<&ReserveOffer>
pub fn reserve_offer(&self, product_id: &str) -> Option<&ReserveOffer>
Get the reserve offer for a specific product, if any.
Sourcepub fn ramp_limited_mw(&self, product: &ReserveProduct) -> f64
pub fn ramp_limited_mw(&self, product: &ReserveProduct) -> f64
Maximum MW deliverable within a product’s deployment window, limited by ramp rate.
Selects the appropriate ramp curve (reg/normal/emergency) based on product context.
Sourcepub fn shutdown_ramp_mw_per_period(&self, dt_hours: f64) -> f64
pub fn shutdown_ramp_mw_per_period(&self, dt_hours: f64) -> f64
Effective shutdown ramp capacity (MW) for one dispatch period of dt_hours.
Uses shutdown_ramp_mw_per_min when present; otherwise falls back to the
economic ramp-down rate. Returns f64::MAX when no ramp curve is defined.
Sourcepub fn startup_ramp_mw_per_period(&self, dt_hours: f64) -> f64
pub fn startup_ramp_mw_per_period(&self, dt_hours: f64) -> f64
Effective startup ramp capacity (MW) for one dispatch period of dt_hours.
Uses startup_ramp_mw_per_min when present; otherwise falls back to the
economic ramp-up rate. Returns f64::MAX when no ramp curve is defined.