Generator struct
#include <gtopt/generator.hpp>
Represents a generation unit (thermal, renewable, hydro) at a bus.
A generator injects active power p ∈ [pmin, pmax] at its connected bus. The LP objective includes gcost × power × duration for operational cost. When expcap and expmod are non-null the solver may invest in additional capacity modules at cost annual_capcost per module per year.
Public static variables
- static LPClassName class_name
Public functions
- auto cogen_mode_enum() const -> std::optional<CogenMode> noexcept
- auto set_attrs(this auto&& self, auto&& attrs) -> auto&
- Sets generator attributes from a GeneratorAttrs object.
Public variables
- OptActive active
- Activation status (default: active).
- OptTRealFieldSched annual_capcost
- Annualized investment cost [$/MW-year].
- OptTRealFieldSched annual_derating
- Annual capacity derating factor [p.u./year].
- SingleId bus
- Bus ID where the generator is connected.
- OptTRealFieldSched capacity
- Installed generation capacity [MW].
- OptTRealFieldSched capmax
- Absolute maximum capacity after expansion [MW].
- OptName cogen_mode
- OptName description
- Array<EmissionCapture> emission_captures
- OptTBRealFieldSched emission_rate
- Array<EmissionSource> emissions
- OptTRealFieldSched expcap
- Capacity added per expansion module [MW].
- OptTRealFieldSched expmod
- Maximum number of expansion modules [dimensionless].
- OptSingleId fuel
- Optional FK to a
Fuelelement. SeeGeneratorAttrs::fuel. - OptTBUidSched fuel_per_block
- OptTBRealFieldSched gcost
- OptTBRealFieldSched heat_rate
- OptReal initial_generation
- OptBool integer_expmod
- Integer-constrain the expmod variable.
- OptTBRealFieldSched lossfactor
- Name name
- Generator name.
- OptTBRealFieldSched outage_fraction
- OptTBRealFieldSched pmax
- Maximum active power output [MW].
- OptTBRealFieldSched pmin
- Minimum active power output [MW].
- OptTBRealFieldSched pmin_fcost
- OptName type
- Uid uid
- Unique identifier.
- OptReal uini
Annuity from overnight cost (per-candidate private rate)
Used only when annual_capcost is unset: the LP charges annual_capcost = overnight_capcost × CRF(wacc, economic_life), CRF(r, n) = r(1+r)^n / ((1+r)^n − 1). wacc unset → the social annual_discount_rate (the stage discount factors are never changed). All unset (default) → today's LP.
LinDistFlow reactive power (network_model = \"lindistflow\")
qmin/qmax make the reactive output a variable in that range; otherwise power_factor fixes Q = sign(pf)·tan(acos|pf|)·P (negative = absorbing); neither → unity power factor.
Function documentation
std::optional<CogenMode> gtopt:: Generator:: cogen_mode_enum() const noexcept
Parse cogen_mode string to typed enum (nullopt = not a cogen OR unknown value). Mirrors Line::line_losses_mode_enum().
auto& gtopt:: Generator:: set_attrs(this auto&& self,
auto&& attrs)
Sets generator attributes from a GeneratorAttrs object.
| Parameters | |
|---|---|
| self | The generator object to update (deduced; supports const/non-const). |
| attrs | Generator attributes to be set |
| Returns | Reference to this Generator object |
Example usage:
Generator gen; GeneratorAttrs attrs; attrs.bus = 1; attrs.pmax = 100.0; gen.set_attrs(std::move(attrs)); // gen.bus should now be 1, and attrs.bus should be empty
Variable documentation
static LPClassName gtopt:: Generator:: class_name
Canonical class-name constant used in LP row labels and config fields like VariableScale::class_name. Single source of truth — GeneratorLP exposes no separate ClassName member; callers reach the constant via Generator::class_name directly (or GeneratorLP::Element::class_name in generic contexts).
OptName gtopt:: Generator:: cogen_mode
Cogeneration mode tag. See GeneratorAttrs::cogen_mode for the authoritative semantics + value enumeration ("dispatched" | "must_run" | unset).
OptName gtopt:: Generator:: description
Free-form label for UI/post-processing; not used by the LP solver.
Array<EmissionCapture> gtopt:: Generator:: emission_captures
Inline CCS / abatement rows for THIS generator, one per pollutant kind captured. Each entry's (1 − rate) factor scales the matching EmissionSource contribution to its zone (cap / pool / price) AND adds rate × (combustion + upstream) × cost to the generator's dispatch-column cost (paid per MWh generated).
OptTBRealFieldSched gtopt:: Generator:: emission_rate
Direct CO₂ emission rate [tCO₂/MWh] per-(stage, block). Additive with fuel-derived combustion+upstream when fuel+heat_rate are set (treats emission_rate as a non-combustion adder, e.g. process / venting / fugitive).
Array<EmissionSource> gtopt:: Generator:: emissions
Inline emission contributions — list of EmissionSource rows scoped to THIS generator. Each entry carries the destination zone FK and the per-MWh emission rate; generator is set automatically by System::expand_emission_sources() and the row is appended to the flat emission_source_array. Mirrors Reservoir.seepage[] / Battery.bus inline expansion.
OptTBUidSched gtopt:: Generator:: fuel_per_block
Optional per-(stage, block) override of fuel. See GeneratorAttrs::fuel_per_block.
OptTBRealFieldSched gtopt:: Generator:: gcost
Variable generation cost [$/MWh] per-(stage, block); see GeneratorAttrs::gcost for accepted JSON shapes.
OptTBRealFieldSched gtopt:: Generator:: heat_rate
Per-(stage, block) heat rate slope [<fuel_unit>/MWh]. See GeneratorAttrs::heat_rate.
OptReal gtopt:: Generator:: initial_generation
Initial generation [MW] at t = 0⁻. See GeneratorAttrs::initial_generation for semantics.
OptTBRealFieldSched gtopt:: Generator:: lossfactor
Network loss factor [p.u.] per-(stage, block). Accepts a scalar (broadcast), a 2-D nested array, or a file-backed schedule.
OptTBRealFieldSched gtopt:: Generator:: outage_fraction
Maintenance outage schedule [p.u. of the unit, 0..1] per (stage, block), kept apart from pmax (derates / profiles) and from active / capacity (entry / retirement). A fraction f of the unit (or of the block's hours, for a monthly average such as PLP plpmance: f = d/D days out) is in maintenance: the available output is (1 − f)·[pmin, pmax] (and (1 − f)·capacity on the expansion row). How reserve offers react is chosen globally by model_options.outage_reserve_mode (none | proportional | exclude). Unset = no outage (legacy behaviour).
OptTBRealFieldSched gtopt:: Generator:: pmin_fcost
Optional penalty cost [$/MWh] making pmin soft via an unserved slack. See GeneratorAttrs::pmin_fcost.
OptTRealFieldSched gtopt:: Generator:: overnight_capcost
Overnight investment cost per unit of capacity [$/MW]
OptTRealFieldSched gtopt:: Generator:: wacc
Private discount rate of the annuity (WACC / hurdle rate) [p.u./year]
OptTRealFieldSched gtopt:: Generator:: fixed_om_cost
Fixed O&M of the expansion capacity [$/unit-year], charged on the capacity built from this stage on, next to the annuity and with the same stage discounting. Unset → no fixed O&M.