gtopt::System struct

Complete physical power system model.

Contains all component arrays that define the electrical network and hydro cascade system. Multiple System objects can be merged with System::merge(), allowing the system to be split across JSON files.

Public functions

void expand_batteries()
Expands unified battery definitions into separate elements.
void expand_emission_sources()
Move inline Generator.emissions[] entries into the flat emission_source_array, stamping generator = <this gen> and auto-allocating uids/names where missing.
void expand_fuel_emission_sources()
Synthesize EmissionSource rows from Generator.fuel × Generator.heat_rate × Fuel.emission_factors[].
void expand_reservoir_constraints()
Extracts inline reservoir constraints into flat system arrays.
void fold_legacy_emission_rate()
Auto-fold the legacy Generator.emission_rate (scalar per-MWh CO₂ rate) into a synthetic CO₂ Emission + EmissionZone + EmissionSource triple, then clear the legacy field on the generator.
void fold_legacy_fuel_emission_factors()
Auto-fold the legacy single-pollutant Fuel.combustion_emission_factor and Fuel.upstream_emission_factor (both CO₂-only) into the new multi-pollutant Fuel.emission_factors[] table.
void fold_legacy_profiles()
Fold legacy generator_profile_array / demand_profile_array entries into the unified capacity_profile_array.
void fold_legacy_simple_commitments()
Fold the deprecated simple_commitment_array into commitment_array (one-time deprecation warning).
void merge(System&& sys)
Merges another system into this one.
void setup_reference_bus(const class PlanningOptionsLP& options)

Public variables

Array<AllowancePool> allowance_pool_array
Array<AmmoniaNode> ammonia_node_array
Carrier-tagged balance nodes (MWh_LHV).
Array<AmmoniaStorage> ammonia_storage_array
Array<Battery> battery_array
Battery energy storage systems.
Array<Bus> bus_array
Electrical buses (nodes).
Array<CapacityProfile> capacity_profile_array
Array<CarrierConverter> carrier_converter_array
Array<Commitment> commitment_array
Generator unit commitment parameters.
Array<Converter> converter_array
Battery ↔ generator/demand couplings.
Array<DecisionVariable> decision_variable_array
Array<Demand> demand_array
Electrical demands (loads).
Array<DemandProfile> demand_profile_array
Array<Emission> emission_array
Array<EmissionSource> emission_source_array
Array<EmissionZone> emission_zone_array
Array<Flow> flow_array
Exogenous inflows / mandatory releases.
Array<FlowRight> flow_right_array
Flow-based water rights (m³/s).
Array<Fuel> fuel_array
Array<FutureCost> future_cost_array
Cost-to-go (FCF / α) planning elements.
Array<GasCompressor> gas_compressor_array
Compressor stations.
Array<GasDemand> gas_demand_array
Gas loads with shedding.
Array<GasNode> gas_node_array
Nodes: π = p² + gas balance.
Array<GasPipe> gas_pipe_array
Weymouth pipes (+ line pack).
Array<GasSupply> gas_supply_array
Fields / imports / regas.
Array<GasTurbine> gas_turbine_array
Generator fuel-gas links.
Array<Generator> generator_array
Generation units.
Array<GeneratorProfile> generator_profile_array
Capacity-factor profiles for generators.
Array<HydrogenDemand> hydrogen_demand_array
Array<HydrogenNode> hydrogen_node_array
Carrier-tagged balance nodes (MWh_LHV).
Array<HydrogenStorage> hydrogen_storage_array
Array<InertiaProvision> inertia_provision_array
Generator → inertia zone links.
Array<InertiaZone> inertia_zone_array
System inertia requirement zones.
Array<Junction> junction_array
Hydraulic nodes.
Array<Line> line_array
Transmission lines.
Array<LineCommitment> line_commitment_array
Array<LngTerminal> lng_terminal_array
LNG storage terminals.
Name name
System name (used in output filenames).
Array<Plant> plant_array
Array<Pump> pump_array
Hydro pumps (demand → waterway upstream).
Array<ReserveProvision> reserve_provision_array
Generator → reserve zone links.
Array<ReserveZone> reserve_zone_array
Spinning-reserve requirement zones.
Array<Reservoir> reservoir_array
Water storage reservoirs.
Array<ReservoirDischargeLimit> reservoir_discharge_limit_array
Array<ReservoirProductionFactor> reservoir_production_factor_array
Array<ReservoirSeepage> reservoir_seepage_array
Waterway → reservoir seepage links.
Array<SimpleCommitment> simple_commitment_array
Simplified dispatch commitments.
Array<ThermalNode> thermal_node_array
Carrier-tagged balance nodes (MW_th).
Array<ThermalStorage> thermal_storage_array
Array<Turbine> turbine_array
Hydro turbines (waterway → generator).
Array<UserConstraint> user_constraint_array
User-defined LP constraints.
OptName user_constraint_file
External JSON/PAMPL file with constraints.
std::vector<Name> user_constraint_files
Multiple external constraint files.
Array<UserModel> user_model_array
Array<UserParam> user_param_array
Named parameters for constraints.
String version
Optional schema version string.
Array<VolumeRight> volume_right_array
Volume-based water rights (hm³).
Array<Waterway> waterway_array
Water channels between junctions.

Function documentation

void gtopt::System::expand_batteries()

Expands unified battery definitions into separate elements.

For each Battery that has the optional bus field set, this method auto-generates:

  • A Generator for the discharge path (name = battery.name + "_gen")
  • A Demand for the charge path (name = battery.name + "_dem")
  • A Converter linking battery, generator, and demand (name = battery.name + "_conv")
Standalone battery (bus only)

Both the discharge Generator and charge Demand are connected to the external bus. This is the default mode.

Generation-coupled battery (bus + source_generator)

When source_generator is also set, an internal bus is created (name = battery.name + "_int_bus"):

  • The discharge Generator connects to the external bus
  • The charge Demand connects to the internal bus
  • The source generator's bus is set to the internal bus

After expansion, both bus and source_generator fields on the battery are cleared so that re-expansion is idempotent.

This is called automatically by PlanningLP before LP construction.

void gtopt::System::expand_emission_sources()

Move inline Generator.emissions[] entries into the flat emission_source_array, stamping generator = <this gen> and auto-allocating uids/names where missing.

Mirrors expand_reservoir_constraints() / expand_batteries() — the inline JSON form is user ergonomics; the LP iterates the top-level flat array. Idempotent: a second call sees empty Generator.emissions and is a no-op.

Called from PlanningLP setup alongside the other expand methods.

void gtopt::System::expand_fuel_emission_sources()

Synthesize EmissionSource rows from Generator.fuel × Generator.heat_rate × Fuel.emission_factors[].

For each Generator with fuel + scalar heat_rate set, for each entry in the referenced Fuel.emission_factors[], for each EmissionZone covering that pollutant: append an EmissionSource{rate = heat_rate × factor.combustion, upstream_rate = heat_rate × factor.upstream} row to emission_source_array. The synthesized row name is <gen>_<pollutant>_via_fuel.

Time-varying heat_rate (vector / FileSched) and piecewise heat_rate_segments get a FUEL-basis row instead: EmissionSource{fuel_rate = heat_content × factor.combustion, upstream_fuel_rate = heat_content × factor.upstream} which the LP applies to the generator's fuel-burn legs (per-block heat rate, or the convex piecewise burn including the heat-rate slack columns) — exact for any heat-rate shape. Generators with fuel_per_block are still skipped (WARN). Time-varying fuel factors and heat_content collapse to their scalar arm (0 when non-scalar). Idempotent on the scalar path: a re-run produces the same rows with the same auto-generated names, so duplicates would collide and skip.

Mirrors expand_emission_sources() (the inline-on-generator unwrap) — both produce the same flat emission_source_array that the LP layer iterates.

void gtopt::System::expand_reservoir_constraints()

Extracts inline reservoir constraints into flat system arrays.

For each Reservoir with non-empty seepage, discharge_limit, or production_factor inline arrays, this method moves entries into the corresponding system-level arrays (reservoir_seepage_array, etc.), auto-generating uids and setting the reservoir field from the parent.

After extraction, the inline arrays on each Reservoir are cleared so that re-expansion is idempotent.

void gtopt::System::fold_legacy_emission_rate()

Auto-fold the legacy Generator.emission_rate (scalar per-MWh CO₂ rate) into a synthetic CO₂ Emission + EmissionZone + EmissionSource triple, then clear the legacy field on the generator.

For each Generator with a non-null scalar emission_rate:

  • If no Emission{name="co2"} exists, create one.
  • If no EmissionZone covers that pollutant, create EmissionZone{name="default_co2", emissions=[{co2, 1.0}]} (pure-reporting zone — no cap, no price).
  • Append an EmissionSource{generator: <this>, zone: default_co2_zone, emission: co2, rate: emission_rate}.

Vector and FileSched legacy factors are NOT downgraded (warning emitted and field left untouched); the user should migrate them manually to the new schema. Idempotent on already-folded generators (skips when emission_rate is null).

Mirrors fold_legacy_profiles() — same migration idiom we used for GeneratorProfile / DemandProfile → CapacityProfile.

void gtopt::System::fold_legacy_fuel_emission_factors()

Auto-fold the legacy single-pollutant Fuel.combustion_emission_factor and Fuel.upstream_emission_factor (both CO₂-only) into the new multi-pollutant Fuel.emission_factors[] table.

For each fuel with either legacy field set: synthesize (or update) a FuelEmissionFactor row keyed by the CO₂ Emission (creating the CO₂ tag if absent). Both legacy fields are cleared so a second call is a no-op. Mirrors fold_legacy_emission_rate().

void gtopt::System::fold_legacy_profiles()

Fold legacy generator_profile_array / demand_profile_array entries into the unified capacity_profile_array.

Each legacy entry becomes a CapacityProfile with the matching owner_kind (Generator / Demand) and owner = legacy.generator / legacy.demand. The legacy arrays are cleared after the move so the LP layer sees only capacity_profile_array, making the unified path the single source of truth for downstream code.

Idempotent: calling twice is safe (second call is a no-op on already-cleared arrays).

void gtopt::System::fold_legacy_simple_commitments()

Fold the deprecated simple_commitment_array into commitment_array (one-time deprecation warning).

A SimpleCommitment becomes a plain Commitment (uid, name, active, generator, relax, must_run kept; dispatch_pmin → pmin). The legacy element turned its generator's pmin into a conditional minimum (it zeroed the generation column bound), while Generator.pmin is an always-on floor for a Commitment. To keep the old results this alias path — and only it — moves the generator's pmin onto the commitment (when dispatch_pmin is unset) and clears it on the generator. A soft pmin (pmin_fcost set) is left on the generator, as the legacy element did not use it either. A uid already taken by a Commitment is replaced by the next free one.

Idempotent (the legacy array is cleared).

void gtopt::System::merge(System&& sys)

Merges another system into this one.

Parameters
sys The system to merge from (will be moved from if it's an rvalue)
Returns Reference to this system after merge

This is a unified template method that handles both lvalue and rvalue references. When merging from an rvalue reference, move semantics are used automatically.

Variable documentation

Array<AllowancePool> gtopt::System::allowance_pool_array

Tradable emission-allowance pools (EU ETS / California C&T / RGGI). Banking + free allocation today; auction (Phase 4) + EmissionZone coupling (Phase 3) come later.

Array<AmmoniaStorage> gtopt::System::ammonia_storage_array

Refrigerated NH₃ tanks; canonical seasonal-storage carrier.

Array<CapacityProfile> gtopt::System::capacity_profile_array

Unified kind-tagged capacity-factor profiles (Commit 1 of the legacy → unified migration). Parses from "capacity_profile_array" in JSON; per-owner-kind dispatch via CapacityProfile::owner_kind.

Array<CarrierConverter> gtopt::System::carrier_converter_array

One-stage flow converters between any two carrier-typed balance nodes.

Array<DecisionVariable> gtopt::System::decision_variable_array

Free continuous decision vars referenced by user constraints (PLEXOS DV maps here)

Array<DemandProfile> gtopt::System::demand_profile_array

Load-shape profiles for demands

Array<Emission> gtopt::System::emission_array

First-class pollutant entities (e.g. co2, so2, nox). Carry optional per-stage price (tax / permit cost in $/ton) and cap (tons / stage, soft constraint with cap_cost slack). Passive in Commit 1 — wiring of cap row and price coefficient lands in Commit 4 alongside the per-fuel emission_factors[] table on Fuel. See emission.hpp.

Array<EmissionSource> gtopt::System::emission_source_array

Generator → EmissionZone bridge rows. Each row says "this generator contributes <tt>rate</tt> tons / MWh of dispatch to this zone's balance". Also accepted inline on Generator.emissions[] and expanded here by System::expand_emission_sources(). Mirrors InertiaProvision / ReserveProvision. Passive in Commit 2 — see emission_source.hpp.

Array<EmissionZone> gtopt::System::emission_zone_array

Constraint-owning zones (cap / soft-cap / price) for each pollutant. Always builds a per-(scenario, stage, block) production column + balance row aggregating all EmissionSource rows pointing at this zone. Mirrors InertiaZone / ReserveZone. Passive in Commit 2 — see emission_zone.hpp.

Array<Fuel> gtopt::System::fuel_array

Time-schedulable fuel price + combustion / upstream emission factors referenced by Generator.fuel. See fuel.hpp.

Array<HydrogenDemand> gtopt::System::hydrogen_demand_array

Hydrogen offtakes (sinks) with optional per-stage energy targets.

Array<HydrogenStorage> gtopt::System::hydrogen_storage_array

Salt cavern / LH₂ / LOHC peers of Battery on StorageLP<>.

Array<LineCommitment> gtopt::System::line_commitment_array

Per-line OTS opt-in records. Presence of a LineCommitment row marks the referenced Line as a switching candidate (binary u_l ∈ {0, 1} decided by the MIP); absence keeps the line as pure-LP continuous flow. See line_commitment.hpp for the per-record field set and LineCommitmentLP for the LP formulation (capacity gating + KVL big-M disjunction).

Rejected on the SDDP / cascade methods at validate_planning.cpp time per issue #509 §"Why monolithic only, not SDDP".

Array<Plant> gtopt::System::plant_array

Plant primitive: groups generator config variants (combined-cycle TGA/TGB/TV, fuel-band families) and emits Σ-capacity / Σ-commit / Σ-uniq rows natively (replaces PlantCap_* / *_Uniq UCs)

Array<ReservoirDischargeLimit> gtopt::System::reservoir_discharge_limit_array

Volume-dependent discharge limits

Array<ReservoirProductionFactor> gtopt::System::reservoir_production_factor_array

Volume-dependent turbine efficiency

Array<ThermalStorage> gtopt::System::thermal_storage_array

Molten-salt / sensible-heat TES peers of Battery on StorageLP<>.

Array<UserModel> gtopt::System::user_model_array

Self-contained AMPL model fragments (bundled user vars + constraints, captured to output/UserModel/<tag>/...)