diff --git a/src/BA_ABA_matrices.jl b/src/BA_ABA_matrices.jl index 315d6666..c39e2443 100644 --- a/src/BA_ABA_matrices.jl +++ b/src/BA_ABA_matrices.jl @@ -15,8 +15,8 @@ Structure containing the BA matrix and other relevant data. with the names of buses and branches - `ref_bus_positions::Set{Int}`: Set containing the indexes of the columns of the BA matrix corresponding - to the refence buses -- `radial_branches::RadialBranches`: + to the reference buses +- `radial_network_reduction::RadialNetworkReduction`: Structure containing the radial branches and leaf buses that were removed while evaluating the matrix """ @@ -25,7 +25,7 @@ struct BA_Matrix{Ax, L <: NTuple{2, Dict}} <: PowerNetworkMatrix{Float64} axes::Ax lookup::L ref_bus_positions::Set{Int} - radial_branches::RadialBranches + radial_network_reduction::RadialNetworkReduction end """ @@ -40,9 +40,9 @@ Build the BA matrix from a given System """ function BA_Matrix(sys::PSY.System; reduce_radial_branches::Bool = false) if reduce_radial_branches - rb = RadialBranches(IncidenceMatrix(sys)) + rb = RadialNetworkReduction(IncidenceMatrix(sys)) else - rb = RadialBranches() + rb = RadialNetworkReduction() end branches = get_ac_branches(sys, rb.radial_branches) buses = get_buses(sys, rb.bus_reduction_map) @@ -72,10 +72,10 @@ Structure containing the ABA matrix and other relevant data. with the number of the buses. - `ref_bus_positions::Set{Int}`: Vector containing the indexes of the columns of the BA matrix corresponding - to the refence buses + to the reference buses - `K<:Union{Nothing, KLU.KLUFactorization{Float64, Int}}`: either nothing or a container for KLU factorization matrices (LU factorization) -- `radial_branches::RadialBranches`: +- `radial_network_reduction::RadialNetworkReduction`: Structure containing the radial branches and leaf buses that were removed while evaluating the matrix """ @@ -89,7 +89,7 @@ struct ABA_Matrix{ lookup::L ref_bus_positions::Set{Int} K::F - radial_branches::RadialBranches + radial_network_reduction::RadialNetworkReduction end """ @@ -108,9 +108,9 @@ function ABA_Matrix( reduce_radial_branches::Bool = false, ) if reduce_radial_branches - rb = RadialBranches(IncidenceMatrix(sys)) + rb = RadialNetworkReduction(IncidenceMatrix(sys)) else - rb = RadialBranches() + rb = RadialNetworkReduction() end branches = get_ac_branches(sys, rb.radial_branches) @@ -155,7 +155,7 @@ function factorize(ABA::ABA_Matrix{Ax, L, Nothing}) where {Ax, L <: NTuple{2, Di deepcopy(ABA.lookup), deepcopy(ABA.ref_bus_positions), klu(ABA.data), - deepcopy(ABA.radial_branches), + deepcopy(ABA.radial_network_reduction), ) return ABA_lu end diff --git a/src/PowerNetworkMatrices.jl b/src/PowerNetworkMatrices.jl index 407e485e..83524523 100644 --- a/src/PowerNetworkMatrices.jl +++ b/src/PowerNetworkMatrices.jl @@ -14,7 +14,7 @@ export IncidenceMatrix export is_factorized export LODF export PTDF -export RadialBranches +export RadialNetworkReduction export to_hdf5 export validate_connectivity export VirtualLODF @@ -50,7 +50,7 @@ import Pardiso include("PowerNetworkMatrix.jl") include("incedence_matrix.jl") include("adjacency_matrix.jl") -include("radial_braches.jl") +include("network_radial_reduction.jl") include("common.jl") include("BA_ABA_matrices.jl") include("definitions.jl") diff --git a/src/adjacency_matrix.jl b/src/adjacency_matrix.jl index 993d75de..49b8538e 100644 --- a/src/adjacency_matrix.jl +++ b/src/adjacency_matrix.jl @@ -17,7 +17,7 @@ The AdjacencyMatrix Struct is indexed using the Bus Numbers, no need for them to with the names of branches and buses - `ref_bus_positions::Set{Int}`: Vector containing the indexes of the columns of the BA matrix corresponding - to the refence buses + to the reference buses """ struct AdjacencyMatrix{Ax, L <: NTuple{2, Dict}} <: PowerNetworkMatrix{Int8} data::SparseArrays.SparseMatrixCSC{Int8, Int} diff --git a/src/common.jl b/src/common.jl index f3d80ef9..9bd8a019 100644 --- a/src/common.jl +++ b/src/common.jl @@ -204,7 +204,7 @@ Evaluates the transposed BA matrix given the System's banches, reference bus pos vector containing the branches of the considered system (should be AC branches). - `ref_bus_positions::Set{Int}`: Vector containing the indexes of the columns of the BA matrix corresponding - to the refence buses + to the reference buses - `bus_lookup::Dict{Int, Int}`: dictionary mapping the bus numbers with their enumerated indexes. """ diff --git a/src/incedence_matrix.jl b/src/incedence_matrix.jl index ccd312e6..5c12d82d 100644 --- a/src/incedence_matrix.jl +++ b/src/incedence_matrix.jl @@ -12,7 +12,7 @@ Incidence matrix: shows connection between buses, defining lines and buses with their enumerated indexes. - `ref_bus_positions::Set{Int}`: Vector containing the indices of the reference slack buses. -- `radial_branches::RadialBranches`: +- `radial_network_reduction::RadialNetworkReduction`: Structure containing the radial branches and leaf buses that were removed while evaluating the matrix """ @@ -52,7 +52,7 @@ values. # Arguments - `sys::PSY.System`: the PowerSystem system to consider -- `radial_branches::RadialBranches`: +- `radial_network_reduction::RadialNetworkReduction`: Structure containing the radial branches and leaf buses that were removed while evaluating the matrix """ diff --git a/src/lodf_calculations.jl b/src/lodf_calculations.jl index 3f5f7c5c..9f817d9b 100644 --- a/src/lodf_calculations.jl +++ b/src/lodf_calculations.jl @@ -14,7 +14,7 @@ of how a change in a line's flow affects the flows on other lines in the system. - `tol::Base.RefValue{Float64}`: tolerance used for sparsifying the matrix (dropping element whose absolute value is below this threshold). -- `radial_branches::RadialBranches`: +- `radial_network_reduction::RadialNetworkReduction`: Structure containing the radial branches and leaf buses that were removed while evaluating the matrix """ @@ -24,7 +24,7 @@ struct LODF{Ax, L <: NTuple{2, Dict}, M <: AbstractArray{Float64, 2}} <: axes::Ax lookup::L tol::Base.RefValue{Float64} - radial_branches::RadialBranches + radial_network_reduction::RadialNetworkReduction end function _buildlodf( @@ -268,7 +268,7 @@ Builds the LODF matrix given the data of branches and buses of the system. Default solver: "KLU". - `tol::Float64`: Tolerance to eliminate entries in the LODF matrix (default eps()) -- `radial_branches::RadialBranches`: +- `radial_network_reduction::RadialNetworkReduction`: Structure containing the radial branches and leaf buses that were removed while evaluating the ma """ @@ -277,7 +277,7 @@ function LODF( buses::Vector{PSY.ACBus}; linear_solver::String = "KLU", tol::Float64 = eps(), - radial_branches::RadialBranches = RadialBranches(), + radial_network_reduction::RadialNetworkReduction = RadialNetworkReduction(), ) # get axis names @@ -292,14 +292,20 @@ function LODF( if tol > eps() lodf_t = _buildlodf(a, ptdf_t, linear_solver) - return LODF(sparsify(lodf_t, tol), axes, look_up, Ref(tol), radial_branches) + return LODF( + sparsify(lodf_t, tol), + axes, + look_up, + Ref(tol), + radial_network_reduction, + ) else return LODF( _buildlodf(a, ptdf_t, linear_solver), axes, look_up, Ref(tol), - radial_branches, + radial_network_reduction, ) end end @@ -323,13 +329,13 @@ function LODF( kwargs..., ) if reduce_radial_branches - rb = RadialBranches(IncidenceMatrix(sys)) + rb = RadialNetworkReduction(IncidenceMatrix(sys)) else - rb = RadialBranches() + rb = RadialNetworkReduction() end branches = get_ac_branches(sys, rb.radial_branches) buses = get_buses(sys, rb.bus_reduction_map) - return LODF(branches, buses; radial_branches = rb, kwargs...) + return LODF(branches, buses; radial_network_reduction = rb, kwargs...) end """ @@ -373,26 +379,26 @@ function LODF( end if reduce_radial_branches - if !isempty(PTDFm.radial_branches) - radial_branches = PTDFm.radial_branches - @info "Non-empty `radial_branches` field found in PTDF matrix. LODF is evaluated considering radial branches and leaf nodes removed." + if !isempty(PTDFm.radial_network_reduction) + radial_network_reduction = PTDFm.radial_network_reduction + @info "Non-empty `radial_network_reduction` field found in PTDF matrix. LODF is evaluated considering radial branches and leaf nodes removed." else - error("PTDF has empty `radial_branches` field.") + error("PTDF has empty `radial_network_reduction` field.") end A_matrix = reduce_A_matrix( A, - radial_branches.bus_reduction_map, - radial_branches.meshed_branches, + radial_network_reduction.bus_reduction_map, + radial_network_reduction.meshed_branches, ) - ax_ref = make_ax_ref(sort!(collect(radial_branches.meshed_branches))) + ax_ref = make_ax_ref(sort!(collect(radial_network_reduction.meshed_branches))) else - if isempty(PTDFm.radial_branches) - radial_branches = RadialBranches() + if isempty(PTDFm.radial_network_reduction) + radial_network_reduction = RadialNetworkReduction() A_matrix = A.data ax_ref = make_ax_ref(A.axes[1]) else error( - "Field `radial_branches` in PTDF must be empty if `reduce_radial_branches` is not true.", + "Field `radial_network_reduction` in PTDF must be empty if `reduce_radial_network_reduction` is not true.", ) end end @@ -404,7 +410,7 @@ function LODF( (A.axes[1], A.axes[1]), (ax_ref, ax_ref), Ref(tol), - radial_branches, + radial_network_reduction, ) end return LODF( @@ -412,7 +418,7 @@ function LODF( (A.axes[1], A.axes[1]), (ax_ref, ax_ref), Ref(tol), - radial_branches, + radial_network_reduction, ) end @@ -447,23 +453,24 @@ function LODF( validate_linear_solver(linear_solver) ax_ref = make_ax_ref(A.axes[1]) if reduce_radial_branches - # BA and ABA must contain the same, non-empty RadialBranches stucture - if !isempty(BA.radial_branches) && !isempty(ABA.radial_branches) && - isequal(BA.radial_branches, ABA.radial_branches) - radial_branches = BA.radial_branches + # BA and ABA must contain the same, non-empty RadialNetworkReduction stucture + if !isempty(BA.radial_network_reduction) && + !isempty(ABA.radial_network_reduction) && + isequal(BA.radial_network_reduction, ABA.radial_network_reduction) + radial_network_reduction = BA.radial_network_reduction @info "Non-empty `radial_branches` field found in BA and ABA matrix. LODF is evaluated considering radial branches and leaf nodes removed." else error("Mismatch in `radial_branches` field between BA and ABA matrices.") end A_matrix = reduce_A_matrix( A, - radial_branches.bus_reduction_map, - radial_branches.meshed_branches, + radial_network_reduction.bus_reduction_map, + radial_network_reduction.meshed_branches, ) else - # BA and ABA must contain the same, empty RadialBranches stucture - if isempty(BA.radial_branches) && isempty(ABA.radial_branches) - radial_branches = RadialBranches() + # BA and ABA must contain the same, empty RadialNetworkReduction stucture + if isempty(BA.radial_network_reduction) && isempty(ABA.radial_network_reduction) + radial_network_reduction = RadialNetworkReduction() A_matrix = A.data else error( @@ -479,7 +486,7 @@ function LODF( (A.axes[1], A.axes[1]), (ax_ref, ax_ref), Ref(tol), - radial_branches, + radial_network_reduction, ) end return LODF( @@ -487,7 +494,7 @@ function LODF( (A.axes[1], A.axes[1]), (ax_ref, ax_ref), Ref(tol), - radial_branches, + radial_network_reduction, ) end diff --git a/src/radial_braches.jl b/src/network_radial_reduction.jl similarity index 84% rename from src/radial_braches.jl rename to src/network_radial_reduction.jl index 91ef19f4..b927286e 100644 --- a/src/radial_braches.jl +++ b/src/network_radial_reduction.jl @@ -1,16 +1,16 @@ -struct RadialBranches +struct RadialNetworkReduction bus_reduction_map::Dict{Int, Set{Int}} reverse_bus_search_map::Dict{Int, Int} radial_branches::Set{String} meshed_branches::Set{String} end -get_bus_reduction_map(rb::RadialBranches) = rb.bus_reduction_map -get_reverse_bus_search_map(rb::RadialBranches) = rb.reverse_bus_search_map -get_radial_branches(rb::RadialBranches) = rb.radial_branches -get_meshed_branches(rb::RadialBranches) = rb.meshed_branches +get_bus_reduction_map(rb::RadialNetworkReduction) = rb.bus_reduction_map +get_reverse_bus_search_map(rb::RadialNetworkReduction) = rb.reverse_bus_search_map +get_radial_branches(rb::RadialNetworkReduction) = rb.radial_branches +get_meshed_branches(rb::RadialNetworkReduction) = rb.meshed_branches -function Base.isempty(rb::RadialBranches) +function Base.isempty(rb::RadialNetworkReduction) if !isempty(rb.bus_reduction_map) return false end @@ -25,12 +25,12 @@ function Base.isempty(rb::RadialBranches) return true end -function RadialBranches(; +function RadialNetworkReduction(; bus_reduction_map::Dict{Int, Set{Int}} = Dict{Int, Set{Int}}(), reverse_bus_search_map::Dict{Int, Int} = Dict{Int, Int}(), radial_branches::Set{String} = Set{String}(), meshed_branches::Set{String} = Set{String}()) - return RadialBranches( + return RadialNetworkReduction( bus_reduction_map, reverse_bus_search_map, radial_branches, @@ -46,7 +46,7 @@ ignored in the models. - `A::IncidenceMatrix`: IncidenceMatrix """ -function RadialBranches(A::IncidenceMatrix) +function RadialNetworkReduction(A::IncidenceMatrix) return calculate_radial_branches(A.data, A.lookup[1], A.lookup[2], A.ref_bus_positions) end @@ -58,8 +58,8 @@ ignored in the models. - `sys::PSY.System`: System Data """ -function RadialBranches(sys::PSY.System) - return RadialBranches(IncidenceMatrix(sys)) +function RadialNetworkReduction(sys::PSY.System) + return RadialNetworkReduction(IncidenceMatrix(sys)) end function _find_upstream_bus( @@ -166,7 +166,7 @@ ignored in the models by exploring the structure of the incidence matrix - `bus_map::Dict{Int, Int}`: Map of Bus Name to Matrix Index - `ref_bus_positions::Set{Int}`: Set containing the indexes of the columns of the BA matrix corresponding - to the refence buses + to the reference buses """ function calculate_radial_branches( A::SparseArrays.SparseMatrixCSC{Int8, Int64}, @@ -205,7 +205,7 @@ function calculate_radial_branches( end push!(meshed_branches, k) end - return RadialBranches( + return RadialNetworkReduction( bus_reduction_map_index, reverse_bus_search_map, radial_branches, @@ -217,23 +217,34 @@ end Interface to obtain the parent bus number of a reduced bus when radial branches are eliminated # Arguments -- `rb::RadialBranches`: RadialBranches object +- `rb::RadialNetworkReduction`: RadialNetworkReduction object - `bus_number::Int`: Bus number of the reduced bus """ -function get_mapped_bus_number(rb::RadialBranches, bus_number::Int) +function get_mapped_bus_number(rb::RadialNetworkReduction, bus_number::Int) if isempty(rb) return bus_number end return get(rb.reverse_bus_search_map, bus_number, bus_number) end +""" +Interface to obtain the parent bus number of a reduced bus when radial branches are eliminated + +# Arguments +- `rb::RadialNetworkReduction`: RadialNetworkReduction object +- `bus::ACBus`: Reduced bus +""" +function get_mapped_bus_number(rb::RadialNetworkReduction, bus::PSY.ACBus) + return get_mapped_bus_number(rb, PSY.get_number(bus)) +end + ############################################################################## ########################### Auxiliary functions ############################## ############################################################################## function isequal( - rb1::RadialBranches, - rb2::RadialBranches, + rb1::RadialNetworkReduction, + rb2::RadialNetworkReduction, ) for field in fieldnames(typeof(rb1)) if getfield(rb1, field) != getfield(rb2, field) diff --git a/src/ptdf_calculations.jl b/src/ptdf_calculations.jl index 3c50595a..7e695ac7 100644 --- a/src/ptdf_calculations.jl +++ b/src/ptdf_calculations.jl @@ -21,7 +21,7 @@ The PTDF struct is indexed using the Bus numbers and Branch names. - `tol::Base.RefValue{Float64}`: tolerance used for sparsifying the matrix (dropping element whose absolute value is below this threshold). -- `radial_branches::RadialBranches`: +- `radial_network_reduction::RadialNetworkReduction`: Structure containing the radial branches and leaf buses that were removed while evaluating the matrix """ @@ -33,7 +33,7 @@ struct PTDF{Ax, L <: NTuple{2, Dict}, M <: AbstractArray{Float64, 2}} <: subnetworks::Dict{Int, Set{Int}} ref_bus_positions::Set{Int} tol::Base.RefValue{Float64} - radial_branches::RadialBranches + radial_network_reduction::RadialNetworkReduction end """ @@ -377,7 +377,7 @@ Builds the PTDF matrix from a group of branches and buses. The return is a PTDF Linear solver to be used. Options are "Dense", "KLU" and "MKLPardiso - `tol::Float64`: Tolerance to eliminate entries in the PTDF matrix (default eps()) -- `radial_branches::RadialBranches`: +- `radial_network_reduction::RadialNetworkReduction`: Structure containing the radial branches and leaf buses that were removed while evaluating the ma """ @@ -387,7 +387,7 @@ function PTDF( dist_slack::Vector{Float64} = Float64[], linear_solver::String = "KLU", tol::Float64 = eps(), - radial_branches::RadialBranches = RadialBranches(), + radial_network_reduction::RadialNetworkReduction = RadialNetworkReduction(), ) validate_linear_solver(linear_solver) @@ -418,10 +418,18 @@ function PTDF( subnetworks, ref_bus_positions, Ref(tol), - radial_branches, + radial_network_reduction, ) end - return PTDF(S, axes, look_up, subnetworks, ref_bus_positions, Ref(tol), radial_branches) + return PTDF( + S, + axes, + look_up, + subnetworks, + ref_bus_positions, + Ref(tol), + radial_network_reduction, + ) end """ @@ -450,11 +458,17 @@ function PTDF( A = IncidenceMatrix(sys) dist_slack, rb = redistribute_dist_slack(dist_slack, A) else - rb = RadialBranches() + rb = RadialNetworkReduction() end branches = get_ac_branches(sys, rb.radial_branches) buses = get_buses(sys, rb.bus_reduction_map) - return PTDF(branches, buses; dist_slack = dist_slack, radial_branches = rb, kwargs...) + return PTDF( + branches, + buses; + dist_slack = dist_slack, + radial_network_reduction = rb, + kwargs..., + ) end """ @@ -489,22 +503,22 @@ function PTDF( validate_linear_solver(linear_solver) @warn "PTDF creates via other matrices doesn't compute the subnetworks" if reduce_radial_branches - if !isempty(BA.radial_branches) - radial_branches = BA.radial_branches + if !isempty(BA.radial_network_reduction) + radial_network_reduction = BA.radial_network_reduction @info "Non-empty `radial_branches` field found in BA matrix. PTDF is evaluated considering radial branches and leaf nodes removed." else error("BA has empty `radial_branches` field.") end A_matrix = reduce_A_matrix( A, - radial_branches.bus_reduction_map, - radial_branches.meshed_branches, + radial_network_reduction.bus_reduction_map, + radial_network_reduction.meshed_branches, ) axes = BA.axes lookup = BA.lookup else - if isempty(BA.radial_branches) - radial_branches = RadialBranches() + if isempty(BA.radial_network_reduction) + radial_network_reduction = RadialNetworkReduction() A_matrix = A.data axes = (A.axes[2], A.axes[1]) lookup = (A.lookup[2], A.lookup[1]) @@ -529,7 +543,7 @@ function PTDF( Dict{Int, Set{Int}}(), BA.ref_bus_positions, Ref(tol), - radial_branches, + radial_network_reduction, ) else return PTDF( @@ -539,7 +553,7 @@ function PTDF( Dict{Int, Set{Int}}(), BA.ref_bus_positions, Ref(tol), - radial_branches, + radial_network_reduction, ) end end @@ -583,7 +597,7 @@ function redistribute_dist_slack( A::IncidenceMatrix, ) dist_slack1 = deepcopy(dist_slack) - rb = RadialBranches(A) + rb = RadialNetworkReduction(A) # if original length of dist_slack is correct if length(dist_slack) == size(A.data, 2) for i in keys(rb.bus_reduction_map) diff --git a/src/serialization.jl b/src/serialization.jl index de0d3684..b500645f 100644 --- a/src/serialization.jl +++ b/src/serialization.jl @@ -83,7 +83,15 @@ function from_hdf5(::Type{PTDF}, filename::AbstractString) subnetworks[key] = Set(subnetworks_matrix[:, col]) end - PTDF(data, axes, lookup, subnetworks, ref_bus_positions, tol, RadialBranches()) + PTDF( + data, + axes, + lookup, + subnetworks, + ref_bus_positions, + tol, + RadialNetworkReduction(), + ) end end diff --git a/src/virtual_lodf_calculations.jl b/src/virtual_lodf_calculations.jl index be9c1662..a4e9c762 100644 --- a/src/virtual_lodf_calculations.jl +++ b/src/virtual_lodf_calculations.jl @@ -21,7 +21,7 @@ The VirtualLODF struct is indexed using branch names. coming from multuiplying the PTDF matrix with th Incidence matrix - `ref_bus_positions::Set{Int}`: Vector containing the indexes of the rows of the transposed BA matrix - corresponding to the refence buses. + corresponding to the reference buses. - `axes<:NTuple{2, Dict}`: Tuple containing two vectors showing the branch names. - `lookup<:NTuple{2, Dict}`: @@ -38,7 +38,7 @@ The VirtualLODF struct is indexed using branch names. Dictionary containing the subsets of buses defining the different subnetwork of the system. - `tol::Base.RefValue{Float64}`: Tolerance related to scarification and values to drop. -- `radial_branches::RadialBranches`: +- `radial_network_reduction::RadialNetworkReduction`: Structure containing the radial branches and leaf buses that were removed while evaluating the matrix """ @@ -55,7 +55,7 @@ struct VirtualLODF{Ax, L <: NTuple{2, Dict}} <: PowerNetworkMatrix{Float64} cache::RowCache subnetworks::Dict{Int, Set{Int}} tol::Base.RefValue{Float64} - radial_branches::RadialBranches + radial_network_reduction::RadialNetworkReduction end function Base.show(io::IO, ::MIME{Symbol("text/plain")}, array::VirtualLODF) @@ -115,13 +115,13 @@ function VirtualLODF( kwargs..., ) if reduce_radial_branches - rb = RadialBranches(IncidenceMatrix(sys)) + rb = RadialNetworkReduction(IncidenceMatrix(sys)) else - rb = RadialBranches() + rb = RadialNetworkReduction() end branches = get_ac_branches(sys, rb.radial_branches) buses = get_buses(sys, rb.bus_reduction_map) - return VirtualLODF(branches, buses; radial_branches = rb, kwargs...) + return VirtualLODF(branches, buses; radial_network_reduction = rb, kwargs...) end """ @@ -141,7 +141,7 @@ VirtualLODF struct with an empty cache. max cache size in MiB (inizialized as MAX_CACHE_SIZE_MiB). - `persistent_lines::Vector{String}`: line to be evaluated as soon as the VirtualPTDF is created (initialized as empty vector of strings). -- `radial_branches::RadialBranches`: +- `radial_network_reduction::RadialNetworkReduction`: Structure containing the radial branches and leaf buses that were removed while evaluating the matrix """ @@ -151,7 +151,7 @@ function VirtualLODF( tol::Float64 = eps(), max_cache_size::Int = MAX_CACHE_SIZE_MiB, persistent_lines::Vector{String} = String[], - radial_branches::RadialBranches = RadialBranches(), + radial_network_reduction::RadialNetworkReduction = RadialNetworkReduction(), ) #Get axis names and lookups @@ -209,7 +209,7 @@ function VirtualLODF( empty_cache, subnetworks, Ref(tol), - radial_branches, + radial_network_reduction, ) end diff --git a/src/virtual_ptdf_calculations.jl b/src/virtual_ptdf_calculations.jl index b3137070..adb8fd0d 100644 --- a/src/virtual_ptdf_calculations.jl +++ b/src/virtual_ptdf_calculations.jl @@ -17,7 +17,7 @@ matrix. BA matric - `ref_bus_positions::Set{Int}`: Vector containing the indexes of the columns of the BA matrix corresponding - to the refence buses + to the reference buses - `dist_slack::Vector{Float64}`: Vector of weights to be used as distributed slack bus. The distributed slack vector has to be the same length as the number of buses. @@ -42,7 +42,7 @@ matrix. Dictionary containing the subsets of buses defining the different subnetwork of the system. - `tol::Base.RefValue{Float64}`: Tolerance related to scarification and values to drop. -- `radial_branches::RadialBranches`: +- `radial_network_reduction::RadialNetworkReduction`: Structure containing the radial branches and leaf buses that were removed while evaluating the matrix """ @@ -58,7 +58,7 @@ struct VirtualPTDF{Ax, L <: NTuple{2, Dict}} <: PowerNetworkMatrix{Float64} cache::RowCache subnetworks::Dict{Int, Set{Int}} tol::Base.RefValue{Float64} - radial_branches::RadialBranches + radial_network_reduction::RadialNetworkReduction end function Base.show(io::IO, ::MIME{Symbol("text/plain")}, array::VirtualPTDF) @@ -89,7 +89,7 @@ VirtualPTDF struct with an empty cache. max cache size in MiB (inizialized as MAX_CACHE_SIZE_MiB). - `persistent_lines::Vector{String}`: line to be evaluated as soon as the VirtualPTDF is created (initialized as empty vector of strings). -- `radial_branches::RadialBranches`: +- `radial_network_reduction::RadialNetworkReduction`: Structure containing the radial branches and leaf buses that were removed while evaluating the matrix """ @@ -100,7 +100,7 @@ function VirtualPTDF( tol::Float64 = eps(), max_cache_size::Int = MAX_CACHE_SIZE_MiB, persistent_lines::Vector{String} = String[], - radial_branches::RadialBranches = RadialBranches(), + radial_network_reduction::RadialNetworkReduction = RadialNetworkReduction(), ) if length(dist_slack) != 0 @info "Distributed bus" @@ -149,7 +149,7 @@ function VirtualPTDF( empty_cache, subnetworks, Ref(tol), - radial_branches, + radial_network_reduction, ) end @@ -181,7 +181,7 @@ function VirtualPTDF( A = IncidenceMatrix(sys) dist_slack, rb = redistribute_dist_slack(dist_slack, A) else - rb = RadialBranches() + rb = RadialNetworkReduction() end branches = get_ac_branches(sys, rb.radial_branches) buses = get_buses(sys, rb.bus_reduction_map) @@ -189,7 +189,7 @@ function VirtualPTDF( branches, buses; dist_slack = dist_slack, - radial_branches = rb, + radial_network_reduction = rb, kwargs..., ) end diff --git a/test/test_A_BA_ABA_with_radial_lines.jl b/test/test_A_BA_ABA_with_radial_lines.jl index c82a6c22..91a045b7 100644 --- a/test/test_A_BA_ABA_with_radial_lines.jl +++ b/test/test_A_BA_ABA_with_radial_lines.jl @@ -7,7 +7,7 @@ # ... and with radial lines BA_rad = BA_Matrix(sys; reduce_radial_branches = true) # get inidices for the leaf nodes - rb = BA_rad.radial_branches + rb = BA_rad.radial_network_reduction bus_numbers = [] for i in keys(rb.bus_reduction_map) append!(bus_numbers, collect(rb.bus_reduction_map[i])) @@ -27,8 +27,8 @@ end # load the system sys = PSB.build_system(PSB.PSITestSystems, name) - # get the RadialBranches struct - rb = RadialBranches(IncidenceMatrix(sys)) + # get the RadialNetworkReduction struct + rb = RadialNetworkReduction(IncidenceMatrix(sys)) # get the original and reduced IncidenceMatrix, BA and ABA A = IncidenceMatrix(sys) diff --git a/test/test_lodf_with_radial_branches.jl b/test/test_lodf_with_radial_branches.jl index 948d7ecb..0404ec9e 100644 --- a/test/test_lodf_with_radial_branches.jl +++ b/test/test_lodf_with_radial_branches.jl @@ -17,7 +17,7 @@ lodf_rad_A_BA_ABA = LODF(A_rad, ABA_rad, BA_rad; reduce_radial_branches = true) lodf_rad_A_PTDF = LODF(A_rad, ptdf_rad; reduce_radial_branches = true) - rb = RadialBranches(IncidenceMatrix(sys)) + rb = RadialNetworkReduction(IncidenceMatrix(sys)) # at first check if all the matrices are the same @test isapprox(lodf_rad.data, lodf_rad_A_BA_ABA.data, atol = 1e-10) diff --git a/test/test_ptdf_with_radial_lines.jl b/test/test_ptdf_with_radial_lines.jl index ddb154ed..5c062b10 100644 --- a/test/test_ptdf_with_radial_lines.jl +++ b/test/test_ptdf_with_radial_lines.jl @@ -3,8 +3,8 @@ # load the system sys = PSB.build_system(PSB.PSITestSystems, name) - # get the RadialBranches struct - rb = RadialBranches(IncidenceMatrix(sys)) + # get the RadialNetworkReduction struct + rb = RadialNetworkReduction(IncidenceMatrix(sys)) # get the A and BA matrices without radial lines A_rad = IncidenceMatrix(sys) @@ -79,7 +79,7 @@ end sys = PSB.build_system(PSB.PSITestSystems, name) # get the radial branches A = IncidenceMatrix(sys) - rb = RadialBranches(A) + rb = RadialNetworkReduction(A) # get number of buses buscount = length(PNM.get_buses(sys)) # now compute distributed slack vector diff --git a/test/test_radial_branches.jl b/test/test_radial_branches.jl index 76519152..e49125cb 100644 --- a/test/test_radial_branches.jl +++ b/test/test_radial_branches.jl @@ -24,7 +24,7 @@ (0.0, 0.0), ), ) - rb = RadialBranches(IncidenceMatrix(sys)) + rb = RadialNetworkReduction(IncidenceMatrix(sys)) @test get_bus_reduction_map(rb)[7] == Set([61, 8]) @test get_radial_branches(rb) == Set(["tl", "Trans4"]) end @@ -32,7 +32,7 @@ end @testset "Radial Branches Large" begin sys = build_system(MatpowerTestSystems, "matpower_ACTIVSg10k_sys"; add_forecasts = false) - rb = RadialBranches(IncidenceMatrix(sys)) + rb = RadialNetworkReduction(IncidenceMatrix(sys)) for (k, v) in get_bus_reduction_map(rb) @test k ∉ v end @@ -42,7 +42,7 @@ end for name in ["matpower_ACTIVSg2000_sys", "matpower_ACTIVSg10k_sys"] sys = build_system(MatpowerTestSystems, name; add_forecasts = false) a_mat = IncidenceMatrix(sys) - rb = RadialBranches(IncidenceMatrix(sys)) + rb = RadialNetworkReduction(IncidenceMatrix(sys)) leaf_buses = Int64[] for i in keys(rb.bus_reduction_map) append!(leaf_buses, collect(rb.bus_reduction_map[i]))