Skip to content

Commit

Permalink
Add optional extra data to PowerFlowData
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielKS committed Sep 4, 2024
1 parent 6a697ac commit f4256fc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/PowerFlowData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ flows and angles, as well as these ones.
- `neighbors::Vector{Set{Int}}`: Vector with the sets of adjacent buses.
"""
struct PowerFlowData{
M <: PNM.PowerNetworkMatrix,
M <: Union{PNM.PowerNetworkMatrix, Nothing},
N <: Union{PNM.PowerNetworkMatrix, Nothing},
E,
}
bus_lookup::Dict{Int, Int}
branch_lookup::Dict{String, Int}
Expand All @@ -69,6 +70,7 @@ struct PowerFlowData{
power_network_matrix::M
aux_network_matrix::N
neighbors::Vector{Set{Int}}
extra_data::E
end

get_bus_lookup(pfd::PowerFlowData) = pfd.bus_lookup
Expand All @@ -88,6 +90,7 @@ get_valid_ix(pfd::PowerFlowData) = pfd.valid_ix
get_power_network_matrix(pfd::PowerFlowData) = pfd.power_network_matrix
get_aux_network_matrix(pfd::PowerFlowData) = pfd.aux_network_matrix
get_neighbor(pfd::PowerFlowData) = pfd.neighbors
get_extra_data(pfd::PowerFlowData) = pfd.extra_data

function clear_injection_data!(pfd::PowerFlowData)
pfd.bus_activepower_injection[:] = 0.0
Expand Down Expand Up @@ -251,6 +254,7 @@ function PowerFlowData(
power_network_matrix,
nothing,
_calculate_neighbors(power_network_matrix),
nothing,
)
end

Expand Down Expand Up @@ -383,6 +387,7 @@ function PowerFlowData(
power_network_matrix,
aux_network_matrix,
Vector{Set{Int}}(),
nothing,
)
end

Expand Down Expand Up @@ -515,6 +520,7 @@ function PowerFlowData(
power_network_matrix,
aux_network_matrix,
Vector{Set{Int}}(),
nothing,
)
end

Expand Down Expand Up @@ -647,5 +653,6 @@ function PowerFlowData(
power_network_matrix,
aux_network_matrix,
Vector{Set{Int}}(),
nothing,
)
end
1 change: 1 addition & 0 deletions src/ac_power_flow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const ACPowerFlowData = PowerFlowData{
Tuple{Dict{Int64, Int64}, Dict{Int64, Int64}},
},
Nothing,
Nothing,
}

struct PolarPowerFlow{F, D}
Expand Down
6 changes: 6 additions & 0 deletions src/powerflow_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ end
struct DCPowerFlow <: PowerFlowEvaluationModel end
struct PTDFDCPowerFlow <: PowerFlowEvaluationModel end
struct vPTDFDCPowerFlow <: PowerFlowEvaluationModel end

Base.@kwdef struct PSSEExportPowerFlow <: PowerFlowEvaluationModel
psse_version::Symbol
export_dir::AbstractString
write_comments::Bool = false
end
4 changes: 3 additions & 1 deletion src/solve_dc_powerflow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ const PTDFPowerFlowData = PowerFlowData{
Tuple{Dict{Int64, Int64}, Dict{Int64, Int64}},
PNM.KLU.KLUFactorization{Float64, Int64},
},
Nothing,
}

# ? change this to have a more detailed definition ?
const vPTDFPowerFlowData = PowerFlowData{}
const vPTDFPowerFlowData = PowerFlowData{<:Any, <:Any, Nothing}

const ABAPowerFlowData = PowerFlowData{
PNM.ABA_Matrix{
Expand All @@ -23,6 +24,7 @@ const ABAPowerFlowData = PowerFlowData{
PNM.BA_Matrix{
Tuple{Vector{Int64}, Vector{String}},
Tuple{Dict{Int64, Int64}, Dict{String, Int64}}},
Nothing,
}

"""
Expand Down

0 comments on commit f4256fc

Please sign in to comment.