Skip to content

Commit 08dd2c9

Browse files
Bugfix load shedding scaling (#1908)
* Fix bugs by (i) removing sign argument and (ii) using isinstance * Remove todo and color and nice_name assignment. * Add release notes. * Change p_nom_extendable=True to p_nom=np.inf * Updated doctables for load_shedding * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9b39110 commit 08dd2c9

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

doc/configtables/solving.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
,Unit,Values,Description
22
options,,,
33
-- clip_p_max_pu,p.u.,float,To avoid too small values in the renewables` per-unit availability time series values below this threshold are set to zero.
4-
-- load_shedding,bool/float,"{'true','false', float}","Add generators with very high marginal cost to simulate load shedding and avoid problem infeasibilities. If load shedding is a float, it denotes the marginal cost in EUR/kWh."
4+
-- load_shedding,bool/float,"{'true','false', float}",Set to true to add generators with very high marginal cost to simulate load shedding and avoid problem infeasibilities. The default value is 1e5 €/MWh = 100 €/kWh (see http://journal.frontiersin.org/article/10.3389/fenrg.2015.00055/full). Override this value by setting a float denoting the new cost in MWh. Consider lowering the cost if you are struggling with long solve times.
55
-- curtailment_mode,bool/float,"{'true','false'}",Fixes the dispatch profiles of generators with time-varying p_max_pu by setting ``p_min_pu = p_max_pu`` and adds an auxiliary curtailment generator (with negative sign to absorb excess power) at every AC bus. This can speed up the solving process as the curtailment decision is aggregated into a single generator per region. Defaults to ``false``.
66
-- noisy_costs,bool,"{'true','false'}","Add random noise to marginal cost of generators by :math:`\mathcal{U}(0.009,0,011)` and capital cost of lines and links by :math:`\mathcal{U}(0.09,0,11)`."
77
-- skip_iterations,bool,"{'true','false'}","Skip iterating, do not update impedances of branches. Defaults to true."

doc/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Release Notes
99
Upcoming Release
1010
================
1111

12+
* Fixed bugs with load shedding due to incorrect use of `sign` argument in `n.add` and `np.isscalar` (https://github.com/PyPSA/pypsa-eur/pull/1908).
13+
1214
* chore: disable PTES dynamic capacity by default
1315

1416
* Add CO2 emission prices configurable per planning horizon for sector-coupled models.

scripts/solve_network.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,22 +462,19 @@ def prepare_network(
462462
if load_shedding := solve_opts.get("load_shedding"):
463463
# intersect between macroeconomic and surveybased willingness to pay
464464
# http://journal.frontiersin.org/article/10.3389/fenrg.2015.00055/full
465-
# TODO: retrieve color and nice name from config
466-
n.add("Carrier", "load", color="#dd2e23", nice_name="Load shedding")
465+
n.add("Carrier", "load")
467466
buses_i = n.buses.index
468-
if not np.isscalar(load_shedding):
469-
# TODO: do not scale via sign attribute (use Eur/MWh instead of Eur/kWh)
470-
load_shedding = 1e2 # Eur/kWh
467+
if isinstance(load_shedding, bool):
468+
load_shedding = 1e5 # Eur/MWh
471469

472470
n.add(
473471
"Generator",
474472
buses_i,
475473
" load",
476474
bus=buses_i,
477475
carrier="load",
478-
sign=1e-3, # Adjust sign to measure p and p_nom in kW instead of MW
479-
marginal_cost=load_shedding, # Eur/kWh
480-
p_nom=1e9, # kW
476+
marginal_cost=load_shedding, # Eur/MWh
477+
p_nom=np.inf,
481478
)
482479

483480
if solve_opts.get("curtailment_mode"):

0 commit comments

Comments
 (0)