Skip to content

Commit

Permalink
adjust for the changes in PNM
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Bolgaryn committed Jan 30, 2025
1 parent 9d59232 commit 4ea859f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/PowerFlowData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function PowerFlowData(
timestep_map = Dict(zip([i for i in 1:time_steps], timestep_names))

# get data for calculations
power_network_matrix = PNM.Ybus(sys; check_connectivity = check_connectivity)
power_network_matrix = PNM.Ybus(sys; check_connectivity = check_connectivity, make_branch_admittance_matrices = true)

# get number of buses and branches
n_buses = length(axes(power_network_matrix, 1))
Expand Down
13 changes: 5 additions & 8 deletions src/newton_ac_powerflow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ end

# Multiperiod power flow - work in progress
function solve_powerflow!(
data::ACPowerFlowData,
sys::PSY.System;
data::ACPowerFlowData;
kwargs...,
)
pf = ACPowerFlow() # todo: somehow store in data which PF to use (see issue #50)
Expand All @@ -185,12 +184,10 @@ function solve_powerflow!(
# TODO If anything in the grid topology changes,
# e.g. tap positions of transformers or in service
# status of branches, Yft and Ytf must be updated!
branches = PNM.get_ac_branches(sys)
buses = PNM.get_buses(sys)
fixed_admittances = collect(PSY.get_components(PSY.FixedAdmittance, sys))
y11, y22, y12, y21, _, fb, tb, _ = PNM._buildybus(branches, buses, fixed_admittances)
Yft = SparseArrays.sparse([1:length(fb); 1:length(fb)], [fb; tb], [y11; y12], length(fb), length(buses))
Ytf = SparseArrays.sparse([1:length(tb); 1:length(tb)], [tb; fb], [y22; y21], length(tb), length(buses))
Yft = data.power_network_matrix.Yft
Ytf = data.power_network_matrix.Ytf
fb = data.power_network_matrix.fb
tb = data.power_network_matrix.tb

for t in sorted_time_steps
converged, V, Sbus_result =
Expand Down

0 comments on commit 4ea859f

Please sign in to comment.