Skip to content

Commit

Permalink
Refactor storage_asymmetric
Browse files Browse the repository at this point in the history
  • Loading branch information
cfe316 committed Oct 13, 2023
1 parent b77e880 commit b88ca26
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions src/model/resources/storage/storage_asymmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,21 @@ Sets up variables and constraints specific to storage resources with asymmetric
"""
function storage_asymmetric_reserves!(EP::Model, inputs::Dict, setup::Dict)

dfGen = inputs["dfGen"]
T = inputs["T"]
CapacityReserveMargin = setup["CapacityReserveMargin"]
T = 1:inputs["T"]
CapacityReserveMargin = setup["CapacityReserveMargin"] > 0

STOR_ASYMMETRIC = inputs["STOR_ASYMMETRIC"]

STOR_ASYM_REG = intersect(STOR_ASYMMETRIC, inputs["REG"]) # Set of asymmetric storage resources with REG reserves
STOR_ASYM_NO_REG = setdiff(STOR_ASYMMETRIC, STOR_ASYM_REG) # Set of asymmetric storage resources without REG reserves

if !isempty(STOR_ASYM_REG)
if CapacityReserveMargin > 0
# Storage units charging can charge faster to provide reserves down and charge slower to provide reserves up
# Maximum charging rate plus contribution to regulation down must be less than charge power rating
@constraint(EP, [y in STOR_ASYM_REG, t in 1:T], EP[:vCHARGE][y,t]+EP[:vREG_charge][y,t]+EP[:vCAPRES_charge][y,t] <= EP[:eTotalCapCharge][y])
else
# Storage units charging can charge faster to provide reserves down and charge slower to provide reserves up
# Maximum charging rate plus contribution to regulation down must be less than charge power rating
@constraint(EP, [y in STOR_ASYM_REG, t in 1:T], EP[:vCHARGE][y,t]+EP[:vREG_charge][y,t]<= EP[:eTotalCapCharge][y])
end
else
if CapacityReserveMargin > 0
# Storage units charging can charge faster to provide reserves down and charge slower to provide reserves up
# Maximum charging rate plus contribution to regulation down must be less than charge power rating
@constraint(EP, [y in STOR_ASYM_NO_REG, t in 1:T], EP[:vCHARGE][y,t]+EP[:vCAPRES_charge][y,t] <= EP[:eTotalCapCharge][y])
else
# Storage units charging can charge faster to provide reserves down and charge slower to provide reserves up
# Maximum charging rate plus contribution to regulation down must be less than charge power rating
@constraint(EP, [y in STOR_ASYM_NO_REG, t in 1:T], EP[:vCHARGE][y,t]<= EP[:eTotalCapCharge][y])
end
end

vCHARGE = EP[:vCHARGE]
vREG_charge = EP[:vREG_charge]
vCAPRES_charge = EP[:vCAPRES_charge]
eTotalCapCharge = EP[:eTotalCapCharge]

expr = @expression(EP, [y in STOR_ASYMMETRIC, t in T], 1 * vCHARGE[y, t]) # NOTE load-bearing "1 *"
add_similar_to_expression!(expr[STOR_ASYM_REG, :], vREG_charge[STOR_ASYM_REG, :])
if CapacityReserveMargin
add_similar_to_expression!(expr[STOR_ASYMMETRIC, :], vCAPRES_charge[STOR_ASYMMETRIC, :])
end
@constraint(EP, [y in STOR_ASYMMETRIC, t in T], expr[y, t] <= eTotalCapCharge[y])
end

0 comments on commit b88ca26

Please sign in to comment.