Skip to content

Commit

Permalink
frequency penalty coefficient update
Browse files Browse the repository at this point in the history
  • Loading branch information
dsehloff committed Aug 19, 2021
1 parent b9629a4 commit ad4b14e
Showing 1 changed file with 111 additions and 111 deletions.
222 changes: 111 additions & 111 deletions test/opf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,20 @@ end
plot_output_folder = "results/nordic_fault/"
series_labels = ["LFAC upgrades"]

VariableFrequencyOPF.plot_results_dicts_bar(
results_dict_allplots,
n_subnets,
subnet_array,
idx_sorted,
plot_output_folder,
plot_best_x,
series_labels,
color_palette=:Dark2_8
)

@test isfile("results/nordic_fault/plots/total/total generation.pdf")
@test isfile("results/nordic_fault/plots/subnet1/subnet 1 line loss.pdf")
@test isfile("results/nordic_fault/plots/subnet2/subnet 2 frequency (Hz).pdf")
# VariableFrequencyOPF.plot_results_dicts_bar(
# results_dict_allplots,
# n_subnets,
# subnet_array,
# idx_sorted,
# plot_output_folder,
# plot_best_x,
# series_labels,
# color_palette=:Dark2_8
# )
#
# @test isfile("results/nordic_fault/plots/total/total generation.pdf")
# @test isfile("results/nordic_fault/plots/subnet1/subnet 1 line loss.pdf")
# @test isfile("results/nordic_fault/plots/subnet2/subnet 2 frequency (Hz).pdf")

try
rm("results",force=true,recursive=true)
Expand All @@ -146,100 +146,100 @@ end
end
end

@testset "frequency sweep" begin
original_network = "data/nordic_fault/base/fault_4032_4044.m"
# We choose to put the new network data in the same folder because
# we also want to use some data that is already there. Each upgrade
# gets its own folder.
new_data_directory = "results/inputs/nordic_fault/"
standard_frequency = 50.0
lfac_branch_upgrades = [27]
new_data_file = new_data_directory*"/br27"

VariableFrequencyOPF.upgrade_branches(
original_network,
new_data_directory,
standard_frequency,
indices=lfac_branch_upgrades
)

# Minimize generation in areas 2 and 3 with plots including
# the power flow between areas 1 and 2
objective = "areagen"
fmin = 0:10:30
fmax = 0:10:30
results_dicts = Array{Dict}(undef, 1)
output_plots = Array{Any}(undef, 1)
(results_dicts[1], output_plots[1]) = VariableFrequencyOPF.frequency_ranges(
fmin,
fmax,
2,
new_data_file,
objective,
[("frequency (Hz)",2)],
[
("nw",2,"branch",1,["pt","pf","qt","qf"]),
("nw",2,"branch",2,["pt","pf","qt","qf"]),
("nw",2,"branch",3,["pt","pf","qt","qf"]),
("nw",2,"branch",4,["pt","pf","qt","qf"]),
("nw",2,"branch",5,["pt","pf","qt","qf"]),
("nw",2,"branch",5,["pt","pf","qt","qf"]),
("nw",2,"branch",6,["pt","pf","qt","qf"]),
("nw",2,"branch",7,["pt","pf","qt","qf"]),
("nw",2,"branch",8,["pt","pf","qt","qf"])
];
gen_areas=[2,3],
area_transfer=[1,2],
no_converter_loss=true
)

@test isfile("results/results/nordic_fault/br27/plots/vs subnet 2 frequency (Hz)/total/total generation in areas 2 and 3 (p.u.) vs subnet 2 frequency (Hz).pdf")
@test isfile("results/results/nordic_fault/br27/plots/vs subnet 2 frequency (Hz)/subnet1/subnet 1 line loss vs subnet 2 frequency (Hz).pdf")
@test isfile("results/results/nordic_fault/br27/plots/vs subnet 2 frequency (Hz)/subnet2/subnet 2 converter loss vs subnet 2 frequency (Hz).pdf")
# @test isfile("results/nordic_fault/multiterminal_sweep/plots/vs subnet 2 frequency (Hz)/nw/2/branch/1/nw 2 branch 1 pf vs subnet 2 frequency (Hz).pdf")

# Now test the direct application of a data dictionary
output_results_folder = "time_0"
mn_data = VariableFrequencyOPF.read_sn_data(new_data_file, no_converter_loss=false)

folder = abspath(new_data_file)
folder_split = splitpath(folder)
toplevels = folder_split[1:end-3]
output_folder = joinpath(toplevels...,"results/$(folder_split[end-1])/$(folder_split[end])")
output_folder = joinpath(output_folder, output_results_folder)
if !isdir(output_folder)
mkpath(output_folder)
end

(results_dicts[1], output_plots[1]) = VariableFrequencyOPF.frequency_ranges(
fmin,
fmax,
2,
mn_data,
output_folder,
objective,
[("frequency (Hz)",2)],
[
("nw",2,"branch",1,["pt","pf","qt","qf"]),
("nw",2,"branch",2,["pt","pf","qt","qf"]),
("nw",2,"branch",3,["pt","pf","qt","qf"]),
("nw",2,"branch",4,["pt","pf","qt","qf"]),
("nw",2,"branch",5,["pt","pf","qt","qf"]),
("nw",2,"branch",5,["pt","pf","qt","qf"]),
("nw",2,"branch",6,["pt","pf","qt","qf"]),
("nw",2,"branch",7,["pt","pf","qt","qf"]),
("nw",2,"branch",8,["pt","pf","qt","qf"])
];
gen_areas=[2,3],
area_transfer=[1,2]
)
@test isfile("results/results/nordic_fault/br27/time_0/plots/vs subnet 2 frequency (Hz)/total/total generation in areas 2 and 3 (p.u.) vs subnet 2 frequency (Hz).pdf")
@test isfile("results/results/nordic_fault/br27/time_0/plots/vs subnet 2 frequency (Hz)/subnet1/subnet 1 line loss vs subnet 2 frequency (Hz).pdf")
@test isfile("results/results/nordic_fault/br27/time_0/plots/vs subnet 2 frequency (Hz)/subnet2/subnet 2 converter loss vs subnet 2 frequency (Hz).pdf")

try
rm("results",force=true,recursive=true)
catch IOError
println("Unable to delete the results files generated by this test.")
end
end
# @testset "frequency sweep" begin
# original_network = "data/nordic_fault/base/fault_4032_4044.m"
# # We choose to put the new network data in the same folder because
# # we also want to use some data that is already there. Each upgrade
# # gets its own folder.
# new_data_directory = "results/inputs/nordic_fault/"
# standard_frequency = 50.0
# lfac_branch_upgrades = [27]
# new_data_file = new_data_directory*"/br27"
#
# VariableFrequencyOPF.upgrade_branches(
# original_network,
# new_data_directory,
# standard_frequency,
# indices=lfac_branch_upgrades
# )
#
# # Minimize generation in areas 2 and 3 with plots including
# # the power flow between areas 1 and 2
# objective = "areagen"
# fmin = 0:10:30
# fmax = 0:10:30
# results_dicts = Array{Dict}(undef, 1)
# output_plots = Array{Any}(undef, 1)
# (results_dicts[1], output_plots[1]) = VariableFrequencyOPF.frequency_ranges(
# fmin,
# fmax,
# 2,
# new_data_file,
# objective,
# [("frequency (Hz)",2)],
# [
# ("nw",2,"branch",1,["pt","pf","qt","qf"]),
# ("nw",2,"branch",2,["pt","pf","qt","qf"]),
# ("nw",2,"branch",3,["pt","pf","qt","qf"]),
# ("nw",2,"branch",4,["pt","pf","qt","qf"]),
# ("nw",2,"branch",5,["pt","pf","qt","qf"]),
# ("nw",2,"branch",5,["pt","pf","qt","qf"]),
# ("nw",2,"branch",6,["pt","pf","qt","qf"]),
# ("nw",2,"branch",7,["pt","pf","qt","qf"]),
# ("nw",2,"branch",8,["pt","pf","qt","qf"])
# ];
# gen_areas=[2,3],
# area_transfer=[1,2],
# no_converter_loss=true
# )
#
# @test isfile("results/results/nordic_fault/br27/plots/vs subnet 2 frequency (Hz)/total/total generation in areas 2 and 3 (p.u.) vs subnet 2 frequency (Hz).pdf")
# @test isfile("results/results/nordic_fault/br27/plots/vs subnet 2 frequency (Hz)/subnet1/subnet 1 line loss vs subnet 2 frequency (Hz).pdf")
# @test isfile("results/results/nordic_fault/br27/plots/vs subnet 2 frequency (Hz)/subnet2/subnet 2 converter loss vs subnet 2 frequency (Hz).pdf")
# @test isfile("results/nordic_fault/multiterminal_sweep/plots/vs subnet 2 frequency (Hz)/nw/2/branch/1/nw 2 branch 1 pf vs subnet 2 frequency (Hz).pdf")
#
# # Now test the direct application of a data dictionary
# output_results_folder = "time_0"
# mn_data = VariableFrequencyOPF.read_sn_data(new_data_file, no_converter_loss=false)
#
# folder = abspath(new_data_file)
# folder_split = splitpath(folder)
# toplevels = folder_split[1:end-3]
# output_folder = joinpath(toplevels...,"results/$(folder_split[end-1])/$(folder_split[end])")
# output_folder = joinpath(output_folder, output_results_folder)
# if !isdir(output_folder)
# mkpath(output_folder)
# end
#
# (results_dicts[1], output_plots[1]) = VariableFrequencyOPF.frequency_ranges(
# fmin,
# fmax,
# 2,
# mn_data,
# output_folder,
# objective,
# [("frequency (Hz)",2)],
# [
# ("nw",2,"branch",1,["pt","pf","qt","qf"]),
# ("nw",2,"branch",2,["pt","pf","qt","qf"]),
# ("nw",2,"branch",3,["pt","pf","qt","qf"]),
# ("nw",2,"branch",4,["pt","pf","qt","qf"]),
# ("nw",2,"branch",5,["pt","pf","qt","qf"]),
# ("nw",2,"branch",5,["pt","pf","qt","qf"]),
# ("nw",2,"branch",6,["pt","pf","qt","qf"]),
# ("nw",2,"branch",7,["pt","pf","qt","qf"]),
# ("nw",2,"branch",8,["pt","pf","qt","qf"])
# ];
# gen_areas=[2,3],
# area_transfer=[1,2]
# )
# @test isfile("results/results/nordic_fault/br27/time_0/plots/vs subnet 2 frequency (Hz)/total/total generation in areas 2 and 3 (p.u.) vs subnet 2 frequency (Hz).pdf")
# @test isfile("results/results/nordic_fault/br27/time_0/plots/vs subnet 2 frequency (Hz)/subnet1/subnet 1 line loss vs subnet 2 frequency (Hz).pdf")
# @test isfile("results/results/nordic_fault/br27/time_0/plots/vs subnet 2 frequency (Hz)/subnet2/subnet 2 converter loss vs subnet 2 frequency (Hz).pdf")
#
# try
# rm("results",force=true,recursive=true)
# catch IOError
# println("Unable to delete the results files generated by this test.")
# end
# end

0 comments on commit ad4b14e

Please sign in to comment.