Skip to content

Commit 383f03d

Browse files
committed
allow for 0.02 buffer in soc
1 parent 6295eb1 commit 383f03d

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/constraints/storage_constraints.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ function add_elec_storage_dispatch_constraints(m, p, b; _n="")
140140

141141
if (p.s.storage.attr[b] isa ElectricStorage || p.s.storage.attr[b] isa MPCElectricStorage) && !isnothing(p.s.storage.attr[b].fixed_soc_series_fraction)
142142
@constraint(m, [ts in p.time_steps],
143-
m[Symbol("dvStoredEnergy"*_n)][b, ts] == p.s.storage.attr[b].fixed_soc_series_fraction[ts] * m[Symbol("dvStorageEnergy"*_n)][b]
143+
# Allow for a 2% buffer on user-provided fixed_soc_series_fraction
144+
m[Symbol("dvStoredEnergy"*_n)][b, ts] <= (0.02 + p.s.storage.attr[b].fixed_soc_series_fraction[ts]) * m[Symbol("dvStorageEnergy"*_n)][b]
145+
)
146+
@constraint(m, [ts in p.time_steps],
147+
m[Symbol("dvStoredEnergy"*_n)][b, ts] >= (-0.02 + p.s.storage.attr[b].fixed_soc_series_fraction[ts]) * m[Symbol("dvStorageEnergy"*_n)][b]
144148
)
145149
end
146150
end

src/core/energy_storage/electric_storage.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ end
190190
optimize_soc_init_fraction::Bool = false # If true, soc_init_fraction will not apply. Model will optimize initial SOC and constrain initial SOC = final SOC.
191191
min_duration_hours::Real = 0.0 # Minimum amount of time storage can discharge at its rated power capacity
192192
max_duration_hours::Real = 100000.0 # Maximum amount of time storage can discharge at its rated power capacity (ratio of ElectricStorage size_kwh to size_kw)
193-
fixed_soc_series_fraction::Union{Nothing, Array{<:Real,1}} = nothing # If provided, SOC (as fraction of total energy capacity) will not be optimized and will instead be fixed in each timestep
193+
fixed_soc_series_fraction::Union{Nothing, Array{<:Real,1}} = nothing # If provided, SOC (as fraction of total energy capacity) will not be optimized and will instead be fixed to the values provided here +- 0.02 (this buffer is to avoid infeasible solutions)
194194
```
195195
"""
196196
Base.@kwdef struct ElectricStorageDefaults
@@ -306,10 +306,11 @@ struct ElectricStorage <: AbstractElectricStorage
306306
optimize_soc_init_fraction = s.optimize_soc_init_fraction
307307
soc_init_fraction = s.soc_init_fraction
308308
if !isnothing(s.fixed_soc_series_fraction)
309-
@warn "Fixing ElectricStorage soc_series_fraction to the provided fixed_soc_series_fraction."
309+
@warn "Fixing ElectricStorage soc_series_fraction to the provided fixed_soc_series_fraction. Other SOC inputs will be ignored."
310310
soc_min_fraction = 0.0
311311
optimize_soc_init_fraction = false
312312
soc_init_fraction = s.fixed_soc_series_fraction[1]
313+
error_if_series_vals_not_0_to_1(s.fixed_soc_series_fraction, "ElectricStorage", "fixed_soc_series_fraction")
313314
end
314315

315316
net_present_cost_per_kw = effective_cost(;

0 commit comments

Comments
 (0)