From 21968a5d77438512c7a2403ff08084857eb32874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=B6rsch?= Date: Tue, 10 Jul 2018 16:29:11 +0200 Subject: [PATCH] Attach conventional generators to base model --- config.yaml | 2 ++ scripts/add_electricity.py | 26 +++++++++++++++++++++++--- scripts/build_powerplants.py | 13 ++++++++++++- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/config.yaml b/config.yaml index 2a73b8f6..2fcf4483 100644 --- a/config.yaml +++ b/config.yaml @@ -28,6 +28,8 @@ electricity: battery: 6 H2: 168 + conventional_carriers: [nuclear, oil, OCGT, CCGT, coal, lignite, geothermal, biomass] + renewable: onwind: cutout: europe-2012-2016-era5 diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index a5d37abe..955c679c 100644 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -143,8 +143,28 @@ def attach_wind_and_solar(n, costs): # # Generators -def attach_existing_generators(n, costs): - raise NotImplementedError("comes later") +def attach_conventional_generators(n, costs, ppl): + carriers = snakemake.config['electricity']['conventional_carriers'] + _add_missing_carriers_from_costs(n, costs, carriers) + ppl = ppl.rename(columns={'Name': 'name', 'Capacity': 'p_nom'}) + ppm_fuels = {'OCGT': 'OCGT', 'CCGT': 'CCGT', + 'oil': 'Oil', 'nuclear': 'Nuclear', + 'geothermal': 'Geothermal', 'biomass': 'Bioenergy', + 'coal': 'Hard Coal', 'lignite': 'Lignite'} + + for tech in carriers: + p = pd.DataFrame(ppl.loc[ppl['Fueltype'] == ppm_fuels[tech]]) + p.index = 'C' + p.index.astype(str) + logger.info('Adding {} generators of type {} with capacity {}' + .format(len(p), tech, p.p_nom.sum())) + + n.madd("Generator", p.index, + carrier=tech, + bus=p['bus'], + p_nom=p['p_nom'], + efficiency=costs.at[tech, 'efficiency'], + marginal_cost=costs.at[tech, 'marginal_cost'], + capital_cost=costs.at[tech, 'capital_cost']) def attach_hydro(n, costs, ppl): @@ -358,7 +378,7 @@ if __name__ == "__main__": attach_load(n) update_transmission_costs(n, costs) - # attach_existing_generators(n, costs) + attach_conventional_generators(n, costs, ppl) attach_wind_and_solar(n, costs) attach_hydro(n, costs, ppl) diff --git a/scripts/build_powerplants.py b/scripts/build_powerplants.py index e9732ed3..0b33c131 100644 --- a/scripts/build_powerplants.py +++ b/scripts/build_powerplants.py @@ -19,7 +19,18 @@ logging.basicConfig(level=snakemake.config['logging_level']) n = pypsa.Network(snakemake.input.base_network) -ppl = ppm.collection.MATCHED_dataset(include_unavailables=True) +ppl = (ppm.collection.MATCHED_dataset(include_unavailables=True) + [lambda df : ~df.Fueltype.isin(('Solar', 'Wind'))] + .pipe(ppm.cleaning.clean_technology) + .assign(Fueltype=lambda df: ( + df.Fueltype.where(df.Fueltype != 'Natural Gas', + df.Technology.replace('Steam Turbine', 'OCGT').fillna('OCGT')))) + .pipe(ppm.utils.fill_geoposition, parse=True, only_saved_locs=True) + .pipe(ppm.heuristics.fill_missing_duration)) + +# ppl.loc[(ppl.Fueltype == 'Other') & ppl.Technology.str.contains('CCGT'), 'Fueltype'] = 'CCGT' +# ppl.loc[(ppl.Fueltype == 'Other') & ppl.Technology.str.contains('Steam Turbine'), 'Fueltype'] = 'CCGT' + ppl = ppl.loc[ppl.lon.notnull() & ppl.lat.notnull()] substation_lv_i = n.buses.index[n.buses['substation_lv']]