potentials.py
Capacity potential overwrites for the modify_prenetwork step.
Two complementary p_nom_max writers share this module because both source their bounds from external capacity studies and follow the same brownfield-deduction pattern:
- :func:
overwrite_pemmdb_capacities— TYNDP PEMMDB trajectory bands for multiple carriers across all modelled countries. - :func:
apply_klien_potential_limits— Austrian KLIEN study regional potentials (ground PV, building PV, onshore wind).
aggregate_by_cluster_and_country(trajectories, skip_countries=None)
Aggregate TYNDP trajectory data to PyPSA-AT cluster regions and country codes.
Maps raw TYNDP bus codes to PyPSA-AT location codes via TYNDP_TO_PYPSA_LOCATION,
sums p_nom_min / p_nom_max per (location, pypsa_eur_carrier) pair, and
additionally aggregates to two-letter country codes so that country-level clustering
configurations (e.g. Italy as a single node) still find a matching trajectory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trajectories
|
pandas.DataFrame
|
Raw trajectory DataFrame with at minimum the columns |
required |
skip_countries
|
tuple[str] | None
|
Two-letter ISO country codes (e.g. |
None
|
Returns:
| Type | Description |
|---|---|
pandas.DataFrame
|
MultiIndex DataFrame indexed by |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any |
Source code in mods/network/potentials.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
apply_klien_potential_limits(n, snakemake)
Cap extendable AT generator p_nom_max values by regional KLIEN study potentials.
Reads pre-processed capacity potential CSVs (in MW) produced by
build_klien_potentials, subtracts already-committed brownfield capacity,
and writes the remaining headroom into p_nom_max for every extendable
AT generator whose carrier appears in klien_potential_limits.technologies.
Only generators on buses whose index starts with "AT" are affected.
Non-AT generators (e.g. DE, CH) are left unchanged. The function skips
silently when klien_potential_limits.technologies is an empty list.
When klien_potential_limits.use_technical_potentials is true, the column
C_technical_potential is used regardless of year, ambition, or
climate_scenario.
The NUTS3-level potential CSVs are always read and aggregated to the
network's clustering resolution via
:func:mods.clustering.utils.combine_regions_by_clustering (AT10 collapses
NUTS3 -> NUTS2; AT35 keeps NUTS3).
Supported carriers and their CSV source:
solar rooftop—nuts3_pv_buildings.csvsolar,solar-hsat—nuts3_pv_ground.csv(shared land area)onwind—nuts3_wind.csv
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
pypsa.Network
|
The pre-network to be modified in place. |
required |
snakemake
|
snakemake.script.Snakemake
|
Snakemake workflow object; config is read via |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any entry in |
KeyError
|
If the requested scenario column is absent from a potential CSV. |
Notes
Brownfield capacity is estimated via n.statistics.installed_capacity(),
which captures carry-over from previous myopic periods.
Source code in mods/network/potentials.py
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | |
apply_trajectories(n, c, traj, carrier, skip_countries, is_myopic_year, at_port=0)
Write trajectory p_nom_min / p_nom_max bounds onto a single carrier.
For each non-skipped location that hosts an extendable component of carrier, the function:
- Looks up the pre-aggregated trajectory bounds from traj.
- Subtracts existing brownfield capacity (myopic horizons only) so that the
bounds represent additional capacity still available to the solver.
The brownfield is measured at the same port as the trajectory: bus-1 units
(
p_nom × efficiency) whenat_port=1, bus-0 units otherwise. - Converts bus-1 output capacity bounds to bus-0 input bounds when
at_port=1by dividing by component efficiency. - Writes the final bounds directly to
n.components[c].static.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
The PyPSA network object to modify in-place. |
required | |
c
|
Component class name, e.g. |
required | |
traj
|
Aggregated trajectory DataFrame as returned by
:func: |
required | |
carrier
|
PyPSA carrier string to match against the network components and
the trajectory index level |
required | |
skip_countries
|
Two-letter ISO country codes whose locations are not touched. |
required | |
is_myopic_year
|
bool
|
True if current planning horizon is not the first planning horizon. |
required |
at_port
|
int
|
Port index used to identify the bus column ( |
0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no extendable locations are found for carrier, or if the
computed |
NotImplementedError
|
If |
Source code in mods/network/potentials.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
overwrite_pemmdb_capacities(n, snakemake)
Apply TYNDP trajectory p_nom_min / p_nom_max bands from PEMMDB data.
Entry point called from :func:mods.network.modify_prenetwork during the
modify DAG phase. Reads the trajectory CSV pointed to by
snakemake.input.tyndp_trajectories, filters it to the current planning
horizon, aggregates it to PyPSA-AT cluster regions, and delegates per-carrier
bound writes to :func:apply_trajectories.
Only trajectory bands are applied; generator profiles and optimised p_nom
values are out of scope.
The function is a no-op when mods.PEMMDB_trajectories.enable is false
in config.at.yaml.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
pypsa.Network
|
The PyPSA network object to modify in-place. |
required |
snakemake
|
snakemake.script.Snakemake
|
Snakemake proxy object providing |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the trajectory CSV contains no rows for the current planning horizon. |
Source code in mods/network/potentials.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | |
register_extendable_nuclear(n, traj, skip_countries, pyear)
Add one extendable nuclear Link per location so :func:apply_trajectories can bound it.
Nuclear is a conventional carrier represented by one or more non-extendable
vintage Links per location (bus0="EU uranium", bus1 = electricity
bus, bus2="co2 atmosphere"), all created by add_existing_baseyear.
Because no extendable variant exists, the trajectory bounds would have nothing
to attach to. This function creates that missing component — a single
extendable Link per location whose newest vintage supplies the full
attribute row (buses, efficiency, capital_cost, ramp limits, ...), with
p_nom reset to zero and build_year set to pyear. Copying every
attribute keeps new capacity consistent with the vintages and prevents future
attributes from silently regressing to defaults. The vintages are left
untouched and carry the brownfield as a fixed floor; the actual p_nom_min
/ p_nom_max bounds are then written by :func:apply_trajectories via the
standard techs loop (("Link", "nuclear", 1)).
To guarantee every created Link is bounded — an unbounded extendable Link would let the solver build unlimited nuclear — the function fails fast instead of leaving a stray component: it raises if no nuclear vintages exist, if a non-skipped nuclear location has no trajectory, or if the target name already exists. Locations in skip_countries are dropped before these checks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
pypsa.Network
|
The PyPSA network object to modify in-place. |
required |
traj
|
pandas.DataFrame
|
Aggregated trajectory DataFrame as returned by
:func: |
required |
skip_countries
|
tuple[str]
|
Two-letter ISO country codes (matched against the location prefix) whose locations are not touched. |
required |
pyear
|
int
|
Current planning horizon, used as the new Link's build year and name suffix. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the network contains no nuclear vintage Links, if a non-skipped nuclear location lacks trajectory data, or if the extendable Link's name collides with an existing component. |
Source code in mods/network/potentials.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |