From 8dac1ff55d617e2607a74533854f398a1635cbaf Mon Sep 17 00:00:00 2001 From: adfarth Date: Mon, 9 Dec 2024 15:50:17 -0700 Subject: [PATCH 1/4] initial commit --- CHANGELOG.md | 4 ++++ src/constraints/electric_utility_constraints.jl | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14896e890..267030dfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,10 @@ Classify the change according to the following categories: ### Removed +## nem-export +### Fixed +- Constrained export to grid in the NEM bin (`dvProductionToGrid"*_n)][t, :NEM, ts`) to be 0 when system is sized over NEM limit (i.e., when binNEM =0) + ## Develop ### Added - Battery residual value if choosing replacement strategy for degradation diff --git a/src/constraints/electric_utility_constraints.jl b/src/constraints/electric_utility_constraints.jl index c1842f578..052d58b1f 100644 --- a/src/constraints/electric_utility_constraints.jl +++ b/src/constraints/electric_utility_constraints.jl @@ -55,7 +55,6 @@ function add_export_constraints(m, p; _n="") max_bene = sum([ld*rate for (ld,rate) in zip(p.s.electric_load.loads_kw, p.s.electric_tariff.export_rates[:NEM])])*p.pwf_e*p.hours_per_time_step*10 NEM_benefit = @variable(m, lower_bound = max_bene) - # If choosing to take advantage of NEM, must have total capacity less than net_metering_limit_kw if solver_is_compatible_with_indicator_constraints(p.s.settings.solver_name) @constraint(m, @@ -92,6 +91,10 @@ function add_export_constraints(m, p; _n="") } ) @constraint(m, !binNEM => {NEM_benefit >= 0}) + @constraint(m,[ts in p.time_steps_with_grid, t in p.techs_by_exportbin[:NEM]], + !binNEM => { m[Symbol("dvProductionToGrid"*_n)][t, :NEM, ts] == 0 + } + ) else @constraint(m, NEM_benefit >= p.pwf_e * p.hours_per_time_step * @@ -99,6 +102,10 @@ function add_export_constraints(m, p; _n="") for t in p.techs_by_exportbin[:NEM]) for ts in p.time_steps) ) @constraint(m, NEM_benefit >= max_bene * binNEM) + @constraint(m,[ts in p.time_steps_with_grid, t in p.techs_by_exportbin[:NEM]], + m[Symbol("dvProductionToGrid"*_n)][t, :NEM, ts] <= binNEM * sum(p.s.electric_load.loads_kw) + ) + p.s.electric_load.loads_kw end EXC_benefit = 0 From 9e5e5cf7cd1f68623cef6467cdd9940ded61ef49 Mon Sep 17 00:00:00 2001 From: adfarth Date: Tue, 10 Dec 2024 08:12:06 -0700 Subject: [PATCH 2/4] Update electric_utility_constraints.jl --- src/constraints/electric_utility_constraints.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/constraints/electric_utility_constraints.jl b/src/constraints/electric_utility_constraints.jl index 052d58b1f..88b0f7a82 100644 --- a/src/constraints/electric_utility_constraints.jl +++ b/src/constraints/electric_utility_constraints.jl @@ -105,7 +105,6 @@ function add_export_constraints(m, p; _n="") @constraint(m,[ts in p.time_steps_with_grid, t in p.techs_by_exportbin[:NEM]], m[Symbol("dvProductionToGrid"*_n)][t, :NEM, ts] <= binNEM * sum(p.s.electric_load.loads_kw) ) - p.s.electric_load.loads_kw end EXC_benefit = 0 From 063f74cfaa9652d771fd0639562ec3ba61a7346e Mon Sep 17 00:00:00 2001 From: adfarth Date: Tue, 10 Dec 2024 10:20:03 -0700 Subject: [PATCH 3/4] add a test --- test/runtests.jl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 0d355fae0..792bb3082 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -652,7 +652,15 @@ else # run HiGHS tests m = Model(optimizer_with_attributes(HiGHS.Optimizer, "output_flag" => false, "log_to_console" => false)) results = run_reopt(m, d) @test results["PV"]["size_kw"] ≈ 7440.0 atol=1e-3 #max benefit provides the upper bound - + + #case 3: net metering limit is exceeded, no WHL, and min RE % + d["ElectricTariff"]["wholesale_rate"] = 0 + d["PV"]["min_kw"] = 50 + d["Site"]["renewable_electricity_min_fraction"] = 0.35 + m = Model(optimizer_with_attributes(HiGHS.Optimizer, "output_flag" => false, "log_to_console" => false)) + results = run_reopt(m, d) + @test sum(results["PV"]["electric_to_grid_series_kw"]) ≈ 0.0 atol=1e-3 + @test results["ElectricTariff"]["lifecycle_export_benefit_after_tax"] ≈ 0.0 atol=1e-3 end end From 8510b03d1f024168b8903ad885f6f00a2d7e51a3 Mon Sep 17 00:00:00 2001 From: Hallie Dunham <70401017+hdunham@users.noreply.github.com> Date: Fri, 20 Dec 2024 14:10:44 -0700 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f9159e9f..4fe7b6287 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ Classify the change according to the following categories: ### Removed -## nem-export +## Develop ### Fixed - Constrained export to grid in the NEM bin (`dvProductionToGrid"*_n)][t, :NEM, ts`) to be 0 when system is sized over NEM limit (i.e., when binNEM =0)