From 4b750c218130ac09406cc33badd6cbe7b0b3c886 Mon Sep 17 00:00:00 2001 From: danareu <122786331+danareu@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:47:19 +0100 Subject: [PATCH] Dev danar (#15) * add intersection between CCS and technologies * remove redundant variables * remove redundant variables pt 2 --------- Co-authored-by: Dimitri Pinel --- src/datastructures.jl | 5 +- src/genesysmod_bounds.jl | 38 +++--- src/genesysmod_dataload.jl | 32 ++--- src/genesysmod_dec.jl | 115 ++++++++--------- src/genesysmod_equ.jl | 258 ++++++++++++++++++------------------- 5 files changed, 222 insertions(+), 226 deletions(-) diff --git a/src/datastructures.jl b/src/datastructures.jl index 83b94ba..fc16707 100644 --- a/src/datastructures.jl +++ b/src/datastructures.jl @@ -365,9 +365,8 @@ struct Parameters <: InputClass TradeLossFactor ::JuMP.Containers.DenseAxisArray TradeRouteInstalledCapacity ::JuMP.Containers.DenseAxisArray TradeLossBetweenRegions ::JuMP.Containers.DenseAxisArray - - CommissionedTradeCapacity ::JuMP.Containers.DenseAxisArray + TradeCapacity ::JuMP.Containers.DenseAxisArray TradeCapacityGrowthCosts ::JuMP.Containers.DenseAxisArray GrowthRateTradeCapacity ::JuMP.Containers.DenseAxisArray @@ -423,7 +422,6 @@ struct Variables VariableOperatingCost ::JuMP.Containers.DenseAxisArray TotalDiscountedCost ::JuMP.Containers.DenseAxisArray TotalDiscountedCostByTechnology ::JuMP.Containers.DenseAxisArray - ModelPeriodCostByRegion ::JuMP.Containers.DenseAxisArray AnnualCurtailmentCost ::JuMP.Containers.DenseAxisArray DiscountedAnnualCurtailmentCost ::JuMP.Containers.DenseAxisArray @@ -465,7 +463,6 @@ struct Variables DiscountedNewTradeCapacityCosts ::JuMP.Containers.DenseAxisArray NetTrade ::JuMP.Containers.DenseAxisArray NetTradeAnnual ::JuMP.Containers.DenseAxisArray - TotalTradeCosts ::JuMP.Containers.DenseAxisArray AnnualTotalTradeCosts ::JuMP.Containers.DenseAxisArray DiscountedAnnualTotalTradeCosts ::JuMP.Containers.DenseAxisArray diff --git a/src/genesysmod_bounds.jl b/src/genesysmod_bounds.jl index 89413c2..f16850d 100755 --- a/src/genesysmod_bounds.jl +++ b/src/genesysmod_bounds.jl @@ -41,7 +41,7 @@ function genesysmod_bounds(model,Sets,Params, Vars,Settings,Switch,Maps) # # ####### Default Values ############# # - + for r ∈ Sets.Region_full for t ∈ Sets.Technology for y ∈ Sets.Year @@ -77,7 +77,7 @@ function genesysmod_bounds(model,Sets,Params, Vars,Settings,Switch,Maps) for y ∈ Sets.Year if Params.VariableCost[r,t,m,y]==0 Params.VariableCost[r,t,m,y] = 0.01 - end end end end end + end end end end end # # ####### Dummy-Technologies [enable for test purposes, if model runs infeasible] ############# @@ -103,15 +103,15 @@ function genesysmod_bounds(model,Sets,Params, Vars,Settings,Switch,Maps) # Error is ignored intentionally end end - + Params.CapacityToActivityUnit[Params.Tags.TagTechnologyToSubsets["DummyTechnology"]] .= 31.56 Params.TotalAnnualMaxCapacity[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:] .= 999999 Params.FixedCost[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:] .= 999 Params.CapitalCost[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:] .= 999 Params.VariableCost[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:,:] .= 999 Params.AvailabilityFactor[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:] .= 1 - Params.CapacityFactor[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:,:] .= 1 - Params.OperationalLife[Params.Tags.TagTechnologyToSubsets["DummyTechnology"]] .= 1 + Params.CapacityFactor[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:,:] .= 1 + Params.OperationalLife[Params.Tags.TagTechnologyToSubsets["DummyTechnology"]] .= 1 Params.EmissionActivityRatio[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:,:,:] .= 0 end @@ -147,7 +147,7 @@ function genesysmod_bounds(model,Sets,Params, Vars,Settings,Switch,Maps) for r ∈ Sets.Region_full for t ∈ Params.Tags.TagTechnologyToSubsets["ImportTechnology"] - Params.OperationalLife[t] = 1 + Params.OperationalLife[t] = 1 end end @@ -188,7 +188,7 @@ function genesysmod_bounds(model,Sets,Params, Vars,Settings,Switch,Maps) end if "CHP" ∈ Sets.Sector - for t ∈ Sets.Technology + for t ∈ Sets.Technology if Params.Tags.TagTechnologyToSector[t,"CHP"] == 1 for r ∈ Sets.Region_full if JuMP.is_fixed(model[:NewCapacity][Switch.StartYear,t,r]) @@ -201,7 +201,7 @@ function genesysmod_bounds(model,Sets,Params, Vars,Settings,Switch,Maps) end - ### ReserveMargin initialization + ### ReserveMargin initialization for r ∈ Sets.Region_full for t ∈ Sets.Technology for y ∈ Sets.Year if ((max(Params.TotalAnnualMaxCapacity[r,t,y], Params.ResidualCapacity[r,t,y]) >0 ) @@ -238,32 +238,34 @@ function genesysmod_bounds(model,Sets,Params, Vars,Settings,Switch,Maps) # if Switch.switch_ccs == 1 - for r ∈ Sets.Region_full for t ∈ Params.Tags.TagTechnologyToSubsets["CCS"] + for r ∈ Sets.Region_full for t ∈ intersect(Sets.Technology, Params.Tags.TagTechnologyToSubsets["CCS"]) Params.AvailabilityFactor[r,t,:] .= 0 Params.TotalAnnualMaxCapacity[r,t,:] .= 99999 Params.TotalTechnologyAnnualActivityUpperLimit[r,t,:] .= 99999 end end - for y ∈ Sets.Year for r ∈ Sets.Region_full + for y ∈ Sets.Year for r ∈ Sets.Region_full if (y > 2020) && (Params.RegionalCCSLimit[r] > 0) - for t ∈ Params.Tags.TagTechnologyToSubsets["CCS"] + for t ∈ intersect(Sets.Technology, Params.Tags.TagTechnologyToSubsets["CCS"]) Params.AvailabilityFactor[r,t,y] = 0.95 end - else - for t ∈ Params.Tags.TagTechnologyToSubsets["CCS"] + else + for t ∈ intersect(Sets.Technology, Params.Tags.TagTechnologyToSubsets["CCS"]) Params.TotalAnnualMaxCapacity[r,t,y] = 0 Params.TotalTechnologyAnnualActivityUpperLimit[r,t,y] = 0 for f ∈ Maps.Tech_Fuel[t] JuMP.fix(Vars.ProductionByTechnologyAnnual[y,t,f,r],0; force=true) end - end + end end - end end + end end Params.TotalAnnualMaxCapacity[Sets.Region_full,"A_Air",:] .= 99999 Params.TotalTechnologyAnnualActivityUpperLimit[Sets.Region_full,"A_Air",:] .= 99999 - Params.EmissionActivityRatio[Sets.Region_full,["X_DAC_HT","X_DAC_LT"],:,:,:] .= -1 + for t ∈ intersect(Sets.Technology, ["X_DAC_HT","X_DAC_LT"]) + Params.EmissionActivityRatio[Sets.Region_full,t,:,:,:] .= -1 + end else for y ∈ Sets.Year for r ∈ Sets.Region_full for t ∈ intersect(Sets.Technology, Params.Tags.TagTechnologyToSubsets["CCS"]) @@ -369,7 +371,7 @@ function YearlyDifferenceMultiplier(y,Sets); i = findfirst(Sets.Year.== y) if i < length(Sets.Year) return max(1,Sets.Year[i+1]-Sets.Year[i]) - else + else return 1 end -end \ No newline at end of file +end diff --git a/src/genesysmod_dataload.jl b/src/genesysmod_dataload.jl index 94ecf7c..3d56e8e 100755 --- a/src/genesysmod_dataload.jl +++ b/src/genesysmod_dataload.jl @@ -44,7 +44,7 @@ function genesysmod_dataload(Switch) # Step 2: Read parameters from regional file -> now includes World values - Params, emp_Sets = read_params(in_data, copy(Sets), Switch, Tags) # copy sets to avoid problems when removing from the sets used to indexed the DAA + Params, emp_Sets = read_params(in_data, copy(Sets), Switch, Tags) # copy sets to avoid problems when removing from the sets used to indexed the DAA # delete world region from region set remove_dummy_regions!(𝓡, Switch.switch_dispatch) @@ -58,7 +58,7 @@ function genesysmod_dataload(Switch) # # ####### Load from hourly Data ############# # - + GENeSYS_MOD.timeseries_reduction!(Params, Sets, Switch) for y ∈ 𝓨 for l ∈ 𝓛 for r ∈ 𝓡 @@ -215,8 +215,8 @@ function update_inftechs_params!(Params, s_infeas::WithInfeasibilityTechs, s_dis Params.OutputActivityRatio[:,"Infeasibility_HHI","Heat_High_Industrial",1,:] .= 1 Params.OutputActivityRatio[:,"Infeasibility_HRI","Heat_Low_Residential",1,:] .= 1 Params.OutputActivityRatio[:,"Infeasibility_Power","Power",1,:] .= 1 - Params.OutputActivityRatio[:,"Infeasibility_Mob_Passenger","Mobility_Passenger",1,:] .= 1 - Params.OutputActivityRatio[:,"Infeasibility_Mob_Freight","Mobility_Freight",1,:] .= 1 + Params.OutputActivityRatio[:,"Infeasibility_Mob_Passenger","Mobility_Passenger",1,:] .= 1 + Params.OutputActivityRatio[:,"Infeasibility_Mob_Freight","Mobility_Freight",1,:] .= 1 Params.CapacityToActivityUnit[Params.Tags.TagTechnologyToSubsets["DummyTechnology"]] .= 31.56 Params.TotalAnnualMaxCapacity[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:] .= 999999 @@ -224,8 +224,8 @@ function update_inftechs_params!(Params, s_infeas::WithInfeasibilityTechs, s_dis Params.CapitalCost[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:] .= 999 Params.VariableCost[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:,:] .= 999 Params.AvailabilityFactor[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:] .= 1 - Params.CapacityFactor[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:,:] .= 1 - Params.OperationalLife[Params.Tags.TagTechnologyToSubsets["DummyTechnology"]] .= 1 + Params.CapacityFactor[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:,:] .= 1 + Params.OperationalLife[Params.Tags.TagTechnologyToSubsets["DummyTechnology"]] .= 1 Params.EmissionActivityRatio[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:,:,:] .= 0 Params.Tags.TagTechnologyToModalType["Infeasibility_Mob_Passenger",1,"MT_PSNG_ROAD"] .= 1 @@ -245,8 +245,8 @@ function update_inftechs_params!(Params, s_infeas::WithInfeasibilityTechs, s_dis Params.OutputActivityRatio[:,"Infeasibility_HHI","Heat_High_Industrial",1,:] .= 1 Params.OutputActivityRatio[:,"Infeasibility_HRI","Heat_Low_Residential",1,:] .= 1 Params.OutputActivityRatio[:,"Infeasibility_Power","Power",1,:] .= 1 - Params.OutputActivityRatio[:,"Infeasibility_Mob_Passenger","Mobility_Passenger",1,:] .= 1 - Params.OutputActivityRatio[:,"Infeasibility_Mob_Freight","Mobility_Freight",1,:] .= 1 + Params.OutputActivityRatio[:,"Infeasibility_Mob_Passenger","Mobility_Passenger",1,:] .= 1 + Params.OutputActivityRatio[:,"Infeasibility_Mob_Freight","Mobility_Freight",1,:] .= 1 Params.CapacityToActivityUnit[Params.Tags.TagTechnologyToSubsets["DummyTechnology"]] .= 31.56 Params.TotalAnnualMaxCapacity[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:] .= 999999 @@ -254,8 +254,8 @@ function update_inftechs_params!(Params, s_infeas::WithInfeasibilityTechs, s_dis Params.CapitalCost[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:] .= 999 Params.VariableCost[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:,:] .= 999 Params.AvailabilityFactor[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:] .= 1 - Params.CapacityFactor[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:,:] .= 1 - Params.OperationalLife[Params.Tags.TagTechnologyToSubsets["DummyTechnology"]] .= 1 + Params.CapacityFactor[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:,:] .= 1 + Params.OperationalLife[Params.Tags.TagTechnologyToSubsets["DummyTechnology"]] .= 1 Params.EmissionActivityRatio[:,Params.Tags.TagTechnologyToSubsets["DummyTechnology"],:,:,:] .= 0 Params.Tags.TagTechnologyToModalType["Infeasibility_Mob_Passenger",1,"MT_PSNG_ROAD"] .= 1 @@ -318,7 +318,7 @@ function read_params(in_data, Sets, Switch, Tags) SpecifiedAnnualDemand = create_daa(in_data, "Par_SpecifiedAnnualDemand", 𝓡, 𝓕, 𝓨) AnnualEmissionLimit = create_daa(in_data,"Par_AnnualEmissionLimit", 𝓔, 𝓨) - AnnualExogenousEmission = create_daa(in_data,"Par_AnnualExogenousEmission", 𝓡, 𝓔, 𝓨) + AnnualExogenousEmission = create_daa(in_data,"Par_AnnualExogenousEmission", 𝓡, 𝓔, 𝓨) AnnualSectoralEmissionLimit = create_daa(in_data, "Par_AnnualSectoralEmissionLimit", 𝓔, 𝓢𝓮, 𝓨) EmissionContentPerFuel = create_daa(in_data, "Par_EmissionContentPerFuel", 𝓕, 𝓔) RegionalAnnualEmissionLimit = create_daa(in_data,"Par_RegionalAnnualEmissionLimit", 𝓡, 𝓔, 𝓨) @@ -353,7 +353,7 @@ function read_params(in_data, Sets, Switch, Tags) ModalSplitByFuelAndModalType = create_daa(in_data, "Par_ModalSplitByFuel", 𝓡, 𝓕, 𝓨, 𝓜𝓽) - + StorageE2PRatio = nothing #StorageE2PRatio = create_daa(in_data, "Par_StorageE2PRatio",dbr, 𝓢) @@ -390,7 +390,7 @@ function read_params(in_data, Sets, Switch, Tags) RampingDownFactor = create_daa(in_data, "Par_RampingDownFactor",𝓣,𝓨) ProductionChangeCost = create_daa(in_data, "Par_ProductionChangeCost",𝓣,𝓨) MinActiveProductionPerTimeslice = DenseArray(zeros(length(𝓨), length(𝓛), length(𝓕), length(𝓣), length(𝓡)), 𝓨, 𝓛, 𝓕, 𝓣, 𝓡) - + MinActiveProductionPerTimeslice[:,:,"Power","RES_Hydro_Large",:] .= 0.1 MinActiveProductionPerTimeslice[:,:,"Power","RES_Hydro_Small",:] .= 0.05 else @@ -510,7 +510,7 @@ function get_aggregate_params(Params_Full, Sets, Sets_full) SpecifiedAnnualDemand = aggregate_daa(Params_Full.SpecifiedAnnualDemand, 𝓡, 𝓡_full, Sum(), 𝓕, 𝓨) AnnualEmissionLimit = Params_Full.AnnualEmissionLimit[:,𝓨] - AnnualExogenousEmission = aggregate_daa(Params_Full.AnnualExogenousEmission, 𝓡, 𝓡_full, Sum(), 𝓔, 𝓨) + AnnualExogenousEmission = aggregate_daa(Params_Full.AnnualExogenousEmission, 𝓡, 𝓡_full, Sum(), 𝓔, 𝓨) AnnualSectoralEmissionLimit = Params_Full.AnnualSectoralEmissionLimit[:,:,𝓨] EmissionContentPerFuel = Params_Full.EmissionContentPerFuel RegionalAnnualEmissionLimit = aggregate_daa(Params_Full.RegionalAnnualEmissionLimit, 𝓡, 𝓡_full, Sum(), 𝓔, 𝓨) @@ -619,7 +619,7 @@ function get_aggregate_params(Params_Full, Sets, Sets_full) AnnualExogenousEmission,AnnualEmissionLimit,RegionalAnnualEmissionLimit, ModelPeriodExogenousEmission,ModelPeriodEmissionLimit,RegionalModelPeriodEmissionLimit, CurtailmentCostFactor,TradeRoute,TradeCosts, - TradeLossFactor,TradeRouteInstalledCapacity,TradeLossBetweenRegions,CommissionedTradeCapacity, + TradeLossFactor,TradeRouteInstalledCapacity,TradeLossBetweenRegions, TradeCapacity,TradeCapacityGrowthCosts,GrowthRateTradeCapacity,SelfSufficiency, RampingUpFactor,RampingDownFactor,ProductionChangeCost,MinActiveProductionPerTimeslice, ModalSplitByFuelAndModalType,EFactorConstruction, EFactorOM, @@ -681,7 +681,7 @@ function aggregate_params(Switch, Sets_full, Params_full, s_dispatch::TwoNodes) for f in 𝓕 for l in 𝓛 for y in 𝓨 sum_demand = sum(Params_full.SpecifiedAnnualDemand[r,f,y] for r in 𝓡_full if r!=considered_regions[1]) if sum_demand!=0 - Params.SpecifiedDemandProfile[considered_regions[2],f,l,y] = + Params.SpecifiedDemandProfile[considered_regions[2],f,l,y] = sum(Params_full.SpecifiedDemandProfile[r,f,l,y]*Params_full.SpecifiedAnnualDemand[r,f,y] for r in 𝓡_full if r!=considered_regions[1])/sum_demand end Params.SpecifiedDemandProfile[considered_regions[1],f,l,y] = Params_full.SpecifiedDemandProfile[considered_regions[1],f,l,y] diff --git a/src/genesysmod_dec.jl b/src/genesysmod_dec.jl index 4ca7997..90c2c47 100644 --- a/src/genesysmod_dec.jl +++ b/src/genesysmod_dec.jl @@ -25,7 +25,7 @@ function def_daa(sets...) #= for i in eachindex(sets...) if sets...[i] == Sets.Technology & any(x -> x == Sets.Mode_of_operation, sets...[i:end]) M = findfirst(x -> x == Sets.Mode_of_operation, sets...[i:end]) - + end for x... in sets... =# @@ -53,7 +53,7 @@ function genesysmod_dec(model,Sets, Params,Switch, Maps) ##################### ############### Capacity Variables ############ - + NewCapacity = @variable(model, NewCapacity[𝓨,𝓣,𝓡] >= 0, container=DenseArray) AccumulatedNewCapacity = @variable(model, AccumulatedNewCapacity[𝓨,𝓣,𝓡] >= 0, container=DenseArray) TotalCapacityAnnual = @variable(model, TotalCapacityAnnual[𝓨,𝓣,𝓡] >= 0, container=DenseArray) @@ -70,26 +70,26 @@ function genesysmod_dec(model,Sets, Params,Switch, Maps) RateOfActivity[y,l,t,m,r] = @variable(model, lower_bound = 0, base_name= "RateOfActivity[$y,$l,$t,$m,$r]") end TotalAnnualTechnologyActivityByMode[y,t,m,r] = @variable(model, lower_bound = 0, base_name= "TotalAnnualTechnologyActivityByMode[$y,$t,$m,$r]") - end + end for f ∈ Maps.Tech_Fuel[t] ProductionByTechnologyAnnual[y,t,f,r] = @variable(model, lower_bound = 0, base_name= "ProductionByTechnologyAnnual[$y,$t,$f,$r]") UseByTechnologyAnnual[y,t,f,r] = @variable(model, lower_bound = 0, base_name= "UseByTechnologyAnnual[$y,$t,$f,$r]") end - end end end + end end end model[:RateOfActivity] = RateOfActivity model[:TotalAnnualTechnologyActivityByMode] = TotalAnnualTechnologyActivityByMode model[:ProductionByTechnologyAnnual] = ProductionByTechnologyAnnual model[:UseByTechnologyAnnual] = UseByTechnologyAnnual @variable(model, TotalTechnologyAnnualActivity[𝓨,𝓣,𝓡] >= 0) - + @variable(model, TotalActivityPerYear[𝓡,𝓛,𝓣,𝓨] >= 0) @variable(model, CurtailedEnergyAnnual[𝓨,𝓕,𝓡] >= 0) @variable(model, CurtailedCapacity[𝓡,𝓛,𝓣,𝓨] >= 0) @variable(model, CurtailedEnergy[𝓨,𝓛,𝓕,𝓡] >= 0) @variable(model, DispatchDummy[𝓡,𝓛,𝓣,𝓨] >= 0) - + ############### Costing Variables ############# CapitalInvestment = @variable(model, CapitalInvestment[𝓨,𝓣,𝓡] >= 0, container=DenseArray) @@ -103,73 +103,72 @@ function genesysmod_dec(model,Sets, Params,Switch, Maps) VariableOperatingCost = @variable(model, VariableOperatingCost[𝓨,𝓛,𝓣,𝓡] >= 0, container=DenseArray) TotalDiscountedCost = @variable(model, TotalDiscountedCost[𝓨,𝓡] >= 0, container=DenseArray) TotalDiscountedCostByTechnology = @variable(model, TotalDiscountedCostByTechnology[𝓨,𝓣,𝓡] >= 0, container=DenseArray) - ModelPeriodCostByRegion = @variable(model, ModelPeriodCostByRegion[𝓡] >= 0, container=DenseArray) AnnualCurtailmentCost = @variable(model, AnnualCurtailmentCost[𝓨,𝓕,𝓡] >= 0, container=DenseArray) DiscountedAnnualCurtailmentCost = @variable(model, DiscountedAnnualCurtailmentCost[𝓨,𝓕,𝓡] >= 0, container=DenseArray) - + ############### Storage Variables ############# StorageLevelYearStart = @variable(model, StorageLevelYearStart[𝓢,𝓨,𝓡] >= 0, container=DenseArray) StorageLevelYearFinish = @variable(model, StorageLevelYearFinish[𝓢,𝓨,𝓡] >= 0, container=DenseArray) StorageLevelTSStart = @variable(model, StorageLevelTSStart[𝓢,𝓨,𝓛,𝓡] >= 0, container=DenseArray) - AccumulatedNewStorageCapacity = @variable(model, AccumulatedNewStorageCapacity[𝓢,𝓨,𝓡] >= 0, container=DenseArray) - NewStorageCapacity = @variable(model, NewStorageCapacity[𝓢,𝓨,𝓡] >= 0, container=DenseArray) - CapitalInvestmentStorage = @variable(model, CapitalInvestmentStorage[𝓢,𝓨,𝓡] >= 0, container=DenseArray) - DiscountedCapitalInvestmentStorage = @variable(model, DiscountedCapitalInvestmentStorage[𝓢,𝓨,𝓡] >= 0, container=DenseArray) - SalvageValueStorage = @variable(model, SalvageValueStorage[𝓢,𝓨,𝓡] >= 0, container=DenseArray) - DiscountedSalvageValueStorage = @variable(model, DiscountedSalvageValueStorage[𝓢,𝓨,𝓡] >= 0, container=DenseArray) - TotalDiscountedStorageCost = @variable(model, TotalDiscountedStorageCost[𝓢,𝓨,𝓡] >= 0, container=DenseArray) + AccumulatedNewStorageCapacity = @variable(model, AccumulatedNewStorageCapacity[𝓢,𝓨,𝓡] >= 0, container=DenseArray) + NewStorageCapacity = @variable(model, NewStorageCapacity[𝓢,𝓨,𝓡] >= 0, container=DenseArray) + CapitalInvestmentStorage = @variable(model, CapitalInvestmentStorage[𝓢,𝓨,𝓡] >= 0, container=DenseArray) + DiscountedCapitalInvestmentStorage = @variable(model, DiscountedCapitalInvestmentStorage[𝓢,𝓨,𝓡] >= 0, container=DenseArray) + SalvageValueStorage = @variable(model, SalvageValueStorage[𝓢,𝓨,𝓡] >= 0, container=DenseArray) + DiscountedSalvageValueStorage = @variable(model, DiscountedSalvageValueStorage[𝓢,𝓨,𝓡] >= 0, container=DenseArray) + TotalDiscountedStorageCost = @variable(model, TotalDiscountedStorageCost[𝓢,𝓨,𝓡] >= 0, container=DenseArray) + - ######## Reserve Margin ############# if Switch.switch_dispatch isa NoDispatch && Switch.switch_reserve == 1 TotalActivityInReserveMargin=@variable(model, TotalActivityInReserveMargin[𝓡,𝓨,𝓛] >= 0, container=DenseArray) - DemandNeedingReserveMargin=@variable(model, DemandNeedingReserveMargin[𝓨,𝓛,𝓡] >= 0, container=DenseArray) + DemandNeedingReserveMargin=@variable(model, DemandNeedingReserveMargin[𝓨,𝓛,𝓡] >= 0, container=DenseArray) else TotalActivityInReserveMargin = nothing DemandNeedingReserveMargin = nothing end - + ######## RE Gen Target ############# - TotalREProductionAnnual = @variable(model, TotalREProductionAnnual[𝓨,𝓡,𝓕], container=DenseArray) - RETotalDemandOfTargetFuelAnnual = @variable(model, RETotalDemandOfTargetFuelAnnual[𝓨,𝓡,𝓕], container=DenseArray) - TotalTechnologyModelPeriodActivity = @variable(model, TotalTechnologyModelPeriodActivity[𝓣,𝓡], container=DenseArray) - RETargetMin = @variable(model, RETargetMin[𝓨,𝓡] >= 0, container=DenseArray) + TotalREProductionAnnual = @variable(model, TotalREProductionAnnual[𝓨,𝓡,𝓕], container=DenseArray) + RETotalDemandOfTargetFuelAnnual = @variable(model, RETotalDemandOfTargetFuelAnnual[𝓨,𝓡,𝓕], container=DenseArray) + TotalTechnologyModelPeriodActivity = @variable(model, TotalTechnologyModelPeriodActivity[𝓣,𝓡], container=DenseArray) + RETargetMin = @variable(model, RETargetMin[𝓨,𝓡] >= 0, container=DenseArray) + - ######## Emissions ############# AnnualTechnologyEmissionByMode = def_daa(𝓨,𝓣,𝓔,𝓜,𝓡) - for y ∈ 𝓨 for r ∈ 𝓡 for t ∈ 𝓣 for e ∈ 𝓔 + for y ∈ 𝓨 for r ∈ 𝓡 for t ∈ 𝓣 for e ∈ 𝓔 for m ∈ Maps.Tech_MO[t] AnnualTechnologyEmissionByMode[y,t,e,m,r] = @variable(model, lower_bound = 0, base_name= "AnnualTechnologyEmissionByMode[$y,$t,$e,$m,$r]") end - end end end end + end end end end model[:AnnualTechnologyEmissionByMode] = AnnualTechnologyEmissionByMode - AnnualTechnologyEmission = @variable(model, AnnualTechnologyEmission[𝓨,𝓣,𝓔,𝓡], container=DenseArray) - AnnualTechnologyEmissionPenaltyByEmission = @variable(model, AnnualTechnologyEmissionPenaltyByEmission[𝓨,𝓣,𝓔,𝓡], container=DenseArray) - AnnualTechnologyEmissionsPenalty = @variable(model, AnnualTechnologyEmissionsPenalty[𝓨,𝓣,𝓡], container=DenseArray) - DiscountedTechnologyEmissionsPenalty = @variable(model, DiscountedTechnologyEmissionsPenalty[𝓨,𝓣,𝓡], container=DenseArray) - AnnualEmissions = @variable(model, AnnualEmissions[𝓨,𝓔,𝓡], container=DenseArray) - ModelPeriodEmissions = @variable(model, ModelPeriodEmissions[𝓔,𝓡], container=DenseArray) + AnnualTechnologyEmission = @variable(model, AnnualTechnologyEmission[𝓨,𝓣,𝓔,𝓡], container=DenseArray) + AnnualTechnologyEmissionPenaltyByEmission = @variable(model, AnnualTechnologyEmissionPenaltyByEmission[𝓨,𝓣,𝓔,𝓡], container=DenseArray) + AnnualTechnologyEmissionsPenalty = @variable(model, AnnualTechnologyEmissionsPenalty[𝓨,𝓣,𝓡], container=DenseArray) + DiscountedTechnologyEmissionsPenalty = @variable(model, DiscountedTechnologyEmissionsPenalty[𝓨,𝓣,𝓡], container=DenseArray) + AnnualEmissions = @variable(model, AnnualEmissions[𝓨,𝓔,𝓡], container=DenseArray) + ModelPeriodEmissions = @variable(model, ModelPeriodEmissions[𝓔,𝓡], container=DenseArray) WeightedAnnualEmissions = @variable(model, WeightedAnnualEmissions[𝓨,𝓔,𝓡], container=DenseArray) - + ######### SectoralEmissions ############# - AnnualSectoralEmissions = @variable(model, AnnualSectoralEmissions[𝓨,𝓔,𝓢𝓮,𝓡], container=DenseArray) + AnnualSectoralEmissions = @variable(model, AnnualSectoralEmissions[𝓨,𝓔,𝓢𝓮,𝓡], container=DenseArray) + - ######### Trade ############# Import = def_daa(𝓨,𝓛,𝓕,𝓡,𝓡) @@ -181,13 +180,13 @@ function genesysmod_dec(model,Sets, Params,Switch, Maps) for y ∈ 𝓨 for f ∈ 𝓕 for r1 ∈ 𝓡 for r2 ∈ 𝓡 if Params.TradeRoute[r1,r2,f,y] != 0 for l ∈ 𝓛 - Import[y,l,f,r1,r2] = @variable(model, lower_bound= 0, base_name="Import[$y,$l,$f,$r1,$r2]") - Export[y,l,f,r1,r2] = @variable(model, lower_bound= 0, base_name="Export[$y,$l,$f,$r1,$r2]") + Import[y,l,f,r1,r2] = @variable(model, lower_bound= 0, base_name="Import[$y,$l,$f,$r1,$r2]") + Export[y,l,f,r1,r2] = @variable(model, lower_bound= 0, base_name="Export[$y,$l,$f,$r1,$r2]") end - NewTradeCapacity[y,f,r1,r2] = @variable(model, lower_bound= 0, base_name="NewTradeCapacity[$y,$f,$r1,$r2]") - TotalTradeCapacity[y,f,r1,r2] = @variable(model, lower_bound= 0, base_name="TotalTradeCapacity[$y,$f,$r1,$r2]") - NewTradeCapacityCosts[y,f,r1,r2] = @variable(model, lower_bound= 0, base_name="NewTradeCapacityCosts[$y,$f,$r1,$r2]") - DiscountedNewTradeCapacityCosts[y,f,r1,r2] = @variable(model, lower_bound= 0, base_name="DiscountedNewTradeCapacityCosts[$y,$f,$r1,$r2]") + NewTradeCapacity[y,f,r1,r2] = @variable(model, lower_bound= 0, base_name="NewTradeCapacity[$y,$f,$r1,$r2]") + TotalTradeCapacity[y,f,r1,r2] = @variable(model, lower_bound= 0, base_name="TotalTradeCapacity[$y,$f,$r1,$r2]") + NewTradeCapacityCosts[y,f,r1,r2] = @variable(model, lower_bound= 0, base_name="NewTradeCapacityCosts[$y,$f,$r1,$r2]") + DiscountedNewTradeCapacityCosts[y,f,r1,r2] = @variable(model, lower_bound= 0, base_name="DiscountedNewTradeCapacityCosts[$y,$f,$r1,$r2]") end end end end end model[:Import] = Import @@ -197,11 +196,10 @@ function genesysmod_dec(model,Sets, Params,Switch, Maps) model[:NewTradeCapacityCosts] = NewTradeCapacityCosts model[:DiscountedNewTradeCapacityCosts] = DiscountedNewTradeCapacityCosts - NetTrade = @variable(model, NetTrade[𝓨,𝓛,𝓕,𝓡], container=DenseArray) - NetTradeAnnual = @variable(model, NetTradeAnnual[𝓨,𝓕,𝓡], container=DenseArray) - TotalTradeCosts = @variable(model, TotalTradeCosts[𝓨,𝓛,𝓡], container=DenseArray) - AnnualTotalTradeCosts = @variable(model, AnnualTotalTradeCosts[𝓨,𝓡], container=DenseArray) - DiscountedAnnualTotalTradeCosts = @variable(model, DiscountedAnnualTotalTradeCosts[𝓨,𝓡], container=DenseArray) + NetTrade = @variable(model, NetTrade[𝓨,𝓛,𝓕,𝓡], container=DenseArray) + NetTradeAnnual = @variable(model, NetTradeAnnual[𝓨,𝓕,𝓡], container=DenseArray) + AnnualTotalTradeCosts = @variable(model, AnnualTotalTradeCosts[𝓨,𝓡], container=DenseArray) + DiscountedAnnualTotalTradeCosts = @variable(model, DiscountedAnnualTotalTradeCosts[𝓨,𝓡], container=DenseArray) ######### Peaking ############# if Switch.switch_peaking_capacity == 1 @@ -215,15 +213,15 @@ function genesysmod_dec(model,Sets, Params,Switch, Maps) ######### Transportation ############# - #TrajectoryLowerLimit(𝓨) - #TrajectoryUpperLimit(𝓨) + #TrajectoryLowerLimit(𝓨) + #TrajectoryUpperLimit(𝓨) - DemandSplitByModalType = @variable(model, DemandSplitByModalType[𝓜𝓽,𝓛,𝓡,Params.Tags.TagFuelToSubsets["TransportFuels"],𝓨], container=DenseArray) - ProductionSplitByModalType = @variable(model, ProductionSplitByModalType[𝓜𝓽,𝓛,𝓡,Params.Tags.TagFuelToSubsets["TransportFuels"],𝓨], container=DenseArray) + DemandSplitByModalType = @variable(model, DemandSplitByModalType[𝓜𝓽,𝓛,𝓡,Params.Tags.TagFuelToSubsets["TransportFuels"],𝓨], container=DenseArray) + ProductionSplitByModalType = @variable(model, ProductionSplitByModalType[𝓜𝓽,𝓛,𝓡,Params.Tags.TagFuelToSubsets["TransportFuels"],𝓨], container=DenseArray) if Switch.switch_ramping == 1 - ######## Ramping ############# + ######## Ramping ############# ProductionUpChangeInTimeslice = def_daa(𝓨,𝓛,𝓕,𝓣,𝓡) ProductionDownChangeInTimeslice = def_daa(𝓨,𝓛,𝓕,𝓣,𝓡) for y ∈ 𝓨 for r ∈ 𝓡 for f ∈ 𝓕 for l ∈ 𝓛 @@ -231,11 +229,11 @@ function genesysmod_dec(model,Sets, Params,Switch, Maps) ProductionUpChangeInTimeslice[y,l,f,t,r] = @variable(model, lower_bound = 0, base_name= "ProductionUpChangeInTimeslice[$y,$l,$f,$t,$r]") ProductionDownChangeInTimeslice[y,l,f,t,r] = @variable(model, lower_bound = 0, base_name= "ProductionDownChangeInTimeslice[$y,$l,$f,$t,$r]") end - end end end end + end end end end model[:ProductionUpChangeInTimeslice] = ProductionUpChangeInTimeslice model[:ProductionDownChangeInTimeslice] = ProductionDownChangeInTimeslice - @variable(model, AnnualProductionChangeCost[𝓨,𝓣,𝓡] >= 0, container=DenseArray) - @variable(model, DiscountedAnnualProductionChangeCost[𝓨,𝓣,𝓡] >= 0, container=DenseArray) + @variable(model, AnnualProductionChangeCost[𝓨,𝓣,𝓡] >= 0, container=DenseArray) + @variable(model, DiscountedAnnualProductionChangeCost[𝓨,𝓣,𝓡] >= 0, container=DenseArray) else ProductionUpChangeInTimeslice=nothing ProductionDownChangeInTimeslice=nothing @@ -249,7 +247,7 @@ function genesysmod_dec(model,Sets, Params,Switch, Maps) RateOfTotalActivity=nothing end - BaseYearSlack= @variable(model, BaseYearSlack[𝓕], container=DenseArray) + BaseYearSlack= @variable(model, BaseYearSlack[𝓕], container=DenseArray) BaseYearBounds_TooLow = def_daa(𝓡,𝓣,𝓕,𝓨) BaseYearBounds_TooHigh = def_daa(𝓡,𝓣,𝓕,𝓨) for y ∈ 𝓨 for r ∈ 𝓡 for t ∈ 𝓣 @@ -264,15 +262,15 @@ function genesysmod_dec(model,Sets, Params,Switch, Maps) end end end model[:BaseYearBounds_TooLow] = BaseYearBounds_TooLow model[:BaseYearBounds_TooHigh] = BaseYearBounds_TooHigh - DiscountedSalvageValueTransmission= @variable(model, DiscountedSalvageValueTransmission[𝓨,𝓡] >= 0, container=DenseArray) - + DiscountedSalvageValueTransmission= @variable(model, DiscountedSalvageValueTransmission[𝓨,𝓡] >= 0, container=DenseArray) + Vars = GENeSYS_MOD.Variables(NewCapacity,AccumulatedNewCapacity,TotalCapacityAnnual, RateOfActivity,TotalAnnualTechnologyActivityByMode,ProductionByTechnologyAnnual, UseByTechnologyAnnual,TotalTechnologyAnnualActivity,TotalActivityPerYear,CurtailedEnergyAnnual, CurtailedCapacity,CurtailedEnergy,DispatchDummy,CapitalInvestment,DiscountedCapitalInvestment, SalvageValue,DiscountedSalvageValue,OperatingCost,DiscountedOperatingCost,AnnualVariableOperatingCost, AnnualFixedOperatingCost,VariableOperatingCost,TotalDiscountedCost,TotalDiscountedCostByTechnology, - ModelPeriodCostByRegion,AnnualCurtailmentCost,DiscountedAnnualCurtailmentCost, + AnnualCurtailmentCost,DiscountedAnnualCurtailmentCost, StorageLevelYearStart,StorageLevelYearFinish,StorageLevelTSStart,AccumulatedNewStorageCapacity,NewStorageCapacity, CapitalInvestmentStorage,DiscountedCapitalInvestmentStorage,SalvageValueStorage, DiscountedSalvageValueStorage,TotalDiscountedStorageCost,TotalActivityInReserveMargin, @@ -281,11 +279,10 @@ function genesysmod_dec(model,Sets, Params,Switch, Maps) AnnualTechnologyEmission,AnnualTechnologyEmissionPenaltyByEmission,AnnualTechnologyEmissionsPenalty, DiscountedTechnologyEmissionsPenalty,AnnualEmissions,ModelPeriodEmissions,WeightedAnnualEmissions, AnnualSectoralEmissions,Import,Export,NewTradeCapacity,TotalTradeCapacity,NewTradeCapacityCosts, - DiscountedNewTradeCapacityCosts,NetTrade,NetTradeAnnual,TotalTradeCosts,AnnualTotalTradeCosts, + DiscountedNewTradeCapacityCosts,NetTrade,NetTradeAnnual,AnnualTotalTradeCosts, DiscountedAnnualTotalTradeCosts,DemandSplitByModalType,ProductionSplitByModalType, ProductionUpChangeInTimeslice,ProductionDownChangeInTimeslice, RateOfTotalActivity,BaseYearSlack,BaseYearBounds_TooLow,BaseYearBounds_TooHigh, DiscountedSalvageValueTransmission,PeakingDemand,PeakingCapacity, AnnualProductionChangeCost,DiscountedAnnualProductionChangeCost) return Vars end - diff --git a/src/genesysmod_equ.jl b/src/genesysmod_equ.jl index 32aad13..08d1c00 100644 --- a/src/genesysmod_equ.jl +++ b/src/genesysmod_equ.jl @@ -50,7 +50,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; + sum(Vars.BaseYearBounds_TooLow[r,t,f,y]*9999 for y ∈ 𝓨 for r ∈ 𝓡 for t ∈ 𝓣 for f ∈ 𝓕) - sum(Vars.DiscountedSalvageValueTransmission[y,r] for y ∈ 𝓨 for r ∈ 𝓡)) print("Cstr: Cost : ",Dates.now()-start,"\n") - + ######################### # Parameter assignments # @@ -67,10 +67,10 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; function CanFuelBeUsedByModeByTech(y, f, r,t,m) temp = Params.InputActivityRatio[r,t,f,m,y]* - Params.TotalAnnualMaxCapacity[r,t,y] * + Params.TotalAnnualMaxCapacity[r,t,y] * sum(Params.CapacityFactor[r,t,l,y] for l ∈ 𝓛) * - Params.AvailabilityFactor[r,t,y] * - Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * + Params.AvailabilityFactor[r,t,y] * + Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * Params.TotalTechnologyAnnualActivityUpperLimit[r,t,y] if (!ismissing(temp)) && (temp > 0) return 1 @@ -81,10 +81,10 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; function CanFuelBeUsedByTech(y, f, r,t) temp = sum(Params.InputActivityRatio[r,t,f,m,y]* - Params.TotalAnnualMaxCapacity[r,t,y] * + Params.TotalAnnualMaxCapacity[r,t,y] * sum(Params.CapacityFactor[r,t,l,y] for l ∈ 𝓛) * - Params.AvailabilityFactor[r,t,y] * - Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * + Params.AvailabilityFactor[r,t,y] * + Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * Params.TotalTechnologyAnnualActivityUpperLimit[r,t,y] for m ∈ 𝓜 ) if (!ismissing(temp)) && (temp > 0) return 1 @@ -95,10 +95,10 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; function CanFuelBeUsed(y, f, r) temp = sum(Params.InputActivityRatio[r,t,f,m,y]* - Params.TotalAnnualMaxCapacity[r,t,y] * + Params.TotalAnnualMaxCapacity[r,t,y] * sum(Params.CapacityFactor[r,t,l,y] for l ∈ 𝓛) * - Params.AvailabilityFactor[r,t,y] * - Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * + Params.AvailabilityFactor[r,t,y] * + Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * Params.TotalTechnologyAnnualActivityUpperLimit[r,t,y] for m ∈ 𝓜 for t ∈ 𝓣) if (!ismissing(temp)) && (temp > 0) return 1 @@ -109,10 +109,10 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; function CanFuelBeUsedInTimeslice(y, l, f, r) temp = sum(Params.InputActivityRatio[r,t,f,m,y]* - Params.TotalAnnualMaxCapacity[r,t,y] * + Params.TotalAnnualMaxCapacity[r,t,y] * Params.CapacityFactor[r,t,l,y] * - Params.AvailabilityFactor[r,t,y] * - Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * + Params.AvailabilityFactor[r,t,y] * + Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * Params.TotalTechnologyAnnualActivityUpperLimit[r,t,y] for m ∈ 𝓜 for t ∈ 𝓣) if (!ismissing(temp)) && (temp > 0) return 1 @@ -124,22 +124,22 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; CanFuelBeUsedOrDemanded = JuMP.Containers.DenseAxisArray(zeros(length(𝓨), length(𝓕), length(𝓡)), 𝓨, 𝓕, 𝓡) for y ∈ 𝓨 for f ∈ 𝓕 for r ∈ 𝓡 temp = (isempty(LoopSetInput[(r,f,y)]) ? 0 : sum(Params.InputActivityRatio[r,t,f,m,y]* - Params.TotalAnnualMaxCapacity[r,t,y] * + Params.TotalAnnualMaxCapacity[r,t,y] * sum(Params.CapacityFactor[r,t,l,y] for l ∈ 𝓛) * - Params.AvailabilityFactor[r,t,y] * - Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * + Params.AvailabilityFactor[r,t,y] * + Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * Params.TotalTechnologyAnnualActivityUpperLimit[r,t,y] for (t,m) ∈ LoopSetInput[(r,f,y)])) if (!ismissing(temp)) && (temp > 0) || Params.SpecifiedAnnualDemand[r,f,y] > 0 CanFuelBeUsedOrDemanded[y,f,r] = 1 end - end end end + end end end function CanFuelBeProducedByTech(y, f, r,t) temp = sum(Params.OutputActivityRatio[r,t,f,m,y]* - Params.TotalAnnualMaxCapacity[r,t,y] * + Params.TotalAnnualMaxCapacity[r,t,y] * sum(Params.CapacityFactor[r,t,l,y] for l ∈ 𝓛) * - Params.AvailabilityFactor[r,t,y] * - Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * + Params.AvailabilityFactor[r,t,y] * + Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * Params.TotalTechnologyAnnualActivityUpperLimit[r,t,y] for m ∈ 𝓜) if (!ismissing(temp)) && (temp > 0) return 1 @@ -150,10 +150,10 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; function CanFuelBeProducedByModeByTech(y, f, r,t,m) temp = Params.OutputActivityRatio[r,t,f,m,y]* - Params.TotalAnnualMaxCapacity[r,t,y] * + Params.TotalAnnualMaxCapacity[r,t,y] * sum(Params.CapacityFactor[r,t,l,y] for l ∈ 𝓛) * - Params.AvailabilityFactor[r,t,y] * - Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * + Params.AvailabilityFactor[r,t,y] * + Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * Params.TotalTechnologyAnnualActivityUpperLimit[r,t,y] if (!ismissing(temp)) && (temp > 0) return 1 @@ -166,10 +166,10 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; CanFuelBeProduced = JuMP.Containers.DenseAxisArray(zeros(length(𝓨), length(𝓕), length(𝓡)), 𝓨, 𝓕, 𝓡) for y ∈ 𝓨 for f ∈ 𝓕 for r ∈ 𝓡 temp = (isempty(LoopSetOutput[(r,f,y)]) ? 0 : sum(Params.OutputActivityRatio[r,t,f,m,y]* - Params.TotalAnnualMaxCapacity[r,t,y] * + Params.TotalAnnualMaxCapacity[r,t,y] * sum(Params.CapacityFactor[r,t,l,y] for l ∈ 𝓛) * - Params.AvailabilityFactor[r,t,y] * - Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * + Params.AvailabilityFactor[r,t,y] * + Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * Params.TotalTechnologyAnnualActivityUpperLimit[r,t,y] for (t,m) ∈ LoopSetOutput[(r,f,y)])) if (temp > 0) CanFuelBeProduced[y,f,r] = 1 @@ -178,10 +178,10 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; function CanFuelBeProducedInTimeslice(y, l, f, r) temp = sum(Params.OutputActivityRatio[r,t,f,m,y]* - Params.TotalAnnualMaxCapacity[r,t,y] * + Params.TotalAnnualMaxCapacity[r,t,y] * Params.CapacityFactor[r,t,l,y] * - Params.AvailabilityFactor[r,t,y] * - Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * + Params.AvailabilityFactor[r,t,y] * + Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * Params.TotalTechnologyAnnualActivityUpperLimit[r,t,y] for m ∈ 𝓜 for t ∈ 𝓣) if (!ismissing(temp)) && (temp > 0) return 1 @@ -241,9 +241,9 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; # Constraints # ############### - + ############### Capacity Adequacy A ############# - + start=Dates.now() for y ∈ 𝓨 for t ∈ 𝓣 for r ∈ 𝓡 cond= (any(x->x>0,[Params.TotalAnnualMaxCapacity[r,t,yy] for yy ∈ 𝓨 if (y - yy < Params.OperationalLife[t]) && (y-yy>= 0)])) && (Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] > 0) @@ -265,8 +265,8 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; for y ∈ 𝓨 for t ∈ 𝓣 for r ∈ 𝓡 temp= (Params.TotalAnnualMaxCapacity[r,t,y] * sum(Params.CapacityFactor[r,t,l,y] for l ∈ 𝓛) * - Params.AvailabilityFactor[r,t,y] * - Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * + Params.AvailabilityFactor[r,t,y] * + Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] * Params.TotalTechnologyAnnualActivityUpperLimit[r,t,y]) if (temp > 0) && ((!JuMP.is_fixed(Vars.TotalCapacityAnnual[y,t,r]) && !JuMP.has_upper_bound(Vars.TotalCapacityAnnual[y,t,r])) || (JuMP.is_fixed(Vars.TotalCapacityAnnual[y,t,r]) && (JuMP.fix_value(Vars.TotalCapacityAnnual[y,t,r]) > 0)) || (JuMP.has_upper_bound(Vars.TotalCapacityAnnual[y,t,r]) && (JuMP.upper_bound(Vars.TotalCapacityAnnual[y,t,r]) > 0))) CanBuildTechnology[y,t,r] = 1 @@ -313,7 +313,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; (Params.AvailabilityFactor[r,t,y] > 0) && (Params.TotalAnnualMaxCapacity[r,t,y] > 0) && (Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] > 0) - @constraint(model, + @constraint(model, sum(Vars.RateOfActivity[y,l,t,m,r] for m ∈ Maps.Tech_MO[t]) == Vars.TotalCapacityAnnual[y,t,r] * Params.CapacityFactor[r,t,l,y] * Params.CapacityToActivityUnit[t] * Params.AvailabilityFactor[r,t,y] - Vars.DispatchDummy[r,l,t,y] * Params.Tags.TagDispatchableTechnology[t] - Vars.CurtailedCapacity[r,l,t,y] * Params.CapacityToActivityUnit[t], base_name="CA3b_RateOfTotalActivity|$(r)|$(l)|$(t)|$(y)") end @@ -325,7 +325,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end end print("Cstr: Cap Adequacy A3 : ",Dates.now()-start,"\n") - + start=Dates.now() for y ∈ 𝓨 for t ∈ 𝓣 for r ∈ 𝓡 if (Params.AvailabilityFactor[r,t,y] < 1) && @@ -338,9 +338,9 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end end print("Cstr: Cap Adequacy B : ",Dates.now()-start,"\n") - + ############### Energy Balance A ############# - + start=Dates.now() for y ∈ 𝓨 for f ∈ 𝓕 for r ∈ 𝓡 for rr ∈ 𝓡 @@ -360,7 +360,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; JuMP.fix.(Vars.NetTrade[y,:,f,r], 0; force=true) else for l ∈ 𝓛 - @constraint(model, sum(Vars.Export[y,l,f,r,rr]*(1+Params.TradeLossBetweenRegions[r,rr,f,y]) - Vars.Import[y,l,f,r,rr] for rr ∈ 𝓡 if Params.TradeRoute[r,rr,f,y] > 0) == Vars.NetTrade[y,l,f,r], + @constraint(model, sum(Vars.Export[y,l,f,r,rr]*(1+Params.TradeLossBetweenRegions[r,rr,f,y]) - Vars.Import[y,l,f,r,rr] for rr ∈ 𝓡 if Params.TradeRoute[r,rr,f,y] > 0) == Vars.NetTrade[y,l,f,r], base_name="EB4_NetTradeBalance|$(y)|$(l)|$(f)|$(r)") end end @@ -378,7 +378,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; print("Cstr: Energy Balance A1 : ",Dates.now()-start,"\n") start=Dates.now() for y ∈ 𝓨 for f ∈ 𝓕 for r ∈ 𝓡 - @constraint(model, Vars.CurtailedEnergyAnnual[y,f,r] == sum(Vars.CurtailedCapacity[r,l,t,y] * Params.OutputActivityRatio[r,t,f,m,y] * Params.YearSplit[l,y] * Params.CapacityToActivityUnit[t] for l ∈ 𝓛 for (t,m) ∈ LoopSetOutput[(r,f,y)]), + @constraint(model, Vars.CurtailedEnergyAnnual[y,f,r] == sum(Vars.CurtailedCapacity[r,l,t,y] * Params.OutputActivityRatio[r,t,f,m,y] * Params.YearSplit[l,y] * Params.CapacityToActivityUnit[t] for l ∈ 𝓛 for (t,m) ∈ LoopSetOutput[(r,f,y)]), base_name="EB6_AnnualEnergyCurtailment|$(y)|$(f)|$(r)") if Params.SelfSufficiency[y,f,r] != 0 @@ -386,11 +386,11 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; (Params.SpecifiedAnnualDemand[r,f,y] + sum(Vars.RateOfActivity[y,l,t,m,r]*Params.InputActivityRatio[r,t,f,m,y]*Params.TimeDepEfficiency[r,t,l,y]*Params.YearSplit[l,y] for l ∈ 𝓛 for (t,m) ∈ LoopSetInput[(r,f,y)]))*Params.SelfSufficiency[y,f,r], base_name="EB7_AnnualSelfSufficiency|$(y)|$(f)|$(r)") end - end end end + end end end print("Cstr: Energy Balance A2 : ",Dates.now()-start,"\n") ############### Energy Balance B ############# - + start=Dates.now() for y ∈ 𝓨 for f ∈ 𝓕 for r ∈ 𝓡 if sum(Params.TradeRoute[r,rr,f,y] for rr ∈ 𝓡) > 0 @@ -398,19 +398,19 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; else JuMP.fix(Vars.NetTradeAnnual[y,f,r],0; force=true) end - + if TagTimeIndependentFuel[y,f,r] != 0 - @constraint(model, sum(Vars.RateOfActivity[y,l,t,m,r]*Params.OutputActivityRatio[r,t,f,m,y]*Params.YearSplit[l,y] for l ∈ 𝓛 for (t,m) ∈ LoopSetOutput[(r,f,y)]) >= - sum( Vars.RateOfActivity[y,l,t,m,r]*Params.InputActivityRatio[r,t,f,m,y]*Params.TimeDepEfficiency[r,t,l,y]*Params.YearSplit[l,y] for l ∈ 𝓛 for (t,m) ∈ LoopSetInput[(r,f,y)]) + Vars.NetTradeAnnual[y,f,r], + @constraint(model, sum(Vars.RateOfActivity[y,l,t,m,r]*Params.OutputActivityRatio[r,t,f,m,y]*Params.YearSplit[l,y] for l ∈ 𝓛 for (t,m) ∈ LoopSetOutput[(r,f,y)]) >= + sum( Vars.RateOfActivity[y,l,t,m,r]*Params.InputActivityRatio[r,t,f,m,y]*Params.TimeDepEfficiency[r,t,l,y]*Params.YearSplit[l,y] for l ∈ 𝓛 for (t,m) ∈ LoopSetInput[(r,f,y)]) + Vars.NetTradeAnnual[y,f,r], base_name="EB3_EnergyBalanceEachYear|$(y)|$(f)|$(r)") end end end end print("Cstr: Energy Balance B : ",Dates.now()-start,"\n") - - + + ############### Trade Capacities & Investments ############# - + for i ∈ eachindex(𝓨) for r ∈ 𝓡 for rr ∈ 𝓡 if Params.TradeRoute[r,rr,"Power",𝓨[i]] > 0 for l ∈ 𝓛 @@ -435,12 +435,12 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; if 𝓨[i] == Switch.StartYear @constraint(model, Vars.TotalTradeCapacity[𝓨[i],f,r,rr] == Params.TradeCapacity[r,rr,f,𝓨[i]], base_name="TrC2a_TotalTradeCapacityStartYear|$(𝓨[i])|$(f)|$(r)|$(rr)") elseif 𝓨[i] > Switch.StartYear - @constraint(model, Vars.TotalTradeCapacity[𝓨[i],f,r,rr] == Vars.TotalTradeCapacity[𝓨[i-1],f,r,rr] + Vars.NewTradeCapacity[𝓨[i],f,r,rr] + Params.CommissionedTradeCapacity[r,rr,f,𝓨[i]], + @constraint(model, Vars.TotalTradeCapacity[𝓨[i],f,r,rr] == Vars.TotalTradeCapacity[𝓨[i-1],f,r,rr] + Vars.NewTradeCapacity[𝓨[i],f,r,rr] + Params.CommissionedTradeCapacity[r,rr,f,𝓨[i]], base_name="TrC2b_TotalTradeCapacity|$(𝓨[i])|$(f)|$(r)|$(rr)") end - if f == "Power" && i > 1 && Params.GrowthRateTradeCapacity[r,rr,f,𝓨[i]] > 0 - @constraint(model, (Params.GrowthRateTradeCapacity[r,rr,f,𝓨[i]]*YearlyDifferenceMultiplier(𝓨[i],Sets))*Vars.TotalTradeCapacity[𝓨[i-1],f,r,rr] >= Vars.NewTradeCapacity[𝓨[i],f,r,rr], + if f == "Power" && i > 1 && Params.GrowthRateTradeCapacity[r,rr,f,𝓨[i]] > 0 + @constraint(model, (Params.GrowthRateTradeCapacity[r,rr,f,𝓨[i]]*YearlyDifferenceMultiplier(𝓨[i],Sets))*Vars.TotalTradeCapacity[𝓨[i-1],f,r,rr] >= Vars.NewTradeCapacity[𝓨[i],f,r,rr], base_name="TrC3_NewTradeCapacityLimitPowerLines|$(𝓨[i])|Power|$(r)|$(rr)") end end @@ -477,14 +477,14 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end #= for f ∈ 𝓕 - if f != "Power" + if f != "Power" JuMP.fix(Vars.NewTradeCapacity[𝓨[i],f,r,rr],0; force=true) end if Params.TradeRoute[r,rr,f,𝓨[i]] == 0 || f != "Power" JuMP.fix(Vars.DiscountedNewTradeCapacityCosts[𝓨[i],f,r,rr],0; force=true) end end =# - end end end + end end end ##############* Pipeline-specific Capacity Accounting ############# @@ -518,10 +518,10 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; JuMP.fix(Vars.AnnualTotalTradeCosts[y,r], 0; force=true) end @constraint(model, Vars.AnnualTotalTradeCosts[y,r]/((1+Settings.GeneralDiscountRate[r])^(y-Switch.StartYear+0.5)) == Vars.DiscountedAnnualTotalTradeCosts[y,r], base_name="TC2_DiscountedAnnualTradeCosts|$(y)|$(r)") - end end - + end end + ############### Accounting Technology Production/Use ############# - + start=Dates.now() for y ∈ 𝓨 for t ∈ 𝓣 for r ∈ 𝓡 for m ∈ Maps.Tech_MO[t] if CanBuildTechnology[y,t,r] > 0 @@ -529,10 +529,10 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; else JuMP.fix(Vars.TotalAnnualTechnologyActivityByMode[y,t,m,r],0; force=true) end - end end end end + end end end end for i ∈ eachindex(𝓨) for f ∈ 𝓕 for r ∈ 𝓡 - for t ∈ Maps.Fuel_Tech[f] + for t ∈ Maps.Fuel_Tech[f] if sum(Params.OutputActivityRatio[r,t,f,m,𝓨[i]] for m ∈ 𝓜) > 0 && Params.AvailabilityFactor[r,t,𝓨[i]] > 0 && Params.TotalAnnualMaxCapacity[r,t,𝓨[i]] > 0 && @@ -560,40 +560,40 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end print("Cstr: Acc. Tech. 1 : ",Dates.now()-start,"\n") - + ############### Capital Costs ############# - + start=Dates.now() for y ∈ 𝓨 for t ∈ 𝓣 for r ∈ 𝓡 @constraint(model, Params.CapitalCost[r,t,y] * Vars.NewCapacity[y,t,r] == Vars.CapitalInvestment[y,t,r], base_name="CC1_UndiscountedCapitalInvestments|$(y)|$(t)|$(r)") @constraint(model, Vars.CapitalInvestment[y,t,r]/((1+Settings.TechnologyDiscountRate[r,t])^(y-Switch.StartYear)) == Vars.DiscountedCapitalInvestment[y,t,r], base_name="CC2_DiscountedCapitalInvestments|$(y)|$(t)|$(r)") end end end print("Cstr: Cap. Cost. : ",Dates.now()-start,"\n") - + ############### Investment & Capacity Limits / Smoothing Constraints ############# - + if Switch.switch_dispatch isa NoDispatch if Switch.switch_investLimit == 1 for i ∈ eachindex(𝓨) if 𝓨[i] > Switch.StartYear - @constraint(model, - sum(Vars.CapitalInvestment[𝓨[i],t,r] for t ∈ 𝓣 for r ∈ 𝓡) <= 1/(max(𝓨...)-Switch.StartYear)*YearlyDifferenceMultiplier(𝓨[i-1],Sets)*Settings.InvestmentLimit*sum(Vars.CapitalInvestment[yy,t,r] for yy ∈𝓨 for t ∈ 𝓣 for r ∈ 𝓡), + @constraint(model, + sum(Vars.CapitalInvestment[𝓨[i],t,r] for t ∈ 𝓣 for r ∈ 𝓡) <= 1/(max(𝓨...)-Switch.StartYear)*YearlyDifferenceMultiplier(𝓨[i-1],Sets)*Settings.InvestmentLimit*sum(Vars.CapitalInvestment[yy,t,r] for yy ∈𝓨 for t ∈ 𝓣 for r ∈ 𝓡), base_name="SC1_SpreadCapitalInvestmentsAcrossTime|$(𝓨[i])") - for r ∈ 𝓡 + for r ∈ 𝓡 for t ∈ intersect(Sets.Technology, Params.Tags.TagTechnologyToSubsets["Renewables"]) @constraint(model, - Vars.NewCapacity[𝓨[i],t,r] <= YearlyDifferenceMultiplier(𝓨[i-1],Sets)*Settings.NewRESCapacity*Params.TotalAnnualMaxCapacity[r,t,𝓨[i]], + Vars.NewCapacity[𝓨[i],t,r] <= YearlyDifferenceMultiplier(𝓨[i-1],Sets)*Settings.NewRESCapacity*Params.TotalAnnualMaxCapacity[r,t,𝓨[i]], base_name="SC2_LimitAnnualCapacityAdditions|$(𝓨[i])|$(r)|$(t)") end for f ∈ 𝓕 for t ∈ intersect(Maps.Fuel_Tech[f],Params.Tags.TagTechnologyToSubsets["PhaseInSet"]) @constraint(model, - Vars.ProductionByTechnologyAnnual[𝓨[i],t,f,r] >= Vars.ProductionByTechnologyAnnual[𝓨[i-1],t,f,r]*Settings.PhaseIn[𝓨[i]]*(Params.SpecifiedAnnualDemand[r,f,𝓨[i]] > 0 ? Params.SpecifiedAnnualDemand[r,f,𝓨[i]]/Params.SpecifiedAnnualDemand[r,f,𝓨[i-1]] : 1), + Vars.ProductionByTechnologyAnnual[𝓨[i],t,f,r] >= Vars.ProductionByTechnologyAnnual[𝓨[i-1],t,f,r]*Settings.PhaseIn[𝓨[i]]*(Params.SpecifiedAnnualDemand[r,f,𝓨[i]] > 0 ? Params.SpecifiedAnnualDemand[r,f,𝓨[i]]/Params.SpecifiedAnnualDemand[r,f,𝓨[i-1]] : 1), base_name="SC3_SmoothingRenewableIntegration|$(𝓨[i])|$(r)|$(t)|$(f)") end for t ∈ intersect(Maps.Fuel_Tech[f],Params.Tags.TagTechnologyToSubsets["PhaseOutSet"]) - @constraint(model, - Vars.ProductionByTechnologyAnnual[𝓨[i],t,f,r] <= Vars.ProductionByTechnologyAnnual[𝓨[i-1],t,f,r]*Settings.PhaseOut[𝓨[i]]*(Params.SpecifiedAnnualDemand[r,f,𝓨[i]] > 0 ? Params.SpecifiedAnnualDemand[r,f,𝓨[i]]/Params.SpecifiedAnnualDemand[r,f,𝓨[i-1]] : 1), + @constraint(model, + Vars.ProductionByTechnologyAnnual[𝓨[i],t,f,r] <= Vars.ProductionByTechnologyAnnual[𝓨[i-1],t,f,r]*Settings.PhaseOut[𝓨[i]]*(Params.SpecifiedAnnualDemand[r,f,𝓨[i]] > 0 ? Params.SpecifiedAnnualDemand[r,f,𝓨[i]]/Params.SpecifiedAnnualDemand[r,f,𝓨[i-1]] : 1), base_name="SC3_SmoothingFossilPhaseOuts|$(𝓨[i])|$(r)|$(t)|$(f)") end end @@ -601,10 +601,10 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; for f ∈ 𝓕 if Settings.ProductionGrowthLimit[𝓨[i],f]>0 @constraint(model, - sum(Vars.ProductionByTechnologyAnnual[𝓨[i],t,f,r]-Vars.ProductionByTechnologyAnnual[𝓨[i-1],t,f,r] for t ∈ Maps.Fuel_Tech[f] for r ∈ 𝓡 if Params.Tags.RETagTechnology[r,t,𝓨[i]]==1) <= + sum(Vars.ProductionByTechnologyAnnual[𝓨[i],t,f,r]-Vars.ProductionByTechnologyAnnual[𝓨[i-1],t,f,r] for t ∈ Maps.Fuel_Tech[f] for r ∈ 𝓡 if Params.Tags.RETagTechnology[r,t,𝓨[i]]==1) <= YearlyDifferenceMultiplier(𝓨[i-1],Sets)*Settings.ProductionGrowthLimit[𝓨[i],f]*sum(Vars.ProductionByTechnologyAnnual[𝓨[i-1],t,f,r] for t ∈ Maps.Fuel_Tech[f] for r ∈ 𝓡)-sum(Vars.ProductionByTechnologyAnnual[𝓨[i-1],t,f,r] for t ∈ intersect(Maps.Fuel_Tech[f],Params.Tags.TagTechnologyToSubsets["StorageDummies"]) for r ∈ 𝓡), base_name="SC4_RelativeTechnologyPhaseInLimit|$(𝓨[i])|$(f)") - for r ∈ 𝓡 + for r ∈ 𝓡 @constraint(model, sum(Vars.ProductionByTechnologyAnnual[𝓨[i],t,f,r]-Vars.ProductionByTechnologyAnnual[𝓨[i-1],t,f,r] for t ∈ intersect(Maps.Fuel_Tech[f],Params.Tags.TagTechnologyToSubsets["StorageDummies"])) <= YearlyDifferenceMultiplier(𝓨[i-1],Sets)*(Settings.ProductionGrowthLimit[𝓨[i],f]+Settings.StorageLimitOffset)*sum(Vars.ProductionByTechnologyAnnual[𝓨[i-1],t,f,r] for t ∈ Maps.Fuel_Tech[f]), base_name="SC5_AnnualStorageChangeLimit|$(𝓨[i])|$(r)|$(f)") @@ -618,7 +618,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; ############## CCS-specific constraints ############# if Switch.switch_ccs == 1 for r ∈ 𝓡 - for i ∈ 2:length(𝓨) for f ∈ setdiff(𝓕,["DAC_Dummy"]) + for i ∈ 2:length(𝓨) for f ∈ setdiff(𝓕,["DAC_Dummy"]) @constraint(model, sum(Vars.ProductionByTechnologyAnnual[𝓨[i],t,f,r]-Vars.ProductionByTechnologyAnnual[𝓨[i-1],t,f,r] for t ∈ intersect(Maps.Fuel_Tech[f],Params.Tags.TagTechnologyToSubsets["CCS"])) <= YearlyDifferenceMultiplier(𝓨[i-1],Sets)*(Settings.ProductionGrowthLimit[𝓨[i],"Air"])*sum(Vars.ProductionByTechnologyAnnual[𝓨[i-1],t,f,r] for t ∈ Maps.Fuel_Tech[f]), base_name="CCS1_CCSAdditionLimit|$(𝓨[i])|$(r)|$(f)") @@ -627,20 +627,20 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; if sum(Params.RegionalCCSLimit[r] for r ∈ 𝓡)>0 @constraint(model, sum(sum( Vars.TotalAnnualTechnologyActivityByMode[y,t,m,r]*Params.EmissionContentPerFuel[f,e]*Params.InputActivityRatio[r,t,f,m,y]*YearlyDifferenceMultiplier(y,Sets)*((Params.EmissionActivityRatio[r,t,m,e,y]>0 ? (1-Params.EmissionActivityRatio[r,t,m,e,y]) : 0)+ - (Params.EmissionActivityRatio[r,t,m,e,y] < 0 ? (-1)*Params.EmissionActivityRatio[r,t,m,e,y] : 0)) for f ∈ Maps.Tech_Fuel[t] for m ∈ Maps.Tech_MO[t] for e ∈ 𝓔) for y ∈ 𝓨 for t ∈ Params.Tags.TagTechnologyToSubsets["CCS"] ) <= Params.RegionalCCSLimit[r], + (Params.EmissionActivityRatio[r,t,m,e,y] < 0 ? (-1)*Params.EmissionActivityRatio[r,t,m,e,y] : 0)) for f ∈ Maps.Tech_Fuel[t] for m ∈ Maps.Tech_MO[t] for e ∈ 𝓔) for y ∈ 𝓨 for t ∈ intersect(𝓣,Params.Tags.TagTechnologyToSubsets["CCS"]) ) <= Params.RegionalCCSLimit[r], base_name="CCS2_MaximumCCStorageLimit|$(r)") end end end - + end - + ############### Salvage Value ############# - + for y ∈ 𝓨 for r ∈ 𝓡 for t ∈ 𝓣 if Settings.DepreciationMethod[r]==1 && ((y + Params.OperationalLife[t] - 1 > max(𝓨...)) && (Settings.TechnologyDiscountRate[r,t] > 0)) - @constraint(model, + @constraint(model, Vars.SalvageValue[y,t,r] == Params.CapitalCost[r,t,y]*Vars.NewCapacity[y,t,r]*(1-(((1+Settings.TechnologyDiscountRate[r,t])^(max(𝓨...) - y + 1 ) -1)/((1+Settings.TechnologyDiscountRate[r,t])^Params.OperationalLife[t]-1))), base_name="SV1_SalvageValueAtEndOfPeriod1|$(y)|$(t)|$(r)") end @@ -666,9 +666,9 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; base_name="SV1b_SalvageValueAtEndOfPeriod1|$(y)|$(r)") end end end - + ############### Operating Costs ############# - + start=Dates.now() for y ∈ 𝓨 for t ∈ 𝓣 for r ∈ 𝓡 if (sum(Params.VariableCost[r,t,m,y] for m ∈ Maps.Tech_MO[t]) > 0) & (CanBuildTechnology[y,t,r] > 0) @@ -683,10 +683,10 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; JuMP.fix(Vars.AnnualFixedOperatingCost[y,t,r],0; force=true) end - if ((JuMP.has_upper_bound(Vars.AnnualVariableOperatingCost[y,t,r]) && JuMP.upper_bound(Vars.AnnualVariableOperatingCost[y,t,r]) >0) || + if ((JuMP.has_upper_bound(Vars.AnnualVariableOperatingCost[y,t,r]) && JuMP.upper_bound(Vars.AnnualVariableOperatingCost[y,t,r]) >0) || (!JuMP.is_fixed(Vars.AnnualVariableOperatingCost[y,t,r]) >0) && !JuMP.has_upper_bound(Vars.AnnualVariableOperatingCost[y,t,r]) || (JuMP.is_fixed(Vars.AnnualVariableOperatingCost[y,t,r]) && JuMP.fix_value(Vars.AnnualVariableOperatingCost[y,t,r]) >0)) || - ((JuMP.has_upper_bound(Vars.AnnualFixedOperatingCost[y,t,r]) && JuMP.upper_bound(Vars.AnnualFixedOperatingCost[y,t,r]) >0) || + ((JuMP.has_upper_bound(Vars.AnnualFixedOperatingCost[y,t,r]) && JuMP.upper_bound(Vars.AnnualFixedOperatingCost[y,t,r]) >0) || (!JuMP.is_fixed(Vars.AnnualFixedOperatingCost[y,t,r]) >0) && !JuMP.has_upper_bound(Vars.AnnualFixedOperatingCost[y,t,r]) || (JuMP.is_fixed(Vars.AnnualFixedOperatingCost[y,t,r]) && JuMP.fix_value(Vars.AnnualFixedOperatingCost[y,t,r]) >0)) #OC3_OperatingCostsTotalAnnual @constraint(model, (Vars.AnnualFixedOperatingCost[y,t,r] + Vars.AnnualVariableOperatingCost[y,t,r])*YearlyDifferenceMultiplier(y,Sets) == Vars.OperatingCost[y,t,r], base_name="OC3_OperatingCostsTotalAnnual|$(y)|$(t)|$(r)") @@ -694,7 +694,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; JuMP.fix(Vars.OperatingCost[y,t,r],0; force=true) end - if ((JuMP.has_upper_bound(Vars.OperatingCost[y,t,r]) && JuMP.upper_bound(Vars.OperatingCost[y,t,r]) >0) || + if ((JuMP.has_upper_bound(Vars.OperatingCost[y,t,r]) && JuMP.upper_bound(Vars.OperatingCost[y,t,r]) >0) || (!JuMP.is_fixed(Vars.OperatingCost[y,t,r]) >0) && !JuMP.has_upper_bound(Vars.OperatingCost[y,t,r]) || (JuMP.is_fixed(Vars.OperatingCost[y,t,r]) && JuMP.fix_value(Vars.OperatingCost[y,t,r]) >0)) # OC4_DiscountedOperatingCostsTotalAnnual @constraint(model, Vars.OperatingCost[y,t,r]/((1+Settings.TechnologyDiscountRate[r,t])^(y-Switch.StartYear+0.5)) == Vars.DiscountedOperatingCost[y,t,r], base_name="OC4_DiscountedOperatingCostsTotalAnnual|$(y)|$(t)|$(r)") @@ -703,12 +703,12 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end end print("Cstr: Op. Cost. : ",Dates.now()-start,"\n") - + ############### Total Discounted Costs ############# - + start=Dates.now() for y ∈ 𝓨 for r ∈ 𝓡 - for t ∈ 𝓣 + for t ∈ 𝓣 @constraint(model, Vars.DiscountedOperatingCost[y,t,r]+Vars.DiscountedCapitalInvestment[y,t,r]+Vars.DiscountedTechnologyEmissionsPenalty[y,t,r]-Vars.DiscountedSalvageValue[y,t,r] + (Switch.switch_ramping ==1 ? Vars.DiscountedAnnualProductionChangeCost[y,t,r] : 0) @@ -719,9 +719,9 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; ,base_name="TDC2_TotalDiscountedCost|$(y)|$(r)") end end print("Cstr: Tot. Disc. Cost 2 : ",Dates.now()-start,"\n") - + ############### Total Capacity Constraints ############## - + start=Dates.now() for y ∈ 𝓨 for t ∈ 𝓣 for r ∈ 𝓡 if (Params.TotalAnnualMaxCapacity[r,t,y] < 999999) && (Params.TotalAnnualMaxCapacity[r,t,y] > 0) @@ -735,9 +735,9 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end end print("Cstr: Tot. Cap. : ",Dates.now()-start,"\n") - + ############### New Capacity Constraints ############## - + for y ∈ 𝓨 for t ∈ 𝓣 for r ∈ 𝓡 if Params.TotalAnnualMaxCapacityInvestment[r,t,y] < 999999 @constraint(model, @@ -748,12 +748,12 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; Vars.NewCapacity[y,t,r] >= Params.TotalAnnualMinCapacityInvestment[r,t,y], base_name="NCC2_TotalAnnualMinNewCapacityConstraint|$(y)|$(t)|$(r)") end end end end - + ################ Annual Activity Constraints ############## - + start=Dates.now() for y ∈ 𝓨 for t ∈ 𝓣 for r ∈ 𝓡 - if (CanBuildTechnology[y,t,r] > 0) && + if (CanBuildTechnology[y,t,r] > 0) && (any(x->x>0, [JuMP.has_upper_bound(Vars.ProductionByTechnologyAnnual[y,t,f,r]) ? JuMP.upper_bound(Vars.ProductionByTechnologyAnnual[y,t,f,r]) : ((JuMP.is_fixed(Vars.ProductionByTechnologyAnnual[y,t,f,r])) && (JuMP.fix_value(Vars.ProductionByTechnologyAnnual[y,t,f,r]) == 0)) ? 0 : 999999 for f ∈ Maps.Tech_Fuel[t]])) @constraint(model, sum(Vars.ProductionByTechnologyAnnual[y,t,f,r] for f ∈ Maps.Tech_Fuel[t]) == Vars.TotalTechnologyAnnualActivity[y,t,r], base_name= "AAC1_TotalAnnualTechnologyActivity|$(y)|$(t)|$(r)") else @@ -767,11 +767,11 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; if Params.TotalTechnologyAnnualActivityLowerLimit[r,t,y] > 0 # AAC3_TotalAnnualTechnologyActivityLowerLimit @constraint(model, Vars.TotalTechnologyAnnualActivity[y,t,r] >= Params.TotalTechnologyAnnualActivityLowerLimit[r,t,y], base_name= "AAC3_TotalAnnualTechnologyActivityLowerLimit|$(y)|$(t)|$(r)") end - end end end + end end end print("Cstr: Annual. Activity : ",Dates.now()-start,"\n") - + ################ Total Activity Constraints ############## - + start=Dates.now() for t ∈ 𝓣 for r ∈ 𝓡 @constraint(model, sum(Vars.TotalTechnologyAnnualActivity[y,t,r]*YearlyDifferenceMultiplier(y,Sets) for y ∈ 𝓨) == Vars.TotalTechnologyModelPeriodActivity[t,r], base_name="TAC1_TotalModelHorizonTechnologyActivity|$(t)|$(r)") @@ -783,15 +783,15 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end print("Cstr: Tot. Activity : ",Dates.now()-start,"\n") - + ############### Reserve Margin Constraint ############## NTS: Should change demand for production - + if Switch.switch_dispatch isa NoDispatch && Switch.switch_reserve == 1 #TODO should this be enabled for dispatch? for r ∈ 𝓡, y ∈ 𝓨, l ∈ 𝓛 @constraint(model, sum((Vars.RateOfActivity[y,l,t,m,r]*Params.OutputActivityRatio[r,t,f,m,y] * Params.YearSplit[l,y] *Params.ReserveMarginTagTechnology[r,t,y] * Params.ReserveMarginTagFuel[r,f,y]) for f ∈ 𝓕 for (t,m) ∈ LoopSetOutput[(r,f,y)]) == Vars.TotalActivityInReserveMargin[r,y,l], base_name="RM1_ReserveMargin_TechologiesIncluded_In_Activity_Units|$(y)|$(l)|$(r)") - + @constraint(model, sum((sum(Vars.RateOfActivity[y,l,t,m,r]*Params.OutputActivityRatio[r,t,f,m,y] for (t,m) ∈ LoopSetOutput[(r,f,y)] if t ∈ Maps.Fuel_Tech[f]) * Params.YearSplit[l,y] *Params.ReserveMarginTagFuel[r,f,y]) for f ∈ 𝓕) == Vars.DemandNeedingReserveMargin[y,l,r], base_name="RM2_ReserveMargin_FuelsIncluded|$(y)|$(l)|$(r)") @@ -803,9 +803,9 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end - + ############### RE Production Target ############## NTS: Should change demand for production - + start=Dates.now() for i ∈ eachindex(𝓨) for f ∈ 𝓕 for r ∈ 𝓡 @constraint(model, @@ -825,9 +825,9 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end print("Cstr: RE target : ",Dates.now()-start,"\n") - + ################ Emissions Accounting ############## - + start=Dates.now() for y ∈ 𝓨 for t ∈ 𝓣 for r ∈ 𝓡 if CanBuildTechnology[y,t,r] > 0 @@ -858,15 +858,15 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; @constraint(model, Vars.AnnualTechnologyEmissionsPenalty[y,t,r]/((1+Settings.SocialDiscountRate[r])^(y-Switch.StartYear+0.5)) == Vars.DiscountedTechnologyEmissionsPenalty[y,t,r], base_name="E5_DiscountedEmissionsPenaltyByTechnology|$(y)|$(t)|$(r)") end - end end + end end for e ∈ 𝓔 for y ∈ 𝓨 for r ∈ 𝓡 - @constraint(model, sum(Vars.AnnualTechnologyEmission[y,t,e,r] for t ∈ 𝓣) == Vars.AnnualEmissions[y,e,r], + @constraint(model, sum(Vars.AnnualTechnologyEmission[y,t,e,r] for t ∈ 𝓣) == Vars.AnnualEmissions[y,e,r], base_name="E6_AnnualEmissionsAccounting|$(y)|$(e)|$(r)") - @constraint(model, Vars.AnnualEmissions[y,e,r]+Params.AnnualExogenousEmission[r,e,y] <= Params.RegionalAnnualEmissionLimit[r,e,y], + @constraint(model, Vars.AnnualEmissions[y,e,r]+Params.AnnualExogenousEmission[r,e,y] <= Params.RegionalAnnualEmissionLimit[r,e,y], base_name="E8_RegionalAnnualEmissionsLimit|$(y)|$(e)|$(r)") end @constraint(model, sum(Vars.AnnualEmissions[y,e,r]+Params.AnnualExogenousEmission[r,e,y] for r ∈ 𝓡) <= Params.AnnualEmissionLimit[e,y], @@ -909,7 +909,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end print("Cstr: Em. Acc. 4 : ",Dates.now()-start,"\n") - + ################ Sectoral Emissions Accounting ############## start=Dates.now() for y ∈ 𝓨, e ∈ 𝓔, se ∈ 𝓢𝓮 @@ -950,7 +950,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; for j ∈ eachindex(𝓛) @constraint(model, - (j>1 ? Vars.StorageLevelTSStart[s,𝓨[i],𝓛[j-1],r] + + (j>1 ? Vars.StorageLevelTSStart[s,𝓨[i],𝓛[j-1],r] + (sum((Params.TechnologyToStorage[t,s,m,𝓨[i]]>0 ? Vars.RateOfActivity[𝓨[i],𝓛[j-1],t,m,r] * Params.TechnologyToStorage[t,s,m,𝓨[i]] : 0) for t ∈ intersect(Sets.Technology, Params.Tags.TagTechnologyToSubsets["StorageDummies"]) for m ∈ Maps.Tech_MO[t]) - sum((Params.TechnologyFromStorage[t,s,m,𝓨[i]]>0 ? Vars.RateOfActivity[𝓨[i],𝓛[j-1],t,m,r] / Params.TechnologyFromStorage[t,s,m,𝓨[i]] : 0 ) for t ∈ intersect(Sets.Technology, Params.Tags.TagTechnologyToSubsets["StorageDummies"]) for m ∈ Maps.Tech_MO[t])) * Params.YearSplit[𝓛[j-1],𝓨[i]] : 0) + (j == 1 ? Vars.StorageLevelYearStart[s,𝓨[i],r] : 0) == Vars.StorageLevelTSStart[s,𝓨[i],𝓛[j],r], @@ -989,10 +989,10 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; base_name="SI5_TotalDiscountedCostByStorage|$(s)|$(𝓨[i])|$(r)") end end end for s ∈ 𝓢 for i ∈ eachindex(𝓨) - for r ∈ 𝓡 + for r ∈ 𝓡 if Params.MinStorageCharge[r,s,𝓨[i]] > 0 for j ∈ eachindex(𝓛) - @constraint(model, + @constraint(model, Params.MinStorageCharge[r,s,𝓨[i]]*sum(Vars.NewStorageCapacity[s,𝓨[i],r] + Params.ResidualStorageCapacity[r,s,𝓨[i]] for yy ∈ 𝓨 if (𝓨[i]-yy < Params.OperationalLifeStorage[s] && 𝓨[i]-yy >= 0)) <= Vars.StorageLevelTSStart[s,𝓨[i],𝓛[j],r], base_name="S5a_StorageChargeLowerLimit|$(s)|$(𝓨[i])|$(𝓛[j])|$(r)") @@ -1010,14 +1010,14 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end end print("Cstr: Storage 1 : ",Dates.now()-start,"\n") - + ######### Transportation Equations ############# start=Dates.now() if Switch.switch_dispatch isa TwoNodes for y ∈ 𝓨 for f ∈ intersect(Sets.Fuel, Params.Tags.TagFuelToSubsets["TransportFuels"]) for l ∈ 𝓛 for mt ∈ 𝓜𝓽 - demand_split = sum(Params_full.SpecifiedAnnualDemand[r,f,y]*Params_full.ModalSplitByFuelAndModalType[r,f,y,mt]*Params_full.SpecifiedDemandProfile[r,f,l,y] for r in Region_Full if r!=𝓡[1]) + demand_split = sum(Params_full.SpecifiedAnnualDemand[r,f,y]*Params_full.ModalSplitByFuelAndModalType[r,f,y,mt]*Params_full.SpecifiedDemandProfile[r,f,l,y] for r in Region_Full if r!=𝓡[1]) @constraint(model, demand_split == Vars.DemandSplitByModalType[mt,l,𝓡[2],f,y], base_name="T1_SpecifiedAnnualDemandByModalSplit|$(mt)|$(l)_ROE|$(f)|$(y)") @@ -1025,7 +1025,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; Params_full.SpecifiedAnnualDemand[𝓡[1],f,y]*Params_full.ModalSplitByFuelAndModalType[𝓡[1],f,y,mt]*Params_full.SpecifiedDemandProfile[𝓡[1],f,l,y] == Vars.DemandSplitByModalType[mt,l,𝓡[1],f,y], base_name="T1_SpecifiedAnnualDemandByModalSplit|$(mt)|$(l)|$(𝓡[1])|$(f)|$(y)") end end - + for mt ∈ 𝓜𝓽 for r ∈ 𝓡 if sum(Params.Tags.TagTechnologyToModalType[:,:,mt]) != 0 && sum(Params.OutputActivityRatio[r,:,f,:,y]) != 0 for l ∈ 𝓛 @@ -1039,7 +1039,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end end - + for l ∈ 𝓛 for r ∈ 𝓡 JuMP.fix(Vars.ProductionSplitByModalType["MT_FRT_SHIP_RE",l,r,"Mobility_Passenger",y], 0; force=true) JuMP.fix(Vars.ProductionSplitByModalType["MT_FRT_ROAD_RE",l,r,"Mobility_Passenger",y], 0; force=true) @@ -1059,13 +1059,13 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; for r ∈ 𝓡 for y ∈ 𝓨 for f ∈ intersect(Sets.Fuel, Params.Tags.TagFuelToSubsets["TransportFuels"]) if Params.SpecifiedAnnualDemand[r,f,y] != 0 - for l ∈ 𝓛 for mt ∈ 𝓜𝓽 + for l ∈ 𝓛 for mt ∈ 𝓜𝓽 @constraint(model, Params.SpecifiedAnnualDemand[r,f,y]*Params.ModalSplitByFuelAndModalType[r,f,y,mt]*Params.SpecifiedDemandProfile[r,f,l,y] == Vars.DemandSplitByModalType[mt,l,r,f,y], base_name="T1_SpecifiedAnnualDemandByModalSplit|$(mt)|$(l)|$(r)|$(f)|$(y)") end end end - + for mt ∈ 𝓜𝓽 if sum(Params.Tags.TagTechnologyToModalType[:,:,mt]) != 0 && sum(Params.OutputActivityRatio[r,:,f,:,y]) != 0 for l ∈ 𝓛 @@ -1080,7 +1080,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end - for l ∈ 𝓛 + for l ∈ 𝓛 JuMP.fix(Vars.ProductionSplitByModalType["MT_FRT_SHIP_RE",l,r,"Mobility_Passenger",y], 0; force=true) JuMP.fix(Vars.ProductionSplitByModalType["MT_FRT_ROAD_RE",l,r,"Mobility_Passenger",y], 0; force=true) JuMP.fix(Vars.ProductionSplitByModalType["MT_FRT_RAIL_RE",l,r,"Mobility_Passenger",y], 0; force=true) @@ -1099,7 +1099,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; print("Cstr: transport: ",Dates.now()-start,"\n") if Switch.switch_ramping == 1 - + ############### Ramping ############# start=Dates.now() for y ∈ 𝓨 for t ∈ 𝓣 for r ∈ 𝓡 @@ -1126,7 +1126,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; ############### Min Runing Constraint ############# if Params.MinActiveProductionPerTimeslice[y,𝓛[i],f,t,r] > 0 @constraint(model, - sum(Vars.RateOfActivity[y,𝓛[i],t,m,r]*Params.OutputActivityRatio[r,t,f,m,y] for m ∈ Maps.Tech_MO[t] if Params.OutputActivityRatio[r,t,f,m,y] != 0) >= + sum(Vars.RateOfActivity[y,𝓛[i],t,m,r]*Params.OutputActivityRatio[r,t,f,m,y] for m ∈ Maps.Tech_MO[t] if Params.OutputActivityRatio[r,t,f,m,y] != 0) >= Vars.TotalCapacityAnnual[y,t,r]*Params.AvailabilityFactor[r,t,y]*Params.CapacityToActivityUnit[t]*Params.MinActiveProductionPerTimeslice[y,𝓛[i],f,t,r], base_name="MRC1_MinRunningConstraint|$(y)|$(𝓛[i])|$(f)|$(t)|$(r)") end @@ -1149,7 +1149,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; JuMP.fix(Vars.AnnualProductionChangeCost[y,t,r], 0; force=true) end end end end - + print("Cstr: Ramping : ",Dates.now()-start,"\n") end @@ -1167,7 +1167,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; print("Cstr: Curtailment : ",Dates.now()-start,"\n") if Switch.switch_base_year_bounds == 1 - + ############### General BaseYear Limits && trajectories ############# start=Dates.now() for y ∈ 𝓨 for t ∈ 𝓣 for r ∈ 𝓡 @@ -1181,7 +1181,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; Vars.ProductionByTechnologyAnnual[y,t,f,r] >= Params.RegionalBaseYearProduction[r,t,f,y]*(1-Settings.BaseYearSlack[f]) - Vars.BaseYearBounds_TooHigh[r,t,f,y], base_name="BYB1_RegionalBaseYearProductionLowerBound|$(y)|$(r)|$(t)|$(f)") end - + if Params.RegionalBaseYearProduction[r,t,f,y] != 0 @constraint(model, Vars.ProductionByTechnologyAnnual[y,t,f,r] <= Params.RegionalBaseYearProduction[r,t,f,y] + Vars.BaseYearBounds_TooLow[r,t,f,y], @@ -1191,7 +1191,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end print("Cstr: Baseyear : ",Dates.now()-start,"\n") end - + ######### Peaking Equations ############# start=Dates.now() if Switch.switch_peaking_capacity == 1 @@ -1229,18 +1229,18 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; base_name="PC3b_PeakingConstraint_Thermal|$(y)|$(r)" ) end - + if Switch.switch_peaking_minrun == 1 for t ∈ 𝓣 - if (Params.Tags.TagTechnologyToSector[t,"Power"]==1 && Params.AvailabilityFactor[r,t,y]<=1 && - Params.Tags.TagDispatchableTechnology[t]==1 && Params.AvailabilityFactor[r,t,y] > 0 && - Params.TotalAnnualMaxCapacity[r,t,y] > 0 && Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] > 0 && + if (Params.Tags.TagTechnologyToSector[t,"Power"]==1 && Params.AvailabilityFactor[r,t,y]<=1 && + Params.Tags.TagDispatchableTechnology[t]==1 && Params.AvailabilityFactor[r,t,y] > 0 && + Params.TotalAnnualMaxCapacity[r,t,y] > 0 && Params.TotalTechnologyModelPeriodActivityUpperLimit[r,t] > 0 && ((((JuMP.has_upper_bound(Vars.TotalCapacityAnnual[y,t,r])) && (JuMP.upper_bound(Vars.TotalCapacityAnnual[y,t,r]) > 0)) || ((!JuMP.has_upper_bound(Vars.TotalCapacityAnnual[y,t,r])) && (!JuMP.is_fixed(Vars.TotalCapacityAnnual[y,t,r]))) || - ((JuMP.is_fixed(Vars.TotalCapacityAnnual[y,t,r])) && (JuMP.fix_value(Vars.TotalCapacityAnnual[y,t,r]) > 0)))) && + ((JuMP.is_fixed(Vars.TotalCapacityAnnual[y,t,r])) && (JuMP.fix_value(Vars.TotalCapacityAnnual[y,t,r]) > 0)))) && y > Switch.set_peaking_startyear) @constraint(model, - sum(sum(Vars.RateOfActivity[y,l,t,m,r] for m ∈ Maps.Tech_MO[t])*Params.YearSplit[l,y] for l ∈ 𝓛 ) >= + sum(sum(Vars.RateOfActivity[y,l,t,m,r] for m ∈ Maps.Tech_MO[t])*Params.YearSplit[l,y] for l ∈ 𝓛 ) >= sum(Vars.TotalCapacityAnnual[y,t,r]*Params.CapacityFactor[r,t,l,y]*Params.YearSplit[l,y]*Params.AvailabilityFactor[r,t,y]*Params.CapacityToActivityUnit[t] for l ∈ 𝓛 )*MinRunShare, base_name="PC4_MinRunConstraint|$(y)|$(t)|$(r)") end @@ -1254,7 +1254,7 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; if Switch.switch_endogenous_employment == 1 ############### Employment effects ############# - + @variable(model, TotalJobs[𝓡, 𝓨]) genesysmod_employment(model,Params,Emp_Sets) @@ -1272,4 +1272,4 @@ function genesysmod_equ(model,Sets,Params, Vars,Emp_Sets,Settings,Switch, Maps; end end end return considered_duals -end \ No newline at end of file +end