Skip to content

Commit 370ca1d

Browse files
committed
cff file is added
1 parent 8ce0a1f commit 370ca1d

9 files changed

+711
-112
lines changed

Data/EnergyBalance/2019/Niue.csv

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Country (2019),Transactions(down)/Commodity(right),Primary Coal and Peat,Coal and Peat Products,Primary Oil,Oil Products,Natural Gas,Biofuels and Waste,Nuclear,Electricity,Heat,Total Energy,memo: Of which Renewables
2-
Niue,Primary production,---,---,---,---,---,1,---,*2,*16,*18,*18
2+
Niue,Primary production,---,---,---,---,---,1,---,*2,*15,*18,*18
33
Niue,Imports,---,---,---,*110,---,---,---,---,---,*110,---
44
Niue,Exports,---,---,---,---,---,---,---,---,---,---,---
55
Niue,International marine bunkers,---,---,---,---,---,---,---,---,---,---,---
@@ -51,4 +51,4 @@ Niue,Agriculture forestry and fishing,---,---,---,*1,---,---,---,---,---,*1,---
5151
Niue,Commerce and public services,---,---,---,*1,---,---,---,*5,---,*6,---
5252
Niue,Households,---,---,---,*2,---,*0,---,*5,*16,*23,*16
5353
Niue,Other consumption n.e.s,---,---,---,---,---,---,---,---,---,---,---
54-
Niue,Non-energy use,---,---,---,---,---,---,---,---,---,---,---
54+
Niue,Non-energy use,---,---,---,---,---,---,---,---,---,---,---

Data/EnergyBalance/2019/all_countries_df.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@
582582
580,Micronesia,Households,0,0,0,0,0,4,0,61,0,64,4,0,0,4
583583
581,Micronesia,Other consumption n.e.s,0,0,0,45,0,11,0,0,0,56,11,0,45,56
584584
582,Micronesia,Non-energy use,0,0,0,92,0,0,0,0,0,92,0,0,92,92
585-
583,Niue,Primary production,0,0,0,0,0,1,0,2,16,18,18,0,0,17
585+
583,Niue,Primary production,0,0,0,0,0,1,0,2,15,18,18,0,0,17
586586
584,Niue,Imports,0,0,0,110,0,0,0,0,0,110,0,0,110,110
587587
585,Niue,Exports,0,0,0,0,0,0,0,0,0,0,0,0,0,0
588588
586,Niue,International marine bunkers,0,0,0,0,0,0,0,0,0,0,0,0,0,0

Data/SummaryTable.csv

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
Country / Territory,Political Status,Land area (km2),Population,Area per person (m2),Population density (Person/km2),GDP ($Million),GDP Per Capita ($),Geographic Type,No. islands,No. inhab. island
2-
American Samoa,US territory,240,"45,443","5,176",193,658,14480,High islands + atolls,7,6
3-
Cook Islands,Independent. NZ-affiliated,180,"17,459","10,310",97,300,17183,High islands + atolls,15,13
4-
Federated States of Micronesia,Independent. US-affiliated,702,"104,468","6,720",149,390,3733,High islands + atolls,607,65
5-
Fiji,Independent,"18,376","929,276","19,775",51,"12,180",13107,High islands + atolls,330,110
6-
French Polynesia,French Territory,"3,521","275,918","12,761",78,"5,490",19897,High islands + atolls,118,67
7-
Guam,US territory,549,"168,801","3,252",307,6,34,High islands,1,1
8-
Kiribati,Independent,726,"119,000","6,101",164,270,2269,Atolls,33,21
9-
Marshall Islands,Independent. US-affiliated,720,"58,413","12,326",81,240,4109,Atolls,34,24
10-
Nauru,Independent,21,"10,670","1,968",508,150,14058,Raised coral island,1,1
11-
Niue,Independent. NZ-affiliated,258,"1,620","159,259",6,10,6235,Raised coral island,1,1
12-
Palau,Independent. US-affiliated,475,"17,907","26,526",38,320,17870,High islands + atolls,1,1
13-
PNG,Independent,"461,690","8,935,000","51,672",19,"38,170",4272,High islands + atolls,600,No data
14-
Solomon Islands,Independent,"29,785","652,857","45,623",22,"1,780",2726,High islands + atolls,992,347
15-
Tokelau,NZ territory,12,"1,500","8,000",125,8,5333,Atolls,3,3
16-
Tonga,Independent,696,"100,651","6,915",145,670,6657,High islands,169,36
17-
Tuvalu,Independent,26,"11,646","2,233",448,50,4293,Atolls,9,8
18-
Vanuatu,Independent,"12,189","307,815","39,598",25,930,3021,High islands + atolls,83,65
19-
Samoa,Independent,"2,934","202,506","14,488",69,"1,280",6321,High islands,12,4
20-
New Caledonia,French Territory,"18,275","297,160","61,499",16,11,37,No Data,55,No data
1+
Country / Territory,Political Status,Land area (km2),Population,Area per person (m2),Population density (Person/km2),GDP Per Capita ($),Geographic Type,No. islands,No. inhab. island
2+
American Samoa,US territory,240,"45,443","5,176",193,14480,High islands + atolls,7,6
3+
Cook Islands,Independent. NZ-affiliated,180,"17,459","10,310",97,16700,High islands + atolls,15,13
4+
Micronesia,Independent. US-affiliated,702,"104,468","6,720",149,3500,High islands + atolls,607,65
5+
Fiji,Independent,"18,376","929,276","19,775",51,11000,High islands + atolls,330,110
6+
French Polynesia,French Territory,"3,521","275,918","12,761",78,17000,High islands + atolls,118,67
7+
Guam,US territory,549,"168,801","3,252",307,35600,High islands,1,1
8+
Kiribati,Independent,726,"119,000","6,101",164,2300,Atolls,33,21
9+
Marshall Islands,Independent. US-affiliated,720,"58,413","12,326",81,4000,Atolls,34,24
10+
Nauru,Independent,21,"10,670","1,968",508,13500,Raised coral island,1,1
11+
Niue,Independent. NZ-affiliated,258,"1,620","159,259",6,5800,Raised coral island,1,1
12+
Palau,Independent. US-affiliated,475,"17,907","26,526",38,17600,High islands + atolls,1,1
13+
PNG,Independent,"461,690","8,935,000","51,672",19,4200,High islands + atolls,600,No data
14+
Solomon Islands,Independent,"29,785","652,857","45,623",22,2500,High islands + atolls,992,347
15+
Tokelau,NZ territory,12,"1,500","8,000",125,60004,Atolls,3,3
16+
Tonga,Independent,696,"100,651","6,915",145,6400,High islands,169,36
17+
Tuvalu,Independent,26,"11,646","2,233",448,4400,Atolls,9,8
18+
Vanuatu,Independent,"12,189","307,815","39,598",25,2800,High islands + atolls,83,65
19+
Samoa,Independent,"2,934","202,506","14,488",69,6300,High islands,12,4
20+
New Caledonia,French Territory,"18,275","297,160","61,499",16,31100,No Data,55,No data

DecarbonizationFunctions.py

+194-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,201 @@
11
import pandas as pd
22
import functions
3-
def calculate_community_battery_size(country,residential_battery_capacity,demand_scenario="Decarbonization", total_storage_days = 5):
4-
demand = functions.fetch_single_country_demand(Country=country,Year=2019)
5-
if demand_scenario == "World average":
6-
demand = demand * 0.8
7-
daily_average_demand = demand/365
8-
total_storage_capacity_GWh = total_storage_days * daily_average_demand
9-
community_storage_capacity = total_storage_capacity_GWh - residential_battery_capacity
3+
from EnergyFlows import Country_List
4+
def calculate_community_battery_size(demand,residential_battery_capacity,technical_pot,total_storage_days = 5):
5+
average_daily_demand = demand/365 #GWH/day
6+
if demand <= technical_pot:
7+
total_storage_capacity_GWh = average_daily_demand * total_storage_days
8+
elif demand > technical_pot:
9+
total_storage_capacity_GWh = (average_daily_demand * total_storage_days)*(technical_pot/demand)
10+
community_battery = max(total_storage_capacity_GWh - residential_battery_capacity,0)
1011

11-
return community_storage_capacity
12+
return community_battery
1213

14+
def calculate_demand(country,demand_scenario):
15+
if demand_scenario == "Decarbonization":
16+
demand = functions.fetch_single_country_demand(Country=country,Year=2019)[0]
17+
elif demand_scenario == "Electrification":
18+
demand = functions.fetch_single_country_demand(Country=country, Year=2019)[1]
19+
elif demand_scenario == "Net_zero":
20+
demand = functions.fetch_single_country_demand(Country=country, Year=2019)[2]
1321

22+
return demand
1423

15-
def run_decarbonization_scenario():
16-
pass
24+
def calculate_renewable_technical_potential(country,available_land,avaialble_coastline,avaialble_buildings=0.3,PV_size=2.5):
25+
technical_potential_df = functions.calculate_PV_Wind_potential(available_land=available_land, available_coastline=avaialble_coastline)
26+
PV_technical_potential = technical_potential_df[technical_potential_df['Country'] == country]['PV_technical_GWh'].values[0]
27+
Wind_technical_potential = technical_potential_df[technical_potential_df['Country'] == country]['Wind_technical_GWh'].values[0]
1728

18-
calculate_community_battery_size("PNG",5)
29+
rooftop_df = functions.calculate_rooftop_PV_potential(available_buildings=avaialble_buildings,PV_size=PV_size)
30+
rooftop_potential = rooftop_df[rooftop_df['Country'] == country]['Generation_GWh'].values[0]
31+
# print(PV_technical_potential,Wind_technical_potential,rooftop_potential)
32+
33+
total = PV_technical_potential + Wind_technical_potential + rooftop_potential
34+
return {"PV_tech_GWh":PV_technical_potential,"Wind_tech_GWh":Wind_technical_potential,"Rooftop_GWh":rooftop_potential,"Total":total}
35+
36+
def calculate_capacity_of_each_technology(country,dic_potential,demand):
37+
38+
rooftop_PV_GWh = min(dic_potential["Rooftop_GWh"],demand)
39+
rooftop_PV_GWh = max(0,rooftop_PV_GWh)
40+
41+
large_PV_GWh = min(dic_potential["PV_tech_GWh"],demand-rooftop_PV_GWh)
42+
large_PV_GWh = max(0,large_PV_GWh)
43+
44+
wind_GWh = min(dic_potential["Wind_tech_GWh"],demand-rooftop_PV_GWh-large_PV_GWh)
45+
wind_GWh = max(0,wind_GWh)
46+
47+
df_potentials = pd.read_excel('Data/Potentials.xlsx')
48+
PV_pot = df_potentials.iloc[0, 2:] #GWh/MW/year
49+
Wind_pot =df_potentials.iloc[2, 2:] #GWh/MW/year
50+
51+
PV_pot = PV_pot[country]
52+
Wind_pot = Wind_pot[country]
53+
# print(PV_pot[country])
54+
55+
rooftop_MW = rooftop_PV_GWh/PV_pot #MW
56+
large_PV_MW = large_PV_GWh/PV_pot #MW
57+
58+
wind_MW = wind_GWh/Wind_pot
59+
60+
total_GWh = wind_GWh + large_PV_GWh + rooftop_PV_GWh
61+
62+
community_battery = calculate_community_battery_size(demand=demand,residential_battery_capacity = rooftop_MW*2/1000,technical_pot=total_GWh,total_storage_days=5 )
63+
64+
return {"Rooftop_MW":rooftop_MW,"Large_PV_MW":large_PV_MW,"Wind_MW":wind_MW,"residential_battery_MWh":rooftop_MW*2,"total_GWh":total_GWh,"Community_battery_GWh":community_battery}
65+
66+
67+
def create_yearly_df(country,decarb_year,capacity_dic,cost_dic,diesel_price,inflation_rate, discount_rate):
68+
from datetime import datetime
69+
now = datetime.now().year
70+
number_of_years = decarb_year - 2022
71+
year_list = []
72+
installation_df = pd.DataFrame()
73+
74+
for i in range(0, 31):
75+
now += 1
76+
year_list.append(now)
77+
78+
# community_battery = calculate_community_battery_size(demand=)
79+
installation_df['Year'] = year_list
80+
installation_df['rooftop_MW'] = capacity_dic["Rooftop_MW"]/number_of_years
81+
installation_df['resid_battery_MW'] = installation_df['rooftop_MW'] * 2
82+
installation_df['PV_MW'] = capacity_dic["Large_PV_MW"]/number_of_years
83+
installation_df['wind_MW'] = capacity_dic["Wind_MW"]/number_of_years
84+
installation_df["Community_battery_GWh"] = capacity_dic['Community_battery_GWh']/number_of_years
85+
86+
installation_df.loc[number_of_years:,'rooftop_MW'] = 0
87+
installation_df.loc[number_of_years:,'resid_battery_MW'] = 0
88+
installation_df.loc[number_of_years:,'PV_MW'] = 0
89+
installation_df.loc[number_of_years:,'wind_MW'] = 0
90+
installation_df.loc[number_of_years:,"Community_battery_GWh"] = 0
91+
92+
# costs are $/W - 1000000/MW
93+
# The output is #$
94+
installation_df['installation_Cost'] = (installation_df['rooftop_MW'] * cost_dic['rooftop'] +
95+
installation_df['resid_battery_MW'] *cost_dic['resid_battery'] +
96+
installation_df['Community_battery_GWh']*1000 *cost_dic['resid_battery'] +
97+
installation_df['PV_MW'] * cost_dic['large_PV'] +\
98+
installation_df['wind_MW'] * cost_dic['wind'])*1000000#Convert to $/MW #in the cost dic, are costs are $/W
99+
100+
101+
installation_df['avoided_demand_GWh'] = capacity_dic["total_GWh"]/number_of_years
102+
installation_df.loc[number_of_years:,'avoided_demand_GWh'] = 0
103+
104+
diesel_efficiency = 0.4
105+
106+
diesel_generatio = 2.5 #kWh/Liter
107+
installation_df["avoided_diesel_liter"] = installation_df["avoided_demand_GWh"] / (2.5/1000000)
108+
installation_df["cumulative_avoided_diesel_liter"] = installation_df["avoided_diesel_liter"].cumsum(axis=0)
109+
installation_df["avoided_diesel_savings"] = installation_df["cumulative_avoided_diesel_liter"] * diesel_price
110+
111+
if country =="New Caledonia":
112+
#coal price is 400 USD/Tonne
113+
# 47% demand is met by diesel, and 53% by coal
114+
# 0.00814 GWh energy in one tonne coal.
115+
installation_df["avoided_diesel_liter"] = installation_df["avoided_diesel_liter"]*0.47
116+
installation_df["avoided_coal_tonne"] = (installation_df["avoided_demand_GWh"]*0.53)/(0.00814 * 0.35)
117+
118+
installation_df["cumulative_avoided_diesel_liter"] = installation_df["avoided_diesel_liter"].cumsum(axis=0)
119+
installation_df["cumulative_avoided_coal_tonne"] = installation_df["avoided_coal_tonne"].cumsum(axis=0)
120+
121+
installation_df["avoided_diesel_savings"] = installation_df["cumulative_avoided_diesel_liter"] * diesel_price
122+
installation_df["avoided_coal_savings"] = installation_df["cumulative_avoided_coal_tonne"] * 400
123+
installation_df["avoided_diesel_savings"] = installation_df["avoided_diesel_savings"] + installation_df["avoided_coal_savings"]
124+
125+
installation_df['Cumulative_avoided_cost'] = installation_df['avoided_diesel_savings'].cumsum(axis=0)
126+
127+
inflation_rate = inflation_rate/100
128+
discount_rate = discount_rate/100
129+
130+
for i, row in installation_df.iterrows():
131+
installation_df.at[i, 'Cumulative_avoided_cost'] = installation_df.at[i, 'Cumulative_avoided_cost'] * ((1+inflation_rate)/(1+discount_rate))**i
132+
installation_df.at[i, 'installation_Cost'] = installation_df.at[i, 'installation_Cost'] * ((1+inflation_rate)/(1+discount_rate))**i
133+
134+
installation_df['Annual_Net_saving'] = installation_df['Cumulative_avoided_cost'] - installation_df['installation_Cost'] # $MM
135+
installation_df["Cumulative_net_saving"] = installation_df['Annual_Net_saving'].cumsum(axis=0)
136+
137+
return installation_df
138+
# demand_df['Net_saving_discounted'] = 0
139+
# demand_df['Emission_red_saving_discounted'] = 0
140+
# inflation_rate = inflation_rate/100
141+
# discount_rate = discount_rate/100
142+
143+
def calculate_diesel_price(country):
144+
diesel_df = pd.read_csv("Data/Diesel.csv")
145+
if country in diesel_df["Country"].to_list():
146+
print("Hi")
147+
diesel_price = diesel_df[diesel_df['Country'] == country]['Tax included'].values[0]
148+
else:
149+
diesel_price = diesel_df['Tax included'].mean()
150+
151+
diesel_price = diesel_price-20 #20c less than retails price
152+
diesel_price = diesel_price/100 # convert to $ from cents
153+
154+
print(diesel_price)
155+
return diesel_price
156+
157+
158+
def run_decarbonization_scenario(cost_scenario,country_list,demand_scenario="Decarbonization",available_land=0.02, avaialble_coastline=0.1,avaialble_buildings=0.3,PV_size=2.5,decarb_year=2030):
159+
# demand_scenario = ["Decarbonization","Electrification","Net_zero"]
160+
costs= {"optimistic":{"rooftop":3,"resid_battery":4,"large_PV":3,"wind":3},"pessimistic":{"rooftop":4.5,"resid_battery":4,"large_PV":4.5,"wind":6}}
161+
all_countries_result = pd.DataFrame()
162+
all_countries_result['Technology'] =["Rooftop_MW", "Large_PV_MW","Wind_MW","Residential_battery_MWh","Community_battery_GWh","total_GWh",'Payback period (years)']
163+
# : rooftop_MW, : large_PV_MW, : wind_MW, : total_GWh, : community_battery
164+
# cost_dic = {"rooftop":4.5,"resid_battery":4,"large_PV":4.5,"wind":6}#Pessimistic
165+
# cost_dic = {"rooftop":3,"resid_battery":4,"large_PV":3,"wind":3}#Optimistic
166+
cost_dic = costs[cost_scenario]
167+
for country in country_list:
168+
diesel_price = calculate_diesel_price(country)
169+
pot = calculate_renewable_technical_potential(country, available_land=available_land, avaialble_coastline=avaialble_coastline,avaialble_buildings=avaialble_buildings,PV_size=PV_size)
170+
demand = calculate_demand(country, demand_scenario)
171+
capacity_dic = calculate_capacity_of_each_technology(country, pot, demand)
172+
final_df = create_yearly_df(country=country,decarb_year=decarb_year,capacity_dic=capacity_dic,cost_dic=cost_dic,diesel_price=diesel_price,inflation_rate=3,discount_rate=7)
173+
final_df.to_csv("Results/{}/Simulation_result_{}.csv".format(demand_scenario,country))
174+
175+
payback_period = final_df[final_df.Cumulative_net_saving < 0].index.values.max()
176+
177+
all_countries_result[country] = [capacity_dic["Rooftop_MW"],
178+
capacity_dic["Large_PV_MW"],
179+
capacity_dic["Wind_MW"],
180+
capacity_dic["residential_battery_MWh"],
181+
capacity_dic["Community_battery_GWh"],
182+
capacity_dic["total_GWh"],
183+
payback_period
184+
]
185+
186+
all_countries_result.reset_index(drop=True,inplace=True)
187+
# all_countries_result = all_countries_result.pivot(columns="Technology",index=all_countries_result.columns)[all_countries_result.columns]
188+
189+
all_countries_result.to_excel("Results/{}/{}_simulation_result_{}_wind_{}_PV_{}.xlsx".format(demand_scenario,cost_scenario,demand_scenario,avaialble_coastline,available_land))
190+
# print(all_countries_result.head())
191+
return final_df
192+
193+
for cost_scenario in ["optimistic",'pessimistic']:
194+
for demand_sceanrio in ['Decarbonization',"Electrification","Net_zero"]:
195+
run_decarbonization_scenario(cost_scenario=cost_scenario,country_list=Country_List,
196+
demand_scenario=demand_sceanrio,available_land=0.1,
197+
avaialble_coastline=0,avaialble_buildings=0.3,
198+
PV_size=2.5,decarb_year=2030)
199+
200+
201+
#check community battery

0 commit comments

Comments
 (0)