Skip to content

Commit

Permalink
In Paris
Browse files Browse the repository at this point in the history
  • Loading branch information
ShayanNaderi committed Oct 10, 2022
1 parent 2ce7262 commit c15ef4f
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 58 deletions.
18 changes: 10 additions & 8 deletions Decarbonization.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,11 @@ def generate_card_deck_2():
generate_select('carbon-price', "Carbon price: $/ton", 0, 100, 0.1, 30),
dbc.Label("RE size and installation cost"),

generate_select('PV-cost',"Large scale PV: $/W",0.5,5,0.1,3),
generate_select('PV-battery-cost',"Small PV+B: $/W",1,15,0.1,7),
generate_select('wind-large-cost',"Large scale wind: $/W",1,5,0.1,3),
generate_select('PV-cost',"Large scale PV: $/W",0.5,8,0.1,4.5),
generate_select('PV-battery-cost',"Rooftop PV: $/W",1,15,0.1,4.5),
generate_select('small-battery-cost', "Residential Battery: $/W", 1, 15, 0.1, 4),

generate_select('wind-large-cost',"Large scale wind: $/W",1,8,0.1,6),
generate_select('wind-battery-cost',"Small Wind+B: $/W",2.5,12,0.1,6),
generate_select('rooftop-size', "Rooftop PV size: kW", 0.5, 5, 0.1,
2.5),
Expand All @@ -312,8 +314,8 @@ def generate_card_deck_2():
),
]
),
generate_select('ComBattery-MWh', "Battery size (MWh):", 0, 10000, 0.5, 3),
generate_select('ComBattery-cost', "Cost(M$/MWh):", 0, 10, 0.05, 2),
generate_select('ComBattery-MWh', "Battery size (MWh):", 0, 50000, 0.5, 3),
generate_select('ComBattery-cost', "Cost(M$/MWh):", 0, 10, 0.05, 3),
html.Div(
[
dbc.Label("Geothermal parameters"),
Expand All @@ -328,7 +330,7 @@ def generate_card_deck_2():
]
),

generate_select('geothermal-MW', "Geothermal (MW):", 0, 4000, 1, 25),
generate_select('geothermal-MW', "Geothermal (MW):", 0, 4000, 1, 0),
generate_select('geothermal-completion', "Completion year:", 2022, 2050, 1, 2035),
generate_select('geothermal-cost', "Geothermal cost (M$/MW):", 0.5, 10,
0.1, 5),
Expand All @@ -340,14 +342,14 @@ def generate_card_deck_2():
html.Br(),

generate_select('small-PV-share', "PV+B to all PV: %", 0, 100, 5, 40),
generate_select('small-wind-share', "Wind+B to all Wind: %", 0, 100, 5, 40),
generate_select('small-wind-share', "Wind+B to all Wind: %", 0, 100, 5, 0),

generate_select('demand-growth', "Demand growth: %/year", 0, 100, 1,
2),
generate_select('decarb-year', "100% RE target:", 2022, 2060, 1,
2030),
generate_select('discount-rate', "Discount rate: %", 0, 100, 1,
6),
7),
generate_select('inflation-rate', "Inflation rate: %", 0, 100, 1,
3),

Expand Down
61 changes: 28 additions & 33 deletions Summary.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
from dash import html
from dash import dcc
import dash_bootstrap_components as dbc
import figures
import EnergyFlows

from app import app
import pandas as pd
import dash
import os
# import dash_daq as daq
import dash_daq as daq
from EnergyFlows import figure_border_style
from EnergyFlows import Year_List
from EnergyFlows import CONTENT_STYLE
import EnergyFlows
from dash import dash_table
import plotly.figure_factory as ff

import figures
summary_df = pd.read_csv('Data/SummaryTable.csv')
table = dbc.Table.from_dataframe(summary_df, striped=False, bordered=True, hover=True,style={'color':'white','fontSize':'18'},responsive=True)
# table = dbc.Table(summary_df, striped=False, bordered=True, hover=True,style={'color':'white'},responsive=True)
# table = ff.create_table(summary_df, height_constant=1500)

table = dbc.Table.from_dataframe(summary_df, striped=True, bordered=True, hover=True,style={'color':'red'},responsive=True)

dataTable = dash_table.DataTable(
data=summary_df.to_dict('records'),
Expand All @@ -29,31 +23,29 @@
},
style_as_list_view=False,
style_header={
'padding': '5px',
'backgroundColor': 'rgb(30, 30, 30)',
'fontWeight': 'bold',
'border': '1px solid grey',
'textAlign': 'left',
'height': 'auto',
'overflow': 'hidden',
'textOverflow': 'ellipsis',
'whiteSpace': 'normal',
# 'textAlign': 'left',
},
style_data={ 'border': '1px solid grey', 'whiteSpace': 'normal',
'height': 'auto',},
style_cell_conditional=[ # style_cell_c. refers to the whole table
{
'if': {'column_id': 'Country / Territory'},
'textAlign': 'left'
}
],

style_table={
'width': '100%',
'margin': '0 0 0 0px',
'padding': '0 0px',
'overflowX': 'auto',
'overflowY': 'auto',
},
style_data={ 'border': '0.15px solid white' },#ff4d4d
# style_cell_conditional=([
# {'if': {'column_id': 'Population density (Person/km2)'},
# 'width': '5%'},
# {'if': {'column_id': 'Youngest volcanism'},
# 'width': '20%'},
# {'if': {'column_id': 'Known geothermal locations'},
# 'width': '20%'},
# {'if': {'column_id': 'Geothermal investigations'},
# 'width': '15%'},
# {'if': {'column_id': 'Observed hot spring temperature'},
# 'width': '20%'},
# {'if': {'column_id': 'Potentials'},
# 'width': '17.5%'}]),
# fixed_rows={'data': 0},
fixed_columns={'headers': True, 'data': 0}, # 'headers': True,

)
Transit = [
Expand Down Expand Up @@ -93,7 +85,7 @@
dbc.Col(html.Div(dcc.Graph(id="Oil-imports", figure=figures.UNstats_plots(2019)[3]),
style=figure_border_style), md=6),

dbc.Col(html.Div(dcc.Graph(id="transit_figure4", figure=figures.imports_to_GDP(2019)[0]),
dbc.Col(html.Div(dcc.Graph(id="imports-to-GDP", figure=figures.imports_to_GDP(2019)[0]),
style=figure_border_style), md=6),
]),
html.Br(),
Expand All @@ -103,6 +95,8 @@
dbc.Col(html.Div(dcc.Graph(id="renewables-per-capita", figure=figures.UNstats_plots(2019)[8]),
style=figure_border_style), md=6),
]),
html.Br(),

dbc.Row([
dbc.Col(html.Div(dcc.Graph(id="transit_figure3", figure=figures.UNstats_plots(2019)[2]),
style=figure_border_style), md=6),
Expand Down Expand Up @@ -141,6 +135,7 @@




BODY = dbc.Container(
[
dbc.Row([dbc.Col(dbc.Card(Transit)), ], style={"marginTop": 30,
Expand All @@ -151,4 +146,4 @@
)


content = [BODY]
content = [EnergyFlows.generate_single_year_drpdwn(),BODY]
14 changes: 6 additions & 8 deletions WindSolar.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,22 @@ def generate_single_country_drpdwn():
html.Br(),

dbc.Row([
# dbc.Col(
# html.Div(dcc.Graph(id="PV_technical_GW", figure=figures.Solar_physical_resources()[6]),
# style=figure_border_style), md=6),

dbc.Col(
html.Div(dcc.Graph(id="PV_theoretical_GW", figure=figures.Solar_physical_resources()[3]),
html.Div(dcc.Graph(id="PV_technical_GW", figure=figures.Solar_physical_resources()[6]),
style=figure_border_style), md=6),

# dbc.Col(
# html.Div(dcc.Graph(id="PV_theoretical_GW", figure=figures.Solar_physical_resources()[3]),
# style=figure_border_style), md=6),
dbc.Col(html.Div(
dcc.Graph(id="Wind_thechnical_MW", figure=figures.Solar_physical_resources()[5]),
style=figure_border_style), md=6),
]),
html.Br(),
dbc.Row([
dbc.Col(html.Div(
dcc.Graph(id="PV_technical_GWh", figure=figures.Solar_physical_resources()[7]),
style=figure_border_style), md=6),
dbc.Col(html.Div(
dcc.Graph(id="PV_technical_GWh", figure=figures.Solar_physical_resources()[4]),
style=figure_border_style), md=6),

dbc.Col(html.Div(
dcc.Graph(id="Wind_thechnical_GWh", figure=figures.Solar_physical_resources()[2]),
Expand Down
5 changes: 3 additions & 2 deletions callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def update_options(Country,style):
State("diesel_price_slider", "value"),
State("PV-cost", "value"),
State("PV-battery-cost", "value"),
State("small-battery-cost", "value"),
State("wind-battery-cost", "value"),
State("wind-large-cost", "value"),
State("demand-growth", "value"),
Expand All @@ -102,7 +103,7 @@ def update_options(Country,style):
State('switches-communityBattery', "value"),
])
def sensor_checklist(n_clicks,year,country,diesel_price,PV_cost,PVBatt_cost,WindBatt_cost,Wind_cost,demand_growth,decarb_year,rooftop_size,
def sensor_checklist(n_clicks,year,country,diesel_price,PV_cost,rooftop_PV_cost,res_batt_cost,WindBatt_cost,Wind_cost,demand_growth,decarb_year,rooftop_size,
emission_tonneperMWh, emission_dollarpertonne,
wind_share, small_PV_share,small_wind_share,
geothermal_switch,geothermal_completion_year,geothermal_MW,geothermal_CF,geothermal_CAPEX,
Expand Down Expand Up @@ -154,7 +155,7 @@ def sensor_checklist(n_clicks,year,country,diesel_price,PV_cost,PVBatt_cost,Wind
emission_cost_mdollar = round(emission_cost_mdollar, 2)
oil_supplied_cost = round(oil_supplied_cost,1)
power_generated_GWh = round(power_generated_GWh,1)
fig_lists = figures.decarbonization_scenarios(country,Efficiency/100,net_oil_product_import_ml,power_generated_GWh, demand_growth, PV_cost, PVBatt_cost,
fig_lists = figures.decarbonization_scenarios(country,Efficiency/100,net_oil_product_import_ml,power_generated_GWh, demand_growth, PV_cost, rooftop_PV_cost,res_batt_cost,
WindBatt_cost, Wind_cost, decarb_year, wind_share, small_PV_share,
small_wind_share, PV_pot, Wind_pot, diesel_HHV, diesel_price,
geothermal_switch,geothermal_completion_year,geothermal_MW,geothermal_CF,geothermal_CAPEX,
Expand Down
45 changes: 40 additions & 5 deletions figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import plotly.express as px
import functions
from EnergyFlows import Country_List
font_color = 'black'
line_color = 'black'
font_color = 'white'
line_color = 'white'

def imports_to_GDP(year):
net_imp_list= []
Expand Down Expand Up @@ -33,7 +33,7 @@ def imports_to_GDP(year):
df_GDP['net_imp_per_capita'] = df_GDP['net_imp_per_capita'].round(0)
# df_GDP['net_imp_per_capita'] = df_GDP['net_imp_per_capita']
fig = go.Figure()
fig.add_trace(go.Bar(x=df_GDP['Country'], y=df_GDP['net_imp_to_GDP'],text=df_GDP['net_imp_to_GDP'],name='dasdsa',marker_color='forestgreen'))
fig.add_trace(go.Bar(x=df_GDP['Country'], y=df_GDP['net_imp_to_GDP'],text=df_GDP['net_imp_to_GDP'],name='',marker_color='forestgreen'))
fig.update_layout(#width=1500,
# height=500,
barmode='relative')
Expand Down Expand Up @@ -325,7 +325,7 @@ def annual_demand(demand,growth_rate,decarb_rate):
return fig


def decarbonization_scenarios(Country,Efficiency,oil_imports_2019,demand,growth_rate,PV_cost,PVBatt_cost,WindBatt_cost,Wind_cost,decarb_year,
def decarbonization_scenarios(Country,Efficiency,oil_imports_2019,demand,growth_rate,PV_cost,rooftop_PV_cost,res_batt_cost,WindBatt_cost,Wind_cost,decarb_year,
total_wind_share,small_PV_share,small_wind_share,
PV_pot,Wind_pot,diesel_HHV,diesel_price,
geothermal_switch,geothermal_completion_year,geothermal_MW,geothermal_CF,geothermal_CAPEX,
Expand Down Expand Up @@ -410,10 +410,16 @@ def decarbonization_scenarios(Country,Efficiency,oil_imports_2019,demand,growth_
demand_df['Small Wind+B'] = demand_df['wind_inst'] * small_wind_share #MW
demand_df['Large Wind'] = demand_df['wind_inst'] * large_wind_share #MW

demand_df['RE_inst_cost'] = (1000000 * demand_df['PV_inst'] * (small_PV_share*PVBatt_cost*1.5+large_PV_share*PV_cost) +\
# demand_df['RE_inst_cost'] = (1000000 * (demand_df['PV_inst'] * (small_PV_share*rooftop_PV_cost+large_PV_share*PV_cost) )+\
# 1000000 * demand_df['wind_inst'] * (small_wind_share*WindBatt_cost+large_wind_share*Wind_cost)+ \
# demand_df['Geothermal_inst_cost']+
# demand_df['Battery_inst_cost']*1000000)/1000000 #M$
demand_df['RE_inst_cost'] = (1000000 * (demand_df['Small PV+B'] *rooftop_PV_cost + demand_df['Small PV+B'] * 2 * res_batt_cost + demand_df['Large PV'] *PV_cost)+\
1000000 * demand_df['wind_inst'] * (small_wind_share*WindBatt_cost+large_wind_share*Wind_cost)+ \
demand_df['Geothermal_inst_cost']+
demand_df['Battery_inst_cost']*1000000)/1000000 #M$


demand_df["non_RE_demand_TJ"] = (demand_df['Demand'] - demand_df['RE_cumulative']-demand_df['Geothermal_GWh'])/0.2777
demand_df['non_RE_demand_TJ'][demand_df['non_RE_demand_TJ'] < 0] = 0
demand_df["diesel_litre_dec"] = demand_df["non_RE_demand_TJ"] / (diesel_HHV*Efficiency) # L
Expand Down Expand Up @@ -1038,6 +1044,35 @@ def UNstats_plots(year):
marker_line_width=1.5, opacity=1)
fig8.update_traces(hovertemplate=None)

fig_re_imp = go.Figure()
fig_re_imp.add_trace(go.Bar(x=summary_df['Country'], y=summary_df['Renewables/Total_imports'], name='Total energy from renewables',text=summary_df['Renewables/Total_imports'],
marker_color='forestgreen'))

fig_re_imp.update_layout(legend=dict(bgcolor='rgba(0,0,0,0)', yanchor="bottom", orientation="h",
y=0.98,
xanchor="center",
x=0.5),
font=dict(
family="Calibri",
size=16,
color=font_color
),
hovermode="x"
)
fig_re_imp.update_layout({
'plot_bgcolor': 'rgba(0,0,0,0)',
'paper_bgcolor': 'rgba(0,0,0,0)',
})
fig_re_imp.update_yaxes(title_text="% of total energy imports", showline=True, linecolor=line_color, gridcolor=line_color)
fig_re_imp.update_xaxes(showline=True, linecolor=line_color,
title_text="<a href=\"http://unstats.un.org/unsd/energystats/pubs/balance\"><sub>Source: Energy Balances, United Nations<sub></a>")
fig_re_imp.update_layout(
title="Proportion of renewable consumption to total energy imports in {}".format(year))
fig_re_imp.update_traces(marker_line_color=font_color,
marker_line_width=1.5, opacity=1)
fig_re_imp.update_traces(hovertemplate=None)
fig_re_imp.write_image("renewables_to_total_imports.png")

fig9 = go.Figure()
fig9.add_trace(go.Bar(x=summary_df['Country'], y=summary_df['Renewables/capita'], name='Total energy from renewables',text=summary_df['Renewables/capita'],
marker_color='forestgreen'))
Expand Down
Loading

0 comments on commit c15ef4f

Please sign in to comment.