Skip to content

Commit

Permalink
added automatic scaling of p_nom of conventional generators
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasFrankenQ committed Jul 17, 2023
1 parent 35b0eea commit b51219e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions rules/build_electricity.smk
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ rule prepare_network:
RESOURCES + "networks/elec_s{simpl}_{gb_regions}_ec.nc",
overrides="data/override_component_attrs",
tech_costs=COSTS,
capacity_constraints=RESOURCES + "fes_capacity_constraints_{fes_scenario}_{planning_horizons}.csv",
heat_profile="data/heat_load_profile_BDEW.csv",
co2_price=RESOURCES + "CO2_price_2022.csv",
heat_demand=RESOURCES + "heat_demand_total_elec_s{simpl}_{gb_regions}.nc",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_fes_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import pandas as pd

from _fes_helper import get_data_point
from _fes_helpers import get_data_point
from _helpers import configure_logging


Expand Down
38 changes: 34 additions & 4 deletions scripts/prepare_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,34 @@ def remove_elec_base_techs(n):
# n.carriers.drop(to_remove, inplace=True, errors="ignore")


def scale_generation_capacity(n, capacity_file):

generation_mapper = {
"gas": ["OCGT", "CCGT"],
"coal": ["coal", "lignite"],
"nuclear": ["nuclear"],
"biomass": ["biomass"],
}

constraints = pd.read_csv(capacity_file, index_col=1)["value"]

gb_gen = n.generators.loc[n.generators.bus.str.contains("GB")]

for fes_gen, target in generation_mapper.items():
index = gb_gen[gb_gen.carrier.isin(target)].index

if not fes_gen in constraints.index:
n.generators.drop(index, inplace=True)
continue

adapted = n.generators.loc[index, "p_nom"].copy()
adapted *= constraints.loc[fes_gen] / adapted.sum()

n.generators.loc[index, "p_nom"] = adapted
n.generators.loc[index, "p_nom_min"] = adapted



def convert_generators_to_links(n, costs):

logger.info("Converting generators to links")
Expand All @@ -300,7 +328,7 @@ def convert_generators_to_links(n, costs):
"lignite": "lignite"}

for generator, carrier in conventionals.items():

if not f"GB_{carrier}_bus" in n.buses.index:
n.add("Bus",
f"GB_{carrier}_bus",
Expand All @@ -314,6 +342,9 @@ def convert_generators_to_links(n, costs):
marginal_cost=costs.at[carrier, "fuel"],
)

if not generator in gb_generation.carrier.unique():
continue

gens = gb_generation.loc[gb_generation.carrier == generator]

n.madd(
Expand Down Expand Up @@ -624,10 +655,9 @@ def add_dac(n, costs):
1.,
)

interesting = ["CCGT", "direct air capture", "coal CCS", "gas CCS"]

scale_generation_capacity(n, snakemake.input.capacity_constraints)
convert_generators_to_links(n, other_costs)

import sys
sys.exit()

Expand Down

0 comments on commit b51219e

Please sign in to comment.