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

auto expand_batteries() -> void
Expands unified battery definitions into separate elements.
auto expand_reservoir_constraints() -> void
Extracts inline reservoir constraints into flat system arrays.
auto merge(System&& sys) -> void
Merges another system into this one.
auto setup_reference_bus(const class PlanningOptionsLP& options) -> void

Public variables

Array<Battery> battery_array
Battery energy storage systems.
Array<Bus> bus_array
Electrical buses (nodes)
Array<Converter> converter_array
Battery ↔ generator/demand couplings.
Array<Demand> demand_array
Electrical demands (loads)
Array<DemandProfile> demand_profile_array
Load-shape profiles for demands.
Array<Flow> flow_array
Exogenous inflows / mandatory releases.
Array<FlowRight> flow_right_array
Flow-based water rights (m³/s)
Array<Generator> generator_array
Generation units.
Array<GeneratorProfile> generator_profile_array
Capacity-factor profiles for generators.
Array<Junction> junction_array
Hydraulic nodes.
Array<Line> line_array
Transmission lines.
Name name
System name (used in output filenames)
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<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<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_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::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<ReservoirDischargeLimit> gtopt::System::reservoir_discharge_limit_array

Volume-dependent discharge limits

Array<ReservoirProductionFactor> gtopt::System::reservoir_production_factor_array

Volume-dependent turbine efficiency