Collections and instances

Time series and scenario sets

A PyPSA folder with several snapshots parses into a TimeSeries{BalancedNetwork}; a GridFM dataset parses into a ScenarioSet{BalancedNetwork}. Both hold typed values and follow Julia's collection conventions, a TimeSeries indexed by position and a ScenarioSet by string key.

series = parse("pypsa_folder/").value    # TimeSeries{BalancedNetwork}
length(series)
series[1]                                # BalancedNetwork, 1-based
for net in series
    sum(l.p_mw for l in net.loads)
end

scenarios = parse("gridfm_case14/").value  # ScenarioSet{BalancedNetwork}
keys(scenarios)                            # ["0", "1", ...]
scenarios["0"]                             # BalancedNetwork
haskey(scenarios, "7")
for (id, net) in scenarios
    println(id, ": ", length(net.buses), " buses")
end

Reading an entry does not copy the network. An OperatingPoint has a network property.

Calculation instances and solutions

A calculation instance pairs a network with the specification of one calculation, and instance.network gives you that network back. You construct one from a network module:

case = parse("case9.m")
opf = to_dc_opf_instance(case)           # PioModule{DcOpfInstance}
opf.value.network                        # the BalancedNetwork
opf.history[1].name                      # "to_dc_opf_instance"
emit(opf, "matpower")                    # writes the network; diagnoses the rest
serialize(opf, "case9_dcopf.pio.json")
ConstructorResult
to_dc_pf_instance, to_ac_pf_instanceDcPfInstance, AcPfInstance
to_dc_opf_instance, to_ac_opf_instanceDcOpfInstance, AcOpfInstance
to_mc_ac_pf_instance, to_mc_ac_opf_instanceMcAcPfInstance, McAcOpfInstance over a MulticonductorNetwork
to_lindist3flow_opf_instanceLinDist3FlowOpfInstance over a radial MulticonductorNetwork

A LinDist3FlowOpfInstance uses fixed reference phasors and lossless, linearized voltage drops. Its metadata property returns owned node and conductor identities, root nodes, and reference voltages in volts and radians. Conductor records identify parent and child terminals, reversal relative to the source line, and source line rows and conductor positions using Julia's 1-based indexing. Positive line power flows from parent to child.

LinDist3FlowOpfSolution quantities include terminal_voltage_squared in squared volts, and line_active_power, line_reactive_power, source_active_power, source_reactive_power, generator_active_power, and generator_reactive_power in watts and vars. Each vector follows its instance axes. These types use PowerIO IR generation 2 with distinct structural type names. Readers without LinDist3Flow support reject those types; existing types retain their representation.

A solution answers an instance. solution.instance is that instance, solution.network is the network the solution is defined over, solution.termination is the solver status ("converged", "iteration_limit", "infeasible", "unbounded", "failed", "not_reported"), and solution.objective is the reported objective or nothing. You read a named quantity by indexing with its name and get one Vector{Float64} in table order:

solution = parse("example_0.json").value  # AcOpfSolution from OPFData
solution.instance.network
solution["bus_voltage_magnitude"]
solution["bus_voltage_angle"]
solution["generator_active_power"]
solution["branch_from_active_flow"]

scuc = parse("scenario_002/").value       # AcScucSolution from a GO Challenge 3 pair
time_count(scuc)
scuc["bus_voltage_magnitude", 1]          # time position 1

An unknown quantity name throws PowerIOError with code REQUEST.CAPI.QUANTITY_UNKNOWN. A SocwrOpfSolution comes from a second order cone relaxation of an AC OPF instance, so it reports an objective_lower_bound and is not an AC feasible point.

AC SCUC inputs

An AcScucInstance also carries the scheduling data of the unit commitment problem. instance.inputs reads it into a ScucInputs record: the collection sizes, the interval durations in hours, the input tables, and the instance wide violation costs. Times are hours, powers and energies per unit, and phase shifts radians.

instance = parse("goc3_small.json").value   # AcScucInstance
inputs = instance.inputs
inputs.dimensions.period_count              # 2
inputs.interval_durations                   # [1.0, 1.0] hours

device = inputs.devices[1]                  # ScucDevice
device.id                                   # ComponentId("generator", "sd_00")
device.kind                                 # "producer"
device.minimum_up_time_hours
device.periods[1].active_power_max_pu       # bounds in interval 1
device.periods[1].energy_cost_blocks        # the piecewise energy price

inputs.active_reserve_zones[1].buses        # Vector{ComponentId}
inputs.contingencies[1].components          # what the contingency takes out
inputs.violation_costs.active_power_balance

Every table is a plain Vector, so filter, map, and indexing all work, and a lookup by source identity is a Dict over the table:

by_uid = Dict(d.id.local_id => d for d in inputs.devices)
by_uid["sd_00"].startup_cost

A device's ScucReactiveCapability states how its reactive range depends on its active power. kind selects which fields the input sets: "none" leaves all of them nothing, "linear" sets the intercept and slope, and "bounded" sets the two intercept bounds and the two slope bounds. The same reading is available through the instance a solution answers, as solution.instance.inputs.

PowerIO.ScucInputs — Type
ScucInputs

The scheduling inputs of one AcScucInstance, read through instance.inputs.

  • dimensions: a NamedTuple of collection sizes, such as dimensions.period_count and dimensions.device_count.
  • interval_durations: the length of each interval in hours, in chronological order.
  • devices, shunts, branch_switching_costs, transformer_controls, active_reserve_zones, reactive_reserve_zones, contingencies: the input tables in source order.
  • violation_costs: the instance wide penalty prices.

The tables are plain vectors, so filter, Dict, and indexing all work. A lookup by source identity is a Dict over the table, as in Dict(d.id.local_id => d for d in inputs.devices).

source
PowerIO.ScucDevice — Type
ScucDevice

One simple dispatchable device. kind is "producer" or "consumer". on_cost, startup_cost, and shutdown_cost price commitment; minimum_up_time_hours and minimum_down_time_hours bound how long a commitment change holds. periods carries one ScucDevicePeriod per interval, in chronological order.

source
PowerIO.ScucDevicePeriod — Type
ScucDevicePeriod

One device in one interval: the commitment status bounds on_status_min and on_status_max, the active and reactive power bounds in per unit, the energy_cost_blocks that price its output, and its reserve_costs.

on_status_min == on_status_max fixes the commitment for that interval.

source
PowerIO.ScucEnergyCostBlock — Type
ScucEnergyCostBlock

One block of a piecewise linear energy cost curve: block_size_pu of active power priced at marginal_cost per unit.

source
PowerIO.ScucReserveCosts — Type
ScucReserveCosts

What one device charges for each reserve product in one interval, per unit of reserve provided.

source
PowerIO.ScucRampLimits — Type
ScucRampLimits

Ramp rates of one dispatchable device in per unit per hour: up_pu_per_hour and down_pu_per_hour while the device stays on, startup_pu_per_hour and shutdown_pu_per_hour across a commitment change.

source
PowerIO.ScucReserveLimits — Type
ScucReserveLimits

The per unit reserve a device can offer in one interval, by reserve product: regulation, synchronized and nonsynchronized reserve, and ramping reserve online and offline in each direction.

source
PowerIO.ScucInitialCommitment — Type
ScucInitialCommitment

How long a device has already been on or off when the horizon starts, in hours. Exactly one of the two is positive: the other records the state the device is not in.

source
PowerIO.ScucReactiveCapability — Type
ScucReactiveCapability

The reactive capability of one device as a function of its active power. kind selects which fields the input states:

  • "none": no coupling, every other field is nothing.
  • "linear": reactive_power_at_zero_active_power_pu and slope.
  • "bounded": the _min_pu and _max_pu intercepts and slope_min and slope_max.

A kind this release does not model reports "unknown" with no fields set.

source
PowerIO.ScucEnergyRequirement — Type
ScucEnergyRequirement

An energy bound of energy_pu on one device between start_time_hours and end_time_hours. A device carries these separately as upper and as lower bounds.

source
PowerIO.ScucShunt — Type
ScucShunt

One switchable shunt: the admittance of a single step in per unit and the step range step_min to step_max with its initial_step.

source
PowerIO.ScucActiveReserveZone — Type
ScucActiveReserveZone

One active power reserve zone over buses. The requirement fractions scale the zone's regulation, synchronized, and nonsynchronized requirements from its load and largest unit; the violation costs price a shortfall of each product. ramping_up_requirement_pu and ramping_down_requirement_pu state the ramping requirement per interval, in chronological order.

source
PowerIO.ScucReactiveReserveZone — Type
ScucReactiveReserveZone

One reactive power reserve zone over buses: the cost of falling short in each direction and the per unit requirement per interval, in chronological order.

source
PowerIO.ScucViolationCosts — Type
ScucViolationCosts

The four penalty prices every AC SCUC instance states: active and reactive power balance, branch thermal limits, and device energy requirements.

source
PowerIO.TimeSeries — Type
TimeSeries{T}

Values of type T in chronological order. Supports length, 1-based getindex, and iteration over the values.

source
PowerIO.ScenarioSet — Type
ScenarioSet{T}

Values of type T keyed by scenario identifier. Supports length, keys, values, haskey, getindex with a scenario id, and iteration over id => value pairs.

source
PowerIO.DcOpfInstance — Type
DcOpfInstance

DC optimal power flow instance over a BalancedNetwork. instance.network is the network.

source
PowerIO.AcOpfInstance — Type
AcOpfInstance

AC optimal power flow instance over a BalancedNetwork. instance.network is the network.

source
PowerIO.McAcPfInstance — Type
McAcPfInstance

Multiconductor AC power flow instance over a MulticonductorNetwork. instance.network is the network.

source
PowerIO.McAcOpfInstance — Type
McAcOpfInstance

Multiconductor AC optimal power flow instance over a MulticonductorNetwork. instance.network is the network.

source
PowerIO.AcScucInstance — Type
AcScucInstance

AC security constrained unit commitment instance over a BalancedNetwork. instance.network is the network.

source
PowerIO.DcPfSolution — Type
DcPfSolution

DC power flow solution. solution.instance is the instance it answers and solution.termination the solver status.

source
PowerIO.AcPfSolution — Type
AcPfSolution

AC power flow solution. solution.instance is the instance it answers and solution.termination the solver status.

source
PowerIO.DcOpfSolution — Type
DcOpfSolution

DC optimal power flow solution. solution.instance is the instance it answers and solution.termination the solver status.

source
PowerIO.AcOpfSolution — Type
AcOpfSolution

AC optimal power flow solution. solution.instance is the instance it answers and solution.termination the solver status.

source
PowerIO.SocwrOpfSolution — Type
SocwrOpfSolution

Second order cone (SOCWR) relaxation of an AC OPF instance; not an AC feasible point. solution.instance is the instance it answers and solution.termination the solver status.

source
PowerIO.McAcPfSolution — Type
McAcPfSolution

Multiconductor AC power flow solution. solution.instance is the instance it answers and solution.termination the solver status.

source
PowerIO.McAcOpfSolution — Type
McAcOpfSolution

Multiconductor AC optimal power flow solution. solution.instance is the instance it answers and solution.termination the solver status.

source
PowerIO.LinDist3FlowOpfSolution — Type
LinDist3FlowOpfSolution

Radial fixed-reference LinDist3Flow OPF solution. solution.instance is the instance it answers and solution.termination the solver status.

source
PowerIO.AcScucSolution — Type
AcScucSolution

AC security constrained unit commitment solution. solution.instance is the instance it answers and solution.termination the solver status.

source
PowerIO.time_count — Function
time_count(solution::AcScucSolution) -> Int

The number of time positions in an AC SCUC solution.

source
PowerIO.to_dc_pf_instance — Function
to_dc_pf_instance(m::PioModule) -> PioModule

Construct a DC power flow instance from a network module. The network is shared, not copied; the new module records the construction in its history.

source
PowerIO.to_ac_pf_instance — Function
to_ac_pf_instance(m::PioModule) -> PioModule

Construct an AC power flow instance from a network module. The network is shared, not copied; the new module records the construction in its history.

source
PowerIO.to_dc_opf_instance — Function
to_dc_opf_instance(m::PioModule) -> PioModule

Construct a DC optimal power flow instance from a network module. The network is shared, not copied; the new module records the construction in its history.

source
PowerIO.to_ac_opf_instance — Function
to_ac_opf_instance(m::PioModule) -> PioModule

Construct an AC optimal power flow instance from a network module. The network is shared, not copied; the new module records the construction in its history.

source
PowerIO.to_mc_ac_pf_instance — Function
to_mc_ac_pf_instance(m::PioModule) -> PioModule

Construct a multiconductor AC power flow instance from a network module. The network is shared, not copied; the new module records the construction in its history.

source
PowerIO.to_mc_ac_opf_instance — Function
to_mc_ac_opf_instance(m::PioModule) -> PioModule

Construct a multiconductor AC optimal power flow instance from a network module. The network is shared, not copied; the new module records the construction in its history.

source
PowerIO.to_lindist3flow_opf_instance — Function
to_lindist3flow_opf_instance(m::PioModule) -> PioModule

Construct a LinDist3Flow optimal power flow instance from a network module. The network is shared, not copied; the new module records the construction in its history.

source