Skip to content

Commit ab08eab

Browse files
committed
Debugging code for multiphase analyses
1 parent 1a8c9e3 commit ab08eab

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/multinode/multinode.jl

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,11 +752,24 @@ function add_bus_voltage_violation_to_the_model(pm, Multinode_Inputs)
752752
for PMD_time_step in PMD_time_steps
753753
for bus_name in bus_names
754754
index = BusInfo[bus_name]["index"]
755-
voltage_squared = [PMD.var(pm, PMD_time_step, :w, index)[terminal] for terminal in BusInfo[bus_name]["terminals"]] # TODO: check that this will work if a bus is on phase 2 and 3 (and not phase 1)
755+
voltage_squared = [PMD.var(pm, PMD_time_step, :w, index)[terminal] for terminal in BusInfo[bus_name]["terminals"]]
756756

757+
#=
758+
# Optional: print out information to understand the approach in the code:
759+
print("\n For bus $(bus_name) the terminals are: ")
760+
print(BusInfo[bus_name]["terminals"])
761+
print("\n")
762+
print("\n For bus $(bus_name) the voltage_squared variable is: ")
763+
print(voltage_squared)
764+
print("\n")
765+
index_temp = findall(x -> x== BusInfo[bus_name]["terminals"][1], BusInfo[bus_name]["terminals"])[1]
766+
print("The index in voltage_squared for terminal $(BusInfo[bus_name]["terminals"][1]) is $(index_temp) ")
767+
=#
768+
757769
for terminal in BusInfo[bus_name]["terminals"]
758-
@constraint(model, voltage_squared[terminal] <= (Multinode_Inputs.bus_per_unit_voltage_target_upper_bound^2) + model[:binBusVoltageViolation][bus_name, PMD_time_step] * 100) # multiply by 100 to make the possible voltage very large
759-
@constraint(model, voltage_squared[terminal] >= (Multinode_Inputs.bus_per_unit_voltage_target_lower_bound^2) * (1 - model[:binBusVoltageViolation][bus_name, PMD_time_step])) # If the binary is one, then the voltage squared can go to zero
770+
terminal_index = findall(x -> x== terminal, BusInfo[bus_name]["terminals"])[1]
771+
@constraint(model, voltage_squared[terminal_index] <= (Multinode_Inputs.bus_per_unit_voltage_target_upper_bound^2) + model[:binBusVoltageViolation][bus_name, PMD_time_step] * 100) # multiply by 100 to make the possible voltage very large
772+
@constraint(model, voltage_squared[terminal_index] >= (Multinode_Inputs.bus_per_unit_voltage_target_lower_bound^2) * (1 - model[:binBusVoltageViolation][bus_name, PMD_time_step])) # If the binary is one, then the voltage squared can go to zero
760773
end
761774

762775
end

src/multinode/multinode_results_processing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function Results_Processing_REopt_PMD_Model(m, results, data_math_mn, REoptInput
6060
ActivePowerFlow_line_temp = []
6161
ReactivePowerFlow_line_temp = []
6262
for i in 1:length(sol_eng["nw"])
63-
push!(ActivePowerFlow_line_temp, sum(sol_eng["nw"][string(i)]["line"][line][pf_name][Phase] for Phase in keys(sol_eng["nw"][string(i)]["line"][line][pf_name])) )
63+
push!(ActivePowerFlow_line_temp, sum(sol_eng["nw"][string(i)]["line"][line][pf_name][Phase] for Phase in keys(sol_eng["nw"][string(i)]["line"][line][pf_name])) ) # The "for Phase in keys(..." sums the power across the phases
6464
push!(ReactivePowerFlow_line_temp, sum(sol_eng["nw"][string(i)]["line"][line][qf_name][Phase] for Phase in keys(sol_eng["nw"][string(i)]["line"][line][qf_name])) )
6565
end
6666

0 commit comments

Comments
 (0)