From 1ba986e0f4db054329221d8c0c5c21457e923f28 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Wed, 6 Sep 2023 09:33:20 -0600 Subject: [PATCH] merge conflict fixes --- src/lodf_calculations.jl | 6 +++--- src/ptdf_calculations.jl | 36 +++--------------------------------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/src/lodf_calculations.jl b/src/lodf_calculations.jl index 0176d387..4785383d 100644 --- a/src/lodf_calculations.jl +++ b/src/lodf_calculations.jl @@ -169,9 +169,9 @@ Builds the LODF matrix given the data of branches and buses of the system. """ function LODF( branches, - buses::Vector{PSY.ACBus}, - linera_solver::String = "KLU", - dist_slack::Vector{Float64} = Float64[], + buses::Vector{PSY.ACBus}; + linear_solver::String = "KLU", + tol::Float64 = eps(), ) # get axis names diff --git a/src/ptdf_calculations.jl b/src/ptdf_calculations.jl index 3647c979..292e9c47 100644 --- a/src/ptdf_calculations.jl +++ b/src/ptdf_calculations.jl @@ -215,39 +215,9 @@ function _calculate_PTDF_matrix_DENSE( _binfo_check(binfo) PTDFm_t = zeros(buscount, linecount) - #build incidence matrix - for (ix, b) in enumerate(branches) - if isa(b, PSY.DCBranch) - @warn("PTDF construction ignores DC-Lines") - continue - end - - (fr_b, to_b) = get_bus_indices(b, bus_lookup) - A[fr_b, ix] = 1 - A[to_b, ix] = -1 - - inv_X[ix, ix] = PSY.get_series_susceptance(b) - end - - slacks = - [bus_lookup[PSY.get_number(n)] for n in nodes if PSY.get_bustype(n) == ACBusTypes.REF] - isempty(slacks) && error("System must have a reference bus!") - - slack_position = slacks[1] - B = gemm( - 'N', - 'T', - gemm('N', 'N', A[setdiff(1:end, slack_position), 1:end], inv_X), - A[setdiff(1:end, slack_position), 1:end], - ) - if dist_slack[1] == 0.1 && length(dist_slack) == 1 - (B, bipiv, binfo) = getrf!(B) - binfo_check(binfo) - S = gemm( - 'N', - 'N', - gemm('N', 'T', inv_X, A[setdiff(1:end, slack_position), :]), - getri!(B, bipiv), + if !isempty(dist_slack) && length(ref_bus_positions) != 1 + error( + "Distibuted slack is not supported for systems with multiple reference buses.", ) elseif isempty(dist_slack) && length(ref_bus_positions) < buscount PTDFm_t[valid_ixs, :] = gemm(