From a76c3d225df3a8ac2fe48c91bc33f8444eff6d7d Mon Sep 17 00:00:00 2001 From: lbonaldo Date: Thu, 14 Dec 2023 18:53:47 -0500 Subject: [PATCH] Rename res into gen --- .../modeling_to_generate_alternatives.jl | 8 +-- src/load_inputs/load_reserves.jl | 6 +-- src/model/core/co2.jl | 20 +++---- src/model/core/discharge/discharge.jl | 6 +-- .../core/discharge/investment_discharge.jl | 36 ++++++------- src/model/core/fuel.jl | 20 +++---- src/model/core/reserves.jl | 12 ++--- .../hydro/hydro_inter_period_linkage.jl | 6 +-- src/model/resources/hydro/hydro_res.jl | 6 +-- src/model/resources/hydrogen/electrolyzer.jl | 22 ++++---- .../resources/storage/investment_charge.jl | 12 ++--- .../resources/storage/investment_energy.jl | 18 +++---- .../storage/long_duration_storage.jl | 10 ++-- src/model/resources/storage/storage_all.jl | 38 ++++++------- .../resources/storage/storage_asymmetric.jl | 2 +- src/model/resources/thermal/thermal.jl | 2 +- src/model/resources/thermal/thermal_commit.jl | 54 +++++++++---------- .../resources/thermal/thermal_no_commit.jl | 18 +++---- src/model/resources/vre_stor/vre_stor.jl | 50 ++++++++--------- src/multi_stage/endogenous_retirement.jl | 54 +++++++++---------- .../write_capacity_value.jl | 4 +- .../write_reserve_margin_revenue.jl | 8 +-- .../write_virtual_discharge.jl | 4 +- .../write_opwrap_lds_dstor.jl | 4 +- .../write_opwrap_lds_stor_init.jl | 4 +- src/write_outputs/reserves/write_reg.jl | 4 +- src/write_outputs/reserves/write_rsv.jl | 4 +- src/write_outputs/ucommit/write_commit.jl | 4 +- src/write_outputs/ucommit/write_shutdown.jl | 4 +- src/write_outputs/ucommit/write_start.jl | 4 +- src/write_outputs/write_capacity.jl | 18 +++---- src/write_outputs/write_capacityfactor.jl | 4 +- src/write_outputs/write_charge.jl | 4 +- src/write_outputs/write_charging_cost.jl | 16 +++--- src/write_outputs/write_co2.jl | 10 ++-- src/write_outputs/write_costs.jl | 8 +-- src/write_outputs/write_curtailment.jl | 4 +- src/write_outputs/write_emissions.jl | 1 - src/write_outputs/write_energy_revenue.jl | 12 ++--- src/write_outputs/write_fuel_consumption.jl | 6 +-- src/write_outputs/write_net_revenue.jl | 26 ++++----- src/write_outputs/write_nse.jl | 1 - src/write_outputs/write_power.jl | 4 +- src/write_outputs/write_power_balance.jl | 18 +++---- src/write_outputs/write_storage.jl | 4 +- src/write_outputs/write_storagedual.jl | 4 +- src/write_outputs/write_subsidy_revenue.jl | 16 +++--- src/write_outputs/write_vre_stor.jl | 4 +- 48 files changed, 301 insertions(+), 303 deletions(-) diff --git a/src/additional_tools/modeling_to_generate_alternatives.jl b/src/additional_tools/modeling_to_generate_alternatives.jl index 6e7b92eea6..8d025bf209 100644 --- a/src/additional_tools/modeling_to_generate_alternatives.jl +++ b/src/additional_tools/modeling_to_generate_alternatives.jl @@ -27,13 +27,13 @@ function mga(EP::Model, path::AbstractString, setup::Dict, inputs::Dict, outpath Least_System_Cost = objective_value(EP) # Read sets - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) Z = inputs["Z"] # Number of zonests zones = unique(inputs["R_ZONES"]) # Create a set of unique technology types - resources_with_mga = resources_with_mga(res) + resources_with_mga = resources_with_mga(gen) TechTypes = unique(resource_type.(resources_with_mga)) # Read slack parameter representing desired increase in budget from the least cost solution @@ -52,8 +52,8 @@ function mga(EP::Model, path::AbstractString, setup::Dict, inputs::Dict, outpath # Constraint to compute total generation in each zone from a given Technology Type function resource_in_zone_with_TechType(tt::Int64, z::Int64) - condition::BitVector = (resource_type.(res) .== TechTypes[tt]) .& (zone_id.(res) .== z) - return resource_id.(res[condition]) + condition::BitVector = (resource_type.(gen) .== TechTypes[tt]) .& (zone_id.(gen) .== z) + return resource_id.(gen[condition]) end @constraint(EP,cGeneration[tt = 1:length(TechTypes), z = 1:Z], vSumvP[tt,z] == sum(EP[:vP][y,t] * inputs["omega"][t] for y in resource_in_zone_with_TechType(tt,z), t in 1:T)) diff --git a/src/load_inputs/load_reserves.jl b/src/load_inputs/load_reserves.jl index 830565c1ea..05b2e67293 100644 --- a/src/load_inputs/load_reserves.jl +++ b/src/load_inputs/load_reserves.jl @@ -7,7 +7,7 @@ function load_reserves!(setup::Dict, path::AbstractString, inputs::Dict) filename = "Reserves.csv" res_in = load_dataframe(joinpath(path, filename)) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] function load_field_with_deprecated_symbol(df::DataFrame, columns::Vector{Symbol}) best = popfirst!(columns) @@ -52,11 +52,11 @@ function load_reserves!(setup::Dict, path::AbstractString, inputs::Dict) if inputs["pDynamic_Contingency"] > 0 inputs["pContingency_BigM"] = zeros(Float64, inputs["G"]) for y in inputs["COMMIT"] - inputs["pContingency_BigM"][y] = max_capacity_mw(res[y]) + inputs["pContingency_BigM"][y] = max_capacity_mw(gen[y]) # When Max_Cap_MW == -1, there is no limit on capacity size if inputs["pContingency_BigM"][y] < 0 # NOTE: this effectively acts as a maximum cluster size when not otherwise specified, adjust accordingly - inputs["pContingency_BigM"][y] = 5000 * cap_size(res[y]) + inputs["pContingency_BigM"][y] = 5000 * cap_size(gen[y]) end end end diff --git a/src/model/core/co2.jl b/src/model/core/co2.jl index cbca927b26..114c8eabba 100644 --- a/src/model/core/co2.jl +++ b/src/model/core/co2.jl @@ -54,7 +54,7 @@ function co2!(EP::Model, inputs::Dict) println("CO2 Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) Z = inputs["Z"] # Number of zones @@ -63,21 +63,21 @@ function co2!(EP::Model, inputs::Dict) ### Expressions ### # CO2 emissions from power plants in "Generators_data.csv" # If all the CO2 capture fractions from Generators_data are zeros, the CO2 emissions from thermal generators are determined by fuel consumption times CO2 content per MMBTU - if all(co2_capture_fraction.(res) .==0) + if all(co2_capture_fraction.(gen) .==0) @expression(EP, eEmissionsByPlant[y=1:G, t=1:T], - ((1-biomass(res[y])) *(EP[:vFuel][y, t] + EP[:eStartFuel][y, t]) * fuel_CO2[fuel(res[y])])) + ((1-biomass(gen[y])) *(EP[:vFuel][y, t] + EP[:eStartFuel][y, t]) * fuel_CO2[fuel(gen[y])])) else @info "Using the CO2 module to determine the CO2 emissions of CCS-equipped plants" # CO2_Capture_Fraction refers to the CO2 capture rate of CCS equiped power plants at a steady state # CO2_Capture_Fraction_Startup refers to the CO2 capture rate of CCS equiped power plants during startup events @expression(EP, eEmissionsByPlant[y=1:G, t=1:T], - (1-biomass(res[y]) - co2_capture_fraction(res[y])) * EP[:vFuel][y, t] * fuel_CO2[fuel(res[y])]+ - (1-biomass(res[y]) - co2_capture_fraction_startup(res[y])) * EP[:eStartFuel][y, t] * fuel_CO2[fuel(res[y])]) + (1-biomass(gen[y]) - co2_capture_fraction(gen[y])) * EP[:vFuel][y, t] * fuel_CO2[fuel(gen[y])]+ + (1-biomass(gen[y]) - co2_capture_fraction_startup(gen[y])) * EP[:eStartFuel][y, t] * fuel_CO2[fuel(gen[y])]) # CO2 captured from power plants in "Generators_data.csv" @expression(EP, eEmissionsCaptureByPlant[y=1:G, t=1:T], - co2_capture_fraction(res[y]) * EP[:vFuel][y, t] * fuel_CO2[fuel(res[y])]+ - co2_capture_fraction_startup(res[y]) * EP[:eStartFuel][y, t] * fuel_CO2[fuel(res[y])]) + co2_capture_fraction(gen[y]) * EP[:vFuel][y, t] * fuel_CO2[fuel(gen[y])]+ + co2_capture_fraction_startup(gen[y]) * EP[:eStartFuel][y, t] * fuel_CO2[fuel(gen[y])]) @expression(EP, eEmissionsCaptureByPlantYear[y=1:G], sum(inputs["omega"][t] * eEmissionsCaptureByPlant[y, t] @@ -86,10 +86,10 @@ function co2!(EP::Model, inputs::Dict) # when scale factor is on tCO2/MWh = > kt CO2/GWh @expression(EP, ePlantCCO2Sequestration[y=1:G], sum(inputs["omega"][t] * eEmissionsCaptureByPlant[y, t] * - ccs_disposal_cost_per_metric_ton(res[y]) for t in 1:T)) + ccs_disposal_cost_per_metric_ton(gen[y]) for t in 1:T)) @expression(EP, eZonalCCO2Sequestration[z=1:Z], - sum(ePlantCCO2Sequestration[y] for y in resources_in_zone_by_rid(res,z))) + sum(ePlantCCO2Sequestration[y] for y in resources_in_zone_by_rid(gen,z))) @expression(EP, eTotaleCCO2Sequestration, sum(eZonalCCO2Sequestration[z] for z in 1:Z)) @@ -99,7 +99,7 @@ function co2!(EP::Model, inputs::Dict) # emissions by zone @expression(EP, eEmissionsByZone[z = 1:Z, t = 1:T], - sum(eEmissionsByPlant[y, t] for y in resources_in_zone_by_rid(res,z))) + sum(eEmissionsByPlant[y, t] for y in resources_in_zone_by_rid(gen,z))) return EP end diff --git a/src/model/core/discharge/discharge.jl b/src/model/core/discharge/discharge.jl index 2a6126734c..2963c7f206 100644 --- a/src/model/core/discharge/discharge.jl +++ b/src/model/core/discharge/discharge.jl @@ -13,7 +13,7 @@ function discharge!(EP::Model, inputs::Dict, setup::Dict) println("Discharge Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps @@ -28,7 +28,7 @@ function discharge!(EP::Model, inputs::Dict, setup::Dict) ## Objective Function Expressions ## # Variable costs of "generation" for resource "y" during hour "t" = variable O&M - @expression(EP, eCVar_out[y=1:G,t=1:T], (inputs["omega"][t]*(var_om_cost_per_mwh(res[y])*vP[y,t]))) + @expression(EP, eCVar_out[y=1:G,t=1:T], (inputs["omega"][t]*(var_om_cost_per_mwh(gen[y])*vP[y,t]))) # Sum individual resource contributions to variable discharging costs to get total variable discharging costs @expression(EP, eTotalCVarOutT[t=1:T], sum(eCVar_out[y,t] for y in 1:G)) @expression(EP, eTotalCVarOut, sum(eTotalCVarOutT[t] for t in 1:T)) @@ -40,7 +40,7 @@ function discharge!(EP::Model, inputs::Dict, setup::Dict) if setup["EnergyShareRequirement"] >= 1 @expression(EP, eESRDischarge[ESR=1:inputs["nESR"]], - + sum(inputs["omega"][t] * esr(res[y],tag=ESR) * EP[:vP][y,t] for y=has_esr(res,tag=ESR), t=1:T) + + sum(inputs["omega"][t] * esr(gen[y],tag=ESR) * EP[:vP][y,t] for y=has_esr(gen,tag=ESR), t=1:T) - sum(inputs["dfESR"][z,ESR]*inputs["omega"][t]*inputs["pD"][t,z] for t=1:T, z=findall(x->x>0,inputs["dfESR"][:,ESR])) ) add_similar_to_expression!(EP[:eESR], eESRDischarge) diff --git a/src/model/core/discharge/investment_discharge.jl b/src/model/core/discharge/investment_discharge.jl index 471474865e..f5e42ffc8a 100644 --- a/src/model/core/discharge/investment_discharge.jl +++ b/src/model/core/discharge/investment_discharge.jl @@ -37,7 +37,7 @@ function investment_discharge!(EP::Model, inputs::Dict, setup::Dict) println("Investment Discharge Module") MultiStage = setup["MultiStage"] - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) @@ -80,7 +80,7 @@ function investment_discharge!(EP::Model, inputs::Dict, setup::Dict) if MultiStage == 1 @expression(EP, eExistingCap[y in 1:G], vEXISTINGCAP[y]) else - @expression(EP, eExistingCap[y in 1:G], existing_capacity_mw(res[y])) + @expression(EP, eExistingCap[y in 1:G], existing_capacity_mw(gen[y])) end # Cap_Size is set to 1 for all variables when unit UCommit == 0 @@ -88,19 +88,19 @@ function investment_discharge!(EP::Model, inputs::Dict, setup::Dict) @expression(EP, eTotalCap[y in 1:G], if y in intersect(NEW_CAP, RET_CAP) # Resources eligible for new capacity and retirements if y in COMMIT - eExistingCap[y] + cap_size(res[y])*(EP[:vCAP][y] - EP[:vRETCAP][y]) + eExistingCap[y] + cap_size(gen[y])*(EP[:vCAP][y] - EP[:vRETCAP][y]) else eExistingCap[y] + EP[:vCAP][y] - EP[:vRETCAP][y] end elseif y in setdiff(NEW_CAP, RET_CAP) # Resources eligible for only new capacity if y in COMMIT - eExistingCap[y] + cap_size(res[y])*EP[:vCAP][y] + eExistingCap[y] + cap_size(gen[y])*EP[:vCAP][y] else eExistingCap[y] + EP[:vCAP][y] end elseif y in setdiff(RET_CAP, NEW_CAP) # Resources eligible for only capacity retirements if y in COMMIT - eExistingCap[y] - cap_size(res[y])*EP[:vRETCAP][y] + eExistingCap[y] - cap_size(gen[y])*EP[:vRETCAP][y] else eExistingCap[y] - EP[:vRETCAP][y] end @@ -116,18 +116,18 @@ function investment_discharge!(EP::Model, inputs::Dict, setup::Dict) @expression(EP, eCFix[y in 1:G], if y in setdiff(NEW_CAP, RETRO) # Resources eligible for new capacity (Non-Retrofit) if y in COMMIT - inv_cost_per_mwyr(res[y])*cap_size(res[y])*vCAP[y] + fixed_om_cost_per_mwyr(res[y])*eTotalCap[y] + inv_cost_per_mwyr(gen[y])*cap_size(gen[y])*vCAP[y] + fixed_om_cost_per_mwyr(gen[y])*eTotalCap[y] else - inv_cost_per_mwyr(res[y])*vCAP[y] + fixed_om_cost_per_mwyr(res[y])*eTotalCap[y] + inv_cost_per_mwyr(gen[y])*vCAP[y] + fixed_om_cost_per_mwyr(gen[y])*eTotalCap[y] end elseif y in intersect(NEW_CAP, RETRO) # Resources eligible for new capacity (Retrofit yr -> y) if y in COMMIT - sum( RETRO_SOURCE_IDS[y][i] in RET_CAP ? RETRO_INV_CAP_COSTS[y][i]*cap_size(res[y])*vRETROFIT[RETRO_SOURCE_IDS[y][i],y]*RETRO_EFFICIENCY[y][i] : 0 for i in 1:NUM_RETRO_SOURCES[y]) + fixed_om_cost_per_mwyr(res[y])*eTotalCap[y] + sum( RETRO_SOURCE_IDS[y][i] in RET_CAP ? RETRO_INV_CAP_COSTS[y][i]*cap_size(gen[y])*vRETROFIT[RETRO_SOURCE_IDS[y][i],y]*RETRO_EFFICIENCY[y][i] : 0 for i in 1:NUM_RETRO_SOURCES[y]) + fixed_om_cost_per_mwyr(gen[y])*eTotalCap[y] else - sum( RETRO_SOURCE_IDS[y][i] in RET_CAP ? RETRO_INV_CAP_COSTS[y][i]*vRETROFIT[RETRO_SOURCE_IDS[y][i],y]*RETRO_EFFICIENCY[y][i] : 0 for i in 1:NUM_RETRO_SOURCES[y]) + fixed_om_cost_per_mwyr(res[y])*eTotalCap[y] + sum( RETRO_SOURCE_IDS[y][i] in RET_CAP ? RETRO_INV_CAP_COSTS[y][i]*vRETROFIT[RETRO_SOURCE_IDS[y][i],y]*RETRO_EFFICIENCY[y][i] : 0 for i in 1:NUM_RETRO_SOURCES[y]) + fixed_om_cost_per_mwyr(gen[y])*eTotalCap[y] end else - fixed_om_cost_per_mwyr(res[y])*eTotalCap[y] + fixed_om_cost_per_mwyr(gen[y])*eTotalCap[y] end ) @@ -148,32 +148,32 @@ function investment_discharge!(EP::Model, inputs::Dict, setup::Dict) if MultiStage == 1 # Existing capacity variable is equal to existing capacity specified in the input file - @constraint(EP, cExistingCap[y in 1:G], EP[:vEXISTINGCAP][y] == existing_capacity_mw(res[y])) + @constraint(EP, cExistingCap[y in 1:G], EP[:vEXISTINGCAP][y] == existing_capacity_mw(gen[y])) end ## Constraints on retirements and capacity additions # Cannot retire more capacity than existing capacity @constraint(EP, cMaxRetNoCommit[y in setdiff(RET_CAP,COMMIT)], vRETCAP[y] <= eExistingCap[y]) - @constraint(EP, cMaxRetCommit[y in intersect(RET_CAP,COMMIT)], cap_size(res[y])*vRETCAP[y] <= eExistingCap[y]) + @constraint(EP, cMaxRetCommit[y in intersect(RET_CAP,COMMIT)], cap_size(gen[y])*vRETCAP[y] <= eExistingCap[y]) ## Constraints on new built capacity # Constraint on maximum capacity (if applicable) [set input to -1 if no constraint on maximum capacity] # DEV NOTE: This constraint may be violated in some cases where Existing_Cap_MW is >= Max_Cap_MW and lead to infeasabilty - MAX_CAP = has_positive_max_capacity_mw(res) - @constraint(EP, cMaxCap[y in MAX_CAP], eTotalCap[y] <= max_capacity_mw(res[y])) + MAX_CAP = has_positive_max_capacity_mw(gen) + @constraint(EP, cMaxCap[y in MAX_CAP], eTotalCap[y] <= max_capacity_mw(gen[y])) # Constraint on minimum capacity (if applicable) [set input to -1 if no constraint on minimum capacity] # DEV NOTE: This constraint may be violated in some cases where Existing_Cap_MW is <= Min_Cap_MW and lead to infeasabilty - MIN_CAP = has_positive_min_capacity_mw(res) - @constraint(EP, cMinCap[y in MIN_CAP], eTotalCap[y] >= min_capacity_mw(res[y])) + MIN_CAP = has_positive_min_capacity_mw(gen) + @constraint(EP, cMinCap[y in MIN_CAP], eTotalCap[y] >= min_capacity_mw(gen[y])) if setup["MinCapReq"] == 1 - @expression(EP, eMinCapResInvest[mincap = 1:inputs["NumberOfMinCapReqs"]], sum(EP[:eTotalCap][y] for y in has_min_cap(res, tag=mincap))) + @expression(EP, eMinCapResInvest[mincap = 1:inputs["NumberOfMinCapReqs"]], sum(EP[:eTotalCap][y] for y in has_min_cap(gen, tag=mincap))) add_similar_to_expression!(EP[:eMinCapRes], eMinCapResInvest) end if setup["MaxCapReq"] == 1 - @expression(EP, eMaxCapResInvest[maxcap = 1:inputs["NumberOfMaxCapReqs"]], sum(EP[:eTotalCap][y] for y in has_max_cap(res, tag=maxcap))) + @expression(EP, eMaxCapResInvest[maxcap = 1:inputs["NumberOfMaxCapReqs"]], sum(EP[:eTotalCap][y] for y in has_max_cap(gen, tag=maxcap))) add_similar_to_expression!(EP[:eMaxCapRes], eMaxCapResInvest) end end diff --git a/src/model/core/fuel.jl b/src/model/core/fuel.jl index 6c839fa96a..0d3ec027ac 100644 --- a/src/model/core/fuel.jl +++ b/src/model/core/fuel.jl @@ -54,7 +54,7 @@ PWFU_Intercept_* for at least one segment. function fuel!(EP::Model, inputs::Dict, setup::Dict) println("Fuel Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) Z = inputs["Z"] # Number of zones @@ -72,8 +72,8 @@ function fuel!(EP::Model, inputs::Dict, setup::Dict) # if unit commitment is modelled @expression(EP, eStartFuel[y in 1:G, t = 1:T], if y in THERM_COMMIT - (cap_size(res[y]) * EP[:vSTART][y, t] * - start_fuel_mmbtu_per_mw(res[y])) + (cap_size(gen[y]) * EP[:vSTART][y, t] * + start_fuel_mmbtu_per_mw(gen[y])) else 0 end) @@ -83,23 +83,23 @@ function fuel!(EP::Model, inputs::Dict, setup::Dict) # eCFuel_start or eCFuel_out is $ or Million$ # Start up fuel cost @expression(EP, eCFuelStart[y = 1:G, t = 1:T], - (inputs["fuel_costs"][fuel(res[y])][t] * EP[:eStartFuel][y, t])) + (inputs["fuel_costs"][fuel(gen[y])][t] * EP[:eStartFuel][y, t])) # plant level start-up fuel cost for output @expression(EP, ePlantCFuelStart[y = 1:G], sum(inputs["omega"][t] * EP[:eCFuelStart][y, t] for t in 1:T)) # zonal level total fuel cost for output @expression(EP, eZonalCFuelStart[z = 1:Z], - sum(EP[:ePlantCFuelStart][y] for y in resources_in_zone_by_rid(res,z))) + sum(EP[:ePlantCFuelStart][y] for y in resources_in_zone_by_rid(gen,z))) # Fuel cost for power generation @expression(EP, eCFuelOut[y = 1:G, t = 1:T], - (inputs["fuel_costs"][fuel(res[y])][t] * EP[:vFuel][y, t])) + (inputs["fuel_costs"][fuel(gen[y])][t] * EP[:vFuel][y, t])) # plant level start-up fuel cost for output @expression(EP, ePlantCFuelOut[y = 1:G], sum(inputs["omega"][t] * EP[:eCFuelOut][y, t] for t in 1:T)) # zonal level total fuel cost for output @expression(EP, eZonalCFuelOut[z = 1:Z], - sum(EP[:ePlantCFuelOut][y] for y in resources_in_zone_by_rid(res,z))) + sum(EP[:ePlantCFuelOut][y] for y in resources_in_zone_by_rid(gen,z))) # system level total fuel cost for output @@ -112,7 +112,7 @@ function fuel!(EP::Model, inputs::Dict, setup::Dict) #fuel consumption (MMBTU or Billion BTU) @expression(EP, eFuelConsumption[f in 1:NUM_FUEL, t in 1:T], sum(EP[:vFuel][y, t] + EP[:eStartFuel][y,t] - for y in resources_with_fuel(res, fuels[f]))) + for y in resources_with_fuel(gen, fuels[f]))) @expression(EP, eFuelConsumptionYear[f in 1:NUM_FUEL], sum(inputs["omega"][t] * EP[:eFuelConsumption][f, t] for t in 1:T)) @@ -121,7 +121,7 @@ function fuel!(EP::Model, inputs::Dict, setup::Dict) ### Constraint ### ### only apply constraint to generators with fuel type other than None @constraint(EP, FuelCalculation[y in setdiff(HAS_FUEL, THERM_COMMIT), t = 1:T], - EP[:vFuel][y, t] - EP[:vP][y, t] * heat_rate_mmbtu_per_mwh(res[y]) == 0) + EP[:vFuel][y, t] - EP[:vP][y, t] * heat_rate_mmbtu_per_mwh(gen[y]) == 0) if !isempty(THERM_COMMIT) # Only apply piecewise fuel consumption to thermal generators in THERM_COMMIT_PWFU set @@ -141,7 +141,7 @@ function fuel!(EP::Model, inputs::Dict, setup::Dict) end # constraint for fuel consumption at a constant heat rate @constraint(EP, FuelCalculationCommit[y in setdiff(THERM_COMMIT,THERM_COMMIT_PWFU), t = 1:T], - EP[:vFuel][y, t] - EP[:vP][y, t] * heat_rate_mmbtu_per_mwh(res[y]) == 0) + EP[:vFuel][y, t] - EP[:vP][y, t] * heat_rate_mmbtu_per_mwh(gen[y]) == 0) end return EP diff --git a/src/model/core/reserves.jl b/src/model/core/reserves.jl index 290e7fd398..e14cb5a597 100644 --- a/src/model/core/reserves.jl +++ b/src/model/core/reserves.jl @@ -71,7 +71,7 @@ function reserves_contingency!(EP::Model, inputs::Dict, setup::Dict) println("Reserves Contingency Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) UCommit = setup["UCommit"] @@ -116,7 +116,7 @@ function reserves_contingency!(EP::Model, inputs::Dict, setup::Dict) # Dynamic contingency related constraints # option 1: ensures vLARGEST_CONTINGENCY is greater than the capacity of the largest installed generator if UCommit == 1 && pDynamic_Contingency == 1 - @constraint(EP, cContingency[y in COMMIT], vLARGEST_CONTINGENCY >= cap_size(res[y])*vCONTINGENCY_AUX[y] ) + @constraint(EP, cContingency[y in COMMIT], vLARGEST_CONTINGENCY >= cap_size(gen[y])*vCONTINGENCY_AUX[y] ) # Ensure vCONTINGENCY_AUX = 0 if total capacity = 0 @constraint(EP, cContAux1[y in COMMIT], vCONTINGENCY_AUX[y] <= EP[:eTotalCap][y]) # Ensure vCONTINGENCY_AUX = 1 if total capacity > 0 @@ -124,7 +124,7 @@ function reserves_contingency!(EP::Model, inputs::Dict, setup::Dict) # option 2: ensures vLARGEST_CONTINGENCY is greater than the capacity of the largest commited generator in each hour elseif UCommit == 1 && pDynamic_Contingency == 2 - @constraint(EP, cContingency[y in COMMIT, t=1:T], vLARGEST_CONTINGENCY[t] >= cap_size(res[y])*vCONTINGENCY_AUX[y,t] ) + @constraint(EP, cContingency[y in COMMIT, t=1:T], vLARGEST_CONTINGENCY[t] >= cap_size(gen[y])*vCONTINGENCY_AUX[y,t] ) # Ensure vCONTINGENCY_AUX = 0 if vCOMMIT = 0 @constraint(EP, cContAux[y in COMMIT, t=1:T], vCONTINGENCY_AUX[y,t] <= EP[:vCOMMIT][y,t]) # Ensure vCONTINGENCY_AUX = 1 if vCOMMIT > 0 @@ -207,7 +207,7 @@ function reserves_core!(EP::Model, inputs::Dict, setup::Dict) println("Reserves Core Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] UCommit = setup["UCommit"] @@ -262,8 +262,8 @@ function reserves_core!(EP::Model, inputs::Dict, setup::Dict) # TODO: check these expressions @expression(EP, eCRsvPen[t=1:T], inputs["omega"][t]*inputs["pC_Rsv_Penalty"]*vUNMET_RSV[t]) @expression(EP, eTotalCRsvPen, sum(eCRsvPen[t] for t=1:T) + - sum(reg_cost(res[y])*vRSV[y,t] for y in RSV, t=1:T) + - sum(rsv_cost(res[y])*vREG[y,t] for y in REG, t=1:T) ) + sum(reg_cost(gen[y])*vRSV[y,t] for y in RSV, t=1:T) + + sum(rsv_cost(gen[y])*vREG[y,t] for y in REG, t=1:T) ) add_to_expression!(EP[:eObj], eTotalCRsvPen) end diff --git a/src/model/resources/hydro/hydro_inter_period_linkage.jl b/src/model/resources/hydro/hydro_inter_period_linkage.jl index 072cf929d0..9e9a115563 100644 --- a/src/model/resources/hydro/hydro_inter_period_linkage.jl +++ b/src/model/resources/hydro/hydro_inter_period_linkage.jl @@ -45,7 +45,7 @@ function hydro_inter_period_linkage!(EP::Model, inputs::Dict) println("Long Duration Storage Module for Hydro Reservoir") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] REP_PERIOD = inputs["REP_PERIOD"] # Number of representative periods @@ -77,7 +77,7 @@ function hydro_inter_period_linkage!(EP::Model, inputs::Dict) # Alternative to cSoCBalStart constraint which is included when not modeling operations wrapping and long duration storage # Note: tw_min = hours_per_subperiod*(w-1)+1; tw_max = hours_per_subperiod*w @constraint(EP, cSoCBalLongDurationStorageStart_H[w=1:REP_PERIOD, y in STOR_HYDRO_LONG_DURATION], - EP[:vS_HYDRO][y,hours_per_subperiod*(w-1)+1] == (EP[:vS_HYDRO][y,hours_per_subperiod*w]-vdSOC_HYDRO[y,w])-(1/efficiency_down(res[y])*EP[:vP][y,hours_per_subperiod*(w-1)+1])-EP[:vSPILL][y,hours_per_subperiod*(w-1)+1]+inputs["pP_Max"][y,hours_per_subperiod*(w-1)+1]*EP[:eTotalCap][y]) + EP[:vS_HYDRO][y,hours_per_subperiod*(w-1)+1] == (EP[:vS_HYDRO][y,hours_per_subperiod*w]-vdSOC_HYDRO[y,w])-(1/efficiency_down(gen[y])*EP[:vP][y,hours_per_subperiod*(w-1)+1])-EP[:vSPILL][y,hours_per_subperiod*(w-1)+1]+inputs["pP_Max"][y,hours_per_subperiod*(w-1)+1]*EP[:eTotalCap][y]) # Storage at beginning of period w = storage at beginning of period w-1 + storage built up in period w (after n representative periods) ## Multiply storage build up term from prior period with corresponding weight @@ -86,7 +86,7 @@ function hydro_inter_period_linkage!(EP::Model, inputs::Dict) # Storage at beginning of each modeled period cannot exceed installed energy capacity @constraint(EP, cSoCBalLongDurationStorageUpper_H[y in STOR_HYDRO_LONG_DURATION, r in MODELED_PERIODS_INDEX], - vSOC_HYDROw[y,r] <= hydro_energy_to_power_ratio(res[y])*EP[:eTotalCap][y]) + vSOC_HYDROw[y,r] <= hydro_energy_to_power_ratio(gen[y])*EP[:eTotalCap][y]) # Initial storage level for representative periods must also adhere to sub-period storage inventory balance # Initial storage = Final storage - change in storage inventory across representative period diff --git a/src/model/resources/hydro/hydro_res.jl b/src/model/resources/hydro/hydro_res.jl index ec6e2edb4c..7178055930 100644 --- a/src/model/resources/hydro/hydro_res.jl +++ b/src/model/resources/hydro/hydro_res.jl @@ -180,7 +180,7 @@ function hydro_res_reserves!(EP::Model, inputs::Dict) println("Hydro Reservoir Reserves Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) @@ -209,6 +209,6 @@ function hydro_res_reserves!(EP::Model, inputs::Dict) @constraint(EP, [y in HYDRO_RES, t in 1:T], max_up_reserves_lhs[y, t] <= eTotalCap[y]) @constraint(EP, [y in HYDRO_RES, t in 1:T], max_dn_reserves_lhs[y, t] >= 0) - @constraint(EP, [y in HYDRO_RES_REG, t in 1:T], vREG[y, t] <= reg_max(res[y]) * eTotalCap[y]) - @constraint(EP, [y in HYDRO_RES_RSV, t in 1:T], vRSV[y, t] <= rsv_max(res[y]) * eTotalCap[y]) + @constraint(EP, [y in HYDRO_RES_REG, t in 1:T], vREG[y, t] <= reg_max(gen[y]) * eTotalCap[y]) + @constraint(EP, [y in HYDRO_RES_RSV, t in 1:T], vRSV[y, t] <= rsv_max(gen[y]) * eTotalCap[y]) end diff --git a/src/model/resources/hydrogen/electrolyzer.jl b/src/model/resources/hydrogen/electrolyzer.jl index 2c06d4d912..e36c13fc20 100644 --- a/src/model/resources/hydrogen/electrolyzer.jl +++ b/src/model/resources/hydrogen/electrolyzer.jl @@ -81,7 +81,7 @@ This constraint permits modeling of the 'three pillars' requirements for clean h function electrolyzer!(EP::Model, inputs::Dict, setup::Dict) println("Electrolyzer Resources Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) Z = inputs["Z"] # Number of zones @@ -101,7 +101,7 @@ function electrolyzer!(EP::Model, inputs::Dict, setup::Dict) ## Power Balance Expressions ## @expression(EP, ePowerBalanceElectrolyzers[t in 1:T, z in 1:Z], - sum(EP[:vUSE][y,t] for y in intersect(ELECTROLYZERS, resources_in_zone_by_rid(res,z)))) + sum(EP[:vUSE][y,t] for y in intersect(ELECTROLYZERS, resources_in_zone_by_rid(gen,z)))) # Electrolyzers consume electricity so their vUSE is subtracted from power balance EP[:ePowerBalance] -= ePowerBalanceElectrolyzers @@ -114,10 +114,10 @@ function electrolyzer!(EP::Model, inputs::Dict, setup::Dict) ### Maximum ramp up and down between consecutive hours (Constraints #1-2) @constraints(EP, begin ## Maximum ramp up between consecutive hours - [y in ELECTROLYZERS, t in 1:T], EP[:vUSE][y,t] - EP[:vUSE][y, hoursbefore(p,t,1)] <= ramp_up_percentage(res[y])*EP[:eTotalCap][y] + [y in ELECTROLYZERS, t in 1:T], EP[:vUSE][y,t] - EP[:vUSE][y, hoursbefore(p,t,1)] <= ramp_up_percentage(gen[y])*EP[:eTotalCap][y] ## Maximum ramp down between consecutive hours - [y in ELECTROLYZERS, t in 1:T], EP[:vUSE][y, hoursbefore(p,t,1)] - EP[:vUSE][y,t] <= ramp_down_percentage(res[y])*EP[:eTotalCap][y] + [y in ELECTROLYZERS, t in 1:T], EP[:vUSE][y, hoursbefore(p,t,1)] - EP[:vUSE][y,t] <= ramp_down_percentage(gen[y])*EP[:eTotalCap][y] end) ### Minimum and maximum power output constraints (Constraints #3-4) @@ -126,7 +126,7 @@ function electrolyzer!(EP::Model, inputs::Dict, setup::Dict) # Could allow them to contribute as a curtailable demand in future. @constraints(EP, begin # Minimum stable power generated per technology "y" at hour "t" Min_Power - [y in ELECTROLYZERS, t in 1:T], EP[:vUSE][y,t] >= min_power(res[y])*EP[:eTotalCap][y] + [y in ELECTROLYZERS, t in 1:T], EP[:vUSE][y,t] >= min_power(gen[y])*EP[:eTotalCap][y] # Maximum power generated per technology "y" at hour "t" [y in ELECTROLYZERS, t in 1:T], EP[:vUSE][y,t] <= inputs["pP_Max"][y,t]*EP[:eTotalCap][y] @@ -136,7 +136,7 @@ function electrolyzer!(EP::Model, inputs::Dict, setup::Dict) kt_to_t = 10^3 @constraint(EP, cHydrogenMin[y in ELECTROLYZERS], - sum(inputs["omega"][t] * EP[:vUSE][y,t] / hydrogen_mwh_per_tonne(res[y]) for t=1:T) >= electrolyzer_min_kt(res[y]) * kt_to_t + sum(inputs["omega"][t] * EP[:vUSE][y,t] / hydrogen_mwh_per_tonne(gen[y]) for t=1:T) >= electrolyzer_min_kt(gen[y]) * kt_to_t ) ### Remove vP (electrolyzers do not produce power so vP = 0 for all periods) @@ -149,10 +149,10 @@ function electrolyzer!(EP::Model, inputs::Dict, setup::Dict) # from within the same zone as the electrolyzers are located to be >= hourly consumption from electrolyzers in the zone # (and any charging by qualified storage within the zone used to help increase electrolyzer utilization). if setup["HydrogenHourlyMatching"] == 1 - HYDROGEN_ZONES = unique(zone_id.(res.ELECTROLYZER)) - QUALIFIED_SUPPLY = resources_with_qualified_hydrogen_supply(res) + HYDROGEN_ZONES = unique(zone_id.(gen.ELECTROLYZER)) + QUALIFIED_SUPPLY = resources_with_qualified_hydrogen_supply(gen) @constraint(EP, cHourlyMatching[z in HYDROGEN_ZONES, t in 1:T], - sum(EP[:vP][y,t] for y=intersect(resources_in_zone_by_rid(res,z), QUALIFIED_SUPPLY)) >= sum(EP[:vUSE][y,t] for y=intersect(resources_in_zone_by_rid(res,z), ELECTROLYZERS)) + sum(EP[:vCHARGE][y,t] for y=intersect(resources_in_zone_by_rid(res,z), QUALIFIED_SUPPLY, STORAGE)) + sum(EP[:vP][y,t] for y=intersect(resources_in_zone_by_rid(gen,z), QUALIFIED_SUPPLY)) >= sum(EP[:vUSE][y,t] for y=intersect(resources_in_zone_by_rid(gen,z), ELECTROLYZERS)) + sum(EP[:vCHARGE][y,t] for y=intersect(resources_in_zone_by_rid(gen,z), QUALIFIED_SUPPLY, STORAGE)) ) end @@ -162,14 +162,14 @@ function electrolyzer!(EP::Model, inputs::Dict, setup::Dict) # Electrolyzer demand is only accounted for in an ESR that the electrolyzer resources is tagged in in Generates_data.csv (e.g. ESR_N > 0) and # a share of electrolyzer demand equal to dfGen[y,:ESR_N] must be met by resources qualifying for ESR_N for each electrolyzer resource y. if setup["EnergyShareRequirement"] >= 1 - @expression(EP, eElectrolyzerESR[ESR in 1:inputs["nESR"]], sum(inputs["omega"][t]*EP[:vUSE][y,t] for y=intersect(ELECTROLYZERS, has_esr(res,tag=ESR)), t in 1:T)) + @expression(EP, eElectrolyzerESR[ESR in 1:inputs["nESR"]], sum(inputs["omega"][t]*EP[:vUSE][y,t] for y=intersect(ELECTROLYZERS, has_esr(gen,tag=ESR)), t in 1:T)) EP[:eESR] -= eElectrolyzerESR end ### Objective Function ### # Subtract hydrogen revenue from objective function scale_factor = setup["ParameterScale"] == 1 ? 10^6 : 1 # If ParameterScale==1, costs are in millions of $ - @expression(EP, eHydrogenValue[y in ELECTROLYZERS, t in 1:T], (inputs["omega"][t] * EP[:vUSE][y,t] / hydrogen_mwh_per_tonne(res[y]) * hydrogen_price_per_tonne(res[y]) / scale_factor)) + @expression(EP, eHydrogenValue[y in ELECTROLYZERS, t in 1:T], (inputs["omega"][t] * EP[:vUSE][y,t] / hydrogen_mwh_per_tonne(gen[y]) * hydrogen_price_per_tonne(gen[y]) / scale_factor)) @expression(EP, eTotalHydrogenValueT[t in 1:T], sum(eHydrogenValue[y,t] for y in ELECTROLYZERS)) @expression(EP, eTotalHydrogenValue, sum(eTotalHydrogenValueT[t] for t in 1:T)) EP[:eObj] -= eTotalHydrogenValue diff --git a/src/model/resources/storage/investment_charge.jl b/src/model/resources/storage/investment_charge.jl index 38d2cc4259..ad1dde8e1b 100644 --- a/src/model/resources/storage/investment_charge.jl +++ b/src/model/resources/storage/investment_charge.jl @@ -42,7 +42,7 @@ function investment_charge!(EP::Model, inputs::Dict, setup::Dict) println("Charge Investment Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] MultiStage = setup["MultiStage"] @@ -70,7 +70,7 @@ function investment_charge!(EP::Model, inputs::Dict, setup::Dict) if MultiStage == 1 @expression(EP, eExistingCapCharge[y in STOR_ASYMMETRIC], vEXISTINGCAPCHARGE[y]) else - @expression(EP, eExistingCapCharge[y in STOR_ASYMMETRIC], existing_charge_capacity_mw(res[y])) + @expression(EP, eExistingCapCharge[y in STOR_ASYMMETRIC], existing_charge_capacity_mw(gen[y])) end @expression(EP, eTotalCapCharge[y in STOR_ASYMMETRIC], @@ -91,9 +91,9 @@ function investment_charge!(EP::Model, inputs::Dict, setup::Dict) # If resource is not eligible for new charge capacity, fixed costs are only O&M costs @expression(EP, eCFixCharge[y in STOR_ASYMMETRIC], if y in NEW_CAP_CHARGE # Resources eligible for new charge capacity - inv_cost_charge_per_mwyr(res[y])*vCAPCHARGE[y] + fixed_om_cost_charge_per_mwyr(res[y])*eTotalCapCharge[y] + inv_cost_charge_per_mwyr(gen[y])*vCAPCHARGE[y] + fixed_om_cost_charge_per_mwyr(gen[y])*eTotalCapCharge[y] else - fixed_om_cost_charge_per_mwyr(res[y])*eTotalCapCharge[y] + fixed_om_cost_charge_per_mwyr(gen[y])*eTotalCapCharge[y] end ) @@ -125,11 +125,11 @@ function investment_charge!(EP::Model, inputs::Dict, setup::Dict) # Constraint on maximum charge capacity (if applicable) [set input to -1 if no constraint on maximum charge capacity] # DEV NOTE: This constraint may be violated in some cases where Existing_Charge_Cap_MW is >= Max_Charge_Cap_MWh and lead to infeasabilty - @constraint(EP, cMaxCapCharge[y in intersect(has_positive_max_capacity_mw(res), STOR_ASYMMETRIC)], eTotalCapCharge[y] <= max_charge_capacity_mw(res[y])) + @constraint(EP, cMaxCapCharge[y in intersect(has_positive_max_capacity_mw(gen), STOR_ASYMMETRIC)], eTotalCapCharge[y] <= max_charge_capacity_mw(gen[y])) # Constraint on minimum charge capacity (if applicable) [set input to -1 if no constraint on minimum charge capacity] # DEV NOTE: This constraint may be violated in some cases where Existing_Charge_Cap_MW is <= Min_Charge_Cap_MWh and lead to infeasabilty - @constraint(EP, cMinCapCharge[y in intersect(has_positive_min_charge_capacity_mw(res), STOR_ASYMMETRIC)], eTotalCapCharge[y] >= min_charge_capacity_mw(res[y])) + @constraint(EP, cMinCapCharge[y in intersect(has_positive_min_charge_capacity_mw(gen), STOR_ASYMMETRIC)], eTotalCapCharge[y] >= min_charge_capacity_mw(gen[y])) end diff --git a/src/model/resources/storage/investment_energy.jl b/src/model/resources/storage/investment_energy.jl index 238c6f885d..66d0f97636 100644 --- a/src/model/resources/storage/investment_energy.jl +++ b/src/model/resources/storage/investment_energy.jl @@ -45,7 +45,7 @@ function investment_energy!(EP::Model, inputs::Dict, setup::Dict) println("Storage Investment Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] MultiStage = setup["MultiStage"] @@ -72,7 +72,7 @@ function investment_energy!(EP::Model, inputs::Dict, setup::Dict) if MultiStage == 1 @expression(EP, eExistingCapEnergy[y in STOR_ALL], vEXISTINGCAPENERGY[y]) else - @expression(EP, eExistingCapEnergy[y in STOR_ALL], existing_capacity_mwh(res[y])) + @expression(EP, eExistingCapEnergy[y in STOR_ALL], existing_capacity_mwh(gen[y])) end @expression(EP, eTotalCapEnergy[y in STOR_ALL], @@ -93,9 +93,9 @@ function investment_energy!(EP::Model, inputs::Dict, setup::Dict) # If resource is not eligible for new energy capacity, fixed costs are only O&M costs @expression(EP, eCFixEnergy[y in STOR_ALL], if y in NEW_CAP_ENERGY # Resources eligible for new capacity - inv_cost_per_mwhyr(res[y])*vCAPENERGY[y] + fixed_om_cost_per_mwhyr(res[y])*eTotalCapEnergy[y] + inv_cost_per_mwhyr(gen[y])*vCAPENERGY[y] + fixed_om_cost_per_mwhyr(gen[y])*eTotalCapEnergy[y] else - fixed_om_cost_per_mwhyr(res[y])*eTotalCapEnergy[y] + fixed_om_cost_per_mwhyr(gen[y])*eTotalCapEnergy[y] end ) @@ -115,7 +115,7 @@ function investment_energy!(EP::Model, inputs::Dict, setup::Dict) ### Constraints ### if MultiStage == 1 - @constraint(EP, cExistingCapEnergy[y in STOR_ALL], EP[:vEXISTINGCAPENERGY][y] == existing_capacity_mwh(res[y])) + @constraint(EP, cExistingCapEnergy[y in STOR_ALL], EP[:vEXISTINGCAPENERGY][y] == existing_capacity_mwh(gen[y])) end ## Constraints on retirements and capacity additions @@ -125,14 +125,14 @@ function investment_energy!(EP::Model, inputs::Dict, setup::Dict) ## Constraints on new built energy capacity # Constraint on maximum energy capacity (if applicable) [set input to -1 if no constraint on maximum energy capacity] # DEV NOTE: This constraint may be violated in some cases where Existing_Cap_MWh is >= Max_Cap_MWh and lead to infeasabilty - @constraint(EP, cMaxCapEnergy[y in intersect(has_positive_max_capacity_mwh(res), STOR_ALL)], eTotalCapEnergy[y] <= max_capacity_mwh(res[y])) + @constraint(EP, cMaxCapEnergy[y in intersect(has_positive_max_capacity_mwh(gen), STOR_ALL)], eTotalCapEnergy[y] <= max_capacity_mwh(gen[y])) # Constraint on minimum energy capacity (if applicable) [set input to -1 if no constraint on minimum energy apacity] # DEV NOTE: This constraint may be violated in some cases where Existing_Cap_MWh is <= Min_Cap_MWh and lead to infeasabilty - @constraint(EP, cMinCapEnergy[y in intersect(has_positive_min_capacity_mwh(res), STOR_ALL)], eTotalCapEnergy[y] >= min_capacity_mwh(res[y])) + @constraint(EP, cMinCapEnergy[y in intersect(has_positive_min_capacity_mwh(gen), STOR_ALL)], eTotalCapEnergy[y] >= min_capacity_mwh(gen[y])) # Max and min constraints on energy storage capacity built (as proportion to discharge power capacity) - @constraint(EP, cMinCapEnergyDuration[y in STOR_ALL], EP[:eTotalCapEnergy][y] >= min_duration(res[y]) * EP[:eTotalCap][y]) - @constraint(EP, cMaxCapEnergyDuration[y in STOR_ALL], EP[:eTotalCapEnergy][y] <= max_duration(res[y]) * EP[:eTotalCap][y]) + @constraint(EP, cMinCapEnergyDuration[y in STOR_ALL], EP[:eTotalCapEnergy][y] >= min_duration(gen[y]) * EP[:eTotalCap][y]) + @constraint(EP, cMaxCapEnergyDuration[y in STOR_ALL], EP[:eTotalCapEnergy][y] <= max_duration(gen[y]) * EP[:eTotalCap][y]) end diff --git a/src/model/resources/storage/long_duration_storage.jl b/src/model/resources/storage/long_duration_storage.jl index c62a19c151..9eb904c8b8 100644 --- a/src/model/resources/storage/long_duration_storage.jl +++ b/src/model/resources/storage/long_duration_storage.jl @@ -66,7 +66,7 @@ function long_duration_storage!(EP::Model, inputs::Dict, setup::Dict) println("Long Duration Storage Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] CapacityReserveMargin = setup["CapacityReserveMargin"] @@ -109,8 +109,8 @@ function long_duration_storage!(EP::Model, inputs::Dict, setup::Dict) # Alternative to cSoCBalStart constraint which is included when not modeling operations wrapping and long duration storage # Note: tw_min = hours_per_subperiod*(w-1)+1; tw_max = hours_per_subperiod*w @constraint(EP, cSoCBalLongDurationStorageStart[w=1:REP_PERIOD, y in STOR_LONG_DURATION], - EP[:vS][y,hours_per_subperiod*(w-1)+1] == (1-self_discharge(res[y]))*(EP[:vS][y,hours_per_subperiod*w]-vdSOC[y,w]) - -(1/efficiency_down(res[y])*EP[:vP][y,hours_per_subperiod*(w-1)+1])+(efficiency_up(res[y])*EP[:vCHARGE][y,hours_per_subperiod*(w-1)+1])) + EP[:vS][y,hours_per_subperiod*(w-1)+1] == (1-self_discharge(gen[y]))*(EP[:vS][y,hours_per_subperiod*w]-vdSOC[y,w]) + -(1/efficiency_down(gen[y])*EP[:vP][y,hours_per_subperiod*(w-1)+1])+(efficiency_up(gen[y])*EP[:vCHARGE][y,hours_per_subperiod*(w-1)+1])) # Storage at beginning of period w = storage at beginning of period w-1 + storage built up in period w (after n representative periods) ## Multiply storage build up term from prior period with corresponding weight @@ -135,8 +135,8 @@ function long_duration_storage!(EP::Model, inputs::Dict, setup::Dict) # Alternative to cVSoCBalStart constraint which is included when not modeling operations wrapping and long duration storage # Note: tw_min = hours_per_subperiod*(w-1)+1; tw_max = hours_per_subperiod*w @constraint(EP, cVSoCBalLongDurationStorageStart[w=1:REP_PERIOD, y in STOR_LONG_DURATION], - EP[:vCAPRES_socinreserve][y,hours_per_subperiod*(w-1)+1] == (1-self_discharge(res[y]))*(EP[:vCAPRES_socinreserve][y,hours_per_subperiod*w]-vCAPRES_dsoc[y,w]) - +(1/efficiency_down(res[y])*EP[:vCAPRES_discharge][y,hours_per_subperiod*(w-1)+1])-(efficiency_up(res[y])*EP[:vCAPRES_charge][y,hours_per_subperiod*(w-1)+1])) + EP[:vCAPRES_socinreserve][y,hours_per_subperiod*(w-1)+1] == (1-self_discharge(gen[y]))*(EP[:vCAPRES_socinreserve][y,hours_per_subperiod*w]-vCAPRES_dsoc[y,w]) + +(1/efficiency_down(gen[y])*EP[:vCAPRES_discharge][y,hours_per_subperiod*(w-1)+1])-(efficiency_up(gen[y])*EP[:vCAPRES_charge][y,hours_per_subperiod*(w-1)+1])) # Storage held in reserve at beginning of period w = storage at beginning of period w-1 + storage built up in period w (after n representative periods) ## Multiply storage build up term from prior period with corresponding weight diff --git a/src/model/resources/storage/storage_all.jl b/src/model/resources/storage/storage_all.jl index c42ca31ad9..8d4cbf6181 100644 --- a/src/model/resources/storage/storage_all.jl +++ b/src/model/resources/storage/storage_all.jl @@ -7,7 +7,7 @@ function storage_all!(EP::Model, inputs::Dict, setup::Dict) # Setup variables, constraints, and expressions common to all storage resources println("Storage Core Resources Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] Reserves = setup["Reserves"] CapacityReserveMargin = setup["CapacityReserveMargin"] @@ -50,7 +50,7 @@ function storage_all!(EP::Model, inputs::Dict, setup::Dict) ## Objective Function Expressions ## #Variable costs of "charging" for technologies "y" during hour "t" in zone "z" - @expression(EP, eCVar_in[y in STOR_ALL,t=1:T], inputs["omega"][t]*var_om_cost_per_mwh_in(res[y])*vCHARGE[y,t]) + @expression(EP, eCVar_in[y in STOR_ALL,t=1:T], inputs["omega"][t]*var_om_cost_per_mwh_in(gen[y])*vCHARGE[y,t]) # Sum individual resource contributions to variable charging costs to get total variable charging costs @expression(EP, eTotalCVarInT[t=1:T], sum(eCVar_in[y,t] for y in STOR_ALL)) @@ -60,13 +60,13 @@ function storage_all!(EP::Model, inputs::Dict, setup::Dict) if CapacityReserveMargin > 0 #Variable costs of "virtual charging" for technologies "y" during hour "t" in zone "z" - @expression(EP, eCVar_in_virtual[y in STOR_ALL,t=1:T], inputs["omega"][t]*var_om_cost_per_mwh_in(res[y])*vCAPRES_charge[y,t]) + @expression(EP, eCVar_in_virtual[y in STOR_ALL,t=1:T], inputs["omega"][t]*var_om_cost_per_mwh_in(gen[y])*vCAPRES_charge[y,t]) @expression(EP, eTotalCVarInT_virtual[t=1:T], sum(eCVar_in_virtual[y,t] for y in STOR_ALL)) @expression(EP, eTotalCVarIn_virtual, sum(eTotalCVarInT_virtual[t] for t in 1:T)) EP[:eObj] += eTotalCVarIn_virtual #Variable costs of "virtual discharging" for technologies "y" during hour "t" in zone "z" - @expression(EP, eCVar_out_virtual[y in STOR_ALL,t=1:T], inputs["omega"][t]*var_om_cost_per_mwh(res[y])*vCAPRES_discharge[y,t]) + @expression(EP, eCVar_out_virtual[y in STOR_ALL,t=1:T], inputs["omega"][t]*var_om_cost_per_mwh(gen[y])*vCAPRES_discharge[y,t]) @expression(EP, eTotalCVarOutT_virtual[t=1:T], sum(eCVar_out_virtual[y,t] for y in STOR_ALL)) @expression(EP, eTotalCVarOut_virtual, sum(eTotalCVarOutT_virtual[t] for t in 1:T)) EP[:eObj] += eTotalCVarOut_virtual @@ -76,7 +76,7 @@ function storage_all!(EP::Model, inputs::Dict, setup::Dict) # Term to represent net dispatch from storage in any period @expression(EP, ePowerBalanceStor[t=1:T, z=1:Z], - sum(EP[:vP][y,t]-EP[:vCHARGE][y,t] for y in intersect(resources_in_zone_by_rid(res,z),STOR_ALL)) + sum(EP[:vP][y,t]-EP[:vCHARGE][y,t] for y in intersect(resources_in_zone_by_rid(gen,z),STOR_ALL)) ) add_similar_to_expression!(EP[:ePowerBalance], ePowerBalanceStor) @@ -92,8 +92,8 @@ function storage_all!(EP::Model, inputs::Dict, setup::Dict) CONSTRAINTSET = STOR_ALL end @constraint(EP, cSoCBalStart[t in START_SUBPERIODS, y in CONSTRAINTSET], EP[:vS][y,t] == - EP[:vS][y,t+hours_per_subperiod-1] - (1/efficiency_down(res[y]) * EP[:vP][y,t]) - + (efficiency_up(res[y])*EP[:vCHARGE][y,t]) - (self_discharge(res[y]) * EP[:vS][y,t+hours_per_subperiod-1])) + EP[:vS][y,t+hours_per_subperiod-1] - (1/efficiency_down(gen[y]) * EP[:vP][y,t]) + + (efficiency_up(gen[y])*EP[:vCHARGE][y,t]) - (self_discharge(gen[y]) * EP[:vS][y,t+hours_per_subperiod-1])) @constraints(EP, begin @@ -102,7 +102,7 @@ function storage_all!(EP::Model, inputs::Dict, setup::Dict) # energy stored for the next hour cSoCBalInterior[t in INTERIOR_SUBPERIODS, y in STOR_ALL], EP[:vS][y,t] == - EP[:vS][y,t-1]-(1/efficiency_down(res[y])*EP[:vP][y,t])+(efficiency_up(res[y])*EP[:vCHARGE][y,t])-(self_discharge(res[y])*EP[:vS][y,t-1]) + EP[:vS][y,t-1]-(1/efficiency_down(gen[y])*EP[:vP][y,t])+(efficiency_up(gen[y])*EP[:vCHARGE][y,t])-(self_discharge(gen[y])*EP[:vS][y,t-1]) end) # Storage discharge and charge power (and reserve contribution) related constraints: @@ -117,18 +117,18 @@ function storage_all!(EP::Model, inputs::Dict, setup::Dict) # wrapping from end of sample period to start of sample period for energy capacity constraint @constraints(EP, begin [y in STOR_ALL, t=1:T], EP[:vP][y,t] + EP[:vCAPRES_discharge][y,t] <= EP[:eTotalCap][y] - [y in STOR_ALL, t=1:T], EP[:vP][y,t] + EP[:vCAPRES_discharge][y,t] <= EP[:vS][y, hoursbefore(hours_per_subperiod,t,1)]*efficiency_down(res[y]) + [y in STOR_ALL, t=1:T], EP[:vP][y,t] + EP[:vCAPRES_discharge][y,t] <= EP[:vS][y, hoursbefore(hours_per_subperiod,t,1)]*efficiency_down(gen[y]) end) else @constraints(EP, begin [y in STOR_ALL, t=1:T], EP[:vP][y,t] <= EP[:eTotalCap][y] - [y in STOR_ALL, t=1:T], EP[:vP][y,t] <= EP[:vS][y, hoursbefore(hours_per_subperiod,t,1)]*efficiency_down(res[y]) + [y in STOR_ALL, t=1:T], EP[:vP][y,t] <= EP[:vS][y, hoursbefore(hours_per_subperiod,t,1)]*efficiency_down(gen[y]) end) end end # From CO2 Policy module - expr = @expression(EP, [z=1:Z], sum(EP[:eELOSS][y] for y in intersect(STOR_ALL, resources_in_zone_by_rid(res,z)))) + expr = @expression(EP, [z=1:Z], sum(EP[:eELOSS][y] for y in intersect(STOR_ALL, resources_in_zone_by_rid(gen,z)))) add_similar_to_expression!(EP[:eELOSSByZone], expr) # Capacity Reserve Margin policy @@ -138,12 +138,12 @@ function storage_all!(EP::Model, inputs::Dict, setup::Dict) # Links energy held in reserve in first time step with decisions in last time step of each subperiod # We use a modified formulation of this constraint (cVSoCBalLongDurationStorageStart) when operations wrapping and long duration storage are being modeled @constraint(EP, cVSoCBalStart[t in START_SUBPERIODS, y in CONSTRAINTSET], EP[:vCAPRES_socinreserve][y,t] == - EP[:vCAPRES_socinreserve][y,t+hours_per_subperiod-1] + (1/efficiency_down(res[y]) * EP[:vCAPRES_discharge][y,t]) - - (efficiency_up(res[y])*EP[:vCAPRES_charge][y,t]) - (self_discharge(res[y]) * EP[:vCAPRES_socinreserve][y,t+hours_per_subperiod-1])) + EP[:vCAPRES_socinreserve][y,t+hours_per_subperiod-1] + (1/efficiency_down(gen[y]) * EP[:vCAPRES_discharge][y,t]) + - (efficiency_up(gen[y])*EP[:vCAPRES_charge][y,t]) - (self_discharge(gen[y]) * EP[:vCAPRES_socinreserve][y,t+hours_per_subperiod-1])) # energy held in reserve for the next hour @constraint(EP, cVSoCBalInterior[t in INTERIOR_SUBPERIODS, y in STOR_ALL], EP[:vCAPRES_socinreserve][y,t] == - EP[:vCAPRES_socinreserve][y,t-1]+(1/efficiency_down(res[y])*EP[:vCAPRES_discharge][y,t])-(efficiency_up(res[y])*EP[:vCAPRES_charge][y,t])-(self_discharge(res[y])*EP[:vCAPRES_socinreserve][y,t-1])) + EP[:vCAPRES_socinreserve][y,t-1]+(1/efficiency_down(gen[y])*EP[:vCAPRES_discharge][y,t])-(efficiency_up(gen[y])*EP[:vCAPRES_charge][y,t])-(self_discharge(gen[y])*EP[:vCAPRES_socinreserve][y,t-1])) # energy held in reserve acts as a lower bound on the total energy held in storage @constraint(EP, cSOCMinCapRes[t in 1:T, y in STOR_ALL], EP[:vS][y,t] >= EP[:vCAPRES_socinreserve][y,t]) @@ -152,7 +152,7 @@ end function storage_all_reserves!(EP::Model, inputs::Dict, setup::Dict) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] p = inputs["hours_per_subperiod"] CapacityReserveMargin = setup["CapacityReserveMargin"] > 1 @@ -176,8 +176,8 @@ function storage_all_reserves!(EP::Model, inputs::Dict, setup::Dict) eTotalCapEnergy = EP[:eTotalCapEnergy] # Maximum storage contribution to reserves is a specified fraction of installed capacity - @constraint(EP, [y in STOR_REG, t in 1:T], vREG[y, t] <= reg_max(res[y]) * eTotalCap[y]) - @constraint(EP, [y in STOR_RSV, t in 1:T], vRSV[y, t] <= rsv_max(res[y]) * eTotalCap[y]) + @constraint(EP, [y in STOR_REG, t in 1:T], vREG[y, t] <= reg_max(gen[y]) * eTotalCap[y]) + @constraint(EP, [y in STOR_RSV, t in 1:T], vRSV[y, t] <= rsv_max(gen[y]) * eTotalCap[y]) # Actual contribution to regulation and reserves is sum of auxilary variables for portions contributed during charging and discharging @constraint(EP, [y in STOR_REG, t in 1:T], vREG[y, t] == vREG_charge[y, t] + vREG_discharge[y, t]) @@ -195,7 +195,7 @@ function storage_all_reserves!(EP::Model, inputs::Dict, setup::Dict) @constraint(EP, [y in STOR_REG, t in 1:T], vP[y, t] - vREG_discharge[y, t] >= 0) # Maximum charging rate plus contribution to regulation down must be less than available storage capacity - @constraint(EP, [y in STOR_REG, t in 1:T], efficiency_up(res[y])*(vCHARGE[y, t]+vREG_charge[y, t]) <= eTotalCapEnergy[y]-vS[y, hoursbefore(p,t,1)]) + @constraint(EP, [y in STOR_REG, t in 1:T], efficiency_up(gen[y])*(vCHARGE[y, t]+vREG_charge[y, t]) <= eTotalCapEnergy[y]-vS[y, hoursbefore(p,t,1)]) # Note: maximum charge rate is also constrained by maximum charge power capacity, but as this differs by storage type, # this constraint is set in functions below for each storage type @@ -209,5 +209,5 @@ function storage_all_reserves!(EP::Model, inputs::Dict, setup::Dict) # Maximum discharging rate and contribution to reserves up must be less than power rating @constraint(EP, [y in STOR_ALL, t in 1:T], expr[y, t] <= eTotalCap[y]) # Maximum discharging rate and contribution to reserves up must be less than available stored energy in prior period - @constraint(EP, [y in STOR_ALL, t in 1:T], expr[y, t] <= vS[y, hoursbefore(p,t,1)] * efficiency_down(res[y])) + @constraint(EP, [y in STOR_ALL, t in 1:T], expr[y, t] <= vS[y, hoursbefore(p,t,1)] * efficiency_down(gen[y])) end diff --git a/src/model/resources/storage/storage_asymmetric.jl b/src/model/resources/storage/storage_asymmetric.jl index 4ee04e650a..102ecddfc3 100644 --- a/src/model/resources/storage/storage_asymmetric.jl +++ b/src/model/resources/storage/storage_asymmetric.jl @@ -10,7 +10,7 @@ function storage_asymmetric!(EP::Model, inputs::Dict, setup::Dict) println("Storage Resources with Asmymetric Charge/Discharge Capacity Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] Reserves = setup["Reserves"] CapacityReserveMargin = setup["CapacityReserveMargin"] diff --git a/src/model/resources/thermal/thermal.jl b/src/model/resources/thermal/thermal.jl index 0ce4d54230..a3a3898c92 100644 --- a/src/model/resources/thermal/thermal.jl +++ b/src/model/resources/thermal/thermal.jl @@ -43,7 +43,7 @@ function thermal!(EP::Model, inputs::Dict, setup::Dict) #= ##CO2 Polcy Module Thermal Generation by zone @expression(EP, eGenerationByThermAll[z=1:Z, t=1:T], # the unit is GW - sum(EP[:vP][y,t] for y in intersect(inputs["THERM_ALL"], resources_in_zone_by_rid(res,z))) + sum(EP[:vP][y,t] for y in intersect(inputs["THERM_ALL"], resources_in_zone_by_rid(gen,z))) ) EP[:eGenerationByZone] += eGenerationByThermAll =# ##From main diff --git a/src/model/resources/thermal/thermal_commit.jl b/src/model/resources/thermal/thermal_commit.jl index f4cd7ec66c..88dcfd64d6 100644 --- a/src/model/resources/thermal/thermal_commit.jl +++ b/src/model/resources/thermal/thermal_commit.jl @@ -128,7 +128,7 @@ function thermal_commit!(EP::Model, inputs::Dict, setup::Dict) println("Thermal (Unit Commitment) Resources Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) Z = inputs["Z"] # Number of zones @@ -155,7 +155,7 @@ function thermal_commit!(EP::Model, inputs::Dict, setup::Dict) ## Power Balance Expressions ## @expression(EP, ePowerBalanceThermCommit[t=1:T, z=1:Z], - sum(EP[:vP][y,t] for y in intersect(THERM_COMMIT, resources_in_zone_by_rid(res,z))) + sum(EP[:vP][y,t] for y in intersect(THERM_COMMIT, resources_in_zone_by_rid(gen,z))) ) add_similar_to_expression!(EP[:ePowerBalance], ePowerBalanceThermCommit) @@ -163,9 +163,9 @@ function thermal_commit!(EP::Model, inputs::Dict, setup::Dict) ### Capacitated limits on unit commitment decision variables (Constraints #1-3) @constraints(EP, begin - [y in THERM_COMMIT, t=1:T], EP[:vCOMMIT][y,t] <= EP[:eTotalCap][y]/cap_size(res[y]) - [y in THERM_COMMIT, t=1:T], EP[:vSTART][y,t] <= EP[:eTotalCap][y]/cap_size(res[y]) - [y in THERM_COMMIT, t=1:T], EP[:vSHUT][y,t] <= EP[:eTotalCap][y]/cap_size(res[y]) + [y in THERM_COMMIT, t=1:T], EP[:vCOMMIT][y,t] <= EP[:eTotalCap][y]/cap_size(gen[y]) + [y in THERM_COMMIT, t=1:T], EP[:vSTART][y,t] <= EP[:eTotalCap][y]/cap_size(gen[y]) + [y in THERM_COMMIT, t=1:T], EP[:vSHUT][y,t] <= EP[:eTotalCap][y]/cap_size(gen[y]) end) # Commitment state constraint linking startup and shutdown decisions (Constraint #4) @@ -179,15 +179,15 @@ function thermal_commit!(EP::Model, inputs::Dict, setup::Dict) # Links last time step with first time step, ensuring position in hour 1 is within eligible ramp of final hour position # rampup constraints @constraint(EP,[y in THERM_COMMIT, t in 1:T], - EP[:vP][y,t] - EP[:vP][y, hoursbefore(p, t, 1)] + regulation_term[y,t] + reserves_term[y,t] <= ramp_up_percentage(res[y])*cap_size(res[y])*(EP[:vCOMMIT][y,t]-EP[:vSTART][y,t]) - + min(inputs["pP_Max"][y,t],max(min_power(res[y]),ramp_up_percentage(res[y])))*cap_size(res[y])*EP[:vSTART][y,t] - - min_power(res[y])*cap_size(res[y])*EP[:vSHUT][y,t]) + EP[:vP][y,t] - EP[:vP][y, hoursbefore(p, t, 1)] + regulation_term[y,t] + reserves_term[y,t] <= ramp_up_percentage(gen[y])*cap_size(gen[y])*(EP[:vCOMMIT][y,t]-EP[:vSTART][y,t]) + + min(inputs["pP_Max"][y,t],max(min_power(gen[y]),ramp_up_percentage(gen[y])))*cap_size(gen[y])*EP[:vSTART][y,t] + - min_power(gen[y])*cap_size(gen[y])*EP[:vSHUT][y,t]) # rampdown constraints @constraint(EP,[y in THERM_COMMIT, t in 1:T], - EP[:vP][y, hoursbefore(p,t,1)] - EP[:vP][y,t] - regulation_term[y,t] + reserves_term[y, hoursbefore(p,t,1)] <= ramp_down_percentage(res[y])*cap_size(res[y])*(EP[:vCOMMIT][y,t]-EP[:vSTART][y,t]) - - min_power(res[y])*cap_size(res[y])*EP[:vSTART][y,t] - + min(inputs["pP_Max"][y,t],max(min_power(res[y]),ramp_down_percentage(res[y])))*cap_size(res[y])*EP[:vSHUT][y,t]) + EP[:vP][y, hoursbefore(p,t,1)] - EP[:vP][y,t] - regulation_term[y,t] + reserves_term[y, hoursbefore(p,t,1)] <= ramp_down_percentage(gen[y])*cap_size(gen[y])*(EP[:vCOMMIT][y,t]-EP[:vSTART][y,t]) + - min_power(gen[y])*cap_size(gen[y])*EP[:vSTART][y,t] + + min(inputs["pP_Max"][y,t],max(min_power(gen[y]),ramp_down_percentage(gen[y])))*cap_size(gen[y])*EP[:vSHUT][y,t]) ### Minimum and maximum power output constraints (Constraints #7-8) @@ -197,28 +197,28 @@ function thermal_commit!(EP::Model, inputs::Dict, setup::Dict) else @constraints(EP, begin # Minimum stable power generated per technology "y" at hour "t" > Min power - [y in THERM_COMMIT, t=1:T], EP[:vP][y,t] >= min_power(res[y])*cap_size(res[y])*EP[:vCOMMIT][y,t] + [y in THERM_COMMIT, t=1:T], EP[:vP][y,t] >= min_power(gen[y])*cap_size(gen[y])*EP[:vCOMMIT][y,t] # Maximum power generated per technology "y" at hour "t" < Max power - [y in THERM_COMMIT, t=1:T], EP[:vP][y,t] <= inputs["pP_Max"][y,t]*cap_size(res[y])*EP[:vCOMMIT][y,t] + [y in THERM_COMMIT, t=1:T], EP[:vP][y,t] <= inputs["pP_Max"][y,t]*cap_size(gen[y])*EP[:vCOMMIT][y,t] end) end ### Minimum up and down times (Constraints #9-10) Up_Time = zeros(Int, G) - Up_Time[THERM_COMMIT] .= Int.(floor.(up_time.(res[THERM_COMMIT]))) + Up_Time[THERM_COMMIT] .= Int.(floor.(up_time.(gen[THERM_COMMIT]))) @constraint(EP, [y in THERM_COMMIT, t in 1:T], EP[:vCOMMIT][y,t] >= sum(EP[:vSTART][y, u] for u in hoursbefore(p, t, 0:(Up_Time[y] - 1))) ) Down_Time = zeros(Int, G) - Down_Time[THERM_COMMIT] .= Int.(floor.(down_time.(res[THERM_COMMIT]))) + Down_Time[THERM_COMMIT] .= Int.(floor.(down_time.(gen[THERM_COMMIT]))) @constraint(EP, [y in THERM_COMMIT, t in 1:T], - EP[:eTotalCap][y]/cap_size(res[y])-EP[:vCOMMIT][y,t] >= sum(EP[:vSHUT][y, u] for u in hoursbefore(p, t, 0:(Down_Time[y] - 1))) + EP[:eTotalCap][y]/cap_size(gen[y])-EP[:vCOMMIT][y,t] >= sum(EP[:vSHUT][y, u] for u in hoursbefore(p, t, 0:(Down_Time[y] - 1))) ) ## END Constraints for thermal units subject to integer (discrete) unit commitment decisions - if !isempty(resources_with_maintenance(res)) + if !isempty(resources_with_maintenance(gen)) maintenance_formulation_thermal_commit!(EP, inputs, setup) end end @@ -269,7 +269,7 @@ function thermal_commit_reserves!(EP::Model, inputs::Dict) println("Thermal Commit Reserves Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) @@ -282,17 +282,17 @@ function thermal_commit_reserves!(EP::Model, inputs::Dict) vREG = EP[:vREG] vRSV = EP[:vRSV] - commit(y,t) = cap_size(res[y]) * EP[:vCOMMIT][y,t] + commit(y,t) = cap_size(gen[y]) * EP[:vCOMMIT][y,t] max_power(y,t) = inputs["pP_Max"][y,t] # Maximum regulation and reserve contributions - @constraint(EP, [y in REG, t in 1:T], vREG[y, t] <= max_power(y, t) * reg_max(res[y]) * commit(y, t)) - @constraint(EP, [y in RSV, t in 1:T], vRSV[y, t] <= max_power(y, t) * rsv_max(res[y]) * commit(y, t)) + @constraint(EP, [y in REG, t in 1:T], vREG[y, t] <= max_power(y, t) * reg_max(gen[y]) * commit(y, t)) + @constraint(EP, [y in RSV, t in 1:T], vRSV[y, t] <= max_power(y, t) * rsv_max(gen[y]) * commit(y, t)) # Minimum stable power generated per technology "y" at hour "t" and contribution to regulation must be > min power expr = extract_time_series_to_expression(vP, THERM_COMMIT) add_similar_to_expression!(expr[REG, :], -vREG[REG, :]) - @constraint(EP, [y in THERM_COMMIT, t in 1:T], expr[y, t] >= min_power(res[y]) * commit(y, t)) + @constraint(EP, [y in THERM_COMMIT, t in 1:T], expr[y, t] >= min_power(gen[y]) * commit(y, t)) # Maximum power generated per technology "y" at hour "t" and contribution to regulation and reserves up must be < max power expr = extract_time_series_to_expression(vP, THERM_COMMIT) @@ -311,11 +311,11 @@ function maintenance_formulation_thermal_commit!(EP::Model, inputs::Dict, setup: @info "Maintenance Module for Thermal plants" ensure_maintenance_variable_records!(inputs) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] - by_rid(rid, sym) = by_rid_df(rid, sym, res) + by_rid(rid, sym) = by_rid_df(rid, sym, gen) - MAINT = resources_with_maintenance(res) + MAINT = resources_with_maintenance(gen) resource_component(y) = by_rid(y, :Resource) cap(y) = by_rid(y, :Cap_Size) maint_dur(y) = Int(floor(by_rid(y, :Maintenance_Duration))) @@ -352,12 +352,12 @@ end """ function thermal_maintenance_capacity_reserve_margin_adjustment!(EP::Model, inputs::Dict) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) ncapres = inputs["NCapacityReserveMargin"] THERM_COMMIT = inputs["THERM_COMMIT"] - MAINT = resources_with_maintenance(res) + MAINT = resources_with_maintenance(gen) applicable_resources = intersect(MAINT, THERM_COMMIT) maint_adj = @expression(EP, [capres in 1:ncapres, t in 1:T], diff --git a/src/model/resources/thermal/thermal_no_commit.jl b/src/model/resources/thermal/thermal_no_commit.jl index cb2683809f..d6e5a4a09c 100644 --- a/src/model/resources/thermal/thermal_no_commit.jl +++ b/src/model/resources/thermal/thermal_no_commit.jl @@ -45,7 +45,7 @@ function thermal_no_commit!(EP::Model, inputs::Dict, setup::Dict) println("Thermal (No Unit Commitment) Resources Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) Z = inputs["Z"] # Number of zones @@ -58,7 +58,7 @@ function thermal_no_commit!(EP::Model, inputs::Dict, setup::Dict) ## Power Balance Expressions ## @expression(EP, ePowerBalanceThermNoCommit[t=1:T, z=1:Z], - sum(EP[:vP][y,t] for y in intersect(THERM_NO_COMMIT, resources_in_zone_by_rid(res,z))) + sum(EP[:vP][y,t] for y in intersect(THERM_NO_COMMIT, resources_in_zone_by_rid(gen,z))) ) add_similar_to_expression!(EP[:ePowerBalance], ePowerBalanceThermNoCommit) @@ -68,10 +68,10 @@ function thermal_no_commit!(EP::Model, inputs::Dict, setup::Dict) @constraints(EP, begin ## Maximum ramp up between consecutive hours - [y in THERM_NO_COMMIT, t in 1:T], EP[:vP][y,t] - EP[:vP][y, hoursbefore(p,t,1)] <= ramp_up_percentage(res[y])*EP[:eTotalCap][y] + [y in THERM_NO_COMMIT, t in 1:T], EP[:vP][y,t] - EP[:vP][y, hoursbefore(p,t,1)] <= ramp_up_percentage(gen[y])*EP[:eTotalCap][y] ## Maximum ramp down between consecutive hours - [y in THERM_NO_COMMIT, t in 1:T], EP[:vP][y, hoursbefore(p,t,1)] - EP[:vP][y,t] <= ramp_down_percentage(res[y])*EP[:eTotalCap][y] + [y in THERM_NO_COMMIT, t in 1:T], EP[:vP][y, hoursbefore(p,t,1)] - EP[:vP][y,t] <= ramp_down_percentage(gen[y])*EP[:eTotalCap][y] end) ### Minimum and maximum power output constraints (Constraints #3-4) @@ -81,7 +81,7 @@ function thermal_no_commit!(EP::Model, inputs::Dict, setup::Dict) else @constraints(EP, begin # Minimum stable power generated per technology "y" at hour "t" Min_Power - [y in THERM_NO_COMMIT, t=1:T], EP[:vP][y,t] >= min_power(res[y])*EP[:eTotalCap][y] + [y in THERM_NO_COMMIT, t=1:T], EP[:vP][y,t] >= min_power(gen[y])*EP[:eTotalCap][y] # Maximum power generated per technology "y" at hour "t" [y in THERM_NO_COMMIT, t=1:T], EP[:vP][y,t] <= inputs["pP_Max"][y,t]*EP[:eTotalCap][y] @@ -138,7 +138,7 @@ function thermal_no_commit_reserves!(EP::Model, inputs::Dict) println("Thermal No Commit Reserves Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) @@ -155,13 +155,13 @@ function thermal_no_commit_reserves!(EP::Model, inputs::Dict) max_power(y,t) = inputs["pP_Max"][y,t] # Maximum regulation and reserve contributions - @constraint(EP, [y in REG, t in 1:T], vREG[y, t] <= max_power(y, t) * reg_max(res[y]) * eTotalCap[y]) - @constraint(EP, [y in RSV, t in 1:T], vRSV[y, t] <= max_power(y, t) * rsv_max(res[y]) * eTotalCap[y]) + @constraint(EP, [y in REG, t in 1:T], vREG[y, t] <= max_power(y, t) * reg_max(gen[y]) * eTotalCap[y]) + @constraint(EP, [y in RSV, t in 1:T], vRSV[y, t] <= max_power(y, t) * rsv_max(gen[y]) * eTotalCap[y]) # Minimum stable power generated per technology "y" at hour "t" and contribution to regulation must be > min power expr = extract_time_series_to_expression(vP, THERM_NO_COMMIT) add_similar_to_expression!(expr[REG, :], -vREG[REG, :]) - @constraint(EP, [y in THERM_NO_COMMIT, t in 1:T], expr[y, t] >= min_power(res[y]) * eTotalCap[y]) + @constraint(EP, [y in THERM_NO_COMMIT, t in 1:T], expr[y, t] >= min_power(gen[y]) * eTotalCap[y]) # Maximum power generated per technology "y" at hour "t" and contribution to regulation and reserves up must be < max power expr = extract_time_series_to_expression(vP, THERM_NO_COMMIT) diff --git a/src/model/resources/vre_stor/vre_stor.jl b/src/model/resources/vre_stor/vre_stor.jl index 9ef75a37b6..0f408caf22 100644 --- a/src/model/resources/vre_stor/vre_stor.jl +++ b/src/model/resources/vre_stor/vre_stor.jl @@ -101,7 +101,7 @@ function vre_stor!(EP::Model, inputs::Dict, setup::Dict) ### LOAD DATA ### # Load generators dataframe, sets, and time periods - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) Z = inputs["Z"] # Number of zones @@ -134,9 +134,9 @@ function vre_stor!(EP::Model, inputs::Dict, setup::Dict) # Separate grid costs @expression(EP, eCGrid[y in VRE_STOR], if y in NEW_CAP # Resources eligible for new capacity - inv_cost_per_mwyr(res[y])*EP[:vCAP][y] + fixed_om_cost_per_mwyr(res[y])*EP[:eTotalCap][y] + inv_cost_per_mwyr(gen[y])*EP[:vCAP][y] + fixed_om_cost_per_mwyr(gen[y])*EP[:eTotalCap][y] else - fixed_om_cost_per_mwyr(res[y])*EP[:eTotalCap][y] + fixed_om_cost_per_mwyr(gen[y])*EP[:eTotalCap][y] end ) @expression(EP, eTotalCGrid, sum(eCGrid[y] for y in VRE_STOR)) @@ -961,7 +961,7 @@ function stor_vre_stor!(EP::Model, inputs::Dict, setup::Dict) T = inputs["T"] Z = inputs["Z"] - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] STOR = inputs["VS_STOR"] dfVRE_STOR = inputs["dfVRE_STOR"] @@ -1020,7 +1020,7 @@ function stor_vre_stor!(EP::Model, inputs::Dict, setup::Dict) if MultiStage == 1 @expression(EP, eExistingCapEnergy_VS[y in STOR], vEXISTINGCAPENERGY_VS[y]) else - @expression(EP, eExistingCapEnergy_VS[y in STOR], existing_cap_mwh(res[y])) + @expression(EP, eExistingCapEnergy_VS[y in STOR], existing_cap_mwh(gen[y])) end # 1. Total storage energy capacity @@ -1041,9 +1041,9 @@ function stor_vre_stor!(EP::Model, inputs::Dict, setup::Dict) # Fixed costs for storage resources (if resource is not eligible for new energy capacity, fixed costs are only O&M costs) @expression(EP, eCFixEnergy_VS[y in STOR], if y in NEW_CAP_STOR # Resources eligible for new capacity - inv_cost_per_mwhyr(res[y])*vCAPENERGY_VS[y] + fixed_om_cost_per_mwhyr(res[y])*eTotalCap_STOR[y] + inv_cost_per_mwhyr(gen[y])*vCAPENERGY_VS[y] + fixed_om_cost_per_mwhyr(gen[y])*eTotalCap_STOR[y] else - fixed_om_cost_per_mwhyr(res[y])*eTotalCap_STOR[y] + fixed_om_cost_per_mwhyr(gen[y])*eTotalCap_STOR[y] end ) @expression(EP, eTotalCFixStor, sum(eCFixEnergy_VS[y] for y in STOR)) @@ -1085,9 +1085,9 @@ function stor_vre_stor!(EP::Model, inputs::Dict, setup::Dict) # SoC expressions @expression(EP, eSoCBalStart_VRE_STOR[y in CONSTRAINTSET, t in START_SUBPERIODS], - vS_VRE_STOR[y,t+hours_per_subperiod-1] - self_discharge(res[y])*vS_VRE_STOR[y,t+hours_per_subperiod-1]) + vS_VRE_STOR[y,t+hours_per_subperiod-1] - self_discharge(gen[y])*vS_VRE_STOR[y,t+hours_per_subperiod-1]) @expression(EP, eSoCBalInterior_VRE_STOR[y in STOR, t in INTERIOR_SUBPERIODS], - vS_VRE_STOR[y,t-1] - self_discharge(res[y])*vS_VRE_STOR[y,t-1]) + vS_VRE_STOR[y,t-1] - self_discharge(gen[y])*vS_VRE_STOR[y,t-1]) # Expression for energy losses related to technologies (increase in effective demand) @expression(EP, eELOSS_VRE_STOR[y in STOR], JuMP.AffExpr()) @@ -1174,7 +1174,7 @@ function stor_vre_stor!(EP::Model, inputs::Dict, setup::Dict) # Constraint 0: Existing capacity variable is equal to existing capacity specified in the input file if MultiStage == 1 - @constraint(EP, cExistingCapEnergy_VS[y in STOR], EP[:vEXISTINGCAPENERGY_VS][y] == existing_capacity_mwh(res[y])) + @constraint(EP, cExistingCapEnergy_VS[y in STOR], EP[:vEXISTINGCAPENERGY_VS][y] == existing_capacity_mwh(gen[y])) end # Constraints 1: Retirements and capacity additions @@ -1182,12 +1182,12 @@ function stor_vre_stor!(EP::Model, inputs::Dict, setup::Dict) @constraint(EP, cMaxRet_Stor[y=RET_CAP_STOR], vRETCAPENERGY_VS[y] <= eExistingCapEnergy_VS[y]) # Constraint on maximum capacity (if applicable) [set input to -1 if no constraint on maximum capacity] # DEV NOTE: This constraint may be violated in some cases where Existing_Cap_MW is >= Max_Cap_MW and lead to infeasabilty - @constraint(EP, cMaxCap_Stor[y in intersect(has_positive_max_capacity_mwh(res), STOR)], - eTotalCap_STOR[y] <= max_capacity_mwh(res[y])) + @constraint(EP, cMaxCap_Stor[y in intersect(has_positive_max_capacity_mwh(gen), STOR)], + eTotalCap_STOR[y] <= max_capacity_mwh(gen[y])) # Constraint on minimum capacity (if applicable) [set input to -1 if no constraint on minimum capacity] # DEV NOTE: This constraint may be violated in some cases where Existing_Cap_MW is <= Min_Cap_MW and lead to infeasabilty - @constraint(EP, cMinCap_Stor[y in intersect(has_positive_min_capacity_mwh(res), STOR)], - eTotalCap_STOR[y] >= min_capacity_mwh(res[y])) + @constraint(EP, cMinCap_Stor[y in intersect(has_positive_min_capacity_mwh(gen), STOR)], + eTotalCap_STOR[y] >= min_capacity_mwh(gen[y])) # Constraint 2: SOC Maximum @constraint(EP, cSOCMax[y in STOR, t=1:T], vS_VRE_STOR[y,t] <= eTotalCap_STOR[y]) @@ -1252,7 +1252,7 @@ function lds_vre_stor!(EP::Model, inputs::Dict) ### LOAD DATA ### VS_LDS = inputs["VS_LDS"] - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] dfVRE_STOR = inputs["dfVRE_STOR"] REP_PERIOD = inputs["REP_PERIOD"] # Number of representative periods @@ -1278,7 +1278,7 @@ function lds_vre_stor!(EP::Model, inputs::Dict) # Note: tw_min = hours_per_subperiod*(w-1)+1; tw_max = hours_per_subperiod*w @expression(EP, eVreStorSoCBalLongDurationStorageStart[y in VS_LDS, w=1:REP_PERIOD], - (1-self_discharge(res[y])) * (EP[:vS_VRE_STOR][y,hours_per_subperiod*w]-EP[:vdSOC_VRE_STOR][y,w])) + (1-self_discharge(gen[y])) * (EP[:vS_VRE_STOR][y,hours_per_subperiod*w]-EP[:vdSOC_VRE_STOR][y,w])) DC_DISCHARGE_CONSTRAINTSET = intersect(inputs["VS_STOR_DC_DISCHARGE"], VS_LDS) DC_CHARGE_CONSTRAINTSET = intersect(inputs["VS_STOR_DC_CHARGE"], VS_LDS) @@ -1875,7 +1875,7 @@ function vre_stor_capres!(EP::Model, inputs::Dict, setup::Dict) ### LOAD DATA ### T = inputs["T"] - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] dfVRE_STOR = inputs["dfVRE_STOR"] STOR = inputs["VS_STOR"] DC_DISCHARGE = inputs["VS_STOR_DC_DISCHARGE"] @@ -1930,10 +1930,10 @@ function vre_stor_capres!(EP::Model, inputs::Dict, setup::Dict) # Virtual State of Charge Expressions @expression(EP, eVreStorVSoCBalStart[y in CONSTRAINTSET, t in START_SUBPERIODS], EP[:vCAPRES_VS_VRE_STOR][y,t+hours_per_subperiod-1] - - self_discharge(res[y])*EP[:vCAPRES_VS_VRE_STOR][y,t+hours_per_subperiod-1]) + - self_discharge(gen[y])*EP[:vCAPRES_VS_VRE_STOR][y,t+hours_per_subperiod-1]) @expression(EP, eVreStorVSoCBalInterior[y in STOR, t in INTERIOR_SUBPERIODS], EP[:vCAPRES_VS_VRE_STOR][y,t-1] - - self_discharge(res[y])*EP[:vCAPRES_VS_VRE_STOR][y,t-1]) + - self_discharge(gen[y])*EP[:vCAPRES_VS_VRE_STOR][y,t-1]) DC_DISCHARGE_CONSTRAINTSET = intersect(CONSTRAINTSET, DC_DISCHARGE) DC_CHARGE_CONSTRAINTSET = intersect(CONSTRAINTSET, DC_CHARGE) @@ -2086,7 +2086,7 @@ function vre_stor_capres!(EP::Model, inputs::Dict, setup::Dict) ### EXPRESSIONS ### @expression(EP, eVreStorVSoCBalLongDurationStorageStart[y in VS_LDS, w=1:REP_PERIOD], - (1-self_discharge(res[y]))*(EP[:vCAPRES_VS_VRE_STOR][y,hours_per_subperiod*w]-vCAPCONTRSTOR_VdSOC_VRE_STOR[y,w])) + (1-self_discharge(gen[y]))*(EP[:vCAPRES_VS_VRE_STOR][y,hours_per_subperiod*w]-vCAPCONTRSTOR_VdSOC_VRE_STOR[y,w])) DC_DISCHARGE_CONSTRAINTSET = intersect(DC_DISCHARGE, VS_LDS) DC_CHARGE_CONSTRAINTSET = intersect(DC_CHARGE, VS_LDS) @@ -2218,7 +2218,7 @@ function vre_stor_reserves!(EP::Model, inputs::Dict, setup::Dict) ### LOAD DATA & CREATE SETS ### - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] VRE_STOR = inputs["VRE_STOR"] @@ -2456,8 +2456,8 @@ function vre_stor_reserves!(EP::Model, inputs::Dict, setup::Dict) if !isempty(VRE_STOR_REG_RSV) @constraints(EP, begin # Maximum VRE-STOR contribution to reserves is a specified fraction of installed grid connection capacity - [y in VRE_STOR_REG_RSV, t=1:T], EP[:vREG][y,t] <= reg_max(res[y])*EP[:eTotalCap][y] - [y in VRE_STOR_REG_RSV, t=1:T], EP[:vRSV][y,t] <= rsv_max(res[y])*EP[:eTotalCap][y] + [y in VRE_STOR_REG_RSV, t=1:T], EP[:vREG][y,t] <= reg_max(gen[y])*EP[:eTotalCap][y] + [y in VRE_STOR_REG_RSV, t=1:T], EP[:vRSV][y,t] <= rsv_max(gen[y])*EP[:eTotalCap][y] # Actual contribution to regulation and reserves is sum of auxilary variables [y in VRE_STOR_REG_RSV, t=1:T], EP[:vREG][y,t] == eVreStorRegOnlyBalance[y,t] @@ -2467,7 +2467,7 @@ function vre_stor_reserves!(EP::Model, inputs::Dict, setup::Dict) if !isempty(VRE_STOR_REG_ONLY) @constraints(EP, begin # Maximum VRE-STOR contribution to reserves is a specified fraction of installed grid connection capacity - [y in VRE_STOR_REG_ONLY, t=1:T], EP[:vREG][y,t] <= reg_max(res[y])*EP[:eTotalCap][y] + [y in VRE_STOR_REG_ONLY, t=1:T], EP[:vREG][y,t] <= reg_max(gen[y])*EP[:eTotalCap][y] # Actual contribution to regulation is sum of auxilary variables [y in VRE_STOR_REG_ONLY, t=1:T], EP[:vREG][y,t] == eVreStorRegOnlyBalance[y,t] @@ -2476,7 +2476,7 @@ function vre_stor_reserves!(EP::Model, inputs::Dict, setup::Dict) if !isempty(VRE_STOR_RSV_ONLY) @constraints(EP, begin # Maximum VRE-STOR contribution to reserves is a specified fraction of installed grid connection capacity - [y in VRE_STOR_RSV_ONLY, t=1:T], EP[:vRSV][y,t] <= rsv_max(res[y])*EP[:eTotalCap][y] + [y in VRE_STOR_RSV_ONLY, t=1:T], EP[:vRSV][y,t] <= rsv_max(gen[y])*EP[:eTotalCap][y] # Actual contribution to reserves is sum of auxilary variables [y in VRE_STOR_RSV_ONLY, t=1:T], EP[:vRSV][y,t] == eVreStorRsvOnlyBalance[y,t] diff --git a/src/multi_stage/endogenous_retirement.jl b/src/multi_stage/endogenous_retirement.jl index b9f064a9b5..cf48a7e75e 100644 --- a/src/multi_stage/endogenous_retirement.jl +++ b/src/multi_stage/endogenous_retirement.jl @@ -135,7 +135,7 @@ function endogenous_retirement_discharge!(EP::Model, inputs::Dict, num_stages::I println("Endogenous Retirement (Discharge) Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] NEW_CAP = inputs["NEW_CAP"] # Set of all resources eligible for new capacity RET_CAP = inputs["RET_CAP"] # Set of all resources eligible for capacity retirements @@ -161,12 +161,12 @@ function endogenous_retirement_discharge!(EP::Model, inputs::Dict, num_stages::I # Construct and add the endogenous retirement constraint expressions @expression(EP, eRetCapTrack[y in RET_CAP], sum(EP[:vRETCAPTRACK][y,p] for p=1:cur_stage)) - @expression(EP, eNewCapTrack[y in RET_CAP], sum(EP[:vCAPTRACK][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(res[y]), stage_lens))) + @expression(EP, eNewCapTrack[y in RET_CAP], sum(EP[:vCAPTRACK][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens))) @expression(EP, eMinRetCapTrack[y in RET_CAP], if y in COMMIT - cum_min_retired_cap_mw(res[y])/cap_size(res[y]) + cum_min_retired_cap_mw(gen[y])/cap_size(gen[y]) else - cum_min_retired_cap_mw(res[y]) + cum_min_retired_cap_mw(gen[y]) end ) @@ -190,7 +190,7 @@ function endogenous_retirement_charge!(EP::Model, inputs::Dict, num_stages::Int, println("Endogenous Retirement (Charge) Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] STOR_ASYMMETRIC = inputs["STOR_ASYMMETRIC"] # Set of storage resources with asymmetric (separte) charge/discharge capacity components @@ -217,8 +217,8 @@ function endogenous_retirement_charge!(EP::Model, inputs::Dict, num_stages::Int, # Construct and add the endogenous retirement constraint expressions @expression(EP, eRetCapTrackCharge[y in RET_CAP_CHARGE], sum(EP[:vRETCAPTRACKCHARGE][y,p] for p=1:cur_stage)) - @expression(EP, eNewCapTrackCharge[y in RET_CAP_CHARGE], sum(EP[:vCAPTRACKCHARGE][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(res[y]), stage_lens))) - @expression(EP, eMinRetCapTrackCharge[y in RET_CAP_CHARGE], cum_min_retired_charge_cap_mw(res[y])) + @expression(EP, eNewCapTrackCharge[y in RET_CAP_CHARGE], sum(EP[:vCAPTRACKCHARGE][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens))) + @expression(EP, eMinRetCapTrackCharge[y in RET_CAP_CHARGE], cum_min_retired_charge_cap_mw(gen[y])) ### Constratints ### @@ -240,7 +240,7 @@ function endogenous_retirement_energy!(EP::Model, inputs::Dict, num_stages::Int, println("Endogenous Retirement (Energy) Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] NEW_CAP_ENERGY = inputs["NEW_CAP_ENERGY"] # Set of all storage resources eligible for new energy capacity RET_CAP_ENERGY = inputs["RET_CAP_ENERGY"] # Set of all storage resources eligible for energy capacity retirements @@ -265,8 +265,8 @@ function endogenous_retirement_energy!(EP::Model, inputs::Dict, num_stages::Int, # Construct and add the endogenous retirement constraint expressions @expression(EP, eRetCapTrackEnergy[y in RET_CAP_ENERGY], sum(EP[:vRETCAPTRACKENERGY][y,p] for p=1:cur_stage)) - @expression(EP, eNewCapTrackEnergy[y in RET_CAP_ENERGY], sum(EP[:vCAPTRACKENERGY][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(res[y]), stage_lens))) - @expression(EP, eMinRetCapTrackEnergy[y in RET_CAP_ENERGY], cum_min_retired_energy_cap_mw(res[y])) + @expression(EP, eNewCapTrackEnergy[y in RET_CAP_ENERGY], sum(EP[:vCAPTRACKENERGY][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens))) + @expression(EP, eMinRetCapTrackEnergy[y in RET_CAP_ENERGY], cum_min_retired_energy_cap_mw(gen[y])) ### Constratints ### @@ -287,7 +287,7 @@ function endogenous_retirement_vre_stor_dc!(EP::Model, inputs::Dict, num_stages: println("Endogenous Retirement (VRE-Storage DC) Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] dfVRE_STOR = inputs["dfVRE_STOR"]; @@ -314,7 +314,7 @@ function endogenous_retirement_vre_stor_dc!(EP::Model, inputs::Dict, num_stages: # Construct and add the endogenous retirement constraint expressions @expression(EP, eRetCapTrackDC[y in RET_CAP_DC], sum(EP[:vRETCAPTRACKDC][y,p] for p=1:cur_stage)) - @expression(EP, eNewCapTrackDC[y in RET_CAP_DC], sum(EP[:vCAPTRACKDC][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(res[y]), stage_lens))) + @expression(EP, eNewCapTrackDC[y in RET_CAP_DC], sum(EP[:vCAPTRACKDC][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens))) @expression(EP, eMinRetCapTrackDC[y in RET_CAP_DC], dfVRE_STOR[y,:Cum_Min_Retired_Cap_Inverter_MW]) ### Constraints ### @@ -336,7 +336,7 @@ function endogenous_retirement_vre_stor_solar!(EP::Model, inputs::Dict, num_stag println("Endogenous Retirement (VRE-Storage Solar) Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] dfVRE_STOR = inputs["dfVRE_STOR"]; @@ -363,7 +363,7 @@ function endogenous_retirement_vre_stor_solar!(EP::Model, inputs::Dict, num_stag # Construct and add the endogenous retirement constraint expressions @expression(EP, eRetCapTrackSolar[y in RET_CAP_SOLAR], sum(EP[:vRETCAPTRACKSOLAR][y,p] for p=1:cur_stage)) - @expression(EP, eNewCapTrackSolar[y in RET_CAP_SOLAR], sum(EP[:vCAPTRACKSOLAR][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(res[y]), stage_lens))) + @expression(EP, eNewCapTrackSolar[y in RET_CAP_SOLAR], sum(EP[:vCAPTRACKSOLAR][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens))) @expression(EP, eMinRetCapTrackSolar[y in RET_CAP_SOLAR], dfVRE_STOR[y,:Cum_Min_Retired_Cap_Solar_MW]) ### Constraints ### @@ -385,7 +385,7 @@ function endogenous_retirement_vre_stor_wind!(EP::Model, inputs::Dict, num_stage println("Endogenous Retirement (VRE-Storage Wind) Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] dfVRE_STOR = inputs["dfVRE_STOR"]; @@ -412,7 +412,7 @@ function endogenous_retirement_vre_stor_wind!(EP::Model, inputs::Dict, num_stage # Construct and add the endogenous retirement constraint expressions @expression(EP, eRetCapTrackWind[y in RET_CAP_WIND], sum(EP[:vRETCAPTRACKWIND][y,p] for p=1:cur_stage)) - @expression(EP, eNewCapTrackWind[y in RET_CAP_WIND], sum(EP[:vCAPTRACKWIND][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(res[y]), stage_lens))) + @expression(EP, eNewCapTrackWind[y in RET_CAP_WIND], sum(EP[:vCAPTRACKWIND][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens))) @expression(EP, eMinRetCapTrackWind[y in RET_CAP_WIND], dfVRE_STOR[y,:Cum_Min_Retired_Cap_Wind_MW]) ### Constraints ### @@ -434,7 +434,7 @@ function endogenous_retirement_vre_stor_stor!(EP::Model, inputs::Dict, num_stage println("Endogenous Retirement (VRE-Storage Storage) Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] NEW_CAP_STOR = inputs["NEW_CAP_STOR"] # Set of all resources eligible for new capacity RET_CAP_STOR = inputs["RET_CAP_STOR"] # Set of all resources eligible for capacity retirements @@ -459,8 +459,8 @@ function endogenous_retirement_vre_stor_stor!(EP::Model, inputs::Dict, num_stage # Construct and add the endogenous retirement constraint expressions @expression(EP, eRetCapTrackEnergy_VS[y in RET_CAP_STOR], sum(EP[:vRETCAPTRACKENERGY_VS][y,p] for p=1:cur_stage)) - @expression(EP, eNewCapTrackEnergy_VS[y in RET_CAP_STOR], sum(EP[:vCAPTRACKENERGY_VS][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(res[y]), stage_lens))) - @expression(EP, eMinRetCapTrackEnergy_VS[y in RET_CAP_STOR], cum_min_retired_energy_cap_mw(res[y])) + @expression(EP, eNewCapTrackEnergy_VS[y in RET_CAP_STOR], sum(EP[:vCAPTRACKENERGY_VS][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens))) + @expression(EP, eMinRetCapTrackEnergy_VS[y in RET_CAP_STOR], cum_min_retired_energy_cap_mw(gen[y])) ### Constratints ### @@ -481,7 +481,7 @@ function endogenous_retirement_vre_stor_discharge_dc!(EP::Model, inputs::Dict, n println("Endogenous Retirement (VRE-Storage Discharge DC) Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] dfVRE_STOR = inputs["dfVRE_STOR"] @@ -508,7 +508,7 @@ function endogenous_retirement_vre_stor_discharge_dc!(EP::Model, inputs::Dict, n # Construct and add the endogenous retirement constraint expressions @expression(EP, eRetCapTrackDischargeDC[y in RET_CAP_DISCHARGE_DC], sum(EP[:vRETCAPTRACKDISCHARGEDC][y,p] for p=1:cur_stage)) - @expression(EP, eNewCapTrackDischargeDC[y in RET_CAP_DISCHARGE_DC], sum(EP[:vCAPTRACKDISCHARGEDC][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(res[y]), stage_lens))) + @expression(EP, eNewCapTrackDischargeDC[y in RET_CAP_DISCHARGE_DC], sum(EP[:vCAPTRACKDISCHARGEDC][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens))) @expression(EP, eMinRetCapTrackDischargeDC[y in RET_CAP_DISCHARGE_DC], dfVRE_STOR[y,:Cum_Min_Retired_Cap_Discharge_DC_MW]) ### Constraints ### @@ -530,7 +530,7 @@ function endogenous_retirement_vre_stor_charge_dc!(EP::Model, inputs::Dict, num_ println("Endogenous Retirement (VRE-Storage Charge DC) Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] dfVRE_STOR = inputs["dfVRE_STOR"]; NEW_CAP_CHARGE_DC = inputs["NEW_CAP_CHARGE_DC"] # Set of all resources eligible for new capacity RET_CAP_CHARGE_DC = inputs["RET_CAP_CHARGE_DC"] # Set of all resources eligible for capacity retirements @@ -555,7 +555,7 @@ function endogenous_retirement_vre_stor_charge_dc!(EP::Model, inputs::Dict, num_ # Construct and add the endogenous retirement constraint expressions @expression(EP, eRetCapTrackChargeDC[y in RET_CAP_CHARGE_DC], sum(EP[:vRETCAPTRACKCHARGEDC][y,p] for p=1:cur_stage)) - @expression(EP, eNewCapTrackChargeDC[y in RET_CAP_CHARGE_DC], sum(EP[:vCAPTRACKCHARGEDC][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(res[y]), stage_lens))) + @expression(EP, eNewCapTrackChargeDC[y in RET_CAP_CHARGE_DC], sum(EP[:vCAPTRACKCHARGEDC][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens))) @expression(EP, eMinRetCapTrackChargeDC[y in RET_CAP_CHARGE_DC], dfVRE_STOR[y,:Cum_Min_Retired_Cap_Charge_DC_MW]) ### Constraints ### @@ -577,7 +577,7 @@ function endogenous_retirement_vre_stor_discharge_ac!(EP::Model, inputs::Dict, n println("Endogenous Retirement (VRE-Storage Discharge AC) Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] dfVRE_STOR = inputs["dfVRE_STOR"]; NEW_CAP_DISCHARGE_AC = inputs["NEW_CAP_DISCHARGE_AC"] # Set of all resources eligible for new capacity RET_CAP_DISCHARGE_AC = inputs["RET_CAP_DISCHARGE_AC"] # Set of all resources eligible for capacity retirements @@ -602,7 +602,7 @@ function endogenous_retirement_vre_stor_discharge_ac!(EP::Model, inputs::Dict, n # Construct and add the endogenous retirement constraint expressions @expression(EP, eRetCapTrackDischargeAC[y in RET_CAP_DISCHARGE_AC], sum(EP[:vRETCAPTRACKDISCHARGEAC][y,p] for p=1:cur_stage)) - @expression(EP, eNewCapTrackDischargeAC[y in RET_CAP_DISCHARGE_AC], sum(EP[:vCAPTRACKDISCHARGEAC][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(res[y]), stage_lens))) + @expression(EP, eNewCapTrackDischargeAC[y in RET_CAP_DISCHARGE_AC], sum(EP[:vCAPTRACKDISCHARGEAC][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens))) @expression(EP, eMinRetCapTrackDischargeAC[y in RET_CAP_DISCHARGE_AC], dfVRE_STOR[y,:Cum_Min_Retired_Cap_Discharge_AC_MW]) ### Constraints ### @@ -624,7 +624,7 @@ function endogenous_retirement_vre_stor_charge_ac!(EP::Model, inputs::Dict, num_ println("Endogenous Retirement (VRE-Storage Charge AC) Module") - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] dfVRE_STOR = inputs["dfVRE_STOR"] NEW_CAP_CHARGE_AC = inputs["NEW_CAP_CHARGE_AC"] # Set of all resources eligible for new capacity RET_CAP_CHARGE_AC = inputs["RET_CAP_CHARGE_AC"] # Set of all resources eligible for capacity retirements @@ -649,7 +649,7 @@ function endogenous_retirement_vre_stor_charge_ac!(EP::Model, inputs::Dict, num_ # Construct and add the endogenous retirement constraint expressions @expression(EP, eRetCapTrackChargeAC[y in RET_CAP_CHARGE_AC], sum(EP[:vRETCAPTRACKCHARGEAC][y,p] for p=1:cur_stage)) - @expression(EP, eNewCapTrackChargeAC[y in RET_CAP_CHARGE_AC], sum(EP[:vCAPTRACKCHARGEAC][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(res[y]), stage_lens))) + @expression(EP, eNewCapTrackChargeAC[y in RET_CAP_CHARGE_AC], sum(EP[:vCAPTRACKCHARGEAC][y,p] for p=1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens))) @expression(EP, eMinRetCapTrackChargeAC[y in RET_CAP_CHARGE_AC], dfVRE_STOR[y,:Cum_Min_Retired_Cap_Charge_AC_MW]) ### Constraints ### diff --git a/src/write_outputs/capacity_reserve_margin/write_capacity_value.jl b/src/write_outputs/capacity_reserve_margin/write_capacity_value.jl index 9afdf91357..e1d24cb9be 100644 --- a/src/write_outputs/capacity_reserve_margin/write_capacity_value.jl +++ b/src/write_outputs/capacity_reserve_margin/write_capacity_value.jl @@ -1,6 +1,6 @@ function write_capacity_value(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) diff --git a/src/write_outputs/capacity_reserve_margin/write_reserve_margin_revenue.jl b/src/write_outputs/capacity_reserve_margin/write_reserve_margin_revenue.jl index 251a2314f0..770bc4b13c 100644 --- a/src/write_outputs/capacity_reserve_margin/write_reserve_margin_revenue.jl +++ b/src/write_outputs/capacity_reserve_margin/write_reserve_margin_revenue.jl @@ -11,10 +11,10 @@ Function for reporting the capacity revenue earned by each generator listed in t function write_reserve_margin_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) scale_factor = setup["ParameterScale"] == 1 ? ModelScalingFactor : 1 - res = inputs["RESOURCES"] - regions = region.(res) - clusters = cluster.(res) - zones = zone_id.(res) + gen = inputs["RESOURCES"] + regions = region.(gen) + clusters = cluster.(gen) + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) diff --git a/src/write_outputs/capacity_reserve_margin/write_virtual_discharge.jl b/src/write_outputs/capacity_reserve_margin/write_virtual_discharge.jl index 61cf2cdb12..44ac77738a 100644 --- a/src/write_outputs/capacity_reserve_margin/write_virtual_discharge.jl +++ b/src/write_outputs/capacity_reserve_margin/write_virtual_discharge.jl @@ -5,8 +5,8 @@ Function for writing the "virtual" discharge of each storage technology. Virtual allow storage resources to contribute to the capacity reserve margin without actually discharging. """ function write_virtual_discharge(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) diff --git a/src/write_outputs/long_duration_storage/write_opwrap_lds_dstor.jl b/src/write_outputs/long_duration_storage/write_opwrap_lds_dstor.jl index cf8d275456..c897823ef9 100644 --- a/src/write_outputs/long_duration_storage/write_opwrap_lds_dstor.jl +++ b/src/write_outputs/long_duration_storage/write_opwrap_lds_dstor.jl @@ -1,7 +1,7 @@ function write_opwrap_lds_dstor(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) ## Extract data frames from input dictionary - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) W = inputs["REP_PERIOD"] # Number of subperiods G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) diff --git a/src/write_outputs/long_duration_storage/write_opwrap_lds_stor_init.jl b/src/write_outputs/long_duration_storage/write_opwrap_lds_stor_init.jl index 2750affdd3..b644d04385 100644 --- a/src/write_outputs/long_duration_storage/write_opwrap_lds_stor_init.jl +++ b/src/write_outputs/long_duration_storage/write_opwrap_lds_stor_init.jl @@ -1,7 +1,7 @@ function write_opwrap_lds_stor_init(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) ## Extract data frames from input dictionary - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) G = inputs["G"] diff --git a/src/write_outputs/reserves/write_reg.jl b/src/write_outputs/reserves/write_reg.jl index 05003456d3..7b69290f09 100644 --- a/src/write_outputs/reserves/write_reg.jl +++ b/src/write_outputs/reserves/write_reg.jl @@ -1,6 +1,6 @@ function write_reg(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) diff --git a/src/write_outputs/reserves/write_rsv.jl b/src/write_outputs/reserves/write_rsv.jl index 7db7c48dc5..feb34a1943 100644 --- a/src/write_outputs/reserves/write_rsv.jl +++ b/src/write_outputs/reserves/write_rsv.jl @@ -1,6 +1,6 @@ function write_rsv(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) diff --git a/src/write_outputs/ucommit/write_commit.jl b/src/write_outputs/ucommit/write_commit.jl index 6c48aaaa60..e3ece4b6e5 100644 --- a/src/write_outputs/ucommit/write_commit.jl +++ b/src/write_outputs/ucommit/write_commit.jl @@ -1,6 +1,6 @@ function write_commit(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) diff --git a/src/write_outputs/ucommit/write_shutdown.jl b/src/write_outputs/ucommit/write_shutdown.jl index 313fa13992..5b4ecd4c78 100644 --- a/src/write_outputs/ucommit/write_shutdown.jl +++ b/src/write_outputs/ucommit/write_shutdown.jl @@ -1,6 +1,6 @@ function write_shutdown(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) diff --git a/src/write_outputs/ucommit/write_start.jl b/src/write_outputs/ucommit/write_start.jl index 374049f028..ea9c2028b5 100644 --- a/src/write_outputs/ucommit/write_start.jl +++ b/src/write_outputs/ucommit/write_start.jl @@ -1,6 +1,6 @@ function write_start(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) diff --git a/src/write_outputs/write_capacity.jl b/src/write_outputs/write_capacity.jl index 5a6aa05138..c875dca109 100644 --- a/src/write_outputs/write_capacity.jl +++ b/src/write_outputs/write_capacity.jl @@ -5,7 +5,7 @@ Function for writing the diferent capacities for the different generation techno """ function write_capacity(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] MultiStage = setup["MultiStage"] @@ -13,7 +13,7 @@ function write_capacity(path::AbstractString, inputs::Dict, setup::Dict, EP::Mod capdischarge = zeros(size(inputs["RESOURCE_NAMES"])) for i in inputs["NEW_CAP"] if i in inputs["COMMIT"] - capdischarge[i] = value(EP[:vCAP][i])*cap_size(res[i]) + capdischarge[i] = value(EP[:vCAP][i])*cap_size(gen[i]) else capdischarge[i] = value(EP[:vCAP][i]) end @@ -22,14 +22,14 @@ function write_capacity(path::AbstractString, inputs::Dict, setup::Dict, EP::Mod retcapdischarge = zeros(size(inputs["RESOURCE_NAMES"])) for i in inputs["RET_CAP"] if i in inputs["COMMIT"] - retcapdischarge[i] = first(value.(EP[:vRETCAP][i]))*cap_size(res[i]) + retcapdischarge[i] = first(value.(EP[:vRETCAP][i]))*cap_size(gen[i]) else retcapdischarge[i] = first(value.(EP[:vRETCAP][i])) end end capacity_constraint_dual = zeros(size(inputs["RESOURCE_NAMES"])) - for y in has_positive_max_capacity_mw(res) + for y in has_positive_max_capacity_mw(gen) capacity_constraint_dual[y] = -dual.(EP[:cMaxCap][y]) end @@ -43,7 +43,7 @@ function write_capacity(path::AbstractString, inputs::Dict, setup::Dict, EP::Mod if i in inputs["RET_CAP_CHARGE"] retcapcharge[i] = value(EP[:vRETCAPCHARGE][i]) end - existingcapcharge[i] = MultiStage == 1 ? value(EP[:vEXISTINGCAPCHARGE][i]) : existing_charge_capacity_mw(res[i]) + existingcapcharge[i] = MultiStage == 1 ? value(EP[:vEXISTINGCAPCHARGE][i]) : existing_charge_capacity_mw(gen[i]) end capenergy = zeros(size(inputs["RESOURCE_NAMES"])) @@ -56,7 +56,7 @@ function write_capacity(path::AbstractString, inputs::Dict, setup::Dict, EP::Mod if i in inputs["RET_CAP_ENERGY"] retcapenergy[i] = value(EP[:vRETCAPENERGY][i]) end - existingcapenergy[i] = MultiStage == 1 ? value(EP[:vEXISTINGCAPENERGY][i]) : existing_capacity_mwh(res[y]) + existingcapenergy[i] = MultiStage == 1 ? value(EP[:vEXISTINGCAPENERGY][i]) : existing_capacity_mwh(gen[y]) end if !isempty(inputs["VRE_STOR"]) for i in inputs["VS_STOR"] @@ -66,13 +66,13 @@ function write_capacity(path::AbstractString, inputs::Dict, setup::Dict, EP::Mod if i in inputs["RET_CAP_STOR"] retcapenergy[i] = value(EP[:vRETCAPENERGY_VS][i]) end - existingcapenergy[i] = existing_capacity_mwh(res[y]) # multistage functionality doesn't exist yet for VRE-storage resources + existingcapenergy[i] = existing_capacity_mwh(gen[y]) # multistage functionality doesn't exist yet for VRE-storage resources end end dfCap = DataFrame( - Resource = inputs["RESOURCE_NAMES"], Zone = zone_id.(res), - StartCap = MultiStage == 1 ? value.(EP[:vEXISTINGCAP]) : existing_capacity_mw(res[y]), + Resource = inputs["RESOURCE_NAMES"], Zone = zone_id.(gen), + StartCap = MultiStage == 1 ? value.(EP[:vEXISTINGCAP]) : existing_capacity_mw(gen[y]), RetCap = retcapdischarge[:], NewCap = capdischarge[:], EndCap = value.(EP[:eTotalCap]), diff --git a/src/write_outputs/write_capacityfactor.jl b/src/write_outputs/write_capacityfactor.jl index 2774a3570b..2cafda8ead 100644 --- a/src/write_outputs/write_capacityfactor.jl +++ b/src/write_outputs/write_capacityfactor.jl @@ -5,7 +5,7 @@ Function for writing the capacity factor of different resources. For co-located value is calculated if the site has either or both a solar PV or wind resource. """ function write_capacityfactor(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) THERM_ALL = inputs["THERM_ALL"] @@ -15,7 +15,7 @@ function write_capacityfactor(path::AbstractString, inputs::Dict, setup::Dict, E ELECTROLYZER = inputs["ELECTROLYZER"] VRE_STOR = inputs["VRE_STOR"] - dfCapacityfactor = DataFrame(Resource=inputs["RESOURCE_NAMES"], Zone=zone_id.(res), AnnualSum=zeros(G), Capacity=zeros(G), CapacityFactor=zeros(G)) + dfCapacityfactor = DataFrame(Resource=inputs["RESOURCE_NAMES"], Zone=zone_id.(gen), AnnualSum=zeros(G), Capacity=zeros(G), CapacityFactor=zeros(G)) scale_factor = setup["ParameterScale"] == 1 ? ModelScalingFactor : 1 dfCapacityfactor.AnnualSum .= value.(EP[:vP]) * inputs["omega"] * scale_factor dfCapacityfactor.Capacity .= value.(EP[:eTotalCap]) * scale_factor diff --git a/src/write_outputs/write_charge.jl b/src/write_outputs/write_charge.jl index 9ec37603a6..e86d285d7c 100644 --- a/src/write_outputs/write_charge.jl +++ b/src/write_outputs/write_charge.jl @@ -4,8 +4,8 @@ Function for writing the charging energy values of the different storage technologies. """ function write_charge(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) diff --git a/src/write_outputs/write_charging_cost.jl b/src/write_outputs/write_charging_cost.jl index aa837f6559..824d668d83 100644 --- a/src/write_outputs/write_charging_cost.jl +++ b/src/write_outputs/write_charging_cost.jl @@ -1,9 +1,9 @@ function write_charging_cost(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] - regions = region.(res) - clusters = cluster.(res) - zones = zone_id.(res) + regions = region.(gen) + clusters = cluster.(gen) + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) @@ -18,16 +18,16 @@ function write_charging_cost(path::AbstractString, inputs::Dict, setup::Dict, EP dfChargingcost = DataFrame(Region = regions, Resource = inputs["RESOURCE_NAMES"], Zone = zones, Cluster = clusters, AnnualSum = Array{Float64}(undef, G),) chargecost = zeros(G, T) if !isempty(STOR_ALL) - chargecost[STOR_ALL, :] .= (value.(EP[:vCHARGE][STOR_ALL, :]).data) .* transpose(price)[zone_id.(res.STOR), :] + chargecost[STOR_ALL, :] .= (value.(EP[:vCHARGE][STOR_ALL, :]).data) .* transpose(price)[zone_id.(gen.STOR), :] end if !isempty(FLEX) - chargecost[FLEX, :] .= value.(EP[:vP][FLEX, :]) .* transpose(price)[zone_id.(res.FLEX), :] + chargecost[FLEX, :] .= value.(EP[:vP][FLEX, :]) .* transpose(price)[zone_id.(gen.FLEX), :] end if !isempty(ELECTROLYZER) - chargecost[ELECTROLYZER, :] .= (value.(EP[:vUSE][ELECTROLYZER, :]).data) .* transpose(price)[zone_id.(res.ELECTROLYZER), :] + chargecost[ELECTROLYZER, :] .= (value.(EP[:vUSE][ELECTROLYZER, :]).data) .* transpose(price)[zone_id.(gen.ELECTROLYZER), :] end if !isempty(VS_STOR) - chargecost[VS_STOR, :] .= value.(EP[:vCHARGE_VRE_STOR][VS_STOR, :].data) .* transpose(price)[zone_id.(res[VS_STOR]), :] + chargecost[VS_STOR, :] .= value.(EP[:vCHARGE_VRE_STOR][VS_STOR, :].data) .* transpose(price)[zone_id.(gen[VS_STOR]), :] end if setup["ParameterScale"] == 1 chargecost *= ModelScalingFactor diff --git a/src/write_outputs/write_co2.jl b/src/write_outputs/write_co2.jl index 09bb7ca889..901f92a4aa 100644 --- a/src/write_outputs/write_co2.jl +++ b/src/write_outputs/write_co2.jl @@ -11,13 +11,13 @@ end function write_co2_emissions_plant(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) Z = inputs["Z"] # Number of zones # CO2 emissions by plant - dfEmissions_plant = DataFrame(Resource=inputs["RESOURCE_NAMES"], Zone=zone_id.(res), AnnualSum=zeros(G)) + dfEmissions_plant = DataFrame(Resource=inputs["RESOURCE_NAMES"], Zone=zone_id.(gen), AnnualSum=zeros(G)) emissions_plant = value.(EP[:eEmissionsByPlant]) if setup["ParameterScale"] == 1 emissions_plant *= ModelScalingFactor @@ -35,13 +35,13 @@ function write_co2_emissions_plant(path::AbstractString, inputs::Dict, setup::Di end function write_co2_capture_plant(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) Z = inputs["Z"] # Number of zones - dfCapturedEmissions_plant = DataFrame(Resource=inputs["RESOURCE_NAMES"], Zone=zone_id.(res), AnnualSum=zeros(G)) - if any(co2_capture_fraction.(res) .!= 0) + dfCapturedEmissions_plant = DataFrame(Resource=inputs["RESOURCE_NAMES"], Zone=zone_id.(gen), AnnualSum=zeros(G)) + if any(co2_capture_fraction.(gen) .!= 0) # Captured CO2 emissions by plant emissions_captured_plant = zeros(G, T) emissions_captured_plant = (value.(EP[:eEmissionsCaptureByPlant])) diff --git a/src/write_outputs/write_costs.jl b/src/write_outputs/write_costs.jl index 75d31083d6..11548801bf 100644 --- a/src/write_outputs/write_costs.jl +++ b/src/write_outputs/write_costs.jl @@ -5,7 +5,7 @@ Function for writing the costs pertaining to the objective function (fixed, vari """ function write_costs(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) ## Cost results - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] SEG = inputs["SEG"] # Number of lines Z = inputs["Z"] # Number of zones T = inputs["T"] # Number of time steps (hours) @@ -80,7 +80,7 @@ function write_costs(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) dfCost[!,2][11] = value(EP[:eTotalCGrid]) * (setup["ParameterScale"] == 1 ? ModelScalingFactor^2 : 1) end - if any(co2_capture_fraction.(res) .!= 0) + if any(co2_capture_fraction.(gen) .!= 0) dfCost[10,2] += value(EP[:eTotaleCCO2Sequestration]) end @@ -102,7 +102,7 @@ function write_costs(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) tempHydrogenValue = 0.0 tempCCO2 = 0.0 - Y_ZONE = resources_in_zone_by_rid(res,z) + Y_ZONE = resources_in_zone_by_rid(gen,z) STOR_ALL_ZONE = intersect(inputs["STOR_ALL"], Y_ZONE) STOR_ASYMMETRIC_ZONE = intersect(inputs["STOR_ASYMMETRIC"], Y_ZONE) FLEX_ZONE = intersect(inputs["FLEX"], Y_ZONE) @@ -218,7 +218,7 @@ function write_costs(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) tempCNSE = sum(value.(EP[:eCNSE][:,:,z])) tempCTotal += tempCNSE - if any(co2_capture_fraction.(res) .!=0) + if any(co2_capture_fraction.(gen) .!=0) tempCCO2 = sum(value.(EP[:ePlantCCO2Sequestration][Y_ZONE,:])) tempCTotal += tempCCO2 end diff --git a/src/write_outputs/write_curtailment.jl b/src/write_outputs/write_curtailment.jl index 1b1033ab2c..21e394bf65 100644 --- a/src/write_outputs/write_curtailment.jl +++ b/src/write_outputs/write_curtailment.jl @@ -5,11 +5,11 @@ Function for writing the curtailment values of the different variable renewable co-located). """ function write_curtailment(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) VRE = inputs["VRE"] - dfCurtailment = DataFrame(Resource = inputs["RESOURCE_NAMES"], Zone = zone_id.(res), AnnualSum = zeros(G)) + dfCurtailment = DataFrame(Resource = inputs["RESOURCE_NAMES"], Zone = zone_id.(gen), AnnualSum = zeros(G)) curtailment = zeros(G, T) scale_factor = setup["ParameterScale"] == 1 ? ModelScalingFactor : 1 curtailment[VRE, :] = scale_factor * (value.(EP[:eTotalCap][VRE]) .* inputs["pP_Max"][VRE, :] .- value.(EP[:vP][VRE, :])) diff --git a/src/write_outputs/write_emissions.jl b/src/write_outputs/write_emissions.jl index 345205ca6a..f29bdbb488 100644 --- a/src/write_outputs/write_emissions.jl +++ b/src/write_outputs/write_emissions.jl @@ -5,7 +5,6 @@ Function for reporting time-dependent CO$_2$ emissions by zone. """ function write_emissions(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) Z = inputs["Z"] # Number of zones diff --git a/src/write_outputs/write_energy_revenue.jl b/src/write_outputs/write_energy_revenue.jl index efbe1b003c..92168c52f1 100644 --- a/src/write_outputs/write_energy_revenue.jl +++ b/src/write_outputs/write_energy_revenue.jl @@ -4,10 +4,10 @@ Function for writing energy revenue from the different generation technologies. """ function write_energy_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] - regions = region.(res) - clusters = cluster.(res) - zones = zone_id.(res) + gen = inputs["RESOURCES"] + regions = region.(gen) + clusters = cluster.(gen) + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) @@ -16,9 +16,9 @@ function write_energy_revenue(path::AbstractString, inputs::Dict, setup::Dict, E dfEnergyRevenue = DataFrame(Region = regions, Resource = inputs["RESOURCE_NAMES"], Zone = zones, Cluster = clusters, AnnualSum = Array{Float64}(undef, G),) energyrevenue = zeros(G, T) price = locational_marginal_price(EP, inputs, setup) - energyrevenue[NONFLEX, :] = value.(EP[:vP][NONFLEX, :]) .* transpose(price)[zone_id.(res[NONFLEX]), :] + energyrevenue[NONFLEX, :] = value.(EP[:vP][NONFLEX, :]) .* transpose(price)[zone_id.(gen[NONFLEX]), :] if !isempty(FLEX) - energyrevenue[FLEX, :] = value.(EP[:vCHARGE_FLEX][FLEX, :]).data .* transpose(price)[zone_id.(res[FLEX]), :] + energyrevenue[FLEX, :] = value.(EP[:vCHARGE_FLEX][FLEX, :]).data .* transpose(price)[zone_id.(gen[FLEX]), :] end if setup["ParameterScale"] == 1 energyrevenue *= ModelScalingFactor diff --git a/src/write_outputs/write_fuel_consumption.jl b/src/write_outputs/write_fuel_consumption.jl index d916261c37..820076f1d4 100644 --- a/src/write_outputs/write_fuel_consumption.jl +++ b/src/write_outputs/write_fuel_consumption.jl @@ -11,13 +11,13 @@ function write_fuel_consumption(path::AbstractString, inputs::Dict, setup::Dict, end function write_fuel_consumption_plant(path::AbstractString,inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] HAS_FUEL = inputs["HAS_FUEL"] # Fuel consumption cost by each resource, including start up fuel dfPlantFuel = DataFrame(Resource = inputs["RESOURCE_NAMES"][HAS_FUEL], - Fuel = fuel.(res[HAS_FUEL]), - Zone = zone_id.(res[HAS_FUEL]), + Fuel = fuel.(gen[HAS_FUEL]), + Zone = zone_id.(gen[HAS_FUEL]), AnnualSum = zeros(length(HAS_FUEL))) tempannualsum = value.(EP[:ePlantCFuelOut][HAS_FUEL]) + value.(EP[:ePlantCFuelStart][HAS_FUEL]) diff --git a/src/write_outputs/write_net_revenue.jl b/src/write_outputs/write_net_revenue.jl index 93fae60ee4..8f7ca250ac 100644 --- a/src/write_outputs/write_net_revenue.jl +++ b/src/write_outputs/write_net_revenue.jl @@ -4,11 +4,11 @@ Function for writing net revenue of different generation technologies. """ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model, dfCap::DataFrame, dfESRRev::DataFrame, dfResRevenue::DataFrame, dfChargingcost::DataFrame, dfPower::DataFrame, dfEnergyRevenue::DataFrame, dfSubRevenue::DataFrame, dfRegSubRevenue::DataFrame, dfVreStor::DataFrame) - res = inputs["RESOURCES"] - zones = zone_id.(res) - regions = region.(res) - clusters = cluster.(res) - rid = resource_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) + regions = region.(gen) + clusters = cluster.(gen) + rid = resource_id.(gen) G = inputs["G"] # Number of generators COMMIT = inputs["COMMIT"] # Thermal units for unit commitment @@ -31,8 +31,8 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP:: dfNetRevenue = DataFrame(region = regions, Resource = inputs["RESOURCE_NAMES"], zone = zones, Cluster = clusters, R_ID = rid) # Add investment cost to the dataframe - dfNetRevenue.Inv_cost_MW = inv_cost_per_mwyr.(res) .* dfCap[1:G,:NewCap] - dfNetRevenue.Inv_cost_MWh = inv_cost_per_mwhyr.(res) .* dfCap[1:G,:NewEnergyCap] + dfNetRevenue.Inv_cost_MW = inv_cost_per_mwyr.(gen) .* dfCap[1:G,:NewCap] + dfNetRevenue.Inv_cost_MWh = inv_cost_per_mwhyr.(gen) .* dfCap[1:G,:NewEnergyCap] if !isempty(VRE_STOR) # Doesn't include charge capacities if !isempty(SOLAR) @@ -51,9 +51,9 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP:: end # Add operations and maintenance cost to the dataframe - dfNetRevenue.Fixed_OM_cost_MW = fixed_om_cost_per_mwyr.(res) .* dfCap[1:G,:EndCap] - dfNetRevenue.Fixed_OM_cost_MWh = fixed_om_cost_per_mwhyr.(res) .* dfCap[1:G,:EndEnergyCap] - dfNetRevenue.Var_OM_cost_out = var_om_cost_per_mwh.(res) .* dfPower[1:G,:AnnualSum] + dfNetRevenue.Fixed_OM_cost_MW = fixed_om_cost_per_mwyr.(gen) .* dfCap[1:G,:EndCap] + dfNetRevenue.Fixed_OM_cost_MWh = fixed_om_cost_per_mwhyr.(gen) .* dfCap[1:G,:EndEnergyCap] + dfNetRevenue.Var_OM_cost_out = var_om_cost_per_mwh.(gen) .* dfPower[1:G,:AnnualSum] if !isempty(VRE_STOR) if !isempty(SOLAR) dfNetRevenue.Fixed_OM_cost_MW[VRE_STOR] += dfVRE_STOR[!,:Fixed_OM_Solar_Cost_per_MWyr] .* dfVreStor[1:VRE_STOR_LENGTH, :EndCapSolar] @@ -88,7 +88,7 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP:: # Add storage cost to the dataframe dfNetRevenue.Var_OM_cost_in = zeros(nrow(dfNetRevenue)) if !isempty(STOR_ALL) - dfNetRevenue.Var_OM_cost_in[STOR_ALL] = var_om_cost_per_mwh_in.(resource.STOR) .* ((value.(EP[:vCHARGE][STOR_ALL,:]).data) * inputs["omega"]) + dfNetRevenue.Var_OM_cost_in[STOR_ALL] = var_om_cost_per_mwh_in.(gen.STOR) .* ((value.(EP[:vCHARGE][STOR_ALL,:]).data) * inputs["omega"]) end if !isempty(VRE_STOR) if !isempty(DC_CHARGE) @@ -144,7 +144,7 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP:: for cap in 1:inputs["NCO2Cap"] co2_cap_dual = dual(EP[:cCO2Emissions_systemwide][cap]) CO2ZONES = findall(x->x==1, inputs["dfCO2CapZones"][:,cap]) - GEN_IN_ZONE = resource_id.(res[y in CO2ZONES for y in zone_id.(res)]) + GEN_IN_ZONE = resource_id.(gen[y in CO2ZONES for y in zone_id.(gen)]) if setup["CO2Cap"]==1 # Mass-based # Cost = sum(sum(emissions of gen y * dual(CO2 constraint[cap]) for z in Z) for cap in setup["NCO2"]) temp_vec = value.(EP[:eEmissionsByPlant][GEN_IN_ZONE, :]) * inputs["omega"] @@ -156,7 +156,7 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP:: elseif setup["CO2Cap"]==3 # Generation + Rate-based SET_WITH_MAXCO2RATE = union(inputs["THERM_ALL"],inputs["VRE"], inputs["VRE"],inputs["MUST_RUN"],inputs["HYDRO_RES"]) Y = intersect(GEN_IN_ZONE, SET_WITH_MAXCO2RATE) - temp_vec = (value.(EP[:eEmissionsByPlant][Y,:]) - (value.(EP[:vP][Y,:]) .* inputs["dfMaxCO2Rate"][zone_id.(res[Y]), cap])) * inputs["omega"] + temp_vec = (value.(EP[:eEmissionsByPlant][Y,:]) - (value.(EP[:vP][Y,:]) .* inputs["dfMaxCO2Rate"][zone_id.(gen[Y]), cap])) * inputs["omega"] dfNetRevenue.EmissionsCost[Y] += - co2_cap_dual * temp_vec end end diff --git a/src/write_outputs/write_nse.jl b/src/write_outputs/write_nse.jl index d318f1c20f..ecc1c72c61 100644 --- a/src/write_outputs/write_nse.jl +++ b/src/write_outputs/write_nse.jl @@ -4,7 +4,6 @@ Function for reporting non-served energy for every model zone, time step and cost-segment. """ function write_nse(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) Z = inputs["Z"] # Number of zones SEG = inputs["SEG"] # Number of demand curtailment segments diff --git a/src/write_outputs/write_power.jl b/src/write_outputs/write_power.jl index 5e5f82e4ab..4db4c294db 100644 --- a/src/write_outputs/write_power.jl +++ b/src/write_outputs/write_power.jl @@ -4,8 +4,8 @@ Function for writing the different values of power generated by the different technologies in operation. """ function write_power(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) diff --git a/src/write_outputs/write_power_balance.jl b/src/write_outputs/write_power_balance.jl index a846b2d1e2..69ec216d44 100644 --- a/src/write_outputs/write_power_balance.jl +++ b/src/write_outputs/write_power_balance.jl @@ -1,5 +1,5 @@ function write_power_balance(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] T = inputs["T"] # Number of time steps (hours) Z = inputs["Z"] # Number of zones SEG = inputs["SEG"] # Number of demand curtailment segments @@ -23,20 +23,20 @@ function write_power_balance(path::AbstractString, inputs::Dict, setup::Dict, EP dfPowerBalance = DataFrame(BalanceComponent = repeat(Com_list, outer = Z), Zone = repeat(1:Z, inner = L), AnnualSum = zeros(L * Z)) powerbalance = zeros(Z * L, T) # following the same style of power/charge/storage/nse for z in 1:Z - POWER_ZONE = intersect(resources_in_zone_by_rid(res,z), union(THERM_ALL, VRE, MUST_RUN, HYDRO_RES)) + POWER_ZONE = intersect(resources_in_zone_by_rid(gen,z), union(THERM_ALL, VRE, MUST_RUN, HYDRO_RES)) powerbalance[(z-1)*L+1, :] = sum(value.(EP[:vP][POWER_ZONE, :]), dims = 1) - if !isempty(intersect(resources_in_zone_by_rid(res,z), STOR_ALL)) - STOR_ALL_ZONE = intersect(resources_in_zone_by_rid(res,z), STOR_ALL) + if !isempty(intersect(resources_in_zone_by_rid(gen,z), STOR_ALL)) + STOR_ALL_ZONE = intersect(resources_in_zone_by_rid(gen,z), STOR_ALL) powerbalance[(z-1)*L+2, :] = sum(value.(EP[:vP][STOR_ALL_ZONE, :]), dims = 1) powerbalance[(z-1)*L+3, :] = (-1) * sum((value.(EP[:vCHARGE][STOR_ALL_ZONE, :]).data), dims = 1) end - if !isempty(intersect(resources_in_zone_by_rid(res,z), VRE_STOR)) - VS_ALL_ZONE = intersect(resources_in_zone_by_rid(res,z), inputs["VS_STOR"]) + if !isempty(intersect(resources_in_zone_by_rid(gen,z), VRE_STOR)) + VS_ALL_ZONE = intersect(resources_in_zone_by_rid(gen,z), inputs["VS_STOR"]) powerbalance[(z-1)*L+2, :] = sum(value.(EP[:vP][VS_ALL_ZONE, :]), dims = 1) powerbalance[(z-1)*L+3, :] = (-1) * sum(value.(EP[:vCHARGE_VRE_STOR][VS_ALL_ZONE, :]).data, dims=1) end - if !isempty(intersect(resources_in_zone_by_rid(res,z), FLEX)) - FLEX_ZONE = intersect(resources_in_zone_by_rid(res,z), FLEX) + if !isempty(intersect(resources_in_zone_by_rid(gen,z), FLEX)) + FLEX_ZONE = intersect(resources_in_zone_by_rid(gen,z), FLEX) powerbalance[(z-1)*L+4, :] = sum((value.(EP[:vCHARGE_FLEX][FLEX_ZONE, :]).data), dims = 1) powerbalance[(z-1)*L+5, :] = (-1) * sum(value.(EP[:vP][FLEX_ZONE, :]), dims = 1) end @@ -50,7 +50,7 @@ function write_power_balance(path::AbstractString, inputs::Dict, setup::Dict, EP end powerbalance[(z-1)*L+10, :] = (((-1) * inputs["pD"][:, z]))' # Transpose if !isempty(ELECTROLYZER) - ELECTROLYZER_ZONE = intersect(dfGen[dfGen.Zone.==z, :R_ID], ELECTROLYZER) + ELECTROLYZER_ZONE = intersect(resources_in_zone_by_rid(gen,z), ELECTROLYZER) powerbalance[(z-1)*L+11, :] = (-1) * sum(value.(EP[:vUSE][ELECTROLYZER_ZONE, :].data), dims = 1) end end diff --git a/src/write_outputs/write_storage.jl b/src/write_outputs/write_storage.jl index d166f28f8a..69fe2f433d 100644 --- a/src/write_outputs/write_storage.jl +++ b/src/write_outputs/write_storage.jl @@ -4,8 +4,8 @@ Function for writing the capacities of different storage technologies, including hydro reservoir, flexible storage tech etc. """ function write_storage(path::AbstractString, inputs::Dict,setup::Dict, EP::Model) - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) T = inputs["T"] # Number of time steps (hours) G = inputs["G"] diff --git a/src/write_outputs/write_storagedual.jl b/src/write_outputs/write_storagedual.jl index 1e7dc39f17..7b762df563 100644 --- a/src/write_outputs/write_storagedual.jl +++ b/src/write_outputs/write_storagedual.jl @@ -4,8 +4,8 @@ Function for reporting dual of storage level (state of charge) balance of each resource in each time step. """ function write_storagedual(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] - zones = zone_id.(res) + gen = inputs["RESOURCES"] + zones = zone_id.(gen) G = inputs["G"] # Number of resources (generators, storage, DR, and DERs) T = inputs["T"] # Number of time steps (hours) diff --git a/src/write_outputs/write_subsidy_revenue.jl b/src/write_outputs/write_subsidy_revenue.jl index e1dae70bc1..c82a150fb8 100644 --- a/src/write_outputs/write_subsidy_revenue.jl +++ b/src/write_outputs/write_subsidy_revenue.jl @@ -4,21 +4,21 @@ Function for reporting subsidy revenue earned if a generator specified `Min_Cap` is provided in the input file, or if a generator is subject to a Minimum Capacity Requirement constraint. The unit is \$. """ function write_subsidy_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] - regions = region.(res) - clusters = cluster.(res) - zones = zone_id.(res) - rid = resource_id.(res) + gen = inputs["RESOURCES"] + regions = region.(gen) + clusters = cluster.(gen) + zones = zone_id.(gen) + rid = resource_id.(gen) G = inputs["G"] dfSubRevenue = DataFrame(Region = regions, Resource = inputs["RESOURCE_NAMES"], Zone = zones, Cluster = clusters, R_ID=rid, SubsidyRevenue = zeros(G)) - MIN_CAP = has_positive_min_capacity_mw(res) + MIN_CAP = has_positive_min_capacity_mw(gen) if !isempty(inputs["VRE_STOR"]) dfVRE_STOR = inputs["dfVRE_STOR"] MIN_CAP_SOLAR = dfVRE_STOR[(dfVRE_STOR[!, :Min_Cap_Solar_MW].>0), :R_ID] MIN_CAP_WIND = dfVRE_STOR[(dfVRE_STOR[!, :Min_Cap_Wind_MW].>0), :R_ID] - MIN_CAP_STOR = has_positive_min_capacity_mwh(res) + MIN_CAP_STOR = has_positive_min_capacity_mwh(gen) if !isempty(MIN_CAP_SOLAR) dfSubRevenue.SubsidyRevenue[MIN_CAP_SOLAR] .+= (value.(EP[:eTotalCap_SOLAR])[MIN_CAP_SOLAR]) .* (dual.(EP[:cMinCap_Solar][MIN_CAP_SOLAR])).data end @@ -34,7 +34,7 @@ function write_subsidy_revenue(path::AbstractString, inputs::Dict, setup::Dict, dfRegSubRevenue = DataFrame(Region = regions, Resource = inputs["RESOURCE_NAMES"], Zone = zones, Cluster = clusters, R_ID=rid, SubsidyRevenue = zeros(G)) if (setup["MinCapReq"] >= 1) for mincap in 1:inputs["NumberOfMinCapReqs"] # This key only exists if MinCapReq >= 1, so we can't get it at the top outside of this condition. - MIN_CAP_GEN = has_min_cap(res, tag=mincap) + MIN_CAP_GEN = has_min_cap(gen, tag=mincap) dfRegSubRevenue.SubsidyRevenue[MIN_CAP_GEN] .= dfRegSubRevenue.SubsidyRevenue[MIN_CAP_GEN] + (value.(EP[:eTotalCap][MIN_CAP_GEN])) * (dual.(EP[:cZoneMinCapReq][mincap])) if !isempty(inputs["VRE_STOR"]) mincap_solar_sym = Symbol("MinCapTagSolar_$mincap") diff --git a/src/write_outputs/write_vre_stor.jl b/src/write_outputs/write_vre_stor.jl index 8d917e2822..88828279e6 100644 --- a/src/write_outputs/write_vre_stor.jl +++ b/src/write_outputs/write_vre_stor.jl @@ -24,7 +24,7 @@ end Function for writing the vre-storage capacities. """ function write_vre_stor_capacity(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) - res = inputs["RESOURCES"] + gen = inputs["RESOURCES"] VRE_STOR = inputs["VRE_STOR"] SOLAR = inputs["VS_SOLAR"] @@ -82,7 +82,7 @@ function write_vre_stor_capacity(path::AbstractString, inputs::Dict, setup::Dict j = 1 for i in VRE_STOR - existingcapgrid[j] = MultiStage == 1 ? value(EP[:vEXISTINGCAP][i]) : existing_capacity_mw(res[i]) + existingcapgrid[j] = MultiStage == 1 ? value(EP[:vEXISTINGCAP][i]) : existing_capacity_mw(gen[i]) if i in inputs["NEW_CAP"] capgrid[j] = value(EP[:vCAP][i]) end