fix p_nom_min values for extendable carriers with positive p_nom
This commit is contained in:
parent
d094119d47
commit
b10317ee3c
@ -125,6 +125,15 @@ def load_network_for_plots(fn, tech_costs, config, combine_hydro_ps=True):
|
||||
|
||||
return n
|
||||
|
||||
def update_p_nom_max(n):
|
||||
# if extendable carriers (solar/onwind/...) have capacity >= 0,
|
||||
# e.g. existing assets from the OPSD project are included to the network,
|
||||
# the installed capacity might exceed the expansion limit.
|
||||
# Hence, we update the assumptions.
|
||||
|
||||
n.generators.p_nom_max = (n.generators
|
||||
.apply(lambda b: b[['p_nom_min','p_nom_max']].max(), axis=1))
|
||||
|
||||
def aggregate_p_nom(n):
|
||||
return pd.concat([
|
||||
n.generators.groupby("carrier").p_nom_opt.sum(),
|
||||
|
@ -84,7 +84,7 @@ It further adds extendable ``generators`` with **zero** capacity for
|
||||
"""
|
||||
|
||||
import logging
|
||||
from _helpers import configure_logging
|
||||
from _helpers import configure_logging, update_p_nom_max
|
||||
|
||||
import pypsa
|
||||
import pandas as pd
|
||||
@ -501,6 +501,7 @@ def attach_OPSD_renewables(n):
|
||||
caps = caps / gens_per_bus.reindex(caps.index, fill_value=1)
|
||||
|
||||
n.generators.p_nom.update(gens.bus.map(caps).dropna())
|
||||
n.generators.p_nom_min.update(gens.bus.map(caps).dropna())
|
||||
|
||||
|
||||
|
||||
@ -536,6 +537,7 @@ def estimate_renewable_capacities(n, tech_map=None):
|
||||
.groupby(n.generators.bus.map(n.buses.country))
|
||||
.transform(lambda s: normed(s) * tech_capacities.at[s.name])
|
||||
.where(lambda s: s>0.1, 0.)) # only capacities above 100kW
|
||||
n.generators.loc[tech_i, 'p_nom_min'] = n.generators.loc[tech_i, 'p_nom']
|
||||
|
||||
|
||||
def add_nice_carrier_names(n, config=None):
|
||||
@ -575,6 +577,7 @@ if __name__ == "__main__":
|
||||
|
||||
estimate_renewable_capacities(n)
|
||||
attach_OPSD_renewables(n)
|
||||
update_p_nom_max(n)
|
||||
|
||||
add_nice_carrier_names(n)
|
||||
|
||||
|
@ -122,7 +122,7 @@ Exemplary unsolved network clustered to 37 nodes:
|
||||
"""
|
||||
|
||||
import logging
|
||||
from _helpers import configure_logging
|
||||
from _helpers import configure_logging, update_p_nom_max
|
||||
|
||||
import pypsa
|
||||
import os
|
||||
@ -282,7 +282,7 @@ def clustering_for_n_clusters(n, n_clusters, custom_busmap=False, aggregate_carr
|
||||
aggregate_generators_carriers=aggregate_carriers,
|
||||
aggregate_one_ports=["Load", "StorageUnit"],
|
||||
line_length_factor=line_length_factor,
|
||||
generator_strategies={'p_nom_max': p_nom_max_strategy},
|
||||
generator_strategies={'p_nom_max': p_nom_max_strategy, 'p_nom_min': np.sum},
|
||||
scale_link_capital_costs=False)
|
||||
|
||||
if not n.links.empty:
|
||||
@ -379,6 +379,8 @@ if __name__ == "__main__":
|
||||
extended_link_costs=hvac_overhead_cost,
|
||||
focus_weights=focus_weights)
|
||||
|
||||
update_p_nom_max(n)
|
||||
|
||||
clustering.network.export_to_netcdf(snakemake.output.network)
|
||||
for attr in ('busmap', 'linemap'): #also available: linemap_positive, linemap_negative
|
||||
getattr(clustering, attr).to_csv(snakemake.output[attr])
|
||||
|
@ -83,7 +83,7 @@ The rule :mod:`simplify_network` does up to four things:
|
||||
"""
|
||||
|
||||
import logging
|
||||
from _helpers import configure_logging
|
||||
from _helpers import configure_logging, update_p_nom_max
|
||||
|
||||
from cluster_network import clustering_for_n_clusters, cluster_regions
|
||||
from add_electricity import load_costs
|
||||
@ -198,7 +198,7 @@ def _aggregate_and_move_components(n, busmap, connection_costs_to_bus, aggregate
|
||||
|
||||
_adjust_capital_costs_using_connection_costs(n, connection_costs_to_bus)
|
||||
|
||||
generators, generators_pnl = aggregategenerators(n, busmap)
|
||||
generators, generators_pnl = aggregategenerators(n, busmap, custom_strategies={'p_nom_min': np.sum})
|
||||
replace_components(n, "Generator", generators, generators_pnl)
|
||||
|
||||
for one_port in aggregate_one_ports:
|
||||
@ -364,6 +364,8 @@ if __name__ == "__main__":
|
||||
n, cluster_map = cluster(n, int(snakemake.wildcards.simpl))
|
||||
busmaps.append(cluster_map)
|
||||
|
||||
update_p_nom_max(n)
|
||||
|
||||
n.export_to_netcdf(snakemake.output.network)
|
||||
|
||||
busmap_s = reduce(lambda x, y: x.map(y), busmaps[1:], busmaps[0])
|
||||
|
Loading…
Reference in New Issue
Block a user