Skip to content

Commit

Permalink
Add test for time domain reduction module
Browse files Browse the repository at this point in the history
  • Loading branch information
lbonaldo committed Feb 25, 2024
1 parent 153d4f3 commit 62ca711
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/TDR/Generators_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Resource,Zone,THERM,MUST_RUN,STOR,FLEX,HYDRO,VRE,LDS,Num_VRE_Bins,New_Build,Existing_Cap_MW,Existing_Cap_MWh,Existing_Charge_Cap_MW,Max_Cap_MW,Max_Cap_MWh,Max_Charge_Cap_MW,Min_Cap_MW,Min_Cap_MWh,Min_Charge_Cap_MW,Inv_Cost_per_MWyr,Inv_Cost_per_MWhyr,Inv_Cost_Charge_per_MWyr,Fixed_OM_Cost_per_MWyr,Fixed_OM_Cost_per_MWhyr,Fixed_OM_Cost_Charge_per_MWyr,Var_OM_Cost_per_MWh,Var_OM_Cost_per_MWh_In,Heat_Rate_MMBTU_per_MWh,Fuel,Cap_Size,Start_Cost_per_MW,Start_Fuel_MMBTU_per_MW,Up_Time,Down_Time,Ramp_Up_Percentage,Ramp_Dn_Percentage,Hydro_Energy_to_Power_Ratio,Min_Power,Self_Disch,Eff_Up,Eff_Down,Min_Duration,Max_Duration,Max_Flexible_Demand_Advance,Max_Flexible_Demand_Delay,Flexible_Demand_Energy_Eff,Reg_Max,Rsv_Max,Reg_Cost,Rsv_Cost,MaxCapTag_1,MaxCapTag_2,MaxCapTag_3,MinCapTag_1,MinCapTag_2,MinCapTag_3,MGA,Resource_Type,CapRes_1,ESR_1,ESR_2,region,cluster
natural_gas_combined_cycle,1,1,0,0,0,0,0,0,0,1,0,0,0,-1,-1,-1,0,0,0,65400,0,0,10287,0,0,3.55,0,7.43,NG,250,91,2,6,6,0.64,0.64,0,0.468,0,1,1,0,0,0,0,1,0.25,0.5,0,0,0,0,0,0,0,0,1,natural_gas_fired_combined_cycle,0.93,0,0,NE,1
solar_pv,1,0,0,0,0,0,1,0,1,1,0,0,0,-1,-1,-1,0,0,0,85300,0,0,18760,0,0,0,0,9.13,None,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,1,solar_photovoltaic,0.8,1,1,NE,1
onshore_wind,1,0,0,0,0,0,1,0,1,1,0,0,0,-1,-1,-1,0,0,0,97200,0,0,43205,0,0,0.1,0,9.12,None,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,1,onshore_wind_turbine,0.8,1,1,NE,1
battery,1,0,0,1,0,0,0,0,0,1,0,0,0,-1,-1,-1,0,0,0,19584,22494,0,4895,5622,0,0.15,0.15,0,None,0,0,0,0,0,1,1,0,0,0,0.92,0.92,1,10,0,0,1,0,0,0,0,0,0,1,0,0,1,0,battery_mid,0.95,0,0,NE,0
Binary file added test/TDR/clusters_true.jld2
Binary file not shown.
43 changes: 43 additions & 0 deletions test/time_domain_reduction.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module TestTDR

import Test, GenX, JLD2, Clustering

# suppress printing
console_out = stdout
redirect_stdout(devnull)

test_folder = settings_path = "TDR"

if isdir(joinpath(test_folder, "TDR_Results"))
rm(joinpath(test_folder, "TDR_Results"), recursive=true)
end

# Inputs for cluster_inputs function
genx_setup = Dict()
genx_setup["NetworkExpansion"] = 0
genx_setup["TimeDomainReduction"] = 1
genx_setup["TimeDomainReductionFolder"] = "TDR_Results"
genx_setup["MultiStage"] = 0
genx_setup["UCommit"] = 2
genx_setup["CapacityReserveMargin"] = 1
genx_setup["Reserves"] = 0
genx_setup["MinCapReq"] = 1
genx_setup["MaxCapReq"] = 1
genx_setup["EnergyShareRequirement"] = 1
genx_setup["CO2Cap"] = 2

clustering_test = GenX.cluster_inputs(test_folder, settings_path, genx_setup)["ClusterObject"]

# Load true clustering
clustering_true = JLD2.load(joinpath(test_folder,"clusters_true.jld2"))["ClusterObject"]

# Clustering validation
R = Clustering.randindex(clustering_test, clustering_true)[2]
I = Clustering.mutualinfo(clustering_test, clustering_true)

# restore printing
redirect_stdout(console_out)
Test.@test R > 0.9 # Rand index should be close to 1
Test.@test I > 0.8 # Mutual information should be close to 1

end # module TestTDR

0 comments on commit 62ca711

Please sign in to comment.