Skip to content

Commit

Permalink
added import export balance based on FES
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasFrankenQ committed Oct 5, 2023
1 parent 806d908 commit d468ef1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
19 changes: 19 additions & 0 deletions scripts/_fes_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,22 @@ def get_commercial_demand(scenario, year):
reference = df.loc[scenario_mapper[scenario], 2022] * 1e-3

return reference, value


def get_import_export_balance(scenario, year):
"""Get GB trade balance with mainland Europe, Norway, Ireland through interconnectors"""

col = string.ascii_uppercase.index("O")

df = (
pd.read_excel(data_file,
sheet_name="FL.15",
header=4,
index_col=0,
usecols=[col+i for i in range(31)],
)
).iloc[1:5]

df.columns = range(2022, 2052)

return df.loc[scenario_mapper[scenario], year] * 1e6
22 changes: 13 additions & 9 deletions scripts/prepare_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
get_battery_capacity,
get_industrial_demand,
get_commercial_demand,
get_import_export_balance,
)

from pypsa.descriptors import expand_series
Expand Down Expand Up @@ -1159,28 +1160,31 @@ def add_batteries(n, costs=None, opts=[]):
)


def add_import_export_balance(n):

n.add(
"Bus",
"import export tracker",
carrier="import export tracker",
)
def add_import_export_balance(n, fes, year):

cc = pd.read_csv(snakemake.input["capacity_constraints"], index_col=1)
total_p_nom = cc.at["DC", "value"]
max_hours = snakemake.config["flexibility"]["balance_link_max_hours"]

balance = get_import_export_balance(fes, year)
e_nom = abs(balance)

e_max_pu = pd.Series(1., n.snapshots)
e_max_pu.iloc[0] = 0.
e_max_pu.iloc[-1] = 0.
e_max_pu.iloc[-1] = balance / max(max_hours * total_p_nom, e_nom)

n.add(
"Bus",
"import export tracker",
carrier="import export tracker",
)

n.add(
"Store",
"import export tracker",
bus="import export tracker",
carrier="import export tracker",
e_nom=max_hours * total_p_nom,
e_nom=max(max_hours * total_p_nom, e_nom),
e_max_pu=e_max_pu,
e_min_pu=-e_max_pu,
)
Expand Down

0 comments on commit d468ef1

Please sign in to comment.