adjust p_nom_max if existing larger

This commit is contained in:
lisazeyen 2023-02-22 17:44:05 +01:00
parent bbeb7af1a8
commit 332936bcec
2 changed files with 24 additions and 10 deletions

View File

@ -338,7 +338,12 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
efficiency2=costs.at[key, 'efficiency-heat'],
lifetime=lifetime_assets.loc[new_capacity.index]
)
# check if existing capacities are larger than technical potential
existing_large = n.generators[n.generators["p_nom_min"] > n.generators["p_nom_max"]].index
if len(existing_large):
logger.warning(f"Existing capacities larger than technical potential for {existing_large},\
adjust technical potential to existing capacities")
n.generators.loc[existing_large, "p_nom_max"] = n.generators.loc[existing_large, "p_nom_min"]
def add_heating_capacities_installed_before_baseyear(n, baseyear, grouping_years, ashp_cop, gshp_cop, time_dep_hp_cop, costs, default_lifetime):
"""
@ -520,11 +525,11 @@ if __name__ == "__main__":
snakemake = mock_snakemake(
'add_existing_baseyear',
simpl='',
clusters="37",
clusters="45",
lv=1.0,
opts='',
sector_opts='800sn-T-H-B-I-A-solar+p3-dist1-co2min-1p7',
planning_horizons=2030,
sector_opts='8760H-T-H-B-I-A-solar+p3-dist1',
planning_horizons=2020,
)
logging.basicConfig(level=snakemake.config['logging_level'])

View File

@ -23,10 +23,19 @@ def _add_land_use_constraint(n):
#warning: this will miss existing offwind which is not classed AC-DC and has carrier 'offwind'
for carrier in ['solar', 'onwind', 'offwind-ac', 'offwind-dc']:
existing = n.generators.loc[n.generators.carrier==carrier,"p_nom"].groupby(n.generators.bus.map(n.buses.location)).sum()
ext_i = (n.generators.carrier==carrier) & ~n.generators.p_nom_extendable
existing = n.generators.loc[ext_i,"p_nom"].groupby(n.generators.bus.map(n.buses.location)).sum()
existing.index += " " + carrier + "-" + snakemake.wildcards.planning_horizons
n.generators.loc[existing.index,"p_nom_max"] -= existing
# check if existing capacities are larger than technical potential
existing_large = n.generators[n.generators["p_nom_min"] > n.generators["p_nom_max"]].index
if len(existing_large):
logger.warning(f"Existing capacities larger than technical potential for {existing_large},\
adjust technical potential to existing capacities")
n.generators.loc[existing_large, "p_nom_max"] = n.generators.loc[existing_large, "p_nom_min"]
n.generators.p_nom_max.clip(lower=0, inplace=True)
@ -241,18 +250,18 @@ def solve_network(n, config, opts="", **kwargs):
return n
#%%
if __name__ == "__main__":
if 'snakemake' not in globals():
from helper import mock_snakemake
snakemake = mock_snakemake(
'solve_network',
'solve_network_myopic',
simpl='',
opts="",
clusters="5",
clusters="45",
lv=1.0,
sector_opts='Co2L0-3H-T-H-B-I-A-solar+p3-dist1',
planning_horizons="2050",
sector_opts='8760H-T-H-B-I-A-solar+p3-dist1',
planning_horizons="2020",
)
logging.basicConfig(filename=snakemake.log.python,