From 6bb9cd1025805e22f1534de7305785195bf4e3e8 Mon Sep 17 00:00:00 2001 From: Jonas Hoersch Date: Fri, 15 Feb 2019 18:27:21 +0100 Subject: [PATCH] add_electricity: Refactor extendable generators to provide a OCGT-ext technology Partially adresses #7. --- scripts/add_electricity.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 3c500254..fc45d0b6 100644 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -30,8 +30,13 @@ def normed(s): return s/s.sum() def _add_missing_carriers_from_costs(n, costs, carriers): missing_carriers = pd.Index(carriers).difference(n.carriers.index) + if missing_carriers.empty: return + emissions_cols = costs.columns.to_series().loc[lambda s: s.str.endswith('_emissions')].values - n.import_components_from_dataframe(costs.loc[missing_carriers, emissions_cols].fillna(0.), 'Carrier') + suptechs = missing_carriers.str.split('-').str[0] + emissions = costs.loc[suptechs, emissions_cols].fillna(0.) + emissions.index = missing_carriers + n.import_components_from_dataframe(emissions, 'Carrier') def load_costs(Nyears=1., tech_costs=None, config=None, elec_config=None): if tech_costs is None: @@ -324,21 +329,26 @@ def attach_hydro(n, costs, ppl): def attach_extendable_generators(n, costs, ppl): elec_opts = snakemake.config['electricity'] - carriers = list(elec_opts['extendable_carriers']['Generator']) - assert set(carriers).issubset(['OCGT']), "Only OCGT plants as extendable generators allowed for now" + carriers = pd.Index(elec_opts['extendable_carriers']['Generator']) _add_missing_carriers_from_costs(n, costs, carriers) - if 'OCGT' in carriers: - ocgt = ppl.loc[ppl.Fueltype.isin(('OCGT', 'CCGT'))].groupby('bus', as_index=False).first() - n.madd('Generator', ocgt.index, - bus=ocgt['bus'], - carrier='OCGT', - p_nom_extendable=True, - p_nom=0., - capital_cost=costs.at['OCGT', 'capital_cost'], - marginal_cost=costs.at['OCGT', 'marginal_cost'], - efficiency=costs.at['OCGT', 'efficiency']) + for tech in carriers: + suptech = tech.split('-')[0] + + if suptech == 'OCGT': + ocgt = ppl.loc[ppl.Fueltype.isin(('OCGT', 'CCGT'))].groupby('bus', as_index=False).first() + n.madd('Generator', ocgt.index, + bus=ocgt['bus'], + carrier=tech, + p_nom_extendable=True, + p_nom=0., + capital_cost=costs.at['OCGT', 'capital_cost'], + marginal_cost=costs.at['OCGT', 'marginal_cost'], + efficiency=costs.at['OCGT', 'efficiency']) + else: + raise NotImplementedError(f"Adding extendable generators for carrier '{tech}' is not implemented, yet." + "Only OCGT are allowed at the moment.") def attach_storage(n, costs):