trajectories.py
TYNDP PEMMDB trajectory overwrites for the modify_prenetwork step.
Writes TYNDP PEMMDB trajectory p_nom_min / p_nom_max bands onto
extendable components for multiple carriers across all modelled countries,
following a brownfield-deduction pattern so the bounds represent the
additional capacity still available to the solver.
- :func:
apply_pemmdb_trajectories— entry point called from :func:mods.network.modify_prenetwork; reads the trajectory CSV, aggregates it to PyPSA-AT cluster regions, and delegates per-carrier bound writes.
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.
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/trajectories.py
29 30 31 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 | |
apply_pemmdb_trajectories(n, snakemake, costs)
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/trajectories.py
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 329 330 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 | |
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/trajectories.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 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 | |
register_extendable_nuclear(n, traj, pyear, costs)
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 that carries a non-zero nuclear trajectory band.
An arbitrary existing nuclear Link acts as the schema donor (buses, ramp
limits, custom PyPSA-Eur columns, ...), while the meaningful attributes
(efficiency, capital_cost, marginal_cost, lifetime) are taken
from costs, p_nom is reset to zero and build_year set to pyear.
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)).
Locations whose nuclear bands are all zero (or absent) receive no extendable
Link. If a Link named {location} nuclear-{pyear} already exists with
p_nom > 0, it is an existing brownfield vintage and no extendable Link
is added for that location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
pypsa.Network
|
The PyPSA network object to modify in-place. Must contain at least one nuclear Link to act as the schema donor. |
required |
traj
|
pandas.DataFrame
|
Aggregated trajectory DataFrame as returned by
:func: |
required |
pyear
|
int
|
Current planning horizon, used as the new Link's build year and name suffix. |
required |
costs
|
pandas.DataFrame
|
The processed costs CSV data. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a Link named |
IndexError
|
If the network contains no nuclear Links at all (no schema donor). |
Source code in mods/network/trajectories.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 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 | |