Skip to content

Commit

Permalink
feat: update COPs for perfect foresight
Browse files Browse the repository at this point in the history
  • Loading branch information
amos-schledorn committed Sep 17, 2024
1 parent 94d628f commit 8871a2d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scripts/add_brownfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,23 @@ def adjust_renewable_profiles(n, input_profiles, params, year):


def update_heat_pump_efficiency(n: pypsa.Network, n_p: pypsa.Network, year: int):
"""
Update the efficiency of heat pumps from previous years to current year (e.g. 2030 heat pumps receive 2040 heat pump COPs in 2030).
Parameters
----------
n : pypsa.Network
The original network.
n_p : pypsa.Network
The network with the updated parameters.
year : int
The year for which the efficiency is being updated.
Returns
-------
None
This function updates the efficiency in place and does not return a value.
"""

for link_name_p in n_p.links.index:
if "heat pump" in link_name_p:
Expand Down
30 changes: 30 additions & 0 deletions scripts/prepare_perfect_foresight.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import logging
from typing import List

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -486,6 +487,32 @@ def apply_time_segmentation_perfect(

return n

def update_heat_pump_efficiency(n: pypsa.Network, years: List[int]):
"""
Update the efficiency of heat pumps from previous years to current year (e.g. 2030 heat pumps receive 2040 heat pump COPs in 2030).
Note: this also updates the efficiency of heat pumps in preceding years for previous years, which should have no effect (e.g. 2040 heat pumps receive 2030 COPs in 2030).
Parameters
----------
n : pypsa.Network
The concatenated network.
years : List[int]
List of planning horizon years.
Returns
-------
None
This function updates the efficiency in place and does not return a value.
"""

for link_name in n.links.index:
if "heat pump" in link_name:
heat_pump_name = link_name[:-4]
for year in years:
correct_efficiency = n.links_t["efficiency"].loc[(year, slice(None)), heat_pump_name+str(year)]
n.links_t["efficiency"].loc[(year, slice(None)), link_name] = correct_efficiency


if __name__ == "__main__":
if "snakemake" not in globals():
Expand Down Expand Up @@ -538,5 +565,8 @@ def apply_time_segmentation_perfect(
# update meta
n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards)))

# update heat pump efficiency
update_heat_pump_efficiency(n=n, years=years)

# export network
n.export_to_netcdf(snakemake.output[0])

0 comments on commit 8871a2d

Please sign in to comment.