Skip to content

Commit

Permalink
Add multi_fuels test
Browse files Browse the repository at this point in the history
  • Loading branch information
lbonaldo committed Dec 5, 2023
1 parent 77afe78 commit 8f48fa4
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/MultiFuels/CO2_cap.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
,Network_zones,CO_2_Cap_Zone_1,CO_2_Max_tons_MWh_1,CO_2_Max_Mtons_1
NE,z1,1,0.05,0.018
2 changes: 2 additions & 0 deletions test/MultiFuels/Capacity_reserve_margin.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
,Network_zones,CapRes_1
NE,z1,0.156
25 changes: 25 additions & 0 deletions test/MultiFuels/Demand_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Voll,Demand_Segment,Cost_of_Demand_Curtailment_per_MW,Max_Demand_Curtailment,Rep_Periods,Timesteps_per_Rep_Period,Sub_Weights,Time_Index,Demand_MW_z1
50000,1,1,1,1,24,8760,1,11162
,,,,,,,2,10556
,,,,,,,3,10105
,,,,,,,4,9878
,,,,,,,5,9843
,,,,,,,6,10017
,,,,,,,7,10390
,,,,,,,8,10727
,,,,,,,9,11298
,,,,,,,10,11859
,,,,,,,11,12196
,,,,,,,12,12321
,,,,,,,13,12381
,,,,,,,14,12270
,,,,,,,15,12149
,,,,,,,16,12219
,,,,,,,17,13410
,,,,,,,18,14539
,,,,,,,19,14454
,,,,,,,20,14012
,,,,,,,21,13494
,,,,,,,22,12772
,,,,,,,23,11877
,,,,,,,24,10874
2 changes: 2 additions & 0 deletions test/MultiFuels/Energy_share_requirement.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
,Network_zones,ESR_1,ESR_2
NE,z1,0.259,0.348
26 changes: 26 additions & 0 deletions test/MultiFuels/Fuels_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Time_Index,NG,None,H2
0,0.05306,0,0
1,5.28,0,16
2,5.28,0,16
3,5.28,0,16
4,5.28,0,16
5,5.28,0,16
6,5.28,0,16
7,5.28,0,16
8,5.28,0,16
9,5.28,0,16
10,5.28,0,16
11,5.28,0,16
12,5.28,0,16
13,5.28,0,16
14,5.28,0,16
15,5.28,0,16
16,5.28,0,16
17,5.28,0,16
18,5.28,0,16
19,5.28,0,16
20,5.28,0,16
21,5.28,0,16
22,5.28,0,16
23,5.28,0,16
24,5.28,0,16
5 changes: 5 additions & 0 deletions test/MultiFuels/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,MULTI_FUELS,New_Build,Can_Retire,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,Num_Fuels,Fuel1,Heat_Rate1_MMBTU_per_MWh,Fuel1_Min_Cofire_Level,Fuel1_Max_Cofire_Level,Fuel1_Min_Cofire_Level_Start,Fuel1_Max_Cofire_Level_Start,Fuel2,Heat_Rate2_MMBTU_per_MWh,Fuel2_Min_Cofire_Level,Fuel2_Max_Cofire_Level,Fuel2_Min_Cofire_Level_Start,Fuel2_Max_Cofire_Level_Start
natural_gas_combined_cycle,1,1,0,0,0,0,0,0,0,1,1,0,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,2,NG,7.43,0,1,0,1,H2,7.43,0.05,1,0.05,1
solar_pv,1,0,0,0,0,0,1,0,1,0,1,0,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,1,None,0,0,0,0,0,None,0,0,0,0,1
onshore_wind,1,0,0,0,0,0,1,0,1,0,1,0,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,1,None,0,0,0,0,1,None,0,0,0,0,1
battery,1,0,0,1,0,0,0,0,0,0,1,0,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,1,None,0,0,0,0,0,None,0,0,0,0,1
25 changes: 25 additions & 0 deletions test/MultiFuels/Generators_variability.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Time_Index,natural_gas_combined_cycle,solar_pv,onshore_wind,battery
1,1,0,0.889717042,1
2,1,0,0.877715468,1
3,1,0,0.903424203,1
4,1,0,0.895153165,1
5,1,0,0.757258117,1
6,1,0,0.630928695,1
7,1,0,0.557177782,1
8,1,0,0.6072492,1
9,1,0.1779,0.423417866,1
10,1,0.429,0.007470775,1
11,1,0.5748,0.002535942,1
12,1,0.6484,0.002153709,1
13,1,0.6208,0.00445132,1
14,1,0.596,0.007711587,1
15,1,0.5013,0.100848213,1
16,1,0.3311,0.201802149,1
17,1,0.0642,0.141933054,1
18,1,0,0.567022562,1
19,1,0,0.946024895,1
20,1,0,0.923394203,1
21,1,0,0.953386247,1
22,1,0,0.929205418,1
23,1,0,0.849528909,1
24,1,0,0.665570974,1
4 changes: 4 additions & 0 deletions test/MultiFuels/Maximum_capacity_requirement.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MaxCapReqConstraint,ConstraintDescription,Max_MW
1,PV,50000
2,Wind,100000
3,Batteries,60000
4 changes: 4 additions & 0 deletions test/MultiFuels/Minimum_capacity_requirement.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MinCapReqConstraint,ConstraintDescription,Min_MW
1,PV,5000
2,Wind,10000
3,Batteries,6000
11 changes: 11 additions & 0 deletions test/MultiFuels/highs_settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# HiGHS Solver Parameters
# Common solver settings
Feasib_Tol: 1.0e-05 # Primal feasibility tolerance # [type: double, advanced: false, range: [1e-10, inf], default: 1e-07]
TimeLimit: 1.0e23 # Time limit # [type: double, advanced: false, range: [0, inf], default: inf]
Pre_Solve: on # Presolve option: "off", "choose" or "on" # [type: string, advanced: false, default: "choose"]
Method: ipm #HiGHS-specific solver settings # Solver option: "simplex", "choose" or "ipm" # [type: string, advanced: false, default: "choose"]
ipm_optimality_tolerance: 1e-04

# run the crossover routine for ipx
# [type: string, advanced: "on", range: {"off", "on"}, default: "off"]
run_crossover: "on"
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ end
@testset "Multi Stage" begin
include("test_multistage.jl")
end

@testset "Multi Fuels" begin
include("test_multifuels.jl")
end
end
52 changes: 52 additions & 0 deletions test/test_multifuels.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module TestMultiFuels

using Test

include(joinpath(@__DIR__, "utilities.jl"))

obj_true = 5494.7919354
test_path = "MultiFuels"

# Define test inputs
genx_setup = Dict(
"PrintModel" => 0,
"NetworkExpansion" => 0,
"Trans_Loss_Segments" => 1,
"Reserves" => 0,
"EnergyShareRequirement" => 1,
"CapacityReserveMargin" => 1,
"CO2Cap" => 0,
"StorageLosses" => 1,
"MinCapReq" => 1,
"MaxCapReq" => 1,
"ParameterScale" => 1,
"WriteShadowPrices" => 1,
"UCommit" => 2,
"TimeDomainReduction" => 0,
"TimeDomainReductionFolder" => "TDR_Results",
"MultiStage" => 0,
"ModelingToGenerateAlternatives" => 0,
"ModelingtoGenerateAlternativeSlack" => 0.1,
"ModelingToGenerateAlternativeIterations" => 3,
"MethodofMorris" => 0,
"EnableJuMPStringNames" => false,
"IncludeLossesInESR" => 0,
)

# Run the case and get the objective value and tolerance
EP, _, _ = redirect_stdout(devnull) do
run_genx_case_testing(test_path, genx_setup)
end
obj_test = objective_value(EP)
optimal_tol_rel = get_attribute(EP, "ipm_optimality_tolerance")
optimal_tol = optimal_tol_rel * obj_test # Convert to absolute tolerance

# Test the objective value
test_result = @test obj_test obj_true atol = optimal_tol

# Round objective value and tolerance. Write to test log.
obj_test = round_from_tol!(obj_test, optimal_tol)
optimal_tol = round_from_tol!(optimal_tol, optimal_tol)
write_testlog(test_path, obj_test, optimal_tol, test_result)

end # module TestMultiFuels

0 comments on commit 8f48fa4

Please sign in to comment.