Skip to content

Commit

Permalink
Dev danar (#15)
Browse files Browse the repository at this point in the history
* add intersection between CCS and technologies

* remove redundant variables

* remove redundant variables pt 2

---------

Co-authored-by: Dimitri Pinel <[email protected]>
  • Loading branch information
danareu and dqpinel authored Nov 6, 2024
1 parent 6dd6f37 commit 4b750c2
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 226 deletions.
5 changes: 1 addition & 4 deletions src/datastructures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
38 changes: 20 additions & 18 deletions src/genesysmod_bounds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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] #############
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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])
Expand All @@ -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 )
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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
end
32 changes: 16 additions & 16 deletions src/genesysmod_dataload.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 𝓡
Expand Down Expand Up @@ -215,17 +215,17 @@ 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
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

Params.Tags.TagTechnologyToModalType["Infeasibility_Mob_Passenger",1,"MT_PSNG_ROAD"] .= 1
Expand All @@ -245,17 +245,17 @@ 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
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

Params.Tags.TagTechnologyToModalType["Infeasibility_Mob_Passenger",1,"MT_PSNG_ROAD"] .= 1
Expand Down Expand Up @@ -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", 𝓡, 𝓔, 𝓨)
Expand Down Expand Up @@ -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, 𝓢)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(), 𝓔, 𝓨)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
Loading

0 comments on commit 4b750c2

Please sign in to comment.