Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endogenous transport option #734

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ sector:
bev_avail_max: 0.95
bev_avail_mean: 0.8
v2g: true
endogenous_transport: false
EV_consumption_1car: 0.01
ICE_consumption_1car: 0.033
H2_consumption_1car: 0.02
land_transport_fuel_cell_share:
2020: 0
2030: 0.05
Expand Down Expand Up @@ -984,3 +988,4 @@ plotting:
DC: "#8a1caf"
DC-DC: "#8a1caf"
DC link: "#8a1caf"
land transport demand: '#2596be'
250 changes: 127 additions & 123 deletions doc/configtables/sector.csv

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Upcoming Release

* Split configuration to enable SMR and SMR CC.

* Add option to optimize fuel type shares of land transport endogenously in configuration file (https://github.com/PyPSA/pypsa-eur/pull/734)

* The ``mock_snakemake`` function can now be used with a Snakefile from a different directory using the new ``root_dir`` argument.


Expand Down
2 changes: 1 addition & 1 deletion rules/build_electricity.smk
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ rule build_renewable_profiles:
BENCHMARKS + "build_renewable_profiles_{technology}"
threads: ATLITE_NPROCESSES
resources:
mem_mb=ATLITE_NPROCESSES * 5000,
mem_mb=ATLITE_NPROCESSES * 9000,
wildcard_constraints:
technology="(?!hydro).*", # Any technology other than hydro
conda:
Expand Down
1 change: 1 addition & 0 deletions rules/solve_myopic.smk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ rule add_existing_baseyear:
existing_solar="data/existing_infrastructure/solar_capacity_IRENA.csv",
existing_onwind="data/existing_infrastructure/onwind_capacity_IRENA.csv",
existing_offwind="data/existing_infrastructure/offwind_capacity_IRENA.csv",
existing_transport=RESOURCES + "transport_data_s{simpl}_{clusters}.csv",
output:
RESULTS
+ "prenetworks-brownfield/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
Expand Down
7 changes: 7 additions & 0 deletions scripts/add_brownfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ def add_brownfield(n, n_p, year):
& (c.df[f"{attr}_nom_opt"] < threshold)
],
)

if not snakemake.config["sector"]["endogenous_transport"]:
n_p.mremove(
c.name,
c.df.index[c.df.carrier.str.contains("land transport" or "V2G" or "EV battery storage" or "BEV charger")
],
)

# copy over assets but fix their capacity
c.df[f"{attr}_nom"] = c.df[f"{attr}_nom_opt"]
Expand Down
47 changes: 47 additions & 0 deletions scripts/add_existing_baseyear.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,47 @@ def add_heating_capacities_installed_before_baseyear(
n.mremove("Link", links_i)


def add_land_transport_installed_before_baseyear(
n,
grouping_year,
):

pop_layout = pd.read_csv(snakemake.input.clustered_pop_layout, index_col=0)
nodes = pop_layout.index

ice_efficiency = options["transport_internal_combustion_efficiency"]
p_set = n.loads_t.p_set[n.loads[n.loads.carrier.str.contains('land transport demand')].index]
p_set.columns = p_set.columns.str.rstrip('land transport')

split_years = costs.at['Liquid fuels ICE (passenger cars)', 'lifetime'] - 1
year = range(int(grouping_year-split_years), int(grouping_year),1)
set_p_nom = p_set.max(axis=0)/len(year)
p_set_year = p_set/(len(year))
for year in year:
n.madd(
"Link",
nodes,
suffix=f" land transport oil-{year}",
bus0=spatial.oil.nodes,
bus1=nodes + " land transport",
bus2="co2 atmosphere",
carrier="land transport oil",
capital_cost = 0,
efficiency = options["transport_internal_combustion_efficiency"],
efficiency2 = costs.at['oil', 'CO2 intensity'],
lifetime = costs.at['Liquid fuels ICE (passenger cars)', 'lifetime'],
p_nom = set_p_nom,
p_min_pu = p_set_year/(set_p_nom*ice_efficiency),
p_max_pu = p_set_year/(set_p_nom*ice_efficiency),
build_year = year
)

number_cars = pd.read_csv(snakemake.input.existing_transport, index_col=0)[
"number cars"
]
logger.info(f"The model only assumes the minimum number of ICE vehicles to supply the transport demand which represents {round(int(snakemake.config['scenario']['clusters'][0])*p_set.max(axis=0).sum()/number_cars.sum()*100,2)}% of the existing ICE vehicle fleet in 2020")


if __name__ == "__main__":
if "snakemake" not in globals():
from _helpers import mock_snakemake
Expand Down Expand Up @@ -697,6 +738,12 @@ def add_heating_capacities_installed_before_baseyear(
default_lifetime,
)

endo_transport = ( (options["land_transport_electric_share"][baseyear] is None )
and (options["land_transport_fuel_cell_share"][baseyear] is None)
and (options["land_transport_ice_share"][baseyear] is None))
if "T" in opts and options["endogenous_transport"] and endo_transport:
add_land_transport_installed_before_baseyear(n, baseyear)

if options.get("cluster_heat_buses", False):
cluster_heat_buses(n)

Expand Down
3 changes: 1 addition & 2 deletions scripts/build_retro_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ def prepare_building_stock_data():

# heated floor area ----------------------------------------------------------
area = building_data[
(building_data.type == "Heated area [Mm²]")
& (building_data.subsector != "Total")
(building_data.type == "Heated area [Mm²]") & (building_data.detail != "Total")
]
area_tot = area[["country", "sector", "value"]].groupby(["country", "sector"]).sum()
area = pd.concat(
Expand Down
Loading