From 25409f6bf4da53e634d0f6e69832717102b24013 Mon Sep 17 00:00:00 2001 From: An Pham Date: Fri, 18 Oct 2024 22:34:36 -0600 Subject: [PATCH] only allow min/max_duration_hours in elec storage --- src/constraints/storage_constraints.jl | 14 +++++---- src/core/energy_storage/thermal_storage.jl | 34 +++++++++++----------- test/runtests.jl | 3 +- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/constraints/storage_constraints.jl b/src/constraints/storage_constraints.jl index c647c61d1..c5e8c5ec5 100644 --- a/src/constraints/storage_constraints.jl +++ b/src/constraints/storage_constraints.jl @@ -23,13 +23,15 @@ function add_storage_size_constraints(m, p, b; _n="") ) # Constraint (4c)-3: Limit on Storage Energy Capacity based on Duration Hours - @constraint(m, - m[Symbol("dvStorageEnergy"*_n)][b] <= m[Symbol("dvStoragePower"*_n)][b] * p.s.storage.attr[b].max_duration_hours - ) + if p.s.storage.attr[b] isa ElectricStorage + @constraint(m, + m[Symbol("dvStorageEnergy"*_n)][b] <= m[Symbol("dvStoragePower"*_n)][b] * p.s.storage.attr[b].max_duration_hours + ) - @constraint(m, - m[Symbol("dvStorageEnergy"*_n)][b] >= m[Symbol("dvStoragePower"*_n)][b] * p.s.storage.attr[b].min_duration_hours #p.s.storage.attr[b].min_duration_hours - ) + @constraint(m, + m[Symbol("dvStorageEnergy"*_n)][b] >= m[Symbol("dvStoragePower"*_n)][b] * p.s.storage.attr[b].min_duration_hours + ) + end end diff --git a/src/core/energy_storage/thermal_storage.jl b/src/core/energy_storage/thermal_storage.jl index de9920575..0a4e8ee0b 100644 --- a/src/core/energy_storage/thermal_storage.jl +++ b/src/core/energy_storage/thermal_storage.jl @@ -22,8 +22,8 @@ Cold thermal energy storage sytem; specifically, a chilled water system used to macrs_itc_reduction::Float64 = 0.5 total_itc_fraction::Float64 = 0.3 total_rebate_per_kwh::Float64 = 0.0 - min_duration_hours::Real = 0.0 - max_duration_hours::Real = 100000.0 + #min_duration_hours::Real = 0.0 + #max_duration_hours::Real = 100000.0 ``` """ Base.@kwdef struct ColdThermalStorageDefaults <: AbstractThermalStorageDefaults @@ -42,8 +42,8 @@ Base.@kwdef struct ColdThermalStorageDefaults <: AbstractThermalStorageDefaults macrs_itc_reduction::Float64 = 0.5 total_itc_fraction::Float64 = 0.3 total_rebate_per_kwh::Float64 = 0.0 - min_duration_hours::Real = 0.0 - max_duration_hours::Real = 100000.0 + #min_duration_hours::Real = 0.0 + #max_duration_hours::Real = 100000.0 end @@ -69,8 +69,8 @@ end can_serve_dhw::Bool = true can_serve_space_heating:Bool = true can_serve_process_heat::Bool = false - min_duration_hours::Real = 0.0 - max_duration_hours::Real = 100000.0 + #min_duration_hours::Real = 0.0 + #max_duration_hours::Real = 100000.0 ``` """ Base.@kwdef struct HotThermalStorageDefaults <: AbstractThermalStorageDefaults @@ -92,8 +92,8 @@ Base.@kwdef struct HotThermalStorageDefaults <: AbstractThermalStorageDefaults can_serve_dhw::Bool = true can_serve_space_heating::Bool = true can_serve_process_heat::Bool = false - min_duration_hours::Real = 0.0 - max_duration_hours::Real = 100000.0 + #min_duration_hours::Real = 0.0 + #max_duration_hours::Real = 100000.0 end @@ -127,8 +127,8 @@ struct ColdThermalStorage <: AbstractThermalStorage discharge_efficiency::Float64 net_present_cost_per_kwh::Float64 om_cost_per_kwh::Float64 - min_duration_hours::Real - max_duration_hours::Real + #min_duration_hours::Real + #max_duration_hours::Real function ColdThermalStorage(s::AbstractThermalStorageDefaults, f::Financial, time_steps_per_hour::Int) @@ -177,9 +177,9 @@ struct ColdThermalStorage <: AbstractThermalStorage charge_efficiency, discharge_efficiency, net_present_cost_per_kwh, - om_cost_per_kwh, - s.min_duration_hours, - s.max_duration_hours + om_cost_per_kwh + #s.min_duration_hours, + #s.max_duration_hours ) end end @@ -217,8 +217,8 @@ struct HotThermalStorage <: AbstractThermalStorage can_serve_dhw::Bool can_serve_space_heating::Bool can_serve_process_heat::Bool - min_duration_hours::Real - max_duration_hours::Real + #min_duration_hours::Real + #max_duration_hours::Real function HotThermalStorage(s::AbstractThermalStorageDefaults, f::Financial, time_steps_per_hour::Int) @@ -272,8 +272,8 @@ struct HotThermalStorage <: AbstractThermalStorage s.can_serve_dhw, s.can_serve_space_heating, s.can_serve_process_heat, - s.min_duration_hours, - s.max_duration_hours + #s.min_duration_hours, + #s.max_duration_hours ) end end diff --git a/test/runtests.jl b/test/runtests.jl index 0a0723cb1..cafd0b300 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2861,6 +2861,7 @@ else # run HiGHS tests end @testset "Storage Duration" begin + ## Battery storage d = JSON.parsefile("scenarios/pv_storage.json") d["ElectricStorage"]["min_duration_hours"] = 8 d["ElectricStorage"]["max_duration_hours"] = 8 @@ -2868,9 +2869,9 @@ else # run HiGHS tests inputs = REoptInputs(s) m = Model(optimizer_with_attributes(HiGHS.Optimizer, "output_flag" => false, "log_to_console" => false)) r = run_reopt(m, inputs) - # Test battery size_kwh = size_hw * duration @test r["ElectricStorage"]["size_kw"]*8 - r["ElectricStorage"]["size_kwh"] ≈ 0.0 atol = 0.1 + end end end \ No newline at end of file