-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ce0a1f
commit 370ca1d
Showing
9 changed files
with
711 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
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 | ||
American Samoa,US territory,240,"45,443","5,176",193,658,14480,High islands + atolls,7,6 | ||
Cook Islands,Independent. NZ-affiliated,180,"17,459","10,310",97,300,17183,High islands + atolls,15,13 | ||
Federated States of Micronesia,Independent. US-affiliated,702,"104,468","6,720",149,390,3733,High islands + atolls,607,65 | ||
Fiji,Independent,"18,376","929,276","19,775",51,"12,180",13107,High islands + atolls,330,110 | ||
French Polynesia,French Territory,"3,521","275,918","12,761",78,"5,490",19897,High islands + atolls,118,67 | ||
Guam,US territory,549,"168,801","3,252",307,6,34,High islands,1,1 | ||
Kiribati,Independent,726,"119,000","6,101",164,270,2269,Atolls,33,21 | ||
Marshall Islands,Independent. US-affiliated,720,"58,413","12,326",81,240,4109,Atolls,34,24 | ||
Nauru,Independent,21,"10,670","1,968",508,150,14058,Raised coral island,1,1 | ||
Niue,Independent. NZ-affiliated,258,"1,620","159,259",6,10,6235,Raised coral island,1,1 | ||
Palau,Independent. US-affiliated,475,"17,907","26,526",38,320,17870,High islands + atolls,1,1 | ||
PNG,Independent,"461,690","8,935,000","51,672",19,"38,170",4272,High islands + atolls,600,No data | ||
Solomon Islands,Independent,"29,785","652,857","45,623",22,"1,780",2726,High islands + atolls,992,347 | ||
Tokelau,NZ territory,12,"1,500","8,000",125,8,5333,Atolls,3,3 | ||
Tonga,Independent,696,"100,651","6,915",145,670,6657,High islands,169,36 | ||
Tuvalu,Independent,26,"11,646","2,233",448,50,4293,Atolls,9,8 | ||
Vanuatu,Independent,"12,189","307,815","39,598",25,930,3021,High islands + atolls,83,65 | ||
Samoa,Independent,"2,934","202,506","14,488",69,"1,280",6321,High islands,12,4 | ||
New Caledonia,French Territory,"18,275","297,160","61,499",16,11,37,No Data,55,No data | ||
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 | ||
American Samoa,US territory,240,"45,443","5,176",193,14480,High islands + atolls,7,6 | ||
Cook Islands,Independent. NZ-affiliated,180,"17,459","10,310",97,16700,High islands + atolls,15,13 | ||
Micronesia,Independent. US-affiliated,702,"104,468","6,720",149,3500,High islands + atolls,607,65 | ||
Fiji,Independent,"18,376","929,276","19,775",51,11000,High islands + atolls,330,110 | ||
French Polynesia,French Territory,"3,521","275,918","12,761",78,17000,High islands + atolls,118,67 | ||
Guam,US territory,549,"168,801","3,252",307,35600,High islands,1,1 | ||
Kiribati,Independent,726,"119,000","6,101",164,2300,Atolls,33,21 | ||
Marshall Islands,Independent. US-affiliated,720,"58,413","12,326",81,4000,Atolls,34,24 | ||
Nauru,Independent,21,"10,670","1,968",508,13500,Raised coral island,1,1 | ||
Niue,Independent. NZ-affiliated,258,"1,620","159,259",6,5800,Raised coral island,1,1 | ||
Palau,Independent. US-affiliated,475,"17,907","26,526",38,17600,High islands + atolls,1,1 | ||
PNG,Independent,"461,690","8,935,000","51,672",19,4200,High islands + atolls,600,No data | ||
Solomon Islands,Independent,"29,785","652,857","45,623",22,2500,High islands + atolls,992,347 | ||
Tokelau,NZ territory,12,"1,500","8,000",125,60004,Atolls,3,3 | ||
Tonga,Independent,696,"100,651","6,915",145,6400,High islands,169,36 | ||
Tuvalu,Independent,26,"11,646","2,233",448,4400,Atolls,9,8 | ||
Vanuatu,Independent,"12,189","307,815","39,598",25,2800,High islands + atolls,83,65 | ||
Samoa,Independent,"2,934","202,506","14,488",69,6300,High islands,12,4 | ||
New Caledonia,French Territory,"18,275","297,160","61,499",16,31100,No Data,55,No data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,201 @@ | ||
import pandas as pd | ||
import functions | ||
def calculate_community_battery_size(country,residential_battery_capacity,demand_scenario="Decarbonization", total_storage_days = 5): | ||
demand = functions.fetch_single_country_demand(Country=country,Year=2019) | ||
if demand_scenario == "World average": | ||
demand = demand * 0.8 | ||
daily_average_demand = demand/365 | ||
total_storage_capacity_GWh = total_storage_days * daily_average_demand | ||
community_storage_capacity = total_storage_capacity_GWh - residential_battery_capacity | ||
from EnergyFlows import Country_List | ||
def calculate_community_battery_size(demand,residential_battery_capacity,technical_pot,total_storage_days = 5): | ||
average_daily_demand = demand/365 #GWH/day | ||
if demand <= technical_pot: | ||
total_storage_capacity_GWh = average_daily_demand * total_storage_days | ||
elif demand > technical_pot: | ||
total_storage_capacity_GWh = (average_daily_demand * total_storage_days)*(technical_pot/demand) | ||
community_battery = max(total_storage_capacity_GWh - residential_battery_capacity,0) | ||
|
||
return community_storage_capacity | ||
return community_battery | ||
|
||
def calculate_demand(country,demand_scenario): | ||
if demand_scenario == "Decarbonization": | ||
demand = functions.fetch_single_country_demand(Country=country,Year=2019)[0] | ||
elif demand_scenario == "Electrification": | ||
demand = functions.fetch_single_country_demand(Country=country, Year=2019)[1] | ||
elif demand_scenario == "Net_zero": | ||
demand = functions.fetch_single_country_demand(Country=country, Year=2019)[2] | ||
|
||
return demand | ||
|
||
def run_decarbonization_scenario(): | ||
pass | ||
def calculate_renewable_technical_potential(country,available_land,avaialble_coastline,avaialble_buildings=0.3,PV_size=2.5): | ||
technical_potential_df = functions.calculate_PV_Wind_potential(available_land=available_land, available_coastline=avaialble_coastline) | ||
PV_technical_potential = technical_potential_df[technical_potential_df['Country'] == country]['PV_technical_GWh'].values[0] | ||
Wind_technical_potential = technical_potential_df[technical_potential_df['Country'] == country]['Wind_technical_GWh'].values[0] | ||
|
||
calculate_community_battery_size("PNG",5) | ||
rooftop_df = functions.calculate_rooftop_PV_potential(available_buildings=avaialble_buildings,PV_size=PV_size) | ||
rooftop_potential = rooftop_df[rooftop_df['Country'] == country]['Generation_GWh'].values[0] | ||
# print(PV_technical_potential,Wind_technical_potential,rooftop_potential) | ||
|
||
total = PV_technical_potential + Wind_technical_potential + rooftop_potential | ||
return {"PV_tech_GWh":PV_technical_potential,"Wind_tech_GWh":Wind_technical_potential,"Rooftop_GWh":rooftop_potential,"Total":total} | ||
|
||
def calculate_capacity_of_each_technology(country,dic_potential,demand): | ||
|
||
rooftop_PV_GWh = min(dic_potential["Rooftop_GWh"],demand) | ||
rooftop_PV_GWh = max(0,rooftop_PV_GWh) | ||
|
||
large_PV_GWh = min(dic_potential["PV_tech_GWh"],demand-rooftop_PV_GWh) | ||
large_PV_GWh = max(0,large_PV_GWh) | ||
|
||
wind_GWh = min(dic_potential["Wind_tech_GWh"],demand-rooftop_PV_GWh-large_PV_GWh) | ||
wind_GWh = max(0,wind_GWh) | ||
|
||
df_potentials = pd.read_excel('Data/Potentials.xlsx') | ||
PV_pot = df_potentials.iloc[0, 2:] #GWh/MW/year | ||
Wind_pot =df_potentials.iloc[2, 2:] #GWh/MW/year | ||
|
||
PV_pot = PV_pot[country] | ||
Wind_pot = Wind_pot[country] | ||
# print(PV_pot[country]) | ||
|
||
rooftop_MW = rooftop_PV_GWh/PV_pot #MW | ||
large_PV_MW = large_PV_GWh/PV_pot #MW | ||
|
||
wind_MW = wind_GWh/Wind_pot | ||
|
||
total_GWh = wind_GWh + large_PV_GWh + rooftop_PV_GWh | ||
|
||
community_battery = calculate_community_battery_size(demand=demand,residential_battery_capacity = rooftop_MW*2/1000,technical_pot=total_GWh,total_storage_days=5 ) | ||
|
||
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} | ||
|
||
|
||
def create_yearly_df(country,decarb_year,capacity_dic,cost_dic,diesel_price,inflation_rate, discount_rate): | ||
from datetime import datetime | ||
now = datetime.now().year | ||
number_of_years = decarb_year - 2022 | ||
year_list = [] | ||
installation_df = pd.DataFrame() | ||
|
||
for i in range(0, 31): | ||
now += 1 | ||
year_list.append(now) | ||
|
||
# community_battery = calculate_community_battery_size(demand=) | ||
installation_df['Year'] = year_list | ||
installation_df['rooftop_MW'] = capacity_dic["Rooftop_MW"]/number_of_years | ||
installation_df['resid_battery_MW'] = installation_df['rooftop_MW'] * 2 | ||
installation_df['PV_MW'] = capacity_dic["Large_PV_MW"]/number_of_years | ||
installation_df['wind_MW'] = capacity_dic["Wind_MW"]/number_of_years | ||
installation_df["Community_battery_GWh"] = capacity_dic['Community_battery_GWh']/number_of_years | ||
|
||
installation_df.loc[number_of_years:,'rooftop_MW'] = 0 | ||
installation_df.loc[number_of_years:,'resid_battery_MW'] = 0 | ||
installation_df.loc[number_of_years:,'PV_MW'] = 0 | ||
installation_df.loc[number_of_years:,'wind_MW'] = 0 | ||
installation_df.loc[number_of_years:,"Community_battery_GWh"] = 0 | ||
|
||
# costs are $/W - 1000000/MW | ||
# The output is #$ | ||
installation_df['installation_Cost'] = (installation_df['rooftop_MW'] * cost_dic['rooftop'] + | ||
installation_df['resid_battery_MW'] *cost_dic['resid_battery'] + | ||
installation_df['Community_battery_GWh']*1000 *cost_dic['resid_battery'] + | ||
installation_df['PV_MW'] * cost_dic['large_PV'] +\ | ||
installation_df['wind_MW'] * cost_dic['wind'])*1000000#Convert to $/MW #in the cost dic, are costs are $/W | ||
|
||
|
||
installation_df['avoided_demand_GWh'] = capacity_dic["total_GWh"]/number_of_years | ||
installation_df.loc[number_of_years:,'avoided_demand_GWh'] = 0 | ||
|
||
diesel_efficiency = 0.4 | ||
|
||
diesel_generatio = 2.5 #kWh/Liter | ||
installation_df["avoided_diesel_liter"] = installation_df["avoided_demand_GWh"] / (2.5/1000000) | ||
installation_df["cumulative_avoided_diesel_liter"] = installation_df["avoided_diesel_liter"].cumsum(axis=0) | ||
installation_df["avoided_diesel_savings"] = installation_df["cumulative_avoided_diesel_liter"] * diesel_price | ||
|
||
if country =="New Caledonia": | ||
#coal price is 400 USD/Tonne | ||
# 47% demand is met by diesel, and 53% by coal | ||
# 0.00814 GWh energy in one tonne coal. | ||
installation_df["avoided_diesel_liter"] = installation_df["avoided_diesel_liter"]*0.47 | ||
installation_df["avoided_coal_tonne"] = (installation_df["avoided_demand_GWh"]*0.53)/(0.00814 * 0.35) | ||
|
||
installation_df["cumulative_avoided_diesel_liter"] = installation_df["avoided_diesel_liter"].cumsum(axis=0) | ||
installation_df["cumulative_avoided_coal_tonne"] = installation_df["avoided_coal_tonne"].cumsum(axis=0) | ||
|
||
installation_df["avoided_diesel_savings"] = installation_df["cumulative_avoided_diesel_liter"] * diesel_price | ||
installation_df["avoided_coal_savings"] = installation_df["cumulative_avoided_coal_tonne"] * 400 | ||
installation_df["avoided_diesel_savings"] = installation_df["avoided_diesel_savings"] + installation_df["avoided_coal_savings"] | ||
|
||
installation_df['Cumulative_avoided_cost'] = installation_df['avoided_diesel_savings'].cumsum(axis=0) | ||
|
||
inflation_rate = inflation_rate/100 | ||
discount_rate = discount_rate/100 | ||
|
||
for i, row in installation_df.iterrows(): | ||
installation_df.at[i, 'Cumulative_avoided_cost'] = installation_df.at[i, 'Cumulative_avoided_cost'] * ((1+inflation_rate)/(1+discount_rate))**i | ||
installation_df.at[i, 'installation_Cost'] = installation_df.at[i, 'installation_Cost'] * ((1+inflation_rate)/(1+discount_rate))**i | ||
|
||
installation_df['Annual_Net_saving'] = installation_df['Cumulative_avoided_cost'] - installation_df['installation_Cost'] # $MM | ||
installation_df["Cumulative_net_saving"] = installation_df['Annual_Net_saving'].cumsum(axis=0) | ||
|
||
return installation_df | ||
# demand_df['Net_saving_discounted'] = 0 | ||
# demand_df['Emission_red_saving_discounted'] = 0 | ||
# inflation_rate = inflation_rate/100 | ||
# discount_rate = discount_rate/100 | ||
|
||
def calculate_diesel_price(country): | ||
diesel_df = pd.read_csv("Data/Diesel.csv") | ||
if country in diesel_df["Country"].to_list(): | ||
print("Hi") | ||
diesel_price = diesel_df[diesel_df['Country'] == country]['Tax included'].values[0] | ||
else: | ||
diesel_price = diesel_df['Tax included'].mean() | ||
|
||
diesel_price = diesel_price-20 #20c less than retails price | ||
diesel_price = diesel_price/100 # convert to $ from cents | ||
|
||
print(diesel_price) | ||
return diesel_price | ||
|
||
|
||
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): | ||
# demand_scenario = ["Decarbonization","Electrification","Net_zero"] | ||
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}} | ||
all_countries_result = pd.DataFrame() | ||
all_countries_result['Technology'] =["Rooftop_MW", "Large_PV_MW","Wind_MW","Residential_battery_MWh","Community_battery_GWh","total_GWh",'Payback period (years)'] | ||
# : rooftop_MW, : large_PV_MW, : wind_MW, : total_GWh, : community_battery | ||
# cost_dic = {"rooftop":4.5,"resid_battery":4,"large_PV":4.5,"wind":6}#Pessimistic | ||
# cost_dic = {"rooftop":3,"resid_battery":4,"large_PV":3,"wind":3}#Optimistic | ||
cost_dic = costs[cost_scenario] | ||
for country in country_list: | ||
diesel_price = calculate_diesel_price(country) | ||
pot = calculate_renewable_technical_potential(country, available_land=available_land, avaialble_coastline=avaialble_coastline,avaialble_buildings=avaialble_buildings,PV_size=PV_size) | ||
demand = calculate_demand(country, demand_scenario) | ||
capacity_dic = calculate_capacity_of_each_technology(country, pot, demand) | ||
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) | ||
final_df.to_csv("Results/{}/Simulation_result_{}.csv".format(demand_scenario,country)) | ||
|
||
payback_period = final_df[final_df.Cumulative_net_saving < 0].index.values.max() | ||
|
||
all_countries_result[country] = [capacity_dic["Rooftop_MW"], | ||
capacity_dic["Large_PV_MW"], | ||
capacity_dic["Wind_MW"], | ||
capacity_dic["residential_battery_MWh"], | ||
capacity_dic["Community_battery_GWh"], | ||
capacity_dic["total_GWh"], | ||
payback_period | ||
] | ||
|
||
all_countries_result.reset_index(drop=True,inplace=True) | ||
# all_countries_result = all_countries_result.pivot(columns="Technology",index=all_countries_result.columns)[all_countries_result.columns] | ||
|
||
all_countries_result.to_excel("Results/{}/{}_simulation_result_{}_wind_{}_PV_{}.xlsx".format(demand_scenario,cost_scenario,demand_scenario,avaialble_coastline,available_land)) | ||
# print(all_countries_result.head()) | ||
return final_df | ||
|
||
for cost_scenario in ["optimistic",'pessimistic']: | ||
for demand_sceanrio in ['Decarbonization',"Electrification","Net_zero"]: | ||
run_decarbonization_scenario(cost_scenario=cost_scenario,country_list=Country_List, | ||
demand_scenario=demand_sceanrio,available_land=0.1, | ||
avaialble_coastline=0,avaialble_buildings=0.3, | ||
PV_size=2.5,decarb_year=2030) | ||
|
||
|
||
#check community battery |
Oops, something went wrong.