Skip to content

Commit d319574

Browse files
author
cpschau
committed
fill lifetime values for plants without DateOut and drop plant if lifetime expired
1 parent 4b5e490 commit d319574

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

scripts/add_existing_baseyear.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
from scripts.build_powerplants import add_custom_powerplants
4343

44+
4445
def add_build_year_to_new_assets(n: pypsa.Network, baseyear: int) -> None:
4546
"""
4647
Add build year to new assets in the network.
@@ -258,7 +259,7 @@ def add_power_capacities_installed_before_baseyear(
258259

259260
# add chp plants
260261
add_chp_plants(n, grouping_years, costs, baseyear)
261-
262+
262263
# drop assets which are already phased out / decommissioned
263264
phased_out = df_agg[df_agg["DateOut"] < baseyear].index
264265
df_agg.drop(phased_out, inplace=True)
@@ -509,10 +510,10 @@ def add_chp_plants(n, grouping_years, costs, baseyear):
509510
# phase out date at the end of the year)
510511
chp.Fueltype = chp.Fueltype.map(rename_fuel)
511512

512-
chp["grouping_year"] = np.take(
513-
grouping_years, np.digitize(chp.DateIn, grouping_years, right=True)
513+
chp["lifetime"] = (chp.DateOut - chp["grouping_year"] + 1).fillna(
514+
snakemake.params.costs["fill_values"]["lifetime"]
514515
)
515-
chp["lifetime"] = chp.DateOut - chp["grouping_year"] + 1
516+
chp = chp.loc[chp.grouping_year + chp.lifetime >= baseyear]
516517

517518
# check if the CHPs were read in from MaStR for Germany
518519
if "Capacity_thermal" in chp.columns:
@@ -735,7 +736,8 @@ def add_chp_plants(n, grouping_years, costs, baseyear):
735736
bus3="co2 atmosphere",
736737
carrier=f"urban central {generator} CHP",
737738
p_nom=p_nom[bus] / costs.at[key, "efficiency"],
738-
capital_cost=costs.at[key, "capital_cost"] * costs.at[key, "efficiency"],
739+
capital_cost=costs.at[key, "capital_cost"]
740+
* costs.at[key, "efficiency"],
739741
overnight_cost=costs.at[key, "investment"]
740742
* costs.at[key, "efficiency"],
741743
marginal_cost=costs.at[key, "VOM"],
@@ -756,7 +758,8 @@ def add_chp_plants(n, grouping_years, costs, baseyear):
756758
bus2=bus + " urban central heat",
757759
carrier=generator,
758760
p_nom=p_nom[bus] / costs.at[key, "efficiency"],
759-
capital_cost=costs.at[key, "capital_cost"] * costs.at[key, "efficiency"],
761+
capital_cost=costs.at[key, "capital_cost"]
762+
* costs.at[key, "efficiency"],
760763
overnight_cost=costs.at[key, "investment"]
761764
* costs.at[key, "efficiency"],
762765
marginal_cost=costs.at[key, "VOM"],
@@ -1050,7 +1053,9 @@ def add_heating_capacities_installed_before_baseyear(
10501053
overnight_cost=costs.at["biomass boiler", "efficiency"]
10511054
* costs.at["biomass boiler", "investment"],
10521055
p_nom=(
1053-
existing_capacities.loc[nodes, (heat_system.value, "biomass boiler")]
1056+
existing_capacities.loc[
1057+
nodes, (heat_system.value, "biomass boiler")
1058+
]
10541059
* ratio
10551060
/ costs.at["biomass boiler", "efficiency"]
10561061
),

0 commit comments

Comments
 (0)