From ff41e5e3a2492dc7f7f0012c96145c3a3468db32 Mon Sep 17 00:00:00 2001 From: AgnesBelt <31009972+AgnesBelt@users.noreply.github.com> Date: Fri, 15 Jan 2021 16:42:57 +0100 Subject: [PATCH 01/22] updated correct name of Adrian Lefvert --- src/osemosys.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osemosys.txt b/src/osemosys.txt index 88e0b4e..48e3a89 100644 --- a/src/osemosys.txt +++ b/src/osemosys.txt @@ -2,7 +2,7 @@ # # Open Source energy MOdeling SYStem # -# Modified by Francesco Gardumi, Constantinos Taliotis, Igor Tatarewicz, Adrian Levfert +# Modified by Francesco Gardumi, Constantinos Taliotis, Igor Tatarewicz, Adrian Lefvert # Main changes to previous version OSeMOSYS_2016_08_01 # Bug fixed in: # - Equation E1 From 15b194dbbf7ed40d182211269ea4648abe02aa14 Mon Sep 17 00:00:00 2001 From: Roberto David Heredia <55062734+robertodawid@users.noreply.github.com> Date: Tue, 9 Feb 2021 17:54:59 +0100 Subject: [PATCH 02/22] changes in code to solve issue #61 --- src/osemosys.txt | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/osemosys.txt b/src/osemosys.txt index 48e3a89..d034b34 100644 --- a/src/osemosys.txt +++ b/src/osemosys.txt @@ -56,11 +56,18 @@ set STORAGE; param ResultsPath, symbolic default 'results'; param YearSplit{l in TIMESLICE, y in YEAR}; -param DiscountRate{r in REGION, t in TECHNOLOGY}; -param CapitalRecoveryFactor{r in REGION, t in TECHNOLOGY, y in YEAR} := - (1 + DiscountRate[r, t]) ^ (y - min{yy in YEAR} min(yy) + 0.0); -param CapitalRecoveryFactorMid{r in REGION, t in TECHNOLOGY, y in YEAR} := - (1 + DiscountRate[r, t]) ^ (y - min{yy in YEAR} min(yy) + 0.5); +param DiscountRate{r in REGION}; +param DiscountRateIdv{r in REGION, t in TECHNOLOGY}; + +param CapitalRecoveryFactor{r in REGION, y in YEAR} := + (1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.0); +param CapitalRecoveryFactorMid{r in REGION, y in YEAR} := + (1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.5); + +param OperationalLife{r in REGION, t in TECHNOLOGY}; + +param CapitalRecoveryFactorIdv{r in REGION, t in TECHNOLOGY, y in YEAR} := + (DiscountRateIdv[r,t] / (1 - (1 + DiscountRateIdv[r,t])^(-(OperationalLife[r,t])))) * ((1 - (1 + DiscountRateIdv[r,t])^(-(OperationalLife[r,t]))) * (1 + DiscountRateIdv[r,t]) / DiscountRateIdv[r,t]) / ((1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.0)); param DiscountRateStorage{r in REGION, s in STORAGE}; param CapitalRecoveryFactorStorage{r in REGION, s in STORAGE, y in YEAR} := @@ -75,6 +82,8 @@ param Conversionlh{l in TIMESLICE, lh in DAILYTIMEBRACKET} binary; param DaysInDayType{ls in SEASON, ld in DAYTYPE, y in YEAR}; param TradeRoute {r in REGION, rr in REGION, f in FUEL, y in YEAR} binary; param DepreciationMethod{r in REGION}; +param TypeOfDiscountRate{r in REGION}; + # ######## Demands ############# # @@ -87,7 +96,7 @@ param AccumulatedAnnualDemand{r in REGION, f in FUEL, y in YEAR}; param CapacityToActivityUnit{r in REGION, t in TECHNOLOGY}; param CapacityFactor{r in REGION, t in TECHNOLOGY, l in TIMESLICE, y in YEAR}; param AvailabilityFactor{r in REGION, t in TECHNOLOGY, y in YEAR}; -param OperationalLife{r in REGION, t in TECHNOLOGY}; + param ResidualCapacity{r in REGION, t in TECHNOLOGY, y in YEAR}; param InputActivityRatio{r in REGION, t in TECHNOLOGY, f in FUEL, m in MODE_OF_OPERATION, y in YEAR}; param OutputActivityRatio{r in REGION, t in TECHNOLOGY, f in FUEL, m in MODE_OF_OPERATION, y in YEAR}; @@ -562,14 +571,17 @@ s.t. SI10_TotalDiscountedCostByStorage{r in REGION, s in STORAGE, y in YEAR}: Di ######### Capital Costs ############# # s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] = CapitalInvestment[r,t,y]; -s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalInvestment[r,t,y]/(CapitalRecoveryFactor[r,t,y]) = DiscountedCapitalInvestment[r,t,y]; + +s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR: TypeOfDiscountRate[r]=1}: CapitalInvestment[r,t,y]/(CapitalRecoveryFactor[r,y]) = DiscountedCapitalInvestment[r,t,y]; + +s.t. CC3_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR: TypeOfDiscountRate[r]=2}: CapitalInvestment[r,t,y]*(CapitalRecoveryFactorIdv[r,t,y]) = DiscountedCapitalInvestment[r,t,y]; # ######### Salvage Value ############# # -s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR: DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r,t]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(((1+DiscountRate[r,t])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r,t])^OperationalLife[r,t]-1))); -s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR: (DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r,t]=0) || (DepreciationMethod[r]=2 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)))}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]); +s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR: DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(((1+DiscountRate[r])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r])^OperationalLife[r,t]-1))); +s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR: (DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]=0) || (DepreciationMethod[r]=2 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)))}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]); s.t. SV3_SalvageValueAtEndOfPeriod3{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) <= (max{yy in YEAR} max(yy))}: SalvageValue[r,t,y] = 0; -s.t. SV4_SalvageValueDiscountedToStartYear{r in REGION, t in TECHNOLOGY, y in YEAR}: DiscountedSalvageValue[r,t,y] = SalvageValue[r,t,y]/((1+DiscountRate[r,t])^(1+max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy))); +s.t. SV4_SalvageValueDiscountedToStartYear{r in REGION, t in TECHNOLOGY, y in YEAR}: DiscountedSalvageValue[r,t,y] = SalvageValue[r,t,y]/((1+DiscountRate[r])^(1+max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy))); # ######### Operating Costs ############# # @@ -591,7 +603,7 @@ s.t. OC3_OperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}: OperatingCost[r,t,y]; s.t. OC4_DiscountedOperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}: - OperatingCost[r,t,y] / CapitalRecoveryFactorMid[r, t, y] + OperatingCost[r,t,y] / CapitalRecoveryFactorMid[r, y] = DiscountedOperatingCost[r,t,y]; @@ -676,7 +688,7 @@ s.t. E4_EmissionsPenaltyByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: AnnualTechnologyEmissionsPenalty[r,t,y]; s.t. E5_DiscountedEmissionsPenaltyByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: - AnnualTechnologyEmissionsPenalty[r,t,y] / CapitalRecoveryFactorMid[r,t,y] + AnnualTechnologyEmissionsPenalty[r,t,y] / CapitalRecoveryFactorMid[r,y] = DiscountedTechnologyEmissionsPenalty[r,t,y]; @@ -734,7 +746,7 @@ for {r in REGION} { } printf "\n" >> ResultsPath & "/SelectedResults.csv"; printf "Cost" >> ResultsPath & "/SelectedResults.csv"; -for {r in REGION} {printf ",%g", sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/CapitalRecoveryFactorMid[r,t,y]+CapitalCost[r,t,y] * NewCapacity[r,t,y]/(CapitalRecoveryFactor[r,t,y])+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactor[r,t,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactor[r,t,y])) >> ResultsPath & "/SelectedResults.csv"; +for {r in REGION} {printf ",%g", sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/CapitalRecoveryFactorMid[r,y]+CapitalCost[r,t,y] * NewCapacity[r,t,y]/(CapitalRecoveryFactor[r,y])+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactor[r,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactor[r,y])) >> ResultsPath & "/SelectedResults.csv"; } printf "\n" >> ResultsPath & "/SelectedResults.csv"; # From 2b84a4d0b130b6a5ec71973ba2dbfa23e1fc3562 Mon Sep 17 00:00:00 2001 From: Roberto David Heredia Date: Thu, 11 Feb 2021 16:01:38 +0100 Subject: [PATCH 03/22] "This is the first commit" --- my_test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 my_test.txt diff --git a/my_test.txt b/my_test.txt new file mode 100644 index 0000000..e4dcd6e --- /dev/null +++ b/my_test.txt @@ -0,0 +1 @@ +This is test. \ No newline at end of file From 2376f40f97f0dd9b85271a12a99a25ff3e9f9c1a Mon Sep 17 00:00:00 2001 From: Roberto David Heredia Date: Thu, 11 Feb 2021 17:19:43 +0100 Subject: [PATCH 04/22] update osemosys short --- src/osemosys_short.txt | 68 +++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/src/osemosys_short.txt b/src/osemosys_short.txt index 190a4a4..7055019 100644 --- a/src/osemosys_short.txt +++ b/src/osemosys_short.txt @@ -55,14 +55,20 @@ set STORAGE; param ResultsPath, symbolic default 'results'; param YearSplit{l in TIMESLICE, y in YEAR}; -param DiscountRate{r in REGION, t in TECHNOLOGY}; -param CapitalRecoveryFactor{r in REGION, t in TECHNOLOGY, y in YEAR} := - (1 + DiscountRate[r,t])^(y - min{yy in YEAR} min(yy)); -param CapitalRecoveryFactorMid{r in REGION, t in TECHNOLOGY, y in YEAR} := - (1 + DiscountRate[r,t]) ^ (y - min{yy in YEAR} min(yy) + 0.5); +param DiscountRate{r in REGION}; +param DiscountRateIdv{r in REGION, t in TECHNOLOGY}; +param DiscountFactor{r in REGION, y in YEAR} := + (1 + DiscountRate[r])^(y - min{yy in YEAR} min(yy)); +param DiscountFactorMid{r in REGION, y in YEAR} := + (1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.5); +param OperationalLife{r in REGION, t in TECHNOLOGY}; +param DiscountFactorIdv{r in REGION, t in TECHNOLOGY, y in YEAR} := + (DiscountRateIdv[r,t] / (1 - (1 + DiscountRateIdv[r,t])^(-(OperationalLife[r,t])))) * ((1 - (1 + DiscountRateIdv[r,t])^(-(OperationalLife[r,t]))) * (1 + DiscountRateIdv[r,t]) / DiscountRateIdv[r,t]) / ((1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.0)); + + param DiscountRateStorage{r in REGION, s in STORAGE}; -param CapitalRecoveryFactorStorage{r in REGION, s in STORAGE, y in YEAR} := +param DiscountFactorStorage{r in REGION, s in STORAGE, y in YEAR} := (1 + DiscountRateStorage[r,s])^(y - min{yy in YEAR} min(yy)); param DaySplit{lh in DAILYTIMEBRACKET, y in YEAR}; @@ -72,6 +78,7 @@ param Conversionlh{l in TIMESLICE, lh in DAILYTIMEBRACKET} binary; param DaysInDayType{ls in SEASON, ld in DAYTYPE, y in YEAR}; param TradeRoute {r in REGION, rr in REGION, f in FUEL, y in YEAR} binary; param DepreciationMethod{r in REGION}; +param TypeOfDiscountRate{r in REGION}, in 0..1; # ######## Demands ############# # @@ -84,7 +91,7 @@ param AccumulatedAnnualDemand{r in REGION, f in FUEL, y in YEAR}; param CapacityToActivityUnit{r in REGION, t in TECHNOLOGY}; param CapacityFactor{r in REGION, t in TECHNOLOGY, l in TIMESLICE, y in YEAR}; param AvailabilityFactor{r in REGION, t in TECHNOLOGY, y in YEAR}; -param OperationalLife{r in REGION, t in TECHNOLOGY}; + param ResidualCapacity{r in REGION, t in TECHNOLOGY, y in YEAR}; param InputActivityRatio{r in REGION, t in TECHNOLOGY, f in FUEL, m in MODE_OF_OPERATION, y in YEAR}; param OutputActivityRatio{r in REGION, t in TECHNOLOGY, f in FUEL, m in MODE_OF_OPERATION, y in YEAR}; @@ -253,8 +260,8 @@ var UseAnnual{r in REGION, f in FUEL, y in YEAR}>= 0; # ######### Costing Variables ############# # -#var CapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; -####var DiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; +var CapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; +var DiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; # var SalvageValue{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; var DiscountedSalvageValue{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; @@ -303,11 +310,11 @@ minimize cost: sum{r in REGION, t in TECHNOLOGY, y in YEAR} + ResidualCapacity[r,t,y]) * FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y] * YearSplit[l,y] * VariableCost[r,t,m,y]) - / CapitalRecoveryFactorMid[r,t,y] - + CapitalCost[r,t,y] * NewCapacity[r,t,y] / CapitalRecoveryFactor[r,t,y] + / DiscountFactorMid[r,y] + + DiscountedCapitalInvestment[r,t,y] + DiscountedTechnologyEmissionsPenalty[r,t,y] - DiscountedSalvageValue[r,t,y])) + sum{r in REGION, s in STORAGE, y in YEAR} - (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / CapitalRecoveryFactorStorage[r,s,y] + (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / DiscountFactorStorage[r,s,y] - SalvageValueStorage[r,s,y] / ((1+DiscountRateStorage[r,s])^(max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy)+1))); # ##################### @@ -360,7 +367,7 @@ s.t. EBb4_EnergyBalanceEachYear4{r in REGION, f in FUEL, y in YEAR}: sum{m in MO #s.t. Acc1_FuelProductionByTechnology{r in REGION, l in TIMESLICE, t in TECHNOLOGY, f in FUEL, y in YEAR}: sum{m in MODE_OF_OPERATION: OutputActivityRatio[r,t,f,m,y] <>0} RateOfActivity[r,l,t,m,y]*OutputActivityRatio[r,t,f,m,y] * YearSplit[l,y] = ProductionByTechnology[r,l,t,f,y]; #s.t. Acc2_FuelUseByTechnology{r in REGION, l in TIMESLICE, t in TECHNOLOGY, f in FUEL, y in YEAR}: sum{m in MODE_OF_OPERATION: InputActivityRatio[r,t,f,m,y]<>0} RateOfActivity[r,l,t,m,y]*InputActivityRatio[r,t,f,m,y] * YearSplit[l,y] = UseByTechnology[r,l,t,f,y]; #s.t. Acc3_AverageAnnualRateOfActivity{r in REGION, t in TECHNOLOGY, m in MODE_OF_OPERATION, y in YEAR}: sum{l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y] = TotalAnnualTechnologyActivityByMode[r,t,m,y]; -####s.t. Acc4_ModelPeriodCostByRegion{r in REGION}:sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/((CapitalRecoveryFactorMid[r,t,y]))+CapitalCost[r,t,y] * NewCapacity[r,t,y]/((CapitalRecoveryFactor[r,t,y]))+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactorStorage[r,s,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactorStorage[r,s,y])) = ModelPeriodCostByRegion[r]; +####s.t. Acc4_ModelPeriodCostByRegion{r in REGION}:sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/((DiscountFactorMid[r,y]))+CapitalCost[r,t,y] * NewCapacity[r,t,y]/((DiscountFactor[r,y]))+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y])) = ModelPeriodCostByRegion[r]; # ######### Storage Equations ############# # @@ -407,33 +414,34 @@ s.t. SI8_SalvageValueStorageAtEndOfPeriod3{r in REGION, s in STORAGE, y in YEAR: #s.t. SI2_StorageLowerLimit{r in REGION, s in STORAGE, y in YEAR}: MinStorageCharge[r,s,y]*(sum{yy in YEAR: y-yy < OperationalLifeStorage[r,s] && y-yy>=0} NewStorageCapacity[r,s,yy]+ResidualStorageCapacity[r,s,y]) = StorageLowerLimit[r,s,y]; #s.t. SI3_TotalNewStorage{r in REGION, s in STORAGE, y in YEAR}: sum{yy in YEAR: y-yy < OperationalLifeStorage[r,s] && y-yy>=0} NewStorageCapacity[r,s,yy]=AccumulatedNewStorageCapacity[r,s,y]; #s.t. SI4_UndiscountedCapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR}: CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] = CapitalInvestmentStorage[r,s,y]; -#s.t. SI5_DiscountingCapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR}: CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/((CapitalRecoveryFactorStorage[r,s,y])) = DiscountedCapitalInvestmentStorage[r,s,y]; +#s.t. SI5_DiscountingCapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR}: CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/((DiscountFactorStorage[r,s,y])) = DiscountedCapitalInvestmentStorage[r,s,y]; #s.t. SI9_SalvageValueStorageDiscountedToStartYear{r in REGION, s in STORAGE, y in YEAR}: SalvageValueStorage[r,s,y]/((1+DiscountRateStorage[r,s])^(max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy)+1)) = DiscountedSalvageValueStorage[r,s,y]; -#s.t. SI10_TotalDiscountedCostByStorage{r in REGION, s in STORAGE, y in YEAR}: (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/((CapitalRecoveryFactorStorage[r,s,y]))-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/((CapitalRecoveryFactorStorage[r,s,y]))) = TotalDiscountedStorageCost[r,s,y]; +#s.t. SI10_TotalDiscountedCostByStorage{r in REGION, s in STORAGE, y in YEAR}: (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/((DiscountFactorStorage[r,s,y]))-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/((DiscountFactorStorage[r,s,y]))) = TotalDiscountedStorageCost[r,s,y]; # ######### Capital Costs ############# # -#s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] = CapitalInvestment[r,t,y]; -####s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y]/((CapitalRecoveryFactor[r,t,y])) = DiscountedCapitalInvestment[r,t,y]; +s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] = CapitalInvestment[r,t,y]; +s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR: TypeOfDiscountRate[r]=0}: CapitalInvestment[r,t,y]/(DiscountFactor[r,y]) = DiscountedCapitalInvestment[r,t,y]; +s.t. CC3_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR: TypeOfDiscountRate[r]=1}: CapitalInvestment[r,t,y]*(DiscountFactorIdv[r,t,y]) = DiscountedCapitalInvestment[r,t,y]; # ######### Salvage Value ############# # -s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR: DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r,t]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(((1+DiscountRate[r,t])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r,t])^OperationalLife[r,t]-1))); -s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR: DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r,t]=0 || (DepreciationMethod[r]=2 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)))}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]); +s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR: DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(((1+DiscountRate[r])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r])^OperationalLife[r,t]-1))); +s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR: DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]=0 || (DepreciationMethod[r]=2 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)))}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]); s.t. SV3_SalvageValueAtEndOfPeriod3{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) <= (max{yy in YEAR} max(yy))}: SalvageValue[r,t,y] = 0; -s.t. SV4_SalvageValueDiscountedToStartYear{r in REGION, t in TECHNOLOGY, y in YEAR}: DiscountedSalvageValue[r,t,y] = SalvageValue[r,t,y]/((1+DiscountRate[r,t])^(1+max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy))); +s.t. SV4_SalvageValueDiscountedToStartYear{r in REGION, t in TECHNOLOGY, y in YEAR}: DiscountedSalvageValue[r,t,y] = SalvageValue[r,t,y]/((1+DiscountRate[r])^(1+max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy))); # ######### Operating Costs ############# # #s.t. OC1_OperatingCostsVariable{r in REGION, t in TECHNOLOGY, y in YEAR}: sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y] = AnnualVariableOperatingCost[r,t,y]; #s.t. OC2_OperatingCostsFixedAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}: ((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] = AnnualFixedOperatingCost[r,t,y]; #s.t. OC3_OperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}: (((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y]) = OperatingCost[r,t,y]; -####s.t. OC4_DiscountedOperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}: (((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/((CapitalRecoveryFactorMid[r,t,y])) = DiscountedOperatingCost[r,t,y]; +####s.t. OC4_DiscountedOperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}: (((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/((DiscountFactorMid[r,y])) = DiscountedOperatingCost[r,t,y]; # ######### Total Discounted Costs ############# # -#s.t. TDC1_TotalDiscountedCostByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: ((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/((CapitalRecoveryFactorMid[r,t,y]))+CapitalCost[r,t,y] * NewCapacity[r,t,y]/((CapitalRecoveryFactor[r,t,y]))+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) = TotalDiscountedCostByTechnology[r,t,y]; -####s.t. TDC2_TotalDiscountedCost{r in REGION, y in YEAR}: sum{t in TECHNOLOGY}((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/((CapitalRecoveryFactorMid[r,t,y]))+CapitalCost[r,t,y] * NewCapacity[r,t,y]/((CapitalRecoveryFactor[r,t,y]))+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/((CapitalRecoveryFactorStorage[r,s,y]))-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/((CapitalRecoveryFactorStorage[r,s,y]))) = TotalDiscountedCost[r,y]; +#s.t. TDC1_TotalDiscountedCostByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: ((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/((DiscountFactorMid[r,y]))+CapitalCost[r,t,y] * NewCapacity[r,t,y]/((DiscountFactor[r,y]))+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) = TotalDiscountedCostByTechnology[r,t,y]; +####s.t. TDC2_TotalDiscountedCost{r in REGION, y in YEAR}: sum{t in TECHNOLOGY}((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/((DiscountFactorMid[r,y]))+CapitalCost[r,t,y] * NewCapacity[r,t,y]/((DiscountFactor[r,y]))+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/((DiscountFactorStorage[r,s,y]))-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/((DiscountFactorStorage[r,s,y]))) = TotalDiscountedCost[r,y]; # ######### Total Capacity Constraints ############## @@ -487,7 +495,7 @@ s.t. RE4_EnergyConstraint{r in REGION, y in YEAR}:REMinProductionTarget[r,y]*sum # ######### Emissions Accounting ############## # -s.t. E5_DiscountedEmissionsPenaltyByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: sum{e in EMISSION, l in TIMESLICE, m in MODE_OF_OPERATION} EmissionActivityRatio[r,t,e,m,y]*RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*EmissionsPenalty[r,e,y]/CapitalRecoveryFactorMid[r,t,y] = DiscountedTechnologyEmissionsPenalty[r,t,y]; +s.t. E5_DiscountedEmissionsPenaltyByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: sum{e in EMISSION, l in TIMESLICE, m in MODE_OF_OPERATION} EmissionActivityRatio[r,t,e,m,y]*RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*EmissionsPenalty[r,e,y]/DiscountFactorMid[r,y] = DiscountedTechnologyEmissionsPenalty[r,t,y]; s.t. E8_AnnualEmissionsLimit{r in REGION, e in EMISSION, y in YEAR: AnnualEmissionLimit[r,e,y] <> -1}: sum{l in TIMESLICE, t in TECHNOLOGY, m in MODE_OF_OPERATION} EmissionActivityRatio[r,t,e,m,y]*RateOfActivity[r,l,t,m,y]*YearSplit[l,y]+AnnualExogenousEmission[r,e,y] <= AnnualEmissionLimit[r,e,y]; s.t. E9_ModelPeriodEmissionsLimit{r in REGION, e in EMISSION: ModelPeriodEmissionLimit[r,e] <> -1}: sum{l in TIMESLICE, t in TECHNOLOGY, m in MODE_OF_OPERATION, y in YEAR} EmissionActivityRatio[r,t,e,m,y]*RateOfActivity[r,l,t,m,y]*YearSplit[l,y] + ModelPeriodExogenousEmission[r,e] <= ModelPeriodEmissionLimit[r,e] ; #s.t. E1_AnnualEmissionProductionByMode{r in REGION, t in TECHNOLOGY, e in EMISSION, m in MODE_OF_OPERATION, y in YEAR}: EmissionActivityRatio[r,t,e,m,y]*sum{l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]=AnnualTechnologyEmissionByMode[r,t,e,m,y]; @@ -535,7 +543,7 @@ for {r in REGION} { } printf "\n" >> ResultsPath & "/SelectedResults.csv"; printf "Cost" >> ResultsPath & "/SelectedResults.csv"; -for {r in REGION} {printf ",%g", sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/((CapitalRecoveryFactorMid[r,t,y]))+CapitalCost[r,t,y] * NewCapacity[r,t,y]/((CapitalRecoveryFactor[r,t,y]))+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactorStorage[r,s,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactorStorage[r,s,y])) >> ResultsPath & "/SelectedResults.csv"; +for {r in REGION} {printf ",%g", sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/((DiscountFactorMid[r,y]))+CapitalCost[r,t,y] * NewCapacity[r,t,y]/((DiscountFactor[r,y]))+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y])) >> ResultsPath & "/SelectedResults.csv"; } printf "\n" >> ResultsPath & "/SelectedResults.csv"; # @@ -1054,13 +1062,13 @@ table TotalDiscountedCostResults ((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy]) + ResidualCapacity[r,t,y]) * FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} - RateOfActivity[r,l,t,m,y] * YearSplit[l,y] * VariableCost[r,t,m,y]) / CapitalRecoveryFactor[r,t,y] + 0.5 - + CapitalCost[r,t,y] * NewCapacity[r,t,y] / CapitalRecoveryFactor[r,t,y] + RateOfActivity[r,l,t,m,y] * YearSplit[l,y] * VariableCost[r,t,m,y]) / DiscountFactor[r,y] + 0.5 + + CapitalCost[r,t,y] * NewCapacity[r,t,y] / DiscountFactor[r,y] + DiscountedTechnologyEmissionsPenalty[r,t,y] - DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} - (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / CapitalRecoveryFactorStorage[r,s,y] - - CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / CapitalRecoveryFactorStorage[r,s,y] + (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / DiscountFactorStorage[r,s,y] + - CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / DiscountFactorStorage[r,s,y] )~VALUE; table TotalTechnologyAnnualActivity @@ -1105,4 +1113,4 @@ table UseByTechnologyResults sum{m in MODE_OF_OPERATION} RateOfActivity[r,l,t,m,y] * InputActivityRatio[r,t,f,m,y] * YearSplit[l,y]~VALUE; -end; +end; \ No newline at end of file From b233928027934820ef5c707dab0b5ddc9b5948f0 Mon Sep 17 00:00:00 2001 From: Roberto David Heredia Date: Wed, 10 Mar 2021 19:16:17 +0100 Subject: [PATCH 05/22] updates osemosys_short --- src/osemosys_short.txt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/osemosys_short.txt b/src/osemosys_short.txt index 7055019..ea50373 100644 --- a/src/osemosys_short.txt +++ b/src/osemosys_short.txt @@ -62,10 +62,6 @@ param DiscountFactor{r in REGION, y in YEAR} := param DiscountFactorMid{r in REGION, y in YEAR} := (1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.5); param OperationalLife{r in REGION, t in TECHNOLOGY}; -param DiscountFactorIdv{r in REGION, t in TECHNOLOGY, y in YEAR} := - (DiscountRateIdv[r,t] / (1 - (1 + DiscountRateIdv[r,t])^(-(OperationalLife[r,t])))) * ((1 - (1 + DiscountRateIdv[r,t])^(-(OperationalLife[r,t]))) * (1 + DiscountRateIdv[r,t]) / DiscountRateIdv[r,t]) / ((1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.0)); - - param DiscountRateStorage{r in REGION, s in STORAGE}; param DiscountFactorStorage{r in REGION, s in STORAGE, y in YEAR} := @@ -78,7 +74,7 @@ param Conversionlh{l in TIMESLICE, lh in DAILYTIMEBRACKET} binary; param DaysInDayType{ls in SEASON, ld in DAYTYPE, y in YEAR}; param TradeRoute {r in REGION, rr in REGION, f in FUEL, y in YEAR} binary; param DepreciationMethod{r in REGION}; -param TypeOfDiscountRate{r in REGION}, in 0..1; + # ######## Demands ############# # @@ -421,8 +417,8 @@ s.t. SI8_SalvageValueStorageAtEndOfPeriod3{r in REGION, s in STORAGE, y in YEAR: ######### Capital Costs ############# # s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] = CapitalInvestment[r,t,y]; -s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR: TypeOfDiscountRate[r]=0}: CapitalInvestment[r,t,y]/(DiscountFactor[r,y]) = DiscountedCapitalInvestment[r,t,y]; -s.t. CC3_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR: TypeOfDiscountRate[r]=1}: CapitalInvestment[r,t,y]*(DiscountFactorIdv[r,t,y]) = DiscountedCapitalInvestment[r,t,y]; +s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: +CapitalInvestment[r,t,y]*(1 + DiscountRateIdv[r,t])/(DiscountFactor[r,y]) = DiscountedCapitalInvestment[r,t,y]; # ######### Salvage Value ############# # From cb7bf94e1f8d7b9aa56c6bc4c2a9c5016a43a7a0 Mon Sep 17 00:00:00 2001 From: Roberto David Heredia Date: Wed, 10 Mar 2021 21:02:54 +0100 Subject: [PATCH 06/22] updates osemosys --- my_test.txt | 1 - src/osemosys.txt | 192 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 177 insertions(+), 16 deletions(-) delete mode 100644 my_test.txt diff --git a/my_test.txt b/my_test.txt deleted file mode 100644 index e4dcd6e..0000000 --- a/my_test.txt +++ /dev/null @@ -1 +0,0 @@ -This is test. \ No newline at end of file diff --git a/src/osemosys.txt b/src/osemosys.txt index d034b34..6e22520 100644 --- a/src/osemosys.txt +++ b/src/osemosys.txt @@ -23,9 +23,12 @@ # limitations under the License. # ============================================================================ # + + # To run OSeMOSYS, enter the following line into your command prompt: # # glpsol -m osemosys.txt -d datafile.txt -o results.txt + # # ######################################### ###################### Model Definition ############# @@ -59,20 +62,17 @@ param YearSplit{l in TIMESLICE, y in YEAR}; param DiscountRate{r in REGION}; param DiscountRateIdv{r in REGION, t in TECHNOLOGY}; -param CapitalRecoveryFactor{r in REGION, y in YEAR} := +param DiscountFactor{r in REGION, y in YEAR} := (1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.0); -param CapitalRecoveryFactorMid{r in REGION, y in YEAR} := +param DiscountFactorMid{r in REGION, y in YEAR} := (1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.5); param OperationalLife{r in REGION, t in TECHNOLOGY}; -param CapitalRecoveryFactorIdv{r in REGION, t in TECHNOLOGY, y in YEAR} := - (DiscountRateIdv[r,t] / (1 - (1 + DiscountRateIdv[r,t])^(-(OperationalLife[r,t])))) * ((1 - (1 + DiscountRateIdv[r,t])^(-(OperationalLife[r,t]))) * (1 + DiscountRateIdv[r,t]) / DiscountRateIdv[r,t]) / ((1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.0)); - param DiscountRateStorage{r in REGION, s in STORAGE}; -param CapitalRecoveryFactorStorage{r in REGION, s in STORAGE, y in YEAR} := +param DiscountFactorStorage{r in REGION, s in STORAGE, y in YEAR} := (1 + DiscountRateStorage[r, s]) ^ (y - min{yy in YEAR} min(yy) + 0.0); -param CapitalRecoveryFactorMidStorage{r in REGION, s in STORAGE, y in YEAR} := +param DiscountFactorMidStorage{r in REGION, s in STORAGE, y in YEAR} := (1 + DiscountRateStorage[r, s]) ^ (y - min{yy in YEAR} min(yy) + 0.5); param DaySplit{lh in DAILYTIMEBRACKET, y in YEAR}; @@ -82,7 +82,6 @@ param Conversionlh{l in TIMESLICE, lh in DAILYTIMEBRACKET} binary; param DaysInDayType{ls in SEASON, ld in DAYTYPE, y in YEAR}; param TradeRoute {r in REGION, rr in REGION, f in FUEL, y in YEAR} binary; param DepreciationMethod{r in REGION}; -param TypeOfDiscountRate{r in REGION}; # ######## Demands ############# @@ -158,6 +157,7 @@ param AnnualEmissionLimit{r in REGION, e in EMISSION, y in YEAR}; param ModelPeriodExogenousEmission{r in REGION, e in EMISSION}; param ModelPeriodEmissionLimit{r in REGION, e in EMISSION}; # + ############## ## ######################################################################## @@ -224,8 +224,10 @@ var StorageLevelDayTypeStart{r in REGION, s in STORAGE, ls in SEASON, ld in DAYT var StorageLevelDayTypeFinish{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, y in YEAR} >=0; var StorageLowerLimit{r in REGION, s in STORAGE, y in YEAR}>=0; var StorageUpperLimit{r in REGION, s in STORAGE, y in YEAR} >=0; + var AccumulatedNewStorageCapacity{r in REGION, s in STORAGE, y in YEAR} >=0; var NewStorageCapacity{r in REGION, s in STORAGE, y in YEAR} >=0; + var CapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR} >=0; var DiscountedCapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR} >=0; var SalvageValueStorage{r in REGION, s in STORAGE, y in YEAR} >=0; @@ -263,6 +265,23 @@ var TradeAnnual{r in REGION, rr in REGION, f in FUEL, y in YEAR}; # var ProductionAnnual{r in REGION, f in FUEL, y in YEAR}>= 0; var UseAnnual{r in REGION, f in FUEL, y in YEAR}>= 0; + + + + + + + + + + + + + + + + + # ######### Costing Variables ############# # @@ -272,7 +291,12 @@ var DiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; var SalvageValue{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; var DiscountedSalvageValue{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; var OperatingCost{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; + + + var DiscountedOperatingCost{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; + + # var AnnualVariableOperatingCost{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; var AnnualFixedOperatingCost{r in REGION, t in TECHNOLOGY, y in YEAR}>= 0; @@ -283,6 +307,7 @@ var TotalDiscountedCost{r in REGION, y in YEAR}>= 0; var ModelPeriodCostByRegion{r in REGION} >= 0; # ######### Reserve Margin ############# + # var TotalCapacityInReserveMargin{r in REGION, y in YEAR}>= 0; var DemandNeedingReserveMargin{r in REGION,l in TIMESLICE, y in YEAR}>= 0; @@ -301,12 +326,35 @@ var AnnualTechnologyEmissionsPenalty{r in REGION, t in TECHNOLOGY, y in YEAR}>=0 var DiscountedTechnologyEmissionsPenalty{r in REGION, t in TECHNOLOGY, y in YEAR}>=0; var AnnualEmissions{r in REGION, e in EMISSION, y in YEAR}>=0; var ModelPeriodEmissions{r in REGION, e in EMISSION}>=0; -# + + + + + +# + + + ###################### # Objective Function # ###################### # minimize cost: sum{r in REGION, y in YEAR} TotalDiscountedCost[r,y]; + + + + + + + + + + + + + + + # ##################### # Constraints # @@ -561,10 +609,15 @@ s.t. SI1_StorageUpperLimit{r in REGION, s in STORAGE, y in YEAR}: AccumulatedNew s.t. SI2_StorageLowerLimit{r in REGION, s in STORAGE, y in YEAR}: MinStorageCharge[r,s,y]*StorageUpperLimit[r,s,y] = StorageLowerLimit[r,s,y]; s.t. SI3_TotalNewStorage{r in REGION, s in STORAGE, y in YEAR}: sum{yy in YEAR: y-yy < OperationalLifeStorage[r,s] && y-yy>=0} NewStorageCapacity[r,s,yy]=AccumulatedNewStorageCapacity[r,s,y]; s.t. SI4_UndiscountedCapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR}: CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] = CapitalInvestmentStorage[r,s,y]; -s.t. SI5_DiscountingCapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR}: CapitalInvestmentStorage[r,s,y]/(CapitalRecoveryFactorStorage[r,s,y]) = DiscountedCapitalInvestmentStorage[r,s,y]; +s.t. SI5_DiscountingCapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR}: CapitalInvestmentStorage[r,s,y]/(DiscountFactorStorage[r,s,y]) = DiscountedCapitalInvestmentStorage[r,s,y]; s.t. SI6_SalvageValueStorageAtEndOfPeriod1{r in REGION, s in STORAGE, y in YEAR: (y+OperationalLifeStorage[r,s]-1) <= (max{yy in YEAR} max(yy))}: 0 = SalvageValueStorage[r,s,y]; s.t. SI7_SalvageValueStorageAtEndOfPeriod2{r in REGION, s in STORAGE, y in YEAR: (DepreciationMethod[r]=1 && (y+OperationalLifeStorage[r,s]-1) > (max{yy in YEAR} max(yy)) && DiscountRateStorage[r,s]=0) || (DepreciationMethod[r]=2 && (y+OperationalLifeStorage[r,s]-1) > (max{yy in YEAR} max(yy)))}: CapitalInvestmentStorage[r,s,y]*(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLifeStorage[r,s]) = SalvageValueStorage[r,s,y]; s.t. SI8_SalvageValueStorageAtEndOfPeriod3{r in REGION, s in STORAGE, y in YEAR: DepreciationMethod[r]=1 && (y+OperationalLifeStorage[r,s]-1) > (max{yy in YEAR} max(yy)) && DiscountRateStorage[r,s]>0}: CapitalInvestmentStorage[r,s,y]*(1-(((1+DiscountRateStorage[r,s])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRateStorage[r,s])^OperationalLifeStorage[r,s]-1))) = SalvageValueStorage[r,s,y]; + + + + + s.t. SI9_SalvageValueStorageDiscountedToStartYear{r in REGION, s in STORAGE, y in YEAR}: SalvageValueStorage[r,s,y]/((1+DiscountRateStorage[r,s])^(max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy)+1)) = DiscountedSalvageValueStorage[r,s,y]; s.t. SI10_TotalDiscountedCostByStorage{r in REGION, s in STORAGE, y in YEAR}: DiscountedCapitalInvestmentStorage[r,s,y]-DiscountedSalvageValueStorage[r,s,y] = TotalDiscountedStorageCost[r,s,y]; # @@ -572,9 +625,9 @@ s.t. SI10_TotalDiscountedCostByStorage{r in REGION, s in STORAGE, y in YEAR}: Di # s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] = CapitalInvestment[r,t,y]; -s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR: TypeOfDiscountRate[r]=1}: CapitalInvestment[r,t,y]/(CapitalRecoveryFactor[r,y]) = DiscountedCapitalInvestment[r,t,y]; +s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalInvestment[r,t,y]*(1 + DiscountRateIdv[r,t])/(DiscountFactor[r,y]) = DiscountedCapitalInvestment[r,t,y]; + -s.t. CC3_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR: TypeOfDiscountRate[r]=2}: CapitalInvestment[r,t,y]*(CapitalRecoveryFactorIdv[r,t,y]) = DiscountedCapitalInvestment[r,t,y]; # ######### Salvage Value ############# # @@ -603,7 +656,7 @@ s.t. OC3_OperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}: OperatingCost[r,t,y]; s.t. OC4_DiscountedOperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}: - OperatingCost[r,t,y] / CapitalRecoveryFactorMid[r, y] + OperatingCost[r,t,y] / DiscountFactorMid[r, y] = DiscountedOperatingCost[r,t,y]; @@ -612,30 +665,52 @@ s.t. OC4_DiscountedOperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in # s.t. TDC1_TotalDiscountedCostByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: DiscountedOperatingCost[r,t,y]+DiscountedCapitalInvestment[r,t,y]+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y] = TotalDiscountedCostByTechnology[r,t,y]; s.t. TDC2_TotalDiscountedCost{r in REGION, y in YEAR}: sum{t in TECHNOLOGY} TotalDiscountedCostByTechnology[r,t,y]+sum{s in STORAGE} TotalDiscountedStorageCost[r,s,y] = TotalDiscountedCost[r,y]; + # ######### Total Capacity Constraints ############## # s.t. TCC1_TotalAnnualMaxCapacityConstraint{r in REGION, t in TECHNOLOGY, y in YEAR: TotalAnnualMaxCapacity[r,t,y] <> -1}: TotalCapacityAnnual[r,t,y] <= TotalAnnualMaxCapacity[r,t,y]; + + + + s.t. TCC2_TotalAnnualMinCapacityConstraint{r in REGION, t in TECHNOLOGY, y in YEAR: TotalAnnualMinCapacity[r,t,y]>0}: TotalCapacityAnnual[r,t,y] >= TotalAnnualMinCapacity[r,t,y]; # ######### New Capacity Constraints ############## # s.t. NCC1_TotalAnnualMaxNewCapacityConstraint{r in REGION, t in TECHNOLOGY, y in YEAR: TotalAnnualMaxCapacityInvestment[r,t,y] <> -1}: NewCapacity[r,t,y] <= TotalAnnualMaxCapacityInvestment[r,t,y]; + + + s.t. NCC2_TotalAnnualMinNewCapacityConstraint{r in REGION, t in TECHNOLOGY, y in YEAR: TotalAnnualMinCapacityInvestment[r,t,y]>0}: NewCapacity[r,t,y] >= TotalAnnualMinCapacityInvestment[r,t,y]; # ######### Annual Activity Constraints ############## + + + + + + + + + + # s.t. AAC1_TotalAnnualTechnologyActivity{r in REGION, t in TECHNOLOGY, y in YEAR}: sum{l in TIMESLICE} RateOfTotalActivity[r,t,l,y]*YearSplit[l,y] = TotalTechnologyAnnualActivity[r,t,y]; s.t. AAC2_TotalAnnualTechnologyActivityUpperLimit{r in REGION, t in TECHNOLOGY, y in YEAR: TotalTechnologyAnnualActivityUpperLimit[r,t,y] <> -1}: TotalTechnologyAnnualActivity[r,t,y] <= TotalTechnologyAnnualActivityUpperLimit[r,t,y] ; s.t. AAC3_TotalAnnualTechnologyActivityLowerLimit{r in REGION, t in TECHNOLOGY, y in YEAR: TotalTechnologyAnnualActivityLowerLimit[r,t,y]>0}: TotalTechnologyAnnualActivity[r,t,y] >= TotalTechnologyAnnualActivityLowerLimit[r,t,y] ; # ######### Total Activity Constraints ############## + + # s.t. TAC1_TotalModelHorizonTechnologyActivity{r in REGION, t in TECHNOLOGY}: sum{y in YEAR} TotalTechnologyAnnualActivity[r,t,y] = TotalTechnologyModelPeriodActivity[r,t]; s.t. TAC2_TotalModelHorizonTechnologyActivityUpperLimit{r in REGION, t in TECHNOLOGY: TotalTechnologyModelPeriodActivityUpperLimit[r,t]<>-1}: TotalTechnologyModelPeriodActivity[r,t] <= TotalTechnologyModelPeriodActivityUpperLimit[r,t] ; s.t. TAC3_TotalModelHorizenTechnologyActivityLowerLimit{r in REGION, t in TECHNOLOGY: TotalTechnologyModelPeriodActivityLowerLimit[r,t]>0}: TotalTechnologyModelPeriodActivity[r,t] >= TotalTechnologyModelPeriodActivityLowerLimit[r,t] ; # ######### Reserve Margin Constraint ############## NTS: Should change demand for production + + # s.t. RM1_ReserveMargin_TechnologiesIncluded_In_Activity_Units{r in REGION, l in TIMESLICE, y in YEAR: ReserveMargin[r,y] > 0}: sum {t in TECHNOLOGY} @@ -656,6 +731,10 @@ s.t. RM3_ReserveMargin_Constraint{r in REGION, l in TIMESLICE, y in YEAR: Reserv # ######### RE Production Target ############## NTS: Should change demand for production + + + + # s.t. RE1_FuelProductionByTechnologyAnnual{r in REGION, t in TECHNOLOGY, f in FUEL, y in YEAR}: sum{l in TIMESLICE} ProductionByTechnology[r,l,t,f,y] = ProductionByTechnologyAnnual[r,t,f,y]; s.t. RE2_TechIncluded{r in REGION, y in YEAR}: sum{t in TECHNOLOGY, f in FUEL} ProductionByTechnologyAnnual[r,t,f,y]*RETagTechnology[r,t,y] = TotalREProductionAnnual[r,y]; @@ -664,6 +743,18 @@ s.t. RE4_EnergyConstraint{r in REGION, y in YEAR}:REMinProductionTarget[r,y]*RET s.t. RE5_FuelUseByTechnologyAnnual{r in REGION, t in TECHNOLOGY, f in FUEL, y in YEAR}: sum{l in TIMESLICE} RateOfUseByTechnology[r,l,t,f,y]*YearSplit[l,y] = UseByTechnologyAnnual[r,t,f,y]; # ######### Emissions Accounting ############## + + + + + + + + + + + + # s.t. E1_AnnualEmissionProductionByMode{r in REGION, t in TECHNOLOGY, e in EMISSION, m in MODE_OF_OPERATION, y in YEAR: EmissionActivityRatio[r,t,e,m,y] <> 0}: @@ -688,7 +779,7 @@ s.t. E4_EmissionsPenaltyByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: AnnualTechnologyEmissionsPenalty[r,t,y]; s.t. E5_DiscountedEmissionsPenaltyByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: - AnnualTechnologyEmissionsPenalty[r,t,y] / CapitalRecoveryFactorMid[r,y] + AnnualTechnologyEmissionsPenalty[r,t,y] / DiscountFactorMid[r,y] = DiscountedTechnologyEmissionsPenalty[r,t,y]; @@ -715,6 +806,7 @@ s.t. E9_ModelPeriodEmissionsLimit{r in REGION, e in EMISSION: ModelPeriodEmissio # ########################################################################################### # + # Solve the problem solve; # @@ -726,6 +818,7 @@ solve; # # ######################################################################################################### # + #### Summary results ### # ### Total costs and emissions by region ### @@ -746,7 +839,7 @@ for {r in REGION} { } printf "\n" >> ResultsPath & "/SelectedResults.csv"; printf "Cost" >> ResultsPath & "/SelectedResults.csv"; -for {r in REGION} {printf ",%g", sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/CapitalRecoveryFactorMid[r,y]+CapitalCost[r,t,y] * NewCapacity[r,t,y]/(CapitalRecoveryFactor[r,y])+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactor[r,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactor[r,y])) >> ResultsPath & "/SelectedResults.csv"; +for {r in REGION} {printf ",%g", sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/DiscountFactorMid[r,y]+CapitalCost[r,t,y] * NewCapacity[r,t,y]/(DiscountFactor[r,y])+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactor[r,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactor[r,y])) >> ResultsPath & "/SelectedResults.csv"; } printf "\n" >> ResultsPath & "/SelectedResults.csv"; # @@ -1038,30 +1131,45 @@ for {r in REGION} {printf ",%s", r >> ResultsPath & "/SelectedResults.csv"; table AccumulatedNewCapacityResults {r in REGION, t in TECHNOLOGY, y in YEAR: AccumulatedNewCapacity[r, t, y] > 0} + OUT "CSV" ResultsPath & "/AccumulatedNewCapacity.csv" : r~REGION, t~TECHNOLOGY, y~YEAR, AccumulatedNewCapacity[r, t, y]~VALUE; + + table AnnualEmissionsResults {r in REGION, e in EMISSION, y in YEAR: AnnualEmissions[r, e, y] > 0} + OUT "CSV" ResultsPath & "/AnnualEmissions.csv" : r~REGION, e~EMISSION, y~YEAR, AnnualEmissions[r, e, y]~VALUE; + + table AnnualFixedOperatingCostResults {r in REGION, t in TECHNOLOGY, y in YEAR: AnnualFixedOperatingCost[r, t, y] > 0} + + + OUT "CSV" ResultsPath & "/AnnualFixedOperatingCost.csv" : r~REGION, t~TECHNOLOGY, y~YEAR, AnnualFixedOperatingCost[r, t, y]~VALUE; + + + table AnnualTechnologyEmissionResults {r in REGION, t in TECHNOLOGY, e in EMISSION, y in YEAR: AnnualTechnologyEmission[r, t, e, y] > 0} + OUT "CSV" ResultsPath & "/AnnualTechnologyEmission.csv" : r~REGION, t~TECHNOLOGY, e~EMISSION, y~YEAR, AnnualTechnologyEmission[r, t, e, y]~VALUE; + + table AnnualTechnologyEmissionByModeResults {r in REGION, t in TECHNOLOGY, e in EMISSION, m in MODE_OF_OPERATION, y in YEAR: @@ -1069,13 +1177,18 @@ table AnnualTechnologyEmissionByModeResults OUT "CSV" ResultsPath & "/AnnualTechnologyEmissionByMode.csv" : r~REGION, t~TECHNOLOGY, e~EMISSION, m~MODE_OF_OPERATION, y~YEAR, AnnualTechnologyEmissionByMode[r, t, e, m, y]~VALUE; + + table AnnualVariableOperatingCostResults {r in REGION, t in TECHNOLOGY, y in YEAR: AnnualVariableOperatingCost[r, t, y] > 0} + OUT "CSV" ResultsPath & "/AnnualVariableOperatingCost.csv" : r~REGION, t~TECHNOLOGY, y~YEAR, AnnualVariableOperatingCost[r, t, y]~VALUE; + + table CapitalInvestmentResults {r in REGION, t in TECHNOLOGY, y in YEAR: @@ -1136,18 +1249,22 @@ table NumberOfNewTechnologyUnitsResults table ProductionByTechnologyResults {r in REGION, l in TIMESLICE, t in TECHNOLOGY, f in FUEL, y in YEAR: ProductionByTechnology[r, l, t, f, y] > 0} + OUT "CSV" ResultsPath & "/ProductionByTechnology.csv" : r~REGION, l~TIMESLICE, t~TECHNOLOGY, f~FUEL, y~YEAR, ProductionByTechnology[r, l, t, f, y]~VALUE; + table ProductionByTechnologyAnnualResults {r in REGION, t in TECHNOLOGY, f in FUEL, y in YEAR: ProductionByTechnologyAnnual[r, t, f, y] > 0} + OUT "CSV" ResultsPath & "/ProductionByTechnologyAnnual.csv" : r~REGION, t~TECHNOLOGY, f~FUEL, y~YEAR, ProductionByTechnologyAnnual[r, t, f, y]~VALUE; + table RateOfActivityResults {r in REGION, l in TIMESLICE, t in TECHNOLOGY, m in MODE_OF_OPERATION, y in YEAR: @@ -1155,14 +1272,17 @@ table RateOfActivityResults OUT "CSV" ResultsPath & "/RateOfActivity.csv" : r~REGION, l~TIMESLICE, t~TECHNOLOGY, m~MODE_OF_OPERATION, y~YEAR, RateOfActivity[r, l, t, m, y]~VALUE; + table RateOfProductionByTechnologyResults {r in REGION, l in TIMESLICE, t in TECHNOLOGY, f in FUEL, y in YEAR: RateOfProductionByTechnology[r, l, t, f, y] > 0} + OUT "CSV" ResultsPath & "/RateOfProductionByTechnology.csv" : r~REGION, l~TIMESLICE, t~TECHNOLOGY, f~FUEL, y~YEAR, RateOfProductionByTechnology[r, l, t, f, y]~VALUE; + table RateOfProductionByTechnologyByModeResults {r in REGION, l in TIMESLICE, t in TECHNOLOGY, m in MODE_OF_OPERATION, f in FUEL, y in YEAR: @@ -1175,9 +1295,11 @@ table RateOfProductionByTechnologyByModeResults table RateOfUseByTechnologyResults {r in REGION, l in TIMESLICE, t in TECHNOLOGY, f in FUEL, y in YEAR: RateOfUseByTechnology[r, l, t, f, y] > 0} + OUT "CSV" ResultsPath & "/RateOfUseByTechnology.csv" : r~REGION, l~TIMESLICE, t~TECHNOLOGY, f~FUEL, y~YEAR, + RateOfUseByTechnology[r, l, t, f, y]~VALUE; table RateOfUseByTechnologyByModeResults @@ -1194,6 +1316,7 @@ table SalvageValueResults OUT "CSV" ResultsPath & "/SalvageValue.csv" : r~REGION, t~TECHNOLOGY, y~YEAR, SalvageValue[r, t, y]~VALUE; + table SalvageValueStorageResults {r in REGION, s in STORAGE, y in YEAR: @@ -1201,14 +1324,30 @@ table SalvageValueStorageResults OUT "CSV" ResultsPath & "/SalvageValueStorage.csv" : r~REGION, s~STORAGE, y~YEAR, SalvageValueStorage[r, s, y]~VALUE; + + + + + + + + + + + table TotalAnnualTechnologyActivityByModeResults {r in REGION, t in TECHNOLOGY, m in MODE_OF_OPERATION, y in YEAR: TotalAnnualTechnologyActivityByMode[r, t, m, y] > 0} + + + OUT "CSV" ResultsPath & "/TotalAnnualTechnologyActivityByMode.csv" : r~REGION, t~TECHNOLOGY, m~MODE_OF_OPERATION, y~YEAR, TotalAnnualTechnologyActivityByMode[r, t, m, y]~VALUE; + + table TotalCapacityAnnualResults {r in REGION, t in TECHNOLOGY, y in YEAR: @@ -1224,35 +1363,58 @@ table TotalDiscountedCostResults ResultsPath & "/TotalDiscountedCost.csv" : r~REGION, y~YEAR, TotalDiscountedCost[r, y]~VALUE; + + + + + + + + + + + table TotalTechnologyAnnualActivityResults {r in REGION, t in TECHNOLOGY, y in YEAR: TotalTechnologyAnnualActivity[r, t, y] > 0} + + OUT "CSV" ResultsPath & "/TotalTechnologyAnnualActivity.csv" : r~REGION, t~TECHNOLOGY, y~YEAR, TotalTechnologyAnnualActivity[r, t, y]~VALUE; + table TotalTechnologyModelPeriodActivityResults {r in REGION, t in TECHNOLOGY: TotalTechnologyModelPeriodActivity[r, t] > 0} + + OUT "CSV" ResultsPath & "/TotalTechnologyModelPeriodActivity.csv" : r~REGION, t~TECHNOLOGY, TotalTechnologyModelPeriodActivity[r, t]~VALUE; + table TradeResults {r in REGION, rr in REGION, l in TIMESLICE, f in FUEL, y in YEAR: Trade[r, rr, l, f, y] <> 0} + OUT "CSV" ResultsPath & "/Trade.csv" : r~REGION, rr~REGION, l~TIMESLICE, f~FUEL, y~YEAR, Trade[r, rr, l, f, y]~VALUE; + table UseByTechnologyResults {r in REGION, l in TIMESLICE, t in TECHNOLOGY, f in FUEL, y in YEAR: + UseByTechnology[r, l, t, f, y] > 0} + OUT "CSV" ResultsPath & "/UseByTechnology.csv" : r~REGION, l~TIMESLICE, t~TECHNOLOGY, f~FUEL, y~YEAR, UseByTechnology[r, l, t, f, y]~VALUE; + + end; From a24720c012fc9413455b7cf0492301026b569179 Mon Sep 17 00:00:00 2001 From: Roberto David Heredia Date: Thu, 11 Mar 2021 22:50:26 +0100 Subject: [PATCH 07/22] update --- src/osemosys.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/osemosys.txt b/src/osemosys.txt index 6e22520..3d8b31e 100644 --- a/src/osemosys.txt +++ b/src/osemosys.txt @@ -69,6 +69,9 @@ param DiscountFactorMid{r in REGION, y in YEAR} := param OperationalLife{r in REGION, t in TECHNOLOGY}; +param AnnuityFactor{r in REGION, t in TECHNOLOGY} := + (1 + DiscountRateIdv[r,t]); + param DiscountRateStorage{r in REGION, s in STORAGE}; param DiscountFactorStorage{r in REGION, s in STORAGE, y in YEAR} := (1 + DiscountRateStorage[r, s]) ^ (y - min{yy in YEAR} min(yy) + 0.0); @@ -625,7 +628,7 @@ s.t. SI10_TotalDiscountedCostByStorage{r in REGION, s in STORAGE, y in YEAR}: Di # s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] = CapitalInvestment[r,t,y]; -s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalInvestment[r,t,y]*(1 + DiscountRateIdv[r,t])/(DiscountFactor[r,y]) = DiscountedCapitalInvestment[r,t,y]; +s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalInvestment[r,t,y]*AnnuityFactor[r,t] / (DiscountFactor[r,y]) = DiscountedCapitalInvestment[r,t,y]; # From 5c9ccbb2bde7724857aeaecdaffb6186a7135e6d Mon Sep 17 00:00:00 2001 From: Roberto David Heredia Date: Fri, 12 Mar 2021 17:37:39 +0100 Subject: [PATCH 08/22] update of the CRF and annuity --- src/osemosys.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/osemosys.txt b/src/osemosys.txt index 3d8b31e..9caf9fb 100644 --- a/src/osemosys.txt +++ b/src/osemosys.txt @@ -60,7 +60,7 @@ param ResultsPath, symbolic default 'results'; param YearSplit{l in TIMESLICE, y in YEAR}; param DiscountRate{r in REGION}; -param DiscountRateIdv{r in REGION, t in TECHNOLOGY}; +param DiscountRateIdv{r in REGION, t in TECHNOLOGY} default DiscountRate{r in REGION}; param DiscountFactor{r in REGION, y in YEAR} := (1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.0); @@ -69,8 +69,10 @@ param DiscountFactorMid{r in REGION, y in YEAR} := param OperationalLife{r in REGION, t in TECHNOLOGY}; -param AnnuityFactor{r in REGION, t in TECHNOLOGY} := - (1 + DiscountRateIdv[r,t]); +param CapitalRecoveryFactor{r in REGION, t in TECHNOLOGY} := + (1 - (1 + DiscountRateIdv[r,t])^(-1))/(1 - (1 + DiscountRateIdv[r,t])^(-(OperationalLife[r,t]))); +param PvAnnuity{r in REGION, t in TECHNOLOGY} := + (1 - (1 + DiscountRate[r])^(-(OperationalLife[r,t]))) * (1 + DiscountRate[r]) / DiscountRate[r]; param DiscountRateStorage{r in REGION, s in STORAGE}; param DiscountFactorStorage{r in REGION, s in STORAGE, y in YEAR} := @@ -628,7 +630,7 @@ s.t. SI10_TotalDiscountedCostByStorage{r in REGION, s in STORAGE, y in YEAR}: Di # s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] = CapitalInvestment[r,t,y]; -s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalInvestment[r,t,y]*AnnuityFactor[r,t] / (DiscountFactor[r,y]) = DiscountedCapitalInvestment[r,t,y]; +s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalInvestment[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] / DiscountFactor[r,y] = DiscountedCapitalInvestment[r,t,y]; # From 3668769e7a31930b5ae9976bc186def43532b071 Mon Sep 17 00:00:00 2001 From: Roberto David Heredia Date: Mon, 15 Mar 2021 16:44:54 +0100 Subject: [PATCH 09/22] update in line 63 --- src/osemosys.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osemosys.txt b/src/osemosys.txt index 9caf9fb..2e91257 100644 --- a/src/osemosys.txt +++ b/src/osemosys.txt @@ -60,7 +60,7 @@ param ResultsPath, symbolic default 'results'; param YearSplit{l in TIMESLICE, y in YEAR}; param DiscountRate{r in REGION}; -param DiscountRateIdv{r in REGION, t in TECHNOLOGY} default DiscountRate{r in REGION}; +param DiscountRateIdv{r in REGION, t in TECHNOLOGY}; param DiscountFactor{r in REGION, y in YEAR} := (1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.0); From 48c9545c7ef45d54043b6be750f3d30767ae1d55 Mon Sep 17 00:00:00 2001 From: Roberto David Heredia Date: Tue, 16 Mar 2021 21:46:17 +0100 Subject: [PATCH 10/22] updated in three versions --- src/osemosys.txt | 2 +- src/osemosys_fast.txt | 68 +++++++++++++++++++++++------------------- src/osemosys_short.txt | 10 +++++-- 3 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/osemosys.txt b/src/osemosys.txt index 2e91257..2a6b803 100644 --- a/src/osemosys.txt +++ b/src/osemosys.txt @@ -60,7 +60,7 @@ param ResultsPath, symbolic default 'results'; param YearSplit{l in TIMESLICE, y in YEAR}; param DiscountRate{r in REGION}; -param DiscountRateIdv{r in REGION, t in TECHNOLOGY}; +param DiscountRateIdv{r in REGION, t in TECHNOLOGY}, default DiscountRate[r]; param DiscountFactor{r in REGION, y in YEAR} := (1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.0); diff --git a/src/osemosys_fast.txt b/src/osemosys_fast.txt index 894906d..d204999 100644 --- a/src/osemosys_fast.txt +++ b/src/osemosys_fast.txt @@ -56,15 +56,23 @@ set STORAGE; # param ResultsPath, symbolic default 'results'; param YearSplit{l in TIMESLICE, y in YEAR}; -param DiscountRate{r in REGION, t in TECHNOLOGY}; +param DiscountRate{r in REGION}; +param DiscountRateIdv{r in REGION, t in TECHNOLOGY}, default DiscountRate[r]; -param CapitalRecoveryFactor{r in REGION, t in TECHNOLOGY, y in YEAR} := - (1 + DiscountRate[r,t]) ^ (y - min{yy in YEAR} min(yy) + 0.0); -param CapitalRecoveryFactorMid{r in REGION, t in TECHNOLOGY, y in YEAR} := - (1 + DiscountRate[r,t]) ^ (y - min{yy in YEAR} min(yy) + 0.5); +param DiscountFactor{r in REGION, y in YEAR} := + (1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.0); +param DiscountFactorMid{r in REGION, y in YEAR} := + (1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.5); + +param OperationalLife{r in REGION, t in TECHNOLOGY}; + +param CapitalRecoveryFactor{r in REGION, t in TECHNOLOGY} := + (1 - (1 + DiscountRateIdv[r,t])^(-1))/(1 - (1 + DiscountRateIdv[r,t])^(-(OperationalLife[r,t]))); +param PvAnnuity{r in REGION, t in TECHNOLOGY} := + (1 - (1 + DiscountRate[r])^(-(OperationalLife[r,t]))) * (1 + DiscountRate[r]) / DiscountRate[r]; param DiscountRateStorage{r in REGION, s in STORAGE}; -param CapitalRecoveryFactorStorage{r in REGION, s in STORAGE, y in YEAR} := +param DiscountFactorStorage{r in REGION, s in STORAGE, y in YEAR} := (1 + DiscountRateStorage[r,s]) ^ (y - min{yy in YEAR} min(yy) + 0.0); @@ -88,7 +96,7 @@ param CapacityToActivityUnit{r in REGION, t in TECHNOLOGY}; param TechWithCapacityNeededToMeetPeakTS{r in REGION, t in TECHNOLOGY}; param CapacityFactor{r in REGION, t in TECHNOLOGY, l in TIMESLICE, y in YEAR}; param AvailabilityFactor{r in REGION, t in TECHNOLOGY, y in YEAR}; -param OperationalLife{r in REGION, t in TECHNOLOGY}; + param ResidualCapacity{r in REGION, t in TECHNOLOGY, y in YEAR}; param InputActivityRatio{r in REGION, t in TECHNOLOGY, f in FUEL, m in MODE_OF_OPERATION, y in YEAR}; param OutputActivityRatio{r in REGION, t in TECHNOLOGY, f in FUEL, m in MODE_OF_OPERATION, y in YEAR}; @@ -329,11 +337,11 @@ minimize cost: sum{r in REGION, t in TECHNOLOGY, y in YEAR} (((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} - RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y]) / CapitalRecoveryFactorMid[r,t,y] + - CapitalCost[r,t,y] * NewCapacity[r,t,y] / CapitalRecoveryFactor[r,t,y] + + RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y]) / DiscountFactorMid[r,y] + + CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] / DiscountFactor[r,y] + DiscountedTechnologyEmissionsPenalty[r,t,y] - DiscountedSalvageValue[r,t,y]) + - sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / CapitalRecoveryFactor[r,t,y] - - CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / CapitalRecoveryFactor[r,t,y])); + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / DiscountFactor[r,y] - + CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / DiscountFactor[r,y])); # ##################### @@ -386,7 +394,7 @@ s.t. EBb4_EnergyBalanceEachYear4{r in REGION, f in FUEL, y in YEAR}: sum{(m,t) i #s.t. Acc1_FuelProductionByTechnology{r in REGION, l in TIMESLICE, t in TECHNOLOGY, f in FUEL, y in YEAR}: sum{m in MODEperTECHNOLOGY[t]} RateOfActivity[r,l,t,m,y]*OutputActivityRatio[r,t,f,m,y] * YearSplit[l,y] = ProductionByTechnology[r,l,t,f,y]; #s.t. Acc2_FuelUseByTechnology{r in REGION, l in TIMESLICE, t in TECHNOLOGY, f in FUEL, y in YEAR}: sum{m in MODEperTECHNOLOGY[t]} RateOfActivity[r,l,t,m,y]*InputActivityRatio[r,t,f,m,y] * YearSplit[l,y] = UseByTechnology[r,l,t,f,y]; #s.t. Acc3_AverageAnnualRateOfActivity{r in REGION, t in TECHNOLOGY, m in MODEperTECHNOLOGY[t], y in YEAR}: sum{l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y] = TotalAnnualTechnologyActivityByMode[r,t,m,y]; -#s.t. Acc4_ModelPeriodCostByRegion{r in REGION}:sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/CapitalRecoveryFactorMid[r,t,y]+CapitalCost[r,t,y] * NewCapacity[r,t,y]/CapitalRecoveryFactor[r,t,y]+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactorStorage[r,s,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactorStorage[r,s,y])) = ModelPeriodCostByRegion[r]; +#s.t. Acc4_ModelPeriodCostByRegion{r in REGION}:sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/DiscountFactorMid[r,y]+CapitalCost[r,t,y] * NewCapacity[r,t,y]/DiscountFactor[r,y]+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y])) = ModelPeriodCostByRegion[r]; # ######### Storage Equations ############# @@ -447,34 +455,34 @@ s.t. SI6_SalvageValueStorageAtEndOfPeriod1{r in REGION, s in STORAGE, y in YEAR: #s.t. SI2_StorageLowerLimit{r in REGION, s in STORAGE, y in YEAR}: MinStorageCharge[r,s,y]*(sum{yy in YEAR: y-yy < OperationalLifeStorage[r,s] && y-yy>=0} NewStorageCapacity[r,s,yy]+ResidualStorageCapacity[r,s,y]) = StorageLowerLimit[r,s,y]; #s.t. SI3_TotalNewStorage{r in REGION, s in STORAGE, y in YEAR}: sum{yy in YEAR: y-yy < OperationalLifeStorage[r,s] && y-yy>=0} NewStorageCapacity[r,s,yy]=AccumulatedNewStorageCapacity[r,s,y]; #s.t. SI4_UndiscountedCapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR}: CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] = CapitalInvestmentStorage[r,s,y]; -#s.t. SI5_DiscountingCapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR}: CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactorStorage[r,s,y] = DiscountedCapitalInvestmentStorage[r,s,y]; +#s.t. SI5_DiscountingCapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR}: CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y] = DiscountedCapitalInvestmentStorage[r,s,y]; #s.t. SI9_SalvageValueStorageDiscountedToStartYear{r in REGION, s in STORAGE, y in YEAR}: SalvageValueStorage[r,s,y]/((1+DiscountRate[r])^(max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy)+1)) = DiscountedSalvageValueStorage[r,s,y]; -#s.t. SI10_TotalDiscountedCostByStorage{r in REGION, s in STORAGE, y in YEAR}: (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactorStorage[r,s,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactorStorage[r,s,y]) = TotalDiscountedStorageCost[r,s,y]; +#s.t. SI10_TotalDiscountedCostByStorage{r in REGION, s in STORAGE, y in YEAR}: (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y]) = TotalDiscountedStorageCost[r,s,y]; # ######### Capital Costs ############# # #s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] = CapitalInvestment[r,t,y]; -####s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y]/CapitalRecoveryFactor[r,t,y] = DiscountedCapitalInvestment[r,t,y]; +####s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] / DiscountFactor[r,y]= DiscountedCapitalInvestment[r,t,y]; # ######### Salvage Value ############# # -s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r,t]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(((1+DiscountRate[r,t])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r,t])^OperationalLife[r,t]-1))); -s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r,t]=0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]); +s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(((1+DiscountRate[r])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r])^OperationalLife[r,t]-1))); +s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]=0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]); s.t. SV3_SalvageValueAtEndOfPeriod3{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) <= (max{yy in YEAR} max(yy))}: SalvageValue[r,t,y] = 0; -s.t. SV4_SalvageValueDiscountedToStartYear{r in REGION, t in TECHNOLOGY, y in YEAR}: DiscountedSalvageValue[r,t,y] = SalvageValue[r,t,y]/((1+DiscountRate[r,t])^(1+max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy))); +s.t. SV4_SalvageValueDiscountedToStartYear{r in REGION, t in TECHNOLOGY, y in YEAR}: DiscountedSalvageValue[r,t,y] = SalvageValue[r,t,y]/((1+DiscountRate[r])^(1+max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy))); # ######### Operating Costs ############# # #s.t. OC1_OperatingCostsVariable{r in REGION, t in TECHNOLOGY, y in YEAR}: sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y] = AnnualVariableOperatingCost[r,t,y]; #s.t. OC2_OperatingCostsFixedAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}: ((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] = AnnualFixedOperatingCost[r,t,y]; #s.t. OC3_OperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}: (((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y]) = OperatingCost[r,t,y]; -####s.t. OC4_DiscountedOperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}: (((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/CapitalRecoveryFactorMid[r,t,y] = DiscountedOperatingCost[r,t,y]; +####s.t. OC4_DiscountedOperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}: (((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/DiscountFactorMid[r,y] = DiscountedOperatingCost[r,t,y]; # ######### Total Discounted Costs ############# # -#s.t. TDC1_TotalDiscountedCostByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: ((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/CapitalRecoveryFactorMid[r,t,y]+CapitalCost[r,t,y] * NewCapacity[r,t,y]/CapitalRecoveryFactor[r,t,y]+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) = TotalDiscountedCostByTechnology[r,t,y]; -####s.t. TDC2_TotalDiscountedCost{r in REGION, y in YEAR}: sum{t in TECHNOLOGY}((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/CapitalRecoveryFactorMid[r,t,y]+CapitalCost[r,t,y] * NewCapacity[r,t,y]/CapitalRecoveryFactor[r,t,y]+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactor[r,t,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/CapitalRecoveryFactor[r,t,y]) = TotalDiscountedCost[r,y]; +#s.t. TDC1_TotalDiscountedCostByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: ((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/DiscountFactorMid[r,y]+CapitalCost[r,t,y] * NewCapacity[r,t,y]/DiscountFactor[r,y]+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) = TotalDiscountedCostByTechnology[r,t,y]; +####s.t. TDC2_TotalDiscountedCost{r in REGION, y in YEAR}: sum{t in TECHNOLOGY}((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/DiscountFactorMid[r,y]+CapitalCost[r,t,y] * NewCapacity[r,t,y]/DiscountFactor[r,y]+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactor[r,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactor[r,y]) = TotalDiscountedCost[r,y]; # ######### Total Capacity Constraints ############## # @@ -527,7 +535,7 @@ s.t. RE4_EnergyConstraint{r in REGION, y in YEAR}:REMinProductionTarget[r,y]*sum # ######### Emissions Accounting ############## # -s.t. E5_DiscountedEmissionsPenaltyByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: sum{e in EMISSION, l in TIMESLICE, (m,tt) in MODExTECHNOLOGYperEMISSION[e]: t=tt} EmissionActivityRatio[r,t,e,m,y]*RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*EmissionsPenalty[r,e,y]/CapitalRecoveryFactorMid[r,t,y] = DiscountedTechnologyEmissionsPenalty[r,t,y]; +s.t. E5_DiscountedEmissionsPenaltyByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}: sum{e in EMISSION, l in TIMESLICE, (m,tt) in MODExTECHNOLOGYperEMISSION[e]: t=tt} EmissionActivityRatio[r,t,e,m,y]*RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*EmissionsPenalty[r,e,y]/DiscountFactorMid[r,y] = DiscountedTechnologyEmissionsPenalty[r,t,y]; s.t. E8_AnnualEmissionsLimit{r in REGION, e in EMISSION, y in YEAR: AnnualEmissionLimit[r,e,y] <> -1}: sum{l in TIMESLICE, (m,t) in MODExTECHNOLOGYperEMISSION[e]} EmissionActivityRatio[r,t,e,m,y]*RateOfActivity[r,l,t,m,y]*YearSplit[l,y]+AnnualExogenousEmission[r,e,y] <= AnnualEmissionLimit[r,e,y]; s.t. E9_ModelPeriodEmissionsLimit{r in REGION, e in EMISSION: ModelPeriodEmissionLimit[r,e] <> -1}: sum{l in TIMESLICE, (m,t) in MODExTECHNOLOGYperEMISSION[e], y in YEAR} EmissionActivityRatio[r,t,e,m,y]*RateOfActivity[r,l,t,m,y]*YearSplit[l,y] + ModelPeriodExogenousEmission[r,e] <= ModelPeriodEmissionLimit[r,e] ; #s.t. E1_AnnualEmissionProductionByMode{r in REGION, t in TECHNOLOGY, e in EMISSION, m in MODEperTECHNOLOGY[t], y in YEAR}: EmissionActivityRatio[r,t,e,m,y]*sum{l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]=AnnualTechnologyEmissionByMode[r,t,e,m,y]; @@ -585,12 +593,12 @@ for {r in REGION} NewCapacity[r,t,yy]) + ResidualCapacity[r,t,y]) * FixedCost[r,t,y] + sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} RateOfActivity[r,l,t,m,y] * YearSplit[l,y] * VariableCost[r,t,m,y]) - / CapitalRecoveryFactorMid[r,t,y] - + CapitalCost[r,t,y] * NewCapacity[r,t,y] / CapitalRecoveryFactor[r,t,y] + / DiscountFactorMid[r,y] + + CapitalCost[r,t,y] * NewCapacity[r,t,y] / DiscountFactor[r,y] + DiscountedTechnologyEmissionsPenalty[r,t,y] - DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} - (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / CapitalRecoveryFactorStorage[r,s,y] - - CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / CapitalRecoveryFactorStorage[r,s,y])) >> ResultsPath & "/SelectedResults.csv"; + (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / DiscountFactorStorage[r,s,y] + - CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / DiscountFactorStorage[r,s,y])) >> ResultsPath & "/SelectedResults.csv"; } printf "\n" >> ResultsPath & "/SelectedResults.csv"; # @@ -1062,13 +1070,13 @@ table TotalDiscountedCostResults ((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy]) + ResidualCapacity[r,t,y]) * FixedCost[r,t,y] + sum{l in TIMESLICE, m in MODEperTECHNOLOGY[t]} - RateOfActivity[r,l,t,m,y] * YearSplit[l,y] * VariableCost[r,t,m,y]) / (CapitalRecoveryFactorMid[r,t,y]) - + CapitalCost[r,t,y] * NewCapacity[r,t,y] / (CapitalRecoveryFactor[r,t,y]) + RateOfActivity[r,l,t,m,y] * YearSplit[l,y] * VariableCost[r,t,m,y]) / (DiscountFactorMid[r,y]) + + CapitalCost[r,t,y] * NewCapacity[r,t,y] / (DiscountFactor[r,y]) + DiscountedTechnologyEmissionsPenalty[r,t,y] - DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} - (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / (CapitalRecoveryFactorStorage[r,s,y]) - - CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / (CapitalRecoveryFactorStorage[r,s,y]) + (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / (DiscountFactorStorage[r,s,y]) + - CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / (DiscountFactorStorage[r,s,y]) )~VALUE; table TotalTechnologyAnnualActivity diff --git a/src/osemosys_short.txt b/src/osemosys_short.txt index ea50373..3e5dc51 100644 --- a/src/osemosys_short.txt +++ b/src/osemosys_short.txt @@ -56,13 +56,18 @@ param ResultsPath, symbolic default 'results'; param YearSplit{l in TIMESLICE, y in YEAR}; param DiscountRate{r in REGION}; -param DiscountRateIdv{r in REGION, t in TECHNOLOGY}; +param DiscountRateIdv{r in REGION, t in TECHNOLOGY}, default DiscountRate[r]; param DiscountFactor{r in REGION, y in YEAR} := (1 + DiscountRate[r])^(y - min{yy in YEAR} min(yy)); param DiscountFactorMid{r in REGION, y in YEAR} := (1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy) + 0.5); param OperationalLife{r in REGION, t in TECHNOLOGY}; +param CapitalRecoveryFactor{r in REGION, t in TECHNOLOGY} := + (1 - (1 + DiscountRateIdv[r,t])^(-1))/(1 - (1 + DiscountRateIdv[r,t])^(-(OperationalLife[r,t]))); +param PvAnnuity{r in REGION, t in TECHNOLOGY} := + (1 - (1 + DiscountRate[r])^(-(OperationalLife[r,t]))) * (1 + DiscountRate[r]) / DiscountRate[r]; + param DiscountRateStorage{r in REGION, s in STORAGE}; param DiscountFactorStorage{r in REGION, s in STORAGE, y in YEAR} := (1 + DiscountRateStorage[r,s])^(y - min{yy in YEAR} min(yy)); @@ -417,8 +422,7 @@ s.t. SI8_SalvageValueStorageAtEndOfPeriod3{r in REGION, s in STORAGE, y in YEAR: ######### Capital Costs ############# # s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] = CapitalInvestment[r,t,y]; -s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: -CapitalInvestment[r,t,y]*(1 + DiscountRateIdv[r,t])/(DiscountFactor[r,y]) = DiscountedCapitalInvestment[r,t,y]; +s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalInvestment[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] / DiscountFactor[r,y] = DiscountedCapitalInvestment[r,t,y]; # ######### Salvage Value ############# # From a38373bd3079fdf0a9bae4f89ad264d528708b0e Mon Sep 17 00:00:00 2001 From: Roberto David Heredia Date: Wed, 17 Mar 2021 19:08:07 +0100 Subject: [PATCH 11/22] updated three vesrions --- src/osemosys.txt | 10 +++++----- src/osemosys_fast.txt | 10 +++++----- src/osemosys_short.txt | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/osemosys.txt b/src/osemosys.txt index 2a6b803..7a13b0b 100644 --- a/src/osemosys.txt +++ b/src/osemosys.txt @@ -628,16 +628,16 @@ s.t. SI10_TotalDiscountedCostByStorage{r in REGION, s in STORAGE, y in YEAR}: Di # ######### Capital Costs ############# # -s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] = CapitalInvestment[r,t,y]; +s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] = CapitalInvestment[r,t,y]; -s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalInvestment[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] / DiscountFactor[r,y] = DiscountedCapitalInvestment[r,t,y]; +s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalInvestment[r,t,y] / DiscountFactor[r,y] = DiscountedCapitalInvestment[r,t,y]; # ######### Salvage Value ############# # -s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR: DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(((1+DiscountRate[r])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r])^OperationalLife[r,t]-1))); -s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR: (DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]=0) || (DepreciationMethod[r]=2 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)))}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]); +s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR: DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] *(1-(((1+DiscountRate[r])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r])^OperationalLife[r,t]-1))); +s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR: (DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]=0) || (DepreciationMethod[r]=2 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)))}: SalvageValue[r,t,y] = CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] *(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]); s.t. SV3_SalvageValueAtEndOfPeriod3{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) <= (max{yy in YEAR} max(yy))}: SalvageValue[r,t,y] = 0; s.t. SV4_SalvageValueDiscountedToStartYear{r in REGION, t in TECHNOLOGY, y in YEAR}: DiscountedSalvageValue[r,t,y] = SalvageValue[r,t,y]/((1+DiscountRate[r])^(1+max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy))); # @@ -844,7 +844,7 @@ for {r in REGION} { } printf "\n" >> ResultsPath & "/SelectedResults.csv"; printf "Cost" >> ResultsPath & "/SelectedResults.csv"; -for {r in REGION} {printf ",%g", sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/DiscountFactorMid[r,y]+CapitalCost[r,t,y] * NewCapacity[r,t,y]/(DiscountFactor[r,y])+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactor[r,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactor[r,y])) >> ResultsPath & "/SelectedResults.csv"; +for {r in REGION} {printf ",%g", sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/DiscountFactorMid[r,y] + DiscountedCapitalInvestment[r,t,y] + DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactor[r,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactor[r,y])) >> ResultsPath & "/SelectedResults.csv"; } printf "\n" >> ResultsPath & "/SelectedResults.csv"; # diff --git a/src/osemosys_fast.txt b/src/osemosys_fast.txt index d204999..4378900 100644 --- a/src/osemosys_fast.txt +++ b/src/osemosys_fast.txt @@ -467,8 +467,8 @@ s.t. SI6_SalvageValueStorageAtEndOfPeriod1{r in REGION, s in STORAGE, y in YEAR: # ######### Salvage Value ############# # -s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(((1+DiscountRate[r])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r])^OperationalLife[r,t]-1))); -s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]=0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]); +s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] * (1-(((1+DiscountRate[r])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r])^OperationalLife[r,t]-1))); +s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]=0}: SalvageValue[r,t,y] = CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] * (1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]); s.t. SV3_SalvageValueAtEndOfPeriod3{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) <= (max{yy in YEAR} max(yy))}: SalvageValue[r,t,y] = 0; s.t. SV4_SalvageValueDiscountedToStartYear{r in REGION, t in TECHNOLOGY, y in YEAR}: DiscountedSalvageValue[r,t,y] = SalvageValue[r,t,y]/((1+DiscountRate[r])^(1+max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy))); # @@ -594,7 +594,7 @@ for {r in REGION} * FixedCost[r,t,y] + sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} RateOfActivity[r,l,t,m,y] * YearSplit[l,y] * VariableCost[r,t,m,y]) / DiscountFactorMid[r,y] - + CapitalCost[r,t,y] * NewCapacity[r,t,y] / DiscountFactor[r,y] + + CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] / DiscountFactor[r,y] + DiscountedTechnologyEmissionsPenalty[r,t,y] - DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / DiscountFactorStorage[r,s,y] @@ -909,7 +909,7 @@ table CapitalInvestmentResults OUT "CSV" ResultsPath & "/CapitalInvestment.csv" : r~REGION, t~TECHNOLOGY, y~YEAR, - CapitalCost[r,t,y] * NewCapacity[r,t,y] ~VALUE; + CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] ~VALUE; table DemandResults {r in REGION, l in TIMESLICE, f in FUEL, y in YEAR: @@ -1071,7 +1071,7 @@ table TotalDiscountedCostResults NewCapacity[r,t,yy]) + ResidualCapacity[r,t,y]) * FixedCost[r,t,y] + sum{l in TIMESLICE, m in MODEperTECHNOLOGY[t]} RateOfActivity[r,l,t,m,y] * YearSplit[l,y] * VariableCost[r,t,m,y]) / (DiscountFactorMid[r,y]) - + CapitalCost[r,t,y] * NewCapacity[r,t,y] / (DiscountFactor[r,y]) + + CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t]/ (DiscountFactor[r,y]) + DiscountedTechnologyEmissionsPenalty[r,t,y] - DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} diff --git a/src/osemosys_short.txt b/src/osemosys_short.txt index 3e5dc51..ad8d143 100644 --- a/src/osemosys_short.txt +++ b/src/osemosys_short.txt @@ -312,7 +312,7 @@ minimize cost: sum{r in REGION, t in TECHNOLOGY, y in YEAR} sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y] * YearSplit[l,y] * VariableCost[r,t,m,y]) / DiscountFactorMid[r,y] - + DiscountedCapitalInvestment[r,t,y] + + CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] / DiscountFactor[r,y] + DiscountedTechnologyEmissionsPenalty[r,t,y] - DiscountedSalvageValue[r,t,y])) + sum{r in REGION, s in STORAGE, y in YEAR} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / DiscountFactorStorage[r,s,y] @@ -421,13 +421,13 @@ s.t. SI8_SalvageValueStorageAtEndOfPeriod3{r in REGION, s in STORAGE, y in YEAR: # ######### Capital Costs ############# # -s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] = CapitalInvestment[r,t,y]; -s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalInvestment[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] / DiscountFactor[r,y] = DiscountedCapitalInvestment[r,t,y]; +#s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] = CapitalInvestment[r,t,y]; +####s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}: CapitalInvestment[r,t,y] / DiscountFactor[r,y] = DiscountedCapitalInvestment[r,t,y]; # ######### Salvage Value ############# # -s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR: DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(((1+DiscountRate[r])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r])^OperationalLife[r,t]-1))); -s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR: DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]=0 || (DepreciationMethod[r]=2 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)))}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]); +s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR: DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] * (1-(((1+DiscountRate[r])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r])^OperationalLife[r,t]-1))); +s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR: DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]=0 || (DepreciationMethod[r]=2 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)))}: SalvageValue[r,t,y] = CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] * (1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]); s.t. SV3_SalvageValueAtEndOfPeriod3{r in REGION, t in TECHNOLOGY, y in YEAR: (y + OperationalLife[r,t]-1) <= (max{yy in YEAR} max(yy))}: SalvageValue[r,t,y] = 0; s.t. SV4_SalvageValueDiscountedToStartYear{r in REGION, t in TECHNOLOGY, y in YEAR}: DiscountedSalvageValue[r,t,y] = SalvageValue[r,t,y]/((1+DiscountRate[r])^(1+max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy))); # @@ -543,7 +543,7 @@ for {r in REGION} { } printf "\n" >> ResultsPath & "/SelectedResults.csv"; printf "Cost" >> ResultsPath & "/SelectedResults.csv"; -for {r in REGION} {printf ",%g", sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/((DiscountFactorMid[r,y]))+CapitalCost[r,t,y] * NewCapacity[r,t,y]/((DiscountFactor[r,y]))+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y])) >> ResultsPath & "/SelectedResults.csv"; +for {r in REGION} {printf ",%g", sum{t in TECHNOLOGY, y in YEAR}(((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y])/((DiscountFactorMid[r,y])) + CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] / DiscountFactor[r,y] +DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y]-CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]/DiscountFactorStorage[r,s,y])) >> ResultsPath & "/SelectedResults.csv"; } printf "\n" >> ResultsPath & "/SelectedResults.csv"; # @@ -900,7 +900,7 @@ table CapitalInvestmentResults OUT "CSV" ResultsPath & "/CapitalInvestment.csv" : r~REGION, t~TECHNOLOGY, y~YEAR, - CapitalCost[r,t,y] * NewCapacity[r,t,y] ~VALUE; + CapitalCost[r,t,y] * NewCapacity[r,t,y]* CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] ~VALUE; table DemandResults {r in REGION, l in TIMESLICE, f in FUEL, y in YEAR: @@ -1063,7 +1063,7 @@ table TotalDiscountedCostResults NewCapacity[r,t,yy]) + ResidualCapacity[r,t,y]) * FixedCost[r,t,y] + sum{m in MODE_OF_OPERATION, l in TIMESLICE} RateOfActivity[r,l,t,m,y] * YearSplit[l,y] * VariableCost[r,t,m,y]) / DiscountFactor[r,y] + 0.5 - + CapitalCost[r,t,y] * NewCapacity[r,t,y] / DiscountFactor[r,y] + + CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t]/ DiscountFactor[r,y] + DiscountedTechnologyEmissionsPenalty[r,t,y] - DiscountedSalvageValue[r,t,y]) + sum{s in STORAGE} From 991c628be4695686db9efcbbe1d73a1bd8f8f93c Mon Sep 17 00:00:00 2001 From: Abhishek Shivakumar Date: Fri, 30 Apr 2021 14:45:34 +0100 Subject: [PATCH 12/22] Fixed bug #66 and other storage-related ones --- scripts/preprocess_data.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/preprocess_data.py b/scripts/preprocess_data.py index a9c0a96..041c8b3 100644 --- a/scripts/preprocess_data.py +++ b/scripts/preprocess_data.py @@ -199,6 +199,7 @@ def main(data_format, data_infile, data_outfile): data_out.append(tuple([fuel, tech, mode])) output_table.append(tuple([tech, fuel, mode, year, value])) + data_all.append(tuple([tech, mode])) if param_current == 'InputActivityRatio': tech = line.split(' ')[1].strip() @@ -206,8 +207,7 @@ def main(data_format, data_infile, data_outfile): mode = line.split(' ')[3].strip() data_inp.append(tuple([fuel, tech, mode])) - - data_all.append(tuple([tech, mode])) + data_all.append(tuple([tech, mode])) if param_current == 'TechnologyToStorage': tech = line.split(' ')[1].strip() @@ -215,6 +215,7 @@ def main(data_format, data_infile, data_outfile): mode = line.split(' ')[3].strip() storage_to.append(tuple([storage, tech, mode])) + data_all.append(tuple([storage, mode])) if param_current == 'TechnologyFromStorage': tech = line.split(' ')[1].strip() @@ -222,6 +223,7 @@ def main(data_format, data_infile, data_outfile): mode = line.split(' ')[3].strip() storage_from.append(tuple([storage, tech, mode])) + data_all.append(tuple([storage, mode])) if param_current == 'EmissionActivityRatio': tech = line.split(' ')[1].strip() @@ -288,11 +290,11 @@ def file_output_function(if_dict, str_dict, set_list, set_name, extra_char): file_output_function(dict_inp, dict_inp, fuel_list, 'set MODExTECHNOLOGYperFUELin[', '') file_output_function(dict_all, dict_all, tech_list, 'set MODEperTECHNOLOGY[', '*') - if len(storage_list) > 1: - file_output_function(dict_stt, dict_out, storage_list, 'set MODExTECHNOLOGYperSTORAGEto[', '') - file_output_function(dict_stf, dict_out, storage_list, 'set MODExTECHNOLOGYperSTORAGEfrom[', '*') + if len(storage_list) > 0: + file_output_function(dict_stt, dict_stt, storage_list, 'set MODExTECHNOLOGYperSTORAGEto[', '') + file_output_function(dict_stf, dict_stf, storage_list, 'set MODExTECHNOLOGYperSTORAGEfrom[', '') - if len(emission_list) > 1: + if len(emission_list) > 0: file_output_function(dict_emi, dict_emi, emission_list, 'set MODExTECHNOLOGYperEMISSION[', '') file_out.write('end;') From 14e0dee0983d8e99ffe7f934710cf63eb1321218 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Tue, 11 May 2021 00:04:32 +0200 Subject: [PATCH 13/22] Fixed issue with writing emission sets --- scripts/preprocess_data.py | 125 +++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 60 deletions(-) diff --git a/scripts/preprocess_data.py b/scripts/preprocess_data.py index 041c8b3..81f2b15 100644 --- a/scripts/preprocess_data.py +++ b/scripts/preprocess_data.py @@ -1,25 +1,25 @@ """Pre-process OSeMOSYS data file to reduce matrix generation time -This script pre-processes an OSeMOSYS input data file by adding lines that list -commodity-technology-mode combinations that data is provided for. Pre-processing -a data file before starting a model run significantly reduces the time taken -for matrix generation. +This script pre-processes an OSeMOSYS input data file by adding lines that list +commodity-technology-mode combinations that data is provided for. Pre-processing +a data file before starting a model run significantly reduces the time taken +for matrix generation. Pre-processing consists of the following steps: -1. Reading the ``InputActivityRatio`` and ``OutputActivityRatio`` sections of the -data file to identify commodity-technology-mode combinations that data has been +1. Reading the ``InputActivityRatio`` and ``OutputActivityRatio`` sections of the +data file to identify commodity-technology-mode combinations that data has been explicitly provided for. -2. Adding a set entry for each commodity that lists all technology-mode combinations -that are associated with it. -3. Values from the ``InputActivityRatios`` and ``OutputActivityRatios`` sections are +2. Adding a set entry for each commodity that lists all technology-mode combinations +that are associated with it. +3. Values from the ``InputActivityRatios`` and ``OutputActivityRatios`` sections are added to the sets ``MODExTECHNOLOGYperFUELin`` and ``MODExTECHNOLOGYperFUELout`` respectively. -4. Values from the ``TechnologyToStorage`` and ``TechnologyFromStorage`` sections +4. Values from the ``TechnologyToStorage`` and ``TechnologyFromStorage`` sections are added to the sets ``MODExTECHNOLOGYperSTORAGEto`` and ``MODExTECHNOLOGYperSTORAGEfrom`` respectively. -5. All values for technology-mode combinations are added to the sets +5. All values for technology-mode combinations are added to the sets ``MODEperTECHNOLOGY``. - In order to start a model run with a pre-processed data file, the following sets + In order to start a model run with a pre-processed data file, the following sets need to be introduced to its associated OSeMOSYS model file:: set MODEperTECHNOLOGY{TECHNOLOGY} within MODE_OF_OPERATION; @@ -70,20 +70,20 @@ def main(data_format, data_infile, data_outfile): storage_from = [] emission_table = [] - param_check = ['OutputActivityRatio', 'InputActivityRatio', 'TechnologyToStorage', 'TechnologyFromStorage', 'EmissionActivityRatio'] + params_to_check = ['OutputActivityRatio', 'InputActivityRatio', 'TechnologyToStorage', 'TechnologyFromStorage', 'EmissionActivityRatio'] with open(data_infile, 'r') as f: for line in f: if parsing_year: year_list += [line.strip()] if line.strip() not in ['', ';'] else [] if parsing_fuel: - fuel_list += [line.strip()] if line.strip() not in ['', ';'] else [] + fuel_list += [line.strip()] if line.strip() not in ['', ';'] else [] if parsing_tech: - tech_list += [line.strip()] if line.strip() not in ['', ';'] else [] + tech_list += [line.strip()] if line.strip() not in ['', ';'] else [] if parsing_storage: - storage_list += [line.strip()] if line.strip() not in ['', ';'] else [] + storage_list += [line.strip()] if line.strip() not in ['', ';'] else [] if parsing_mode: - mode_list += [line.strip()] if line.strip() not in ['', ';'] else [] + mode_list += [line.strip()] if line.strip() not in ['', ';'] else [] if parsing_emission: emission_list += [line.strip()] if line.strip() not in ['', ';'] else [] @@ -92,12 +92,12 @@ def main(data_format, data_infile, data_outfile): year_list = line.split(' ')[3:-1] else: parsing_year = True - if line.startswith('set COMMODITY'): # Extracts list of COMMODITIES from data file. Some models use FUEL instead. + if line.startswith('set COMMODITY'): # Extracts list of COMMODITIES from data file. Some models use FUEL instead. if len(line.split('=')[1]) > 1: fuel_list = line.split(' ')[3:-1] else: parsing_fuel = True - if line.startswith('set FUEL'): # Extracts list of FUELS from data file. Some models use COMMODITIES instead. + if line.startswith('set FUEL'): # Extracts list of FUELS from data file. Some models use COMMODITIES instead. if len(line.split('=')[1]) > 1: fuel_list = line.split(' ')[3:-1] else: @@ -150,13 +150,13 @@ def main(data_format, data_infile, data_outfile): values = line.rstrip().split(' ')[1:] mode = line.split(' ')[0] - if param_current == 'OutputActivityRatio': + if param_current == 'OutputActivityRatio': data_out.append(tuple([fuel, tech, mode])) for i in range(0, len(years)): output_table.append(tuple([tech, fuel, mode, years[i], values[i]])) if param_current == 'InputActivityRatio': - data_inp.append(tuple([fuel, tech, mode])) + data_inp.append(tuple([fuel, tech, mode])) data_all.append(tuple([tech, mode])) @@ -186,54 +186,61 @@ def main(data_format, data_infile, data_outfile): if data_format == 'otoole': with open(data_infile, 'r') as f: for line in f: + details = line.split(' ') if line.startswith(";"): parsing = False if parsing: - if len(line.split(' ')) > 1: + if len(details) > 1: if param_current == 'OutputActivityRatio': - tech = line.split(' ')[1].strip() - fuel = line.split(' ')[2].strip() - mode = line.split(' ')[3].strip() - year = line.split(' ')[4].strip() - value = line.split(' ')[5].strip() + tech = details[1].strip() + fuel = details[2].strip() + mode = details[3].strip() + year = details[4].strip() + value = details[5].strip() - data_out.append(tuple([fuel, tech, mode])) - output_table.append(tuple([tech, fuel, mode, year, value])) - data_all.append(tuple([tech, mode])) + if float(value) != 0.0: + data_out.append(tuple([fuel, tech, mode])) + output_table.append(tuple([tech, fuel, mode, year, value])) + data_all.append(tuple([tech, mode])) if param_current == 'InputActivityRatio': - tech = line.split(' ')[1].strip() - fuel = line.split(' ')[2].strip() - mode = line.split(' ')[3].strip() - - data_inp.append(tuple([fuel, tech, mode])) - data_all.append(tuple([tech, mode])) + tech = details[1].strip() + fuel = details[2].strip() + mode = details[3].strip() + value = details[5].strip() + if float(value) != 0.0: + data_inp.append(tuple([fuel, tech, mode])) + data_all.append(tuple([tech, mode])) if param_current == 'TechnologyToStorage': - tech = line.split(' ')[1].strip() - storage = line.split(' ')[2].strip() - mode = line.split(' ')[3].strip() - - storage_to.append(tuple([storage, tech, mode])) - data_all.append(tuple([storage, mode])) + tech = details[1].strip() + storage = details[2].strip() + mode = details[3].strip() + value = details[4].strip() + if value > 0.0: + storage_to.append(tuple([storage, tech, mode])) + data_all.append(tuple([storage, mode])) if param_current == 'TechnologyFromStorage': - tech = line.split(' ')[1].strip() - storage = line.split(' ')[2].strip() - mode = line.split(' ')[3].strip() - - storage_from.append(tuple([storage, tech, mode])) - data_all.append(tuple([storage, mode])) + tech = details[1].strip() + storage = details[2].strip() + mode = details[3].strip() + value = details[4].strip() + if value > 0.0: + storage_from.append(tuple([storage, tech, mode])) + data_all.append(tuple([storage, mode])) if param_current == 'EmissionActivityRatio': - tech = line.split(' ')[1].strip() - emission = line.split(' ')[2].strip() - mode = line.split(' ')[3].strip() - - emission_table.append(tuple([emission, tech, mode])) - - if any(param in line for param in param_check): - param_current = line.split(' ')[-2] + tech = details[1].strip() + emission = details[2].strip() + mode = details[3].strip() + value = details[5].strip() + if float(value) != 0.0: + emission_table.append(tuple([emission, tech, mode])) + data_all.append(tuple([tech, mode])) + + if any(param in line for param in params_to_check): + param_current = details[-2] parsing = True data_out = list(set(data_out)) @@ -277,9 +284,7 @@ def file_output_function(if_dict, str_dict, set_list, set_name, extra_char): line = line.replace(',','').replace(':=[',':= ').replace(']*','').replace("'","") else: line = line.replace('),',')').replace('[(',' (').replace(')]',')').replace("'","") - else: - line = set_name + str(each) + ']:=' - file_out.write(line + ';' + '\n') + file_out.write(line + ';' + '\n') # Append lines at the end of the data file with open(data_outfile, 'w') as file_out: # 'a' to open in 'append' mode @@ -310,4 +315,4 @@ def file_output_function(if_dict, str_dict, set_list, set_name, extra_char): data_format = sys.argv[1] data_infile = sys.argv[2] data_outfile = sys.argv[3] - main(data_format, data_infile, data_outfile) + main(data_format, data_infile, data_outfile) \ No newline at end of file From fe98533a164a5362b4c03634e10f977c68600140 Mon Sep 17 00:00:00 2001 From: Abhishek Shivakumar Date: Wed, 12 May 2021 18:26:06 +0100 Subject: [PATCH 14/22] Fixed bug related to sets of sets with missing inputs or outputs --- scripts/preprocess_data.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/preprocess_data.py b/scripts/preprocess_data.py index 81f2b15..d8c0622 100644 --- a/scripts/preprocess_data.py +++ b/scripts/preprocess_data.py @@ -284,7 +284,13 @@ def file_output_function(if_dict, str_dict, set_list, set_name, extra_char): line = line.replace(',','').replace(':=[',':= ').replace(']*','').replace("'","") else: line = line.replace('),',')').replace('[(',' (').replace(')]',')').replace("'","") - file_out.write(line + ';' + '\n') + else: + line = set_name + str(each) + ']:=' + + file_out.write(line + ';' + '\n') + + storage_list_len = {'otoole': 0, + 'momani': 1} # Append lines at the end of the data file with open(data_outfile, 'w') as file_out: # 'a' to open in 'append' mode @@ -295,7 +301,8 @@ def file_output_function(if_dict, str_dict, set_list, set_name, extra_char): file_output_function(dict_inp, dict_inp, fuel_list, 'set MODExTECHNOLOGYperFUELin[', '') file_output_function(dict_all, dict_all, tech_list, 'set MODEperTECHNOLOGY[', '*') - if len(storage_list) > 0: + if len(storage_list) > storage_list_len[data_format]: + print(len(storage_list)) file_output_function(dict_stt, dict_stt, storage_list, 'set MODExTECHNOLOGYperSTORAGEto[', '') file_output_function(dict_stf, dict_stf, storage_list, 'set MODExTECHNOLOGYperSTORAGEfrom[', '') From e62db90d7304810050e623eac2bc2d144b868ae1 Mon Sep 17 00:00:00 2001 From: Abhishek Shivakumar Date: Wed, 12 May 2021 18:27:35 +0100 Subject: [PATCH 15/22] Removed unnecessary print statements and whitespaces --- scripts/preprocess_data.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/preprocess_data.py b/scripts/preprocess_data.py index d8c0622..fe150a8 100644 --- a/scripts/preprocess_data.py +++ b/scripts/preprocess_data.py @@ -286,7 +286,7 @@ def file_output_function(if_dict, str_dict, set_list, set_name, extra_char): line = line.replace('),',')').replace('[(',' (').replace(')]',')').replace("'","") else: line = set_name + str(each) + ']:=' - + file_out.write(line + ';' + '\n') storage_list_len = {'otoole': 0, @@ -302,7 +302,6 @@ def file_output_function(if_dict, str_dict, set_list, set_name, extra_char): file_output_function(dict_all, dict_all, tech_list, 'set MODEperTECHNOLOGY[', '*') if len(storage_list) > storage_list_len[data_format]: - print(len(storage_list)) file_output_function(dict_stt, dict_stt, storage_list, 'set MODExTECHNOLOGYperSTORAGEto[', '') file_output_function(dict_stf, dict_stf, storage_list, 'set MODExTECHNOLOGYperSTORAGEfrom[', '') From bcb23d48315f63dfc774ed0c64a24f7dcb87b1f5 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Fri, 21 May 2021 16:01:08 +0200 Subject: [PATCH 16/22] Add author metadata for Zenodo --- .zenodo.json | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .zenodo.json diff --git a/.zenodo.json b/.zenodo.json new file mode 100644 index 0000000..4e2e148 --- /dev/null +++ b/.zenodo.json @@ -0,0 +1,31 @@ +{ + "license": "MIT", + "upload_type": "software", + "creators": [ + { + "name": "Mark Howells", + "orcid": "0000-0001-6419-4957", + "affiliation": "Imperial College London; Loughborough University Department of Social Sciences" + }, + { + "name": "Abhishek Shivakumar", + "orcid": "0000-0002-2535-4134" + }, + { + "affiliation": "University College Cork", + "name": "Maarten Brinkerink", + "orcid": "0000-0002-8980-9062" + }, + { + "affiliation": "Simon Fraser University", + "name": "Taco Niet", + "orcid": "0000-0003-0266-2705" + }, + { + "affiliation": "KTH Royal Institute of Technology", + "name": "Will Usher", + "orcid": "0000-0001-9367-1791" + } + ], + "access_right": "open" +} \ No newline at end of file From 70ab0158fe03263c5359f15a41dd0c614dec567b Mon Sep 17 00:00:00 2001 From: Will Usher Date: Fri, 21 May 2021 16:42:53 +0200 Subject: [PATCH 17/22] Added more authors --- .zenodo.json | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/.zenodo.json b/.zenodo.json index 4e2e148..a3bcaed 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -8,19 +8,39 @@ "affiliation": "Imperial College London; Loughborough University Department of Social Sciences" }, { - "name": "Abhishek Shivakumar", - "orcid": "0000-0002-2535-4134" + "affiliation": "KTH Royal Institute of Technology", + "name": "Francesco Gardumi", + "orcid": "0000-0001-8371-9325" }, { - "affiliation": "University College Cork", - "name": "Maarten Brinkerink", - "orcid": "0000-0002-8980-9062" + "affiliation": "KTH Royal Institute of Technology", + "name": "Vignesh Sridharan", + "orcid": "0000-0003-0764-2615" + }, + { + "affiliation": "KTH Royal Institute of Technology", + "name": "Agnese Beltramo", + "orcid": "0000-0001-6591-3028" + }, + { + "affiliation": "KTH Royal Institute of Technology", + "name": "Nandi Moksnes", + "orcid": "0000-0002-8641-564X" }, { "affiliation": "Simon Fraser University", "name": "Taco Niet", "orcid": "0000-0003-0266-2705" }, + { + "name": "Abhishek Shivakumar", + "orcid": "0000-0002-2535-4134" + }, + { + "affiliation": "KTH Royal Institute of Technology", + "name": "Roberto Heredia Fonseca", + "orcid": "0000-0003-3947-8725" + }, { "affiliation": "KTH Royal Institute of Technology", "name": "Will Usher", From cc8033bf27e2d122ba5e16c8c6d159c7a07e2f62 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Mon, 24 May 2021 14:30:21 +0200 Subject: [PATCH 18/22] Update .zenodo.json Add further authors Co-authored-by: AgnesBelt <31009972+AgnesBelt@users.noreply.github.com> --- .zenodo.json | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.zenodo.json b/.zenodo.json index a3bcaed..16eeb15 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -8,6 +8,33 @@ "affiliation": "Imperial College London; Loughborough University Department of Social Sciences" }, { + "name": "Manuel Welsch", + "affiliation": "International Atomic Energy Agency" + }, + { + "name": "Constantinos Taliotis", + "orcid": "0000-0003-4022-5506", + "affiliation": "The Cyprus Institute" + }, + { + "name": "Adrian Lefvert", + "orcid": "0000-0001-8587-4054", + "affiliation": "KTH Royal Institute of Technology" + }, + { + "name": "Igor Tatarewicz", + "orcid": "", + "affiliation": "" + } + { + "name": "Tom Alfstad", + "affiliation": "United Nations Department of Economic and Social Affairs" + } + { + "name": "Nawfal Saadi", + "orcid": "0000-0001-8923-7431", + "affiliation": "Enel Green Power" + } "affiliation": "KTH Royal Institute of Technology", "name": "Francesco Gardumi", "orcid": "0000-0001-8371-9325" @@ -48,4 +75,4 @@ } ], "access_right": "open" -} \ No newline at end of file +} From 45da7d8c455b94557ab7ffcf3eea4def5d2643e2 Mon Sep 17 00:00:00 2001 From: abhishek0208 Date: Mon, 24 May 2021 17:50:34 +0100 Subject: [PATCH 19/22] Added affiliation --- .zenodo.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.zenodo.json b/.zenodo.json index 16eeb15..982e6f5 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -60,6 +60,7 @@ "orcid": "0000-0003-0266-2705" }, { + "affiliation": "United Nations Department of Economic and Social Affairs", "name": "Abhishek Shivakumar", "orcid": "0000-0002-2535-4134" }, From d645fa40988f04f1023f3ccc4581824e115eaf63 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Mon, 24 May 2021 19:08:28 +0200 Subject: [PATCH 20/22] Re-ordered fields, spacing --- .zenodo.json | 60 ++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.zenodo.json b/.zenodo.json index 982e6f5..b7bdaae 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -8,70 +8,70 @@ "affiliation": "Imperial College London; Loughborough University Department of Social Sciences" }, { - "name": "Manuel Welsch", - "affiliation": "International Atomic Energy Agency" - }, - { - "name": "Constantinos Taliotis", - "orcid": "0000-0003-4022-5506", - "affiliation": "The Cyprus Institute" - }, - { - "name": "Adrian Lefvert", - "orcid": "0000-0001-8587-4054", - "affiliation": "KTH Royal Institute of Technology" - }, - { - "name": "Igor Tatarewicz", - "orcid": "", - "affiliation": "" - } + "name": "Manuel Welsch", + "affiliation": "International Atomic Energy Agency" + }, + { + "name": "Constantinos Taliotis", + "orcid": "0000-0003-4022-5506", + "affiliation": "The Cyprus Institute" + }, + { + "name": "Adrian Lefvert", + "orcid": "0000-0001-8587-4054", + "affiliation": "KTH Royal Institute of Technology" + }, { - "name": "Tom Alfstad", + "name": "Igor Tatarewicz", + "affiliation": "" + }, + { + "name": "Tom Alfstad", "affiliation": "United Nations Department of Economic and Social Affairs" - } - { + }, + { "name": "Nawfal Saadi", "orcid": "0000-0001-8923-7431", "affiliation": "Enel Green Power" - } - "affiliation": "KTH Royal Institute of Technology", + }, + { "name": "Francesco Gardumi", + "affiliation": "KTH Royal Institute of Technology", "orcid": "0000-0001-8371-9325" }, { - "affiliation": "KTH Royal Institute of Technology", "name": "Vignesh Sridharan", + "affiliation": "KTH Royal Institute of Technology", "orcid": "0000-0003-0764-2615" }, { - "affiliation": "KTH Royal Institute of Technology", "name": "Agnese Beltramo", + "affiliation": "KTH Royal Institute of Technology", "orcid": "0000-0001-6591-3028" }, { - "affiliation": "KTH Royal Institute of Technology", "name": "Nandi Moksnes", + "affiliation": "KTH Royal Institute of Technology", "orcid": "0000-0002-8641-564X" }, { - "affiliation": "Simon Fraser University", "name": "Taco Niet", + "affiliation": "Simon Fraser University", "orcid": "0000-0003-0266-2705" }, { - "affiliation": "United Nations Department of Economic and Social Affairs", "name": "Abhishek Shivakumar", + "affiliation": "United Nations Department of Economic and Social Affairs", "orcid": "0000-0002-2535-4134" }, { - "affiliation": "KTH Royal Institute of Technology", "name": "Roberto Heredia Fonseca", + "affiliation": "KTH Royal Institute of Technology", "orcid": "0000-0003-3947-8725" }, { - "affiliation": "KTH Royal Institute of Technology", "name": "Will Usher", + "affiliation": "KTH Royal Institute of Technology", "orcid": "0000-0001-9367-1791" } ], From c3b469884337a296de73dbec766df98ce89772a4 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Mon, 24 May 2021 19:14:30 +0200 Subject: [PATCH 21/22] Added affiliation for Igor --- .zenodo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zenodo.json b/.zenodo.json index b7bdaae..b035a8b 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -23,7 +23,7 @@ }, { "name": "Igor Tatarewicz", - "affiliation": "" + "affiliation": "Institute of Environmental Protection - National Research Institute / National Centre for Emissions Management (KOBiZE)" }, { "name": "Tom Alfstad", From da79c228408036c657942204ea12d17715089656 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Mon, 24 May 2021 19:24:42 +0200 Subject: [PATCH 22/22] Added Christoph as author (TODO: check orcid) --- .zenodo.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.zenodo.json b/.zenodo.json index b035a8b..d206df9 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -73,6 +73,11 @@ "name": "Will Usher", "affiliation": "KTH Royal Institute of Technology", "orcid": "0000-0001-9367-1791" + }, + { + "name": "Christoph Muschner", + "affiliation": "KTH Royal Institute of Technology", + "orcid": "0000-0001-8144-5260" } ], "access_right": "open"