diff --git a/src/model/core/transmission.jl b/src/model/core/transmission.jl index f56e30c618..d19310e5ff 100644 --- a/src/model/core/transmission.jl +++ b/src/model/core/transmission.jl @@ -102,7 +102,6 @@ function transmission!(EP::Model, inputs::Dict, setup::Dict) UCommit = setup["UCommit"] NetworkExpansion = setup["NetworkExpansion"] - CapacityReserveMargin = setup["CapacityReserveMargin"] MultiStage = setup["MultiStage"] ## sets and indices for transmission losses and expansion diff --git a/src/model/policies/cap_reserve_margin.jl b/src/model/policies/cap_reserve_margin.jl index 09bd28e39a..af81d872e1 100644 --- a/src/model/policies/cap_reserve_margin.jl +++ b/src/model/policies/cap_reserve_margin.jl @@ -61,10 +61,9 @@ function cap_reserve_margin!(EP::Model, inputs::Dict, setup::Dict) SEG = inputs["SEG"] Z = inputs["Z"] L = inputs["L"] - OperationWrapping = setup["OperationWrapping"] START_SUBPERIODS = inputs["START_SUBPERIODS"] INTERIOR_SUBPERIODS = inputs["INTERIOR_SUBPERIODS"] - hours_per_subperiod = inputs["hours_per_subperiod"] #total number of hours per subperiod + p = inputs["hours_per_subperiod"] #total number of hours per subperiod println("Capacity Reserve Margin Policies Module") @expression(EP, eCapResMarBalance[res=1:NCRM, t=1:T], 1*EP[:vZERO]) @@ -95,8 +94,8 @@ function cap_reserve_margin!(EP::Model, inputs::Dict, setup::Dict) if Z > 1 @expression(EP, eCapContributionTransAll[res=1:NCRM, t = 1:T], - sum(inputs["dfCapRes_network"][l, Symbol("DerateCapRes_$res")] * - inputs["dfCapRes_network"][l, Symbol("CapRes_Excl_$res")] * + sum(inputs["dfDerateTransCapRes"][l, res] * + inputs["dfTransCapRes_excl"][l, res] * vCapContributionTrans[l, t] for l in 1:L) ) add_to_expression!.(EP[:eCapResMarBalance], EP[:eCapContributionTransAll]) @@ -131,21 +130,10 @@ function cap_reserve_margin!(EP::Model, inputs::Dict, setup::Dict) if !isempty(STOR_ALL) @constraint(EP, cCapContriSTORCap[y in STOR_ALL, t = 1:T], EP[:vCapContribution][y, t] <= (EP[:eTotalCap][y])) - if OperationWrapping ==1 - @constraint(EP, cCapContriSTORSoC_Start[y in STOR_ALL, t in START_SUBPERIODS], - EP[:vCapContribution][y, t] <= (EP[:vS][y, t + hours_per_subperiod - 1] * - dfGen[y, :Eff_Down]/ dfGen[y, :CapRes_duration_requirement]) - ) - @constraint(EP, cCapContriSTORSoC_Interior[y in STOR_ALL, t in INTERIOR_SUBPERIODS], - EP[:vCapContribution][y, t] <= (EP[:vS][y, t - 1]* - dfGen[y, :Eff_Down]/ dfGen[y, :CapRes_duration_requirement]) - ) - else - @constraint(EP, cCapContriSTORSoC[y in STOR_ALL, t = 2:T], - EP[:vCapContribution][y, t] <= (EP[:vS][y, t-1]* - dfGen[y, :Eff_Down]/ dfGen[y, :CapRes_duration_requirement]) - ) - end + + @constraint(EP, cCapContriSTORSoC[y in STOR_ALL, t = 1:T], + EP[:vCapContribution][y, t] <= (EP[:vS][y, hoursbefore(p,t,1)]* + dfGen[y, :Eff_Down]/ dfGen[y, :CapRes_duration_requirement])) end # Flexible demand @@ -159,7 +147,7 @@ function cap_reserve_margin!(EP::Model, inputs::Dict, setup::Dict) if SEG >= 2 @expression(EP, eCapResMarBalanceNSE[res=1:NCRM, t=1:T], sum(EP[:eDemandResponse][t, z] - for z in findall(x -> x != 0, inputs["dfCapRes"][:, Symbol("CapRes_$res")]))) + for z in findall(x -> x != 0, inputs["dfCapRes"][:, res]))) add_to_expression!.(EP[:eCapResMarBalance], EP[:eCapResMarBalanceNSE]) end @@ -171,7 +159,7 @@ function cap_reserve_margin!(EP::Model, inputs::Dict, setup::Dict) end @constraint(EP, cCapacityResMargin[res=1:NCRM, t=1:T], EP[:eCapResMarBalance][res, t] - >= sum(inputs["pD"][t,z] * (1 + inputs["dfCapRes"][z,Symbol("CapRes_$res")]) - for z=findall(x -> x != 0,inputs["dfCapRes"][:,Symbol("CapRes_$res")]))) + >= sum(inputs["pD"][t,z] * (1 + inputs["dfCapRes"][z,res]) + for z=findall(x -> x != 0,inputs["dfCapRes"][:,res]))) end diff --git a/src/write_outputs/capacity_reserve_margin/write_reserve_margin_demand_response_saving.jl b/src/write_outputs/capacity_reserve_margin/write_reserve_margin_demand_response_saving.jl index 871d50e61e..5a0183c85f 100644 --- a/src/write_outputs/capacity_reserve_margin/write_reserve_margin_demand_response_saving.jl +++ b/src/write_outputs/capacity_reserve_margin/write_reserve_margin_demand_response_saving.jl @@ -26,13 +26,13 @@ function write_reserve_margin_demand_response_saving(path::AbstractString, input dfResDRSaving = DataFrame(Zone = 1:Z, AnnualSum = zeros(Z)) for i in 1:inputs["NCapacityReserveMargin"] pariticpatingzone = zeros(Z) - pariticpatingzone[findall(x -> x != 0, inputs["dfCapRes"][:, Symbol("CapRes_$i")])] .= 1 + pariticpatingzone[findall(x -> x != 0, inputs["dfCapRes"][:, i])] .= 1 resdrsaving = (transpose(value.(EP[:eDemandResponse])) .* pariticpatingzone) * dual.(EP[:cCapacityResMargin][i, :]) if setup["ParameterScale"] == 1 resdrsaving *= ModelScalingFactor^2 end dfResDRSaving.AnnualSum .+= resdrsaving - dfResDRSaving = hcat(dfResDRSaving, DataFrame([resdrsaving], [Symbol("CapRes_$i")])) + dfResDRSaving = hcat(dfResDRSaving, DataFrame([resdrsaving], i)) end CSV.write(joinpath(path, "ReserveMarginDemandResponseSaving.csv"), dfResDRSaving) return dfResDRSaving diff --git a/src/write_outputs/capacity_reserve_margin/write_reserve_margin_payment.jl b/src/write_outputs/capacity_reserve_margin/write_reserve_margin_payment.jl index de34d4ec42..40ded5dbba 100644 --- a/src/write_outputs/capacity_reserve_margin/write_reserve_margin_payment.jl +++ b/src/write_outputs/capacity_reserve_margin/write_reserve_margin_payment.jl @@ -21,8 +21,8 @@ function write_reserve_margin_payment(path::AbstractString, inputs::Dict, setup: Z = inputs["Z"] # Number of zonests dfResPayment = DataFrame(Zone = 1:Z, AnnualSum = zeros(Z)) for i in 1:inputs["NCapacityReserveMargin"] - oneplusreservemargin = (inputs["dfCapRes"][:, Symbol("CapRes_$i")] .+ 1) - oneplusreservemargin[findall(x -> x == 0, inputs["dfCapRes"][:, Symbol("CapRes_$i")])] .= 0 + oneplusreservemargin = (inputs["dfCapRes"][:, i] .+ 1) + oneplusreservemargin[findall(x -> x == 0, inputs["dfCapRes"][:, i])] .= 0 reservemarginpayment = (transpose(inputs["pD"]) .* oneplusreservemargin) * dual.(EP[:cCapacityResMargin][i, :]) if setup["ParameterScale"] == 1 reservemarginpayment *= (ModelScalingFactor^2) diff --git a/src/write_outputs/capacity_reserve_margin/write_reserve_margin_transmission_revenue.jl b/src/write_outputs/capacity_reserve_margin/write_reserve_margin_transmission_revenue.jl index e07e617631..b0d6744823 100644 --- a/src/write_outputs/capacity_reserve_margin/write_reserve_margin_transmission_revenue.jl +++ b/src/write_outputs/capacity_reserve_margin/write_reserve_margin_transmission_revenue.jl @@ -22,8 +22,8 @@ function write_reserve_margin_transmission_revenue(path::AbstractString, inputs: dfResTransRevenue = DataFrame(Line = 1:L, AnnualSum = zeros(L)) for i in 1:inputs["NCapacityReserveMargin"] restransrevenue = (value.(EP[:vCapContributionTrans]) .* - inputs["dfCapRes_network"][:, Symbol("DerateCapRes_$i")] .* - inputs["dfCapRes_network"][:, Symbol("CapRes_Excl_$i")]) * + inputs["dfDerateTransCapRes"][:, i] .* + inputs["dfTransCapRes_excl"][:, i]) * dual.(EP[:cCapacityResMargin][i, :]) if setup["ParameterScale"] == 1 restransrevenue *= (ModelScalingFactor^2)