User Documentation

ExaPowerIO exports 1 function:

ExaPowerIO.parse_matpowerFunction
function parse_matpower(
    ::Type{T},
    ::Type{V},
    path :: String;
    library=nothing,
) :: PowerData{T} where {T<:Real, V<:AbstractVector}

T and V can be ommited and have default values Float64, and Vector respectively.

library can be one of the following values:

  • :nothing indicates that the filesystem should be searched for path
  • :pglib indicates that the PGLib database should be searched for path
  • :matpower indicates that the MATPOWER database should be searched for path
ExaPowerIO.PowerDataType
struct Data{T <: Real}
    version :: String
    baseMVA :: T
    bus :: Vector{BusData{T}}
    gen :: Vector{GenData{T}}
    branch :: Vector{BranchData{T}}
    storage :: Vector{StorageData{T}}
end

version, baseMVA, bus, gen, branch, and storage all corespond to members of the mpc object created by a matpower file. Their fields correspond exactly with the columns of the relevant mpc member.

ExaPowerIO.BusDataType
struct BusData{T <: Real}
    bus_i :: Int
    type :: Int
    pd :: T
    qd :: T
    gs :: T
    bs :: T
    area :: Int
    vm :: T
    va :: T
    baseKV :: T
    zone :: Int
    vmax :: T
    vmin :: T
end
ExaPowerIO.GenDataType
struct GenData{T <: Real}
    bus :: Int
    pg :: T
    qg :: T
    qmax :: T
    qmin :: T
    vg :: T
    mbase :: T
    status :: Int
    pmax :: T
    pmin :: T
    model_poly :: Bool
    startup :: T
    shutdown :: T
    n :: Int
    c :: NTuple{3, T}
end

bus is an index into the PowerData.bus Vector, not bus_i values

ExaPowerIO.BranchDataType
struct BranchData{T <: Real}
    f_bus :: Int
    t_bus :: Int
    br_r :: T
    br_x :: T
    b_fr :: T,
    b_to :: T,
    g_fr :: T,
    g_to :: T,
    rate_a ::T
    rate_b :: T
    rate_c :: T
    tap :: T
    shift :: T
    status :: Int
    angmin :: T
    angmax :: T
    f_idx::Int
    t_idx::Int
    c1 :: T
    c2 :: T
    c3 :: T
    c4 :: T
    c5 :: T
    c6 :: T
    c7 :: T
    c8 :: T
end

fbus and tbus are indices into the PowerData.bus Vector, not bus_i values

ExaPowerIO.StorageDataType
struct StorageData{T <: Real}
    storage_bus :: Int
    ps :: T
    qs :: T
    energy :: T
    energy_rating :: T
    charge_rating :: T
    discharge_rating :: T
    charge_efficiency :: T
    discharge_efficiency :: T
    thermal_rating :: T
    qmin :: T
    qmax :: T
    r :: T
    x :: T
    p_loss :: T
    q_loss :: T
    status :: Int
end

Example Usage

julia> using ExaPowerIO

julia> result = parse_matpower("pglib_opf_case3_lmbd.m"; library=:pglib);

julia> result.version
"2"

julia> result.baseMVA
100.0

julia> result.bus
3-element Vector{BusData{Float64}}:
 BusData{Float64}(1, 3, 1.1, 0.4, 0.0, 0.0, 1, 1.0, 0.0, 240.0, 1, 1.1, 0.9)
 BusData{Float64}(2, 2, 1.1, 0.4, 0.0, 0.0, 1, 1.0, 0.0, 240.0, 1, 1.1, 0.9)
 BusData{Float64}(3, 2, 0.95, 0.5, 0.0, 0.0, 1, 1.0, 0.0, 240.0, 1, 1.1, 0.9)

julia> result.gen
3-element Vector{GenData{Float64}}:
 GenData{Float64}(1, 10.0, 0.0, 10.0, -10.0, 1.0, 100.0, 1, 20.0, 0.0, true, 0.0, 0.0, 3, (1100.0, 500.0, 0.0))
 GenData{Float64}(2, 10.0, 0.0, 10.0, -10.0, 1.0, 100.0, 1, 20.0, 0.0, true, 0.0, 0.0, 3, (850.0000000000001, 120.0, 0.0))
 GenData{Float64}(3, 0.0, 0.0, 10.0, -10.0, 1.0, 100.0, 1, 0.0, 0.0, true, 0.0, 0.0, 3, (0.0, 0.0, 0.0))

julia> result.branch
3-element Vector{BranchData{Float64}}:
 BranchData{Float64}(1, 3, 0.065, 0.62, 0.225, 0.225, 0.0, 0.0, 90.0, 90.0, 90.0, 1.0, 0.0, 1, -0.5235987755982988, 0.5235987755982988, 1, 4, -0.16725635252492763, 1.5953682856223865, -0.16725635252492763, 1.5953682856223865, 0.16725635252492763, -1.3703682856223864, 0.16725635252492763, -1.3703682856223864)
 BranchData{Float64}(3, 2, 0.025, 0.75, 0.35, 0.35, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 0.0, 1, -0.5235987755982988, 0.5235987755982988, 2, 5, -0.044395116537180916, 1.3318534961154274, -0.044395116537180916, 1.3318534961154274, 0.044395116537180916, -0.9818534961154274, 0.044395116537180916, -0.9818534961154274)
 BranchData{Float64}(1, 2, 0.042, 0.9, 0.15, 0.15, 0.0, 0.0, 90.0, 90.0, 90.0, 1.0, 0.0, 1, -0.5235987755982988, 0.5235987755982988, 3, 6, -0.05173917542536994, 1.1086966162579273, -0.05173917542536994, 1.1086966162579273, 0.05173917542536994, -0.9586966162579272, 0.05173917542536994, -0.9586966162579272)

julia> result.storage
StorageData{Float64}[]