merge master
This commit is contained in:
commit
b560d95b6a
@ -89,6 +89,7 @@ Future release
|
||||
* Separate basic chemicals into HVC, chlorine, methanol and ammonia [`#166 <https://github.com/PyPSA/PyPSA-Eur-Sec/pull/166>`_].
|
||||
* Add option to specify reuse, primary production, and mechanical and chemical recycling fraction of platics [`#166 <https://github.com/PyPSA/PyPSA-Eur-Sec/pull/166>`_].
|
||||
* Include today's district heating shares in myopic optimisation and add option to specify exogenous path for district heating share increase under ``sector: district_heating:`` [`#149 <https://github.com/PyPSA/PyPSA-Eur-Sec/pull/149>`_].
|
||||
* The myopic option can now be used together with different clustering for the generators and the network. The existing renewable capacities are split evenly among the regions in every country [`#144 <https://github.com/PyPSA/PyPSA-Eur-Sec/pull/144>`_].
|
||||
|
||||
PyPSA-Eur-Sec 0.5.0 (21st May 2021)
|
||||
===================================
|
||||
|
@ -155,6 +155,11 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
|
||||
# assign clustered bus
|
||||
busmap_s = pd.read_csv(snakemake.input.busmap_s, index_col=0, squeeze=True)
|
||||
busmap = pd.read_csv(snakemake.input.busmap, index_col=0, squeeze=True)
|
||||
|
||||
inv_busmap = {}
|
||||
for k, v in busmap.iteritems():
|
||||
inv_busmap[v] = inv_busmap.get(v, []) + [k]
|
||||
|
||||
clustermaps = busmap_s.map(busmap)
|
||||
clustermaps.index = clustermaps.index.astype(int)
|
||||
|
||||
@ -192,23 +197,53 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
|
||||
capacity = capacity[capacity > snakemake.config['existing_capacities']['threshold_capacity']]
|
||||
|
||||
if generator in ['solar', 'onwind', 'offwind']:
|
||||
|
||||
suffix = '-ac' if generator == 'offwind' else ''
|
||||
name_suffix = f' {generator}{suffix}-{baseyear}'
|
||||
|
||||
rename = {"offwind": "offwind-ac"}
|
||||
p_max_pu=n.generators_t.p_max_pu[capacity.index + ' ' + rename.get(generator, generator) + '-' + str(baseyear)]
|
||||
if 'm' in snakemake.wildcards.clusters:
|
||||
|
||||
n.madd("Generator",
|
||||
capacity.index,
|
||||
suffix=' ' + generator +"-"+ str(grouping_year),
|
||||
bus=capacity.index,
|
||||
carrier=generator,
|
||||
p_nom=capacity,
|
||||
marginal_cost=costs.at[generator, 'VOM'],
|
||||
capital_cost=costs.at[generator, 'fixed'],
|
||||
efficiency=costs.at[generator, 'efficiency'],
|
||||
p_max_pu=p_max_pu.rename(columns=n.generators.bus),
|
||||
build_year=grouping_year,
|
||||
lifetime=costs.at[generator, 'lifetime']
|
||||
)
|
||||
for ind in capacity.index:
|
||||
|
||||
# existing capacities are split evenly among regions in every country
|
||||
inv_ind = [i for i in inv_busmap[ind]]
|
||||
|
||||
# for offshore the spliting only inludes coastal regions
|
||||
inv_ind = [i for i in inv_ind if (i + name_suffix) in n.generators.index]
|
||||
|
||||
p_max_pu = n.generators_t.p_max_pu[[i + name_suffix for i in inv_ind]]
|
||||
p_max_pu.columns=[i + name_suffix for i in inv_ind ]
|
||||
|
||||
n.madd("Generator",
|
||||
[i + name_suffix for i in inv_ind],
|
||||
bus=ind,
|
||||
carrier=generator,
|
||||
p_nom=capacity[ind] / len(inv_ind), # split among regions in a country
|
||||
marginal_cost=costs.at[generator,'VOM'],
|
||||
capital_cost=costs.at[generator,'fixed'],
|
||||
efficiency=costs.at[generator, 'efficiency'],
|
||||
p_max_pu=p_max_pu,
|
||||
build_year=grouping_year,
|
||||
lifetime=costs.at[generator,'lifetime']
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
p_max_pu = n.generators_t.p_max_pu[capacity.index + name_suffix]
|
||||
|
||||
n.madd("Generator",
|
||||
capacity.index,
|
||||
suffix=' ' + generator +"-"+ str(grouping_year),
|
||||
bus=capacity.index,
|
||||
carrier=generator,
|
||||
p_nom=capacity,
|
||||
marginal_cost=costs.at[generator, 'VOM'],
|
||||
capital_cost=costs.at[generator, 'fixed'],
|
||||
efficiency=costs.at[generator, 'efficiency'],
|
||||
p_max_pu=p_max_pu.rename(columns=n.generators.bus),
|
||||
build_year=grouping_year,
|
||||
lifetime=costs.at[generator, 'lifetime']
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
|
@ -20,12 +20,47 @@ pypsa.pf.logger.setLevel(logging.WARNING)
|
||||
|
||||
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()
|
||||
existing.index += " " + carrier + "-" + snakemake.wildcards.planning_horizons
|
||||
n.generators.loc[existing.index, "p_nom_max"] -= existing
|
||||
if 'm' in snakemake.wildcards.clusters:
|
||||
_add_land_use_constraint_m(n)
|
||||
else:
|
||||
_add_land_use_constraint(n)
|
||||
|
||||
|
||||
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()
|
||||
existing.index += " " + carrier + "-" + snakemake.wildcards.planning_horizons
|
||||
n.generators.loc[existing.index,"p_nom_max"] -= existing
|
||||
|
||||
n.generators.p_nom_max.clip(lower=0, inplace=True)
|
||||
|
||||
|
||||
def _add_land_use_constraint_m(n):
|
||||
# if generators clustering is lower than network clustering, land_use accounting is at generators clusters
|
||||
|
||||
planning_horizons = snakemake.config["scenario"]["planning_horizons"]
|
||||
grouping_years = snakemake.config["existing_capacities"]["grouping_years"]
|
||||
current_horizon = snakemake.wildcards.planning_horizons
|
||||
|
||||
for carrier in ['solar', 'onwind', 'offwind-ac', 'offwind-dc']:
|
||||
|
||||
existing = n.generators.loc[n.generators.carrier==carrier,"p_nom"]
|
||||
ind = list(set([i.split(sep=" ")[0] + ' ' + i.split(sep=" ")[1] for i in existing.index]))
|
||||
|
||||
previous_years = [
|
||||
str(y) for y in
|
||||
planning_horizons + grouping_years
|
||||
if y < int(snakemake.wildcards.planning_horizons)
|
||||
]
|
||||
|
||||
for p_year in previous_years:
|
||||
ind2 = [i for i in ind if i + " " + carrier + "-" + p_year in existing.index]
|
||||
sel_current = [i + " " + carrier + "-" + current_horizon for i in ind2]
|
||||
sel_p_year = [i + " " + carrier + "-" + p_year for i in ind2]
|
||||
n.generators.loc[sel_current, "p_nom_max"] -= existing.loc[sel_p_year].rename(lambda x: x[:-4] + current_horizon)
|
||||
|
||||
n.generators.p_nom_max.clip(lower=0, inplace=True)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user