Skip to content

Commit 161d921

Browse files
committed
Draft code for including reactive power. Deleted unnecessary code.
1 parent 673f1ac commit 161d921

1 file changed

Lines changed: 14 additions & 66 deletions

File tree

src/multinode/multinode.jl

Lines changed: 14 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,7 @@ end
622622

623623

624624
function generate_PMD_information(Multinode_Inputs, REopt_nodes, REopt_inputs_combined, data_math_mn)
625-
#print("\n keys of data_math_mn with key nw is:")
626-
#print(keys(data_math_mn["nw"]))
627-
625+
628626
gen_name2ind = Dict(gen["name"] => gen["index"] for (_,gen) in data_math_mn["nw"]["1"]["gen"])
629627

630628
load_phase_dictionary = create_load_phase_dictionary(Multinode_Inputs, REopt_nodes, REopt_inputs_combined)
@@ -661,93 +659,43 @@ function LinkREoptAndPMD(pm, m, data_math_mn, Multinode_Inputs, REopt_nodes, REo
661659
for e in REopt_nodes
662660
for phase in load_phase_dictionary[e]
663661
# Add the gen index to the REopt_gen_ind_e list
664-
665662
gen_ind_e_temp = gen_name2ind["REopt_gen_node$(e)_phase$(phase)"]
666663
push!(REopt_gen_ind_e, gen_ind_e_temp)
667664

668-
# Specify how many phases are associated with that gen_index
669-
#=
670-
if length(load_phase_dictionary[e]) == 1
671-
push!(gen_ind_with_one_phase, gen_ind_e_temp)
672-
elseif length(load_phase_dictionary[e]) == 2
673-
push!(gen_ind_with_two_phases, gen_ind_e_temp)
674-
elseif length(load_phase_dictionary[e]) == 3
675-
push!(gen_ind_with_three_phases, gen_ind_e_temp)
676-
else
677-
throw(@error("load_phase_dictionary has an invalid length"))
678-
end
679-
=#
680665
end
681666
end
682667
else
683668
throw(@error("Error in the number of phases"))
684669
end
685-
#=
686-
print("\n PMD Generator Index with one phase are: ")
687-
print(gen_ind_with_one_phase)
688-
print("\n PMD Generator Index with two phases are: ")
689-
print(gen_ind_with_two_phases)
690-
print("\n PMD Generator Index with three phases are: ")
691-
print(gen_ind_with_three_phases)
692-
print("\n")
693-
=#
670+
694671
PMDTimeSteps_InREoptTimes = Multinode_Inputs.PMD_time_steps
695672
PMDTimeSteps_Indeces = collect(1:length(PMDTimeSteps_InREoptTimes))
696-
697-
#PMD_Pg_ek = [PMD.var(pm, k, :pg, e).data[1] for e in REopt_gen_ind_e, k in PMDTimeSteps_Indeces] # The [1] here should be okay
698-
#PMD_Qg_ek = [PMD.var(pm, k, :qg, e).data[1] for e in REopt_gen_ind_e, k in PMDTimeSteps_Indeces]
699-
673+
700674
# Get the gen indeces this way:
701675
#gen_name2ind = Dict(gen["name"] => gen["index"] for (_,gen) in data_math_mn["nw"]["1"]["gen"])
702676

703-
#dv = "dvReactivePower"
704-
#m[Symbol(dv)] = @variable(m, [REopt_gen_ind_e, PMDTimeSteps_Indeces], base_name=dv)
705-
706-
#@constraint(m, [e in REopt_gen_ind_e, ts in PMDTimeSteps_Indeces], m[:dvReactivePower][e, ts] .<= 1000)
707-
#@constraint(m, [e in REopt_gen_ind_e, ts in PMDTimeSteps_Indeces], m[:dvReactivePower][e, ts] .>= -1000)
677+
#=
678+
dv = "dvFreeReactivePower"
679+
m[Symbol(dv)] = @variable(m, [REopt_gen_ind_e, PMDTimeSteps_Indeces], base_name=dv)
708680
681+
@constraint(m, [k in PMDTimeSteps_Indeces, e in REopt_gen_ind_e], m[:dvFreeReactivePower][e,k] .<= 0), #500 )
682+
@constraint(m, [k in PMDTimeSteps_Indeces, e in REopt_gen_ind_e], m[:dvFreeReactivePower][e,k] .>= 0), #-500 )
683+
=#
709684

710685
for e in REopt_gen_ind_e #Note: the REopt_gen_ind_e does not contain the facility meter
711-
#=
712-
713-
if Multinode_Inputs.number_of_phases == 1
714-
number_of_phases_at_load = 1
715-
elseif Multinode_Inputs.number_of_phases in [2,3]
716-
if e in gen_ind_with_one_phase
717-
number_of_phases_at_load = 1
718-
elseif e in gen_ind_with_two_phases
719-
number_of_phases_at_load = 2
720-
elseif e in gen_ind_with_three_phases
721-
number_of_phases_at_load = 3
722-
else
723-
throw(@error("Error in the number of phases at a load"))
724-
end
725-
else
726-
throw(@error("Error in the number of phases"))
727-
end
728-
=#
729-
# Note: evenly split the total export and import across each phase associated with that load (aka REopt node, aka PMD generator)
686+
730687
number_of_phases_at_load = ""
731688
number_of_phases_at_load = length(load_phase_dictionary[gen_ind_e_to_REopt_node[e]])
732-
733-
print("\n ")
734689
print("\n The number of phases at gen index $(e) (aka REopt node $(gen_ind_e_to_REopt_node[e])) is $(number_of_phases_at_load) ")
735-
# (1/number_of_phases_at_load) (1/(length(load_phase_dictionary[gen_ind_e_to_REopt_node[e]]))) *
736-
737-
#print("\n The number of phases at load is: $(number_of_phases_at_load)")
738-
#print("\n The e is: $(e)")
739-
#print("\n PMD time step indeces are: $(PMDTimeSteps_Indeces)")
740-
741-
#row_index = findall( gen_name2ind["REopt_gen_node$(e)_phase$(phase)"] in REopt_gen_ind_e)
742-
#PMD_Pg_ek[row_index, k]
743-
# Note: PMD_Pg_ek is a 2-dimensional array of decision variables
690+
691+
# Note: evenly split the total export and import across each phase associated with that load (aka REopt node, aka PMD generator)
744692
JuMP.@constraint(m, [k in PMDTimeSteps_Indeces],
745693
PMD.var(pm, k, :pg, e).data[1] .== round((1/number_of_phases_at_load), digits = 3) * (m[Symbol("TotalExport_"*string(gen_ind_e_to_REopt_node[e]))][PMDTimeSteps_InREoptTimes[k]] - m[Symbol("dvGridPurchase_"*string(gen_ind_e_to_REopt_node[e]))][PMDTimeSteps_InREoptTimes[k]]) # negative power "generation" is a load
746694
)
747-
#PMD_Qg_ek[row_index, k]
695+
748696
# TODO: add reactive power to the REopt nodes
749697
JuMP.@constraint(m, [k in PMDTimeSteps_Indeces],
750-
PMD.var(pm, k, :qg, e).data[1] .== 0.0 # m[:dvReactivePower][e, k] # (1/number_of_phases_at_load) * m[Symbol("TotalExport_"*string(buses[e]))][PMDTimeSteps_InREoptTimes[k]] - m[Symbol("dvGridPurchase_"*string(buses[e]))][PMDTimeSteps_InREoptTimes[k]]
698+
PMD.var(pm, k, :qg, e).data[1] .== 0.0 # m[:dvFreeReactivePower][e,k] # (1/number_of_phases_at_load) * m[Symbol("TotalExport_"*string(buses[e]))][PMDTimeSteps_InREoptTimes[k]] - m[Symbol("dvGridPurchase_"*string(buses[e]))][PMDTimeSteps_InREoptTimes[k]]
751699
)
752700
end
753701

0 commit comments

Comments
 (0)