Adapt to new snapshot weightings (#259)
* for now use n.snapshot_weightings.generators * require pypsa master; use .objective for Nyears * implement suggestions from code review * add release note
This commit is contained in:
parent
2aa59a3905
commit
4cc5e49ca8
@ -24,6 +24,7 @@ Upcoming Release
|
||||
* The ``focus_weights`` are now also considered when pre-clustering in the :mod:`simplify_network` rule [`#241 <https://github.com/PyPSA/pypsa-eur/pull/241>`_].
|
||||
* Continuous integration testing switches to Github Actions from Travis CI [`#252 <https://github.com/PyPSA/pypsa-eur/pull/252>`_].
|
||||
* Bugfix in :mod:`build_renewable_profile` where offshore wind profiles could no longer be created [`#249 <https://github.com/PyPSA/pypsa-eur/pull/249>`_].
|
||||
* Implements changes to ``n.snapshot_weightings`` in upcoming PyPSA version (cf. `PyPSA/PyPSA/#227 <https://github.com/PyPSA/PyPSA/pull/227>`_) [`#259 <https://github.com/PyPSA/pypsa-eur/pull/259>`_].
|
||||
* Bugfix: Lower expansion limit of extendable carriers is now set to the existing capacity, i.e. ``p_nom_min = p_nom`` (0 before). Simultaneously, the upper limit (``p_nom_max``) is now the maximum of the installed capacity (``p_nom``) and the previous estimate based on land availability (``p_nom_max``) [`#260 <https://github.com/PyPSA/pypsa-eur/pull/260>`_].
|
||||
|
||||
PyPSA-Eur 0.3.0 (7th December 2020)
|
||||
|
@ -8,7 +8,7 @@ channels:
|
||||
dependencies:
|
||||
- python<=3.7
|
||||
- pip
|
||||
- pypsa>=0.17.1
|
||||
#- pypsa>=0.17.1
|
||||
- atlite>=0.2.2
|
||||
- dask<=2021.3.1 # until https://github.com/dask/dask/issues/7583 is solved
|
||||
- pre-commit
|
||||
@ -27,6 +27,7 @@ dependencies:
|
||||
- descartes
|
||||
|
||||
- pip:
|
||||
- git+https://github.com/pypsa/pypsa.git#egg=pypsa
|
||||
- vresutils==0.3.1
|
||||
- sphinx
|
||||
- sphinx_rtd_theme
|
||||
|
@ -12,7 +12,7 @@ dependencies:
|
||||
- pip
|
||||
- mamba # esp for windows build
|
||||
|
||||
- pypsa>=0.17.1
|
||||
#- pypsa>=0.17.1
|
||||
- atlite>=0.2.4
|
||||
- dask<=2021.3.1 # until https://github.com/dask/dask/issues/7583 is solved
|
||||
|
||||
@ -54,5 +54,6 @@ dependencies:
|
||||
- country_converter
|
||||
|
||||
- pip:
|
||||
- git+https://github.com/pypsa/pypsa.git#egg=pypsa
|
||||
- vresutils==0.3.1
|
||||
- tsam>=1.1.0
|
||||
|
@ -119,7 +119,7 @@ def load_network_for_plots(fn, tech_costs, config, combine_hydro_ps=True):
|
||||
# bus_carrier = n.storage_units.bus.map(n.buses.carrier)
|
||||
# n.storage_units.loc[bus_carrier == "heat","carrier"] = "water tanks"
|
||||
|
||||
Nyears = n.snapshot_weightings.sum() / 8760.
|
||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.
|
||||
costs = load_costs(Nyears, tech_costs, config['costs'], config['electricity'])
|
||||
update_transmission_costs(n, costs)
|
||||
|
||||
|
@ -561,7 +561,7 @@ if __name__ == "__main__":
|
||||
configure_logging(snakemake)
|
||||
|
||||
n = pypsa.Network(snakemake.input.base_network)
|
||||
Nyears = n.snapshot_weightings.sum() / 8760.
|
||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.
|
||||
|
||||
costs = load_costs(Nyears)
|
||||
ppl = load_powerplants()
|
||||
|
@ -197,7 +197,7 @@ if __name__ == "__main__":
|
||||
configure_logging(snakemake)
|
||||
|
||||
n = pypsa.Network(snakemake.input.network)
|
||||
Nyears = n.snapshot_weightings.sum() / 8760.
|
||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.
|
||||
costs = load_costs(Nyears, tech_costs=snakemake.input.tech_costs,
|
||||
config=snakemake.config['costs'],
|
||||
elec_config=snakemake.config['electricity'])
|
||||
|
@ -357,7 +357,8 @@ if __name__ == "__main__":
|
||||
clustering = pypsa.networkclustering.Clustering(n, busmap, linemap, linemap, pd.Series(dtype='O'))
|
||||
else:
|
||||
line_length_factor = snakemake.config['lines']['length_factor']
|
||||
hvac_overhead_cost = (load_costs(n.snapshot_weightings.sum()/8760,
|
||||
Nyears = n.snapshot_weightings.objective.sum()/8760
|
||||
hvac_overhead_cost = (load_costs(Nyears,
|
||||
tech_costs=snakemake.input.tech_costs,
|
||||
config=snakemake.config['costs'],
|
||||
elec_config=snakemake.config['electricity'])
|
||||
|
@ -111,15 +111,15 @@ def calculate_costs(n, label, costs):
|
||||
costs.loc[idx[raw_index],label] = capital_costs_grouped.values
|
||||
|
||||
if c.name == "Link":
|
||||
p = c.pnl.p0.multiply(n.snapshot_weightings,axis=0).sum()
|
||||
p = c.pnl.p0.multiply(n.snapshot_weightings.generators,axis=0).sum()
|
||||
elif c.name == "Line":
|
||||
continue
|
||||
elif c.name == "StorageUnit":
|
||||
p_all = c.pnl.p.multiply(n.snapshot_weightings,axis=0)
|
||||
p_all = c.pnl.p.multiply(n.snapshot_weightings.generators,axis=0)
|
||||
p_all[p_all < 0.] = 0.
|
||||
p = p_all.sum()
|
||||
else:
|
||||
p = c.pnl.p.multiply(n.snapshot_weightings,axis=0).sum()
|
||||
p = c.pnl.p.multiply(n.snapshot_weightings.generators,axis=0).sum()
|
||||
|
||||
marginal_costs = p*c.df.marginal_cost
|
||||
|
||||
@ -144,10 +144,12 @@ def calculate_energy(n, label, energy):
|
||||
|
||||
for c in n.iterate_components(n.one_port_components|n.branch_components):
|
||||
|
||||
if c.name in n.one_port_components:
|
||||
c_energies = c.pnl.p.multiply(n.snapshot_weightings,axis=0).sum().multiply(c.df.sign).groupby(c.df.carrier).sum()
|
||||
if c.name in {'Generator', 'Load', 'ShuntImpedance'}:
|
||||
c_energies = c.pnl.p.multiply(n.snapshot_weightings.generators,axis=0).sum().multiply(c.df.sign).groupby(c.df.carrier).sum()
|
||||
elif c.name in {'StorageUnit', 'Store'}:
|
||||
c_energies = c.pnl.p.multiply(n.snapshot_weightings.stores,axis=0).sum().multiply(c.df.sign).groupby(c.df.carrier).sum()
|
||||
else:
|
||||
c_energies = (-c.pnl.p1.multiply(n.snapshot_weightings,axis=0).sum() - c.pnl.p0.multiply(n.snapshot_weightings,axis=0).sum()).groupby(c.df.carrier).sum()
|
||||
c_energies = (-c.pnl.p1.multiply(n.snapshot_weightings.generators,axis=0).sum() - c.pnl.p0.multiply(n.snapshot_weightings.generators,axis=0).sum()).groupby(c.df.carrier).sum()
|
||||
|
||||
energy = include_in_summary(energy, [c.list_name], label, c_energies)
|
||||
|
||||
@ -400,7 +402,7 @@ def make_summaries(networks_dict, country='all'):
|
||||
if country != 'all':
|
||||
n = n[n.buses.country == country]
|
||||
|
||||
Nyears = n.snapshot_weightings.sum() / 8760.
|
||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.
|
||||
costs = load_costs(Nyears, snakemake.input[0],
|
||||
snakemake.config['costs'], snakemake.config['electricity'])
|
||||
update_transmission_costs(n, costs, simple_hvdc_costs=False)
|
||||
|
@ -196,7 +196,7 @@ def plot_total_energy_pie(n, ax=None):
|
||||
def plot_total_cost_bar(n, ax=None):
|
||||
if ax is None: ax = plt.gca()
|
||||
|
||||
total_load = (n.snapshot_weightings * n.loads_t.p.sum(axis=1)).sum()
|
||||
total_load = (n.snapshot_weightings.generators * n.loads_t.p.sum(axis=1)).sum()
|
||||
tech_colors = opts['tech_colors']
|
||||
|
||||
def split_costs(n):
|
||||
|
@ -150,6 +150,7 @@ def average_every_nhours(n, offset):
|
||||
|
||||
return m
|
||||
|
||||
|
||||
def apply_time_segmentation(n, segments):
|
||||
logger.info(f"Aggregating time series to {segments} segments.")
|
||||
try:
|
||||
@ -223,7 +224,7 @@ if __name__ == "__main__":
|
||||
opts = snakemake.wildcards.opts.split('-')
|
||||
|
||||
n = pypsa.Network(snakemake.input[0])
|
||||
Nyears = n.snapshot_weightings.sum() / 8760.
|
||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.
|
||||
|
||||
set_line_s_max_pu(n)
|
||||
|
||||
|
@ -141,7 +141,8 @@ def simplify_network_to_380(n):
|
||||
def _prepare_connection_costs_per_link(n):
|
||||
if n.links.empty: return {}
|
||||
|
||||
costs = load_costs(n.snapshot_weightings.sum() / 8760, snakemake.input.tech_costs,
|
||||
Nyears = n.snapshot_weightings.objective.sum() / 8760
|
||||
costs = load_costs(Nyears, snakemake.input.tech_costs,
|
||||
snakemake.config['costs'], snakemake.config['electricity'])
|
||||
|
||||
connection_costs_per_link = {}
|
||||
|
@ -174,16 +174,16 @@ def add_EQ_constraints(n, o, scaling=1e-1):
|
||||
ggrouper = n.generators.bus
|
||||
lgrouper = n.loads.bus
|
||||
sgrouper = n.storage_units.bus
|
||||
load = n.snapshot_weightings @ \
|
||||
load = n.snapshot_weightings.generators @ \
|
||||
n.loads_t.p_set.groupby(lgrouper, axis=1).sum()
|
||||
inflow = n.snapshot_weightings @ \
|
||||
inflow = n.snapshot_weightings.stores @ \
|
||||
n.storage_units_t.inflow.groupby(sgrouper, axis=1).sum()
|
||||
inflow = inflow.reindex(load.index).fillna(0.)
|
||||
rhs = scaling * ( level * load - inflow )
|
||||
lhs_gen = linexpr((n.snapshot_weightings * scaling,
|
||||
lhs_gen = linexpr((n.snapshot_weightings.generators * scaling,
|
||||
get_var(n, "Generator", "p").T)
|
||||
).T.groupby(ggrouper, axis=1).apply(join_exprs)
|
||||
lhs_spill = linexpr((-n.snapshot_weightings * scaling,
|
||||
lhs_spill = linexpr((-n.snapshot_weightings.stores * scaling,
|
||||
get_var(n, "StorageUnit", "spill").T)
|
||||
).T.groupby(sgrouper, axis=1).apply(join_exprs)
|
||||
lhs_spill = lhs_spill.reindex(lhs_gen.index).fillna("")
|
||||
|
Loading…
Reference in New Issue
Block a user