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 |
A solution answers an instance. solution.instance is that instance, 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.
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.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.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.