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")
endReading 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")| Constructor | Result |
|---|---|
to_dc_pf_instance, to_ac_pf_instance | DcPfInstance, AcPfInstance |
to_dc_opf_instance, to_ac_opf_instance | DcOpfInstance, AcOpfInstance |
to_mc_ac_pf_instance, to_mc_ac_opf_instance | McAcPfInstance, McAcOpfInstance over a MulticonductorNetwork |
to_lindist3flow_opf_instance | LinDist3FlowOpfInstance over a radial MulticonductorNetwork |
McAcPfInstance.source_boundaries is a lazy vector of VoltageSource records. Each row supplies the source bus, phase terminals, phasors and optional reference_terminal; a named reference is the other voltage endpoint on that bus and does not imply grounding. The vector retains its instance owner.
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 1An 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_balanceEvery 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_costA 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
ScucInputsThe scheduling inputs of one AcScucInstance, read through instance.inputs.
dimensions: aNamedTupleof collection sizes, such asdimensions.period_countanddimensions.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).
PowerIO.ScucDevice — Type
ScucDeviceOne 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.
PowerIO.ScucDevicePeriod — Type
ScucDevicePeriodOne 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.
PowerIO.ScucEnergyCostBlock — Type
ScucEnergyCostBlockOne block of a piecewise linear energy cost curve: block_size_pu of active power priced at marginal_cost per unit.
PowerIO.ScucReserveCosts — Type
ScucReserveCostsWhat one device charges for each reserve product in one interval, per unit of reserve provided.
PowerIO.ScucRampLimits — Type
ScucRampLimitsRamp 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.
PowerIO.ScucReserveLimits — Type
ScucReserveLimitsThe 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.
PowerIO.ScucInitialCommitment — Type
ScucInitialCommitmentHow 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.
PowerIO.ScucReactiveCapability — Type
ScucReactiveCapabilityThe 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 isnothing."linear":reactive_power_at_zero_active_power_puandslope."bounded": the_min_puand_max_puintercepts andslope_minandslope_max.
A kind this release does not model reports "unknown" with no fields set.
PowerIO.ScucStartupCostAdjustment — Type
ScucStartupCostAdjustmentOne startup cost tier: cost applies when the device has been off for at most maximum_down_time_hours.
PowerIO.ScucStartupLimit — Type
ScucStartupLimitAt most maximum_startups starts of one device between start_time_hours and end_time_hours.
PowerIO.ScucEnergyRequirement — Type
ScucEnergyRequirementAn 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.
PowerIO.ScucShunt — Type
ScucShuntOne switchable shunt: the admittance of a single step in per unit and the step range step_min to step_max with its initial_step.
PowerIO.ScucBranchSwitchingCost — Type
ScucBranchSwitchingCostWhat connecting or disconnecting one branch costs.
PowerIO.ScucTransformerControl — Type
ScucTransformerControlThe controllable range of one transformer: its tap ratio bounds and its phase shift bounds in radians.
PowerIO.ScucActiveReserveZone — Type
ScucActiveReserveZoneOne 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.
PowerIO.ScucReactiveReserveZone — Type
ScucReactiveReserveZoneOne reactive power reserve zone over buses: the cost of falling short in each direction and the per unit requirement per interval, in chronological order.
PowerIO.ScucContingency — Type
ScucContingencyOne named contingency: the components it takes out of service.
PowerIO.ScucViolationCosts — Type
ScucViolationCostsThe four penalty prices every AC SCUC instance states: active and reactive power balance, branch thermal limits, and device energy requirements.
PowerIO.TimeSeries — Type
TimeSeries{T}Values of type T in chronological order. Supports length, 1-based getindex, and iteration over the values.
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.
PowerIO.OperatingPoint — Type
OperatingPoint{N}One operating point over a network of type N. point.network is that network.
PowerIO.DcPfInstance — Type
DcPfInstanceDC power flow instance over a BalancedNetwork. instance.network is the network.
PowerIO.AcPfInstance — Type
AcPfInstanceAC power flow instance over a BalancedNetwork. instance.network is the network.
PowerIO.DcOpfInstance — Type
DcOpfInstanceDC optimal power flow instance over a BalancedNetwork. instance.network is the network.
PowerIO.AcOpfInstance — Type
AcOpfInstanceAC optimal power flow instance over a BalancedNetwork. instance.network is the network.
PowerIO.McAcPfInstance — Type
McAcPfInstanceMulticonductor AC power flow instance over a MulticonductorNetwork. instance.network is the network.
PowerIO.McAcOpfInstance — Type
McAcOpfInstanceMulticonductor AC optimal power flow instance over a MulticonductorNetwork. instance.network is the network.
PowerIO.LinDist3FlowOpfInstance — Type
LinDist3FlowOpfInstanceRadial fixed-reference LinDist3Flow OPF instance over a MulticonductorNetwork. instance.network is the network.
PowerIO.AcScucInstance — Type
AcScucInstanceAC security constrained unit commitment instance over a BalancedNetwork. instance.network is the network.
PowerIO.DcPfSolution — Type
DcPfSolutionDC power flow solution. solution.instance is the instance it answers and solution.termination the solver status.
PowerIO.AcPfSolution — Type
AcPfSolutionAC power flow solution. solution.instance is the instance it answers and solution.termination the solver status.
PowerIO.DcOpfSolution — Type
DcOpfSolutionDC optimal power flow solution. solution.instance is the instance it answers and solution.termination the solver status.
PowerIO.AcOpfSolution — Type
AcOpfSolutionAC optimal power flow solution. solution.instance is the instance it answers and solution.termination the solver status.
PowerIO.SocwrOpfSolution — Type
SocwrOpfSolutionSecond 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.
PowerIO.McAcPfSolution — Type
McAcPfSolutionMulticonductor AC power flow solution. solution.instance is the instance it answers and solution.termination the solver status.
PowerIO.McAcOpfSolution — Type
McAcOpfSolutionMulticonductor AC optimal power flow solution. solution.instance is the instance it answers and solution.termination the solver status.
PowerIO.LinDist3FlowOpfSolution — Type
LinDist3FlowOpfSolutionRadial fixed-reference LinDist3Flow OPF solution. solution.instance is the instance it answers and solution.termination the solver status.
PowerIO.AcScucSolution — Type
AcScucSolutionAC security constrained unit commitment solution. solution.instance is the instance it answers and solution.termination the solver status.
PowerIO.time_count — Function
time_count(solution::AcScucSolution) -> IntThe number of time positions in an AC SCUC solution.
PowerIO.to_dc_pf_instance — Function
to_dc_pf_instance(m::PioModule) -> PioModuleConstruct a DC power flow instance from a network module. The network is shared, not copied; the new module records the construction in its history.
PowerIO.to_ac_pf_instance — Function
to_ac_pf_instance(m::PioModule) -> PioModuleConstruct an AC power flow instance from a network module. The network is shared, not copied; the new module records the construction in its history.
PowerIO.to_dc_opf_instance — Function
to_dc_opf_instance(m::PioModule) -> PioModuleConstruct 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.
PowerIO.to_ac_opf_instance — Function
to_ac_opf_instance(m::PioModule) -> PioModuleConstruct 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.
PowerIO.to_mc_ac_pf_instance — Function
to_mc_ac_pf_instance(m::PioModule) -> PioModuleConstruct 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.
PowerIO.to_mc_ac_opf_instance — Function
to_mc_ac_opf_instance(m::PioModule) -> PioModuleConstruct 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.
PowerIO.to_lindist3flow_opf_instance — Function
to_lindist3flow_opf_instance(m::PioModule) -> PioModuleConstruct 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.