Skip to content

Commit b185740

Browse files
committed
add domestic aviation (bugfix) and subtract international navigation from national co2 limits
1 parent f0a9304 commit b185740

File tree

1 file changed

+53
-11
lines changed

1 file changed

+53
-11
lines changed

scripts/pypsa-de/additional_functionality.py

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ def add_national_co2_budgets(n, snakemake, national_co2_budgets, investment_year
373373
nyears = nhours / 8760
374374

375375
sectors = determine_emission_sectors(n.config["sector"])
376+
energy_totals = pd.read_csv(snakemake.input.energy_totals, index_col=[0, 1])
376377

377378
# convert MtCO2 to tCO2
378379
co2_totals = 1e6 * pd.read_csv(snakemake.input.co2_totals_name, index_col=0)
@@ -397,8 +398,8 @@ def add_national_co2_budgets(n, snakemake, national_co2_budgets, investment_year
397398
links = n.links.index[
398399
(n.links.index.str[:2] == ct)
399400
& (n.links[f"bus{port}"] == "co2 atmosphere")
400-
& (
401-
n.links.carrier != "kerosene for aviation"
401+
& ~n.links.carrier.str.contains(
402+
"shipping|aviation"
402403
) # first exclude aviation to multiply it with a domestic factor later
403404
]
404405

@@ -422,27 +423,68 @@ def add_national_co2_budgets(n, snakemake, national_co2_budgets, investment_year
422423
)
423424

424425
# Aviation demand
425-
energy_totals = pd.read_csv(snakemake.input.energy_totals, index_col=[0, 1])
426426
domestic_aviation = energy_totals.loc[
427427
(ct, snakemake.params.energy_year), "total domestic aviation"
428428
]
429429
international_aviation = energy_totals.loc[
430430
(ct, snakemake.params.energy_year), "total international aviation"
431431
]
432-
domestic_factor = domestic_aviation / (
432+
domestic_aviation_factor = domestic_aviation / (
433433
domestic_aviation + international_aviation
434434
)
435435
aviation_links = n.links[
436436
(n.links.index.str[:2] == ct) & (n.links.carrier == "kerosene for aviation")
437437
]
438-
lhs.append
439-
(
440-
n.model["Link-p"].loc[:, aviation_links.index]
441-
* aviation_links.efficiency2
442-
* n.snapshot_weightings.generators
443-
).sum() * domestic_factor
438+
lhs.append(
439+
(
440+
n.model["Link-p"].loc[:, aviation_links.index]
441+
* aviation_links.efficiency2
442+
* n.snapshot_weightings.generators
443+
).sum()
444+
* domestic_aviation_factor
445+
)
446+
logger.info(
447+
f"Adding domestic aviation emissions for {ct} with a factor of {domestic_aviation_factor}"
448+
)
449+
450+
# Shipping oil
451+
domestic_navigation = energy_totals.loc[
452+
(ct, snakemake.params.energy_year), "total domestic navigation"
453+
]
454+
international_navigation = energy_totals.loc[
455+
(ct, snakemake.params.energy_year), "total international navigation"
456+
]
457+
domestic_navigation_factor = domestic_navigation / (
458+
domestic_navigation + international_navigation
459+
)
460+
shipping_links = n.links[
461+
(n.links.index.str[:2] == ct) & (n.links.carrier == "shipping oil")
462+
]
463+
lhs.append(
464+
(
465+
n.model["Link-p"].loc[:, shipping_links.index]
466+
* shipping_links.efficiency2
467+
* n.snapshot_weightings.generators
468+
).sum()
469+
* domestic_navigation_factor
470+
)
471+
472+
# Shipping methanol
473+
shipping_meoh_links = n.links[
474+
(n.links.index.str[:2] == ct) & (n.links.carrier == "shipping methanol")
475+
]
476+
if not shipping_meoh_links.empty: # no shipping methanol in 2025
477+
lhs.append(
478+
(
479+
n.model["Link-p"].loc[:, shipping_meoh_links.index]
480+
* shipping_meoh_links.efficiency2
481+
* n.snapshot_weightings.generators
482+
).sum()
483+
* domestic_navigation_factor
484+
)
485+
444486
logger.info(
445-
f"Adding domestic aviation emissions for {ct} with a factor of {domestic_factor}"
487+
f"Adding domestic shipping emissions for {ct} with a factor of {domestic_navigation_factor}"
446488
)
447489

448490
# Adding Efuel imports and exports to constraint

0 commit comments

Comments
 (0)