solve: add option for post-discretization of lines and links

This commit is contained in:
Fabian Neumann 2024-05-15 14:56:50 +02:00
parent 84689e9257
commit 9b50c846a0
6 changed files with 28 additions and 18 deletions

View File

@ -770,11 +770,20 @@ solving:
# io_api: "direct" # Increases performance but only supported for the highs and gurobi solvers
# options that go into the optimize function
track_iterations: false
min_iterations: 4
max_iterations: 6
min_iterations: 2
max_iterations: 3
transmission_losses: 2
linearized_unit_commitment: true
horizon: 365
post_discretization:
enable: false
line_unit_size: 1700
link_unit_size:
DC: 2000
H2 pipeline: 1200
gas pipeline: 1500
line_threshold: 0.3
link_threshold: 0.3
constraints:
CCL: false

View File

@ -1,10 +0,0 @@
,Unit,Values,Description
post-discretization,,,
-- AC,int,1700,Minimum capacity of discrete "AC" line expansion steps.
links,,,
-- DC,int,2000,Check
-- gas pipeline,int,1500,Minimum capacity of discrete "gas pipeline".
-- gas pipeline new,int,1500,Minimum capacity of discrete "new gas pipeline".
-- H2 pipeline,int,1200,Minimum capacity of discrete "H2 pipeline".
-- H2 pipeline (Kernnetz),int,1200,Minimum capacity of discrete "H2 pipeline (Kernnetz)".
-- H2 pipeline retrofitted,int,1200,Minimum capacity of discrete "retrofitted H2 pipeline".
Can't render this file because it contains an unexpected character in line 3 and column 45.

View File

@ -14,6 +14,13 @@ options,,,
-- transmission_losses,int,[0-9],"Add piecewise linear approximation of transmission losses based on n tangents. Defaults to 0, which means losses are ignored."
-- linearized_unit_commitment,bool,"{'true','false'}",Whether to optimise using the linearized unit commitment formulation.
-- horizon,--,int,Number of snapshots to consider in each iteration. Defaults to 100.
-- post_discretization,,,
-- -- enable,bool,"{'true','false'}",Switch to enable post-discretization of the network. Disabled by default.
-- -- line_unit_size,MW,float,Discrete unit size of lines in MW.
-- -- link_unit_size,MW,float,Discrete unit size of links in MW by carrier (given in dictionary style.
-- -- -- {carrier},,,
-- -- line_threshold,,float,The threshold relative to the discrete line unit size beyond which to round up to the next unit. Defaults to 0.3.
-- -- link_threshold,,float,The threshold relative to the discrete link unit size beyond which to round up to the next unit. Defaults to 0.3.
constraints ,,,
-- CCL,bool,"{'true','false'}",Add minimum and maximum levels of generator nominal capacity per carrier for individual countries. These can be specified in the file linked at ``electricity: agg_p_nom_limits`` in the configuration. File defaults to ``data/agg_p_nom_minmax.csv``.
-- EQ,bool/string,"{'false',`n(c| )``; i.e. ``0.5``-``0.7c``}",Require each country or node to on average produce a minimal share of its total consumption itself. Example: ``EQ0.5c`` demands each country to produce on average at least 50% of its consumption; ``EQ0.5`` demands each node to produce on average at least 50% of its consumption.

1 Unit Values Description
14 -- transmission_losses int [0-9] Add piecewise linear approximation of transmission losses based on n tangents. Defaults to 0, which means losses are ignored.
15 -- linearized_unit_commitment bool {'true','false'} Whether to optimise using the linearized unit commitment formulation.
16 -- horizon -- int Number of snapshots to consider in each iteration. Defaults to 100.
17 -- post_discretization
18 -- -- enable bool {'true','false'} Switch to enable post-discretization of the network. Disabled by default.
19 -- -- line_unit_size MW float Discrete unit size of lines in MW.
20 -- -- link_unit_size MW float Discrete unit size of links in MW by carrier (given in dictionary style.
21 -- -- -- {carrier}
22 -- -- line_threshold float The threshold relative to the discrete line unit size beyond which to round up to the next unit. Defaults to 0.3.
23 -- -- link_threshold float The threshold relative to the discrete link unit size beyond which to round up to the next unit. Defaults to 0.3.
24 constraints
25 -- CCL bool {'true','false'} Add minimum and maximum levels of generator nominal capacity per carrier for individual countries. These can be specified in the file linked at ``electricity: agg_p_nom_limits`` in the configuration. File defaults to ``data/agg_p_nom_minmax.csv``.
26 -- EQ bool/string {'false',`n(c| )``; i.e. ``0.5``-``0.7c``} Require each country or node to on average produce a minimal share of its total consumption itself. Example: ``EQ0.5c`` demands each country to produce on average at least 50% of its consumption; ``EQ0.5`` demands each node to produce on average at least 50% of its consumption.

View File

@ -43,7 +43,10 @@ Upcoming Release
* Allow dictionary for the config aviation_demand_factor.
* Post discretize network infrastructure like lines and links.
* Add option to post-discretize line and link capacities based on unit sizes and
rounding thresholds specified in the configuration under ``solving: options:
post_discretization:`` when iterative solving is enables (``solving: optiosn:
skip_iterations: false``). This option is disabled by default.
* Group existing capacities to the earlier grouping_year for consistency with optimized capacities.

View File

@ -11,7 +11,7 @@ dependencies:
- pip
- atlite>=0.2.9
- pypsa>=0.26.1
- pypsa>=0.28
- linopy
- dask

View File

@ -45,7 +45,6 @@ from _helpers import (
)
from pypsa.descriptors import get_activity_mask
from pypsa.descriptors import get_switchable_as_dense as get_as_dense
from pypsa.optimization.abstract import optimize_transmission_expansion_iteratively
logger = logging.getLogger(__name__)
pypsa.pf.logger.setLevel(logging.WARNING)
@ -923,9 +922,11 @@ def solve_network(n, config, solving, **kwargs):
kwargs["track_iterations"] = cf_solving["track_iterations"]
kwargs["min_iterations"] = cf_solving["min_iterations"]
kwargs["max_iterations"] = cf_solving["max_iterations"]
kwargs["lines_disc"] = config["post-discretization"]["lines"]
kwargs["links_disc"] = config["post-discretization"]["links"]
status, condition = optimize_transmission_expansion_iteratively(n, **kwargs)
if cf_solving["post_discretization"].pop("enable"):
kwargs.update(cf_solving["post_discretization"])
status, condition = n.optimize.optimize_transmission_expansion_iteratively(
**kwargs
)
if status != "ok" and not rolling_horizon:
logger.warning(