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

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 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.

PowerIO.TimeSeriesType
TimeSeries{T}

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

source
PowerIO.ScenarioSetType
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.DcOpfInstanceType
DcOpfInstance

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

source
PowerIO.AcOpfInstanceType
AcOpfInstance

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

source
PowerIO.McAcPfInstanceType
McAcPfInstance

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

source
PowerIO.McAcOpfInstanceType
McAcOpfInstance

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

source
PowerIO.AcScucInstanceType
AcScucInstance

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

source
PowerIO.DcPfSolutionType
DcPfSolution

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

source
PowerIO.AcPfSolutionType
AcPfSolution

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

source
PowerIO.DcOpfSolutionType
DcOpfSolution

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

source
PowerIO.AcOpfSolutionType
AcOpfSolution

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

source
PowerIO.SocwrOpfSolutionType
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.McAcPfSolutionType
McAcPfSolution

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

source
PowerIO.McAcOpfSolutionType
McAcOpfSolution

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

source
PowerIO.AcScucSolutionType
AcScucSolution

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

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

The number of time positions in an AC SCUC solution.

source
PowerIO.to_dc_pf_instanceFunction
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_instanceFunction
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_instanceFunction
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_instanceFunction
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_instanceFunction
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_instanceFunction
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