Solve network
Functions to add constraints and prepare the network for the solver.
Associated with the solve_networks
rule in the Snakefile.
add_battery_constraints(n)
Add constraint ensuring that charger = discharger, i.e. 1 * charger_size - efficiency * discharger_size = 0
Source code in workflow/scripts/solve_network.py
add_chp_constraints(n)
Add constraints to couple the heat and electricity output of CHP plants (using the cb and cv parameter). See the DEA technology cataloge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
Network
|
the pypsa network object to which's model the constraints are added |
required |
Source code in workflow/scripts/solve_network.py
add_co2_constraints_prices(network, co2_control)
Add co2 constraints or prices
Parameters:
Name | Type | Description | Default |
---|---|---|---|
network
|
Network
|
the network to which prices or constraints are to be added |
required |
co2_control
|
dict
|
the config |
required |
Raises:
Type | Description |
---|---|
ValueError
|
unrecognised co2 control option |
Source code in workflow/scripts/solve_network.py
add_emission_prices(n, emission_prices={'co2': 0.0}, exclude_co2=False)
From pypsa-eur: add GHG price to marginal costs of generators and storage units
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
Network
|
the pypsa network |
required |
emission_prices
|
dict
|
emission prices per GHG. Defaults to {"co2": 0.0}. |
{'co2': 0.0}
|
exclude_co2
|
bool
|
do not charge for CO2 emissions. Defaults to False. |
False
|
Source code in workflow/scripts/solve_network.py
add_land_use_constraint(n, planning_horizons)
Add land use constraints for renewable energy potential. This ensures that the brownfield + greenfield vre installations for each generator tech do not exceed the technical potential.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
Network
|
the network object to add the constraints to |
required |
planning_horizons
|
str | int
|
the planning horizon year as string |
required |
Source code in workflow/scripts/solve_network.py
add_operational_reserve_margin(n, config)
Build operational reserve margin constraints based on the formulation given in https://genxproject.github.io/GenX.jl/stable/Model_Reference/core/#GenX.operational_reserves_core!-Tuple{JuMP.Model,%20Dict,%20Dict}
The constraint is network wide and not at each node!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
Network
|
the network object to optimize |
required |
config
|
dict
|
the configuration dictionary |
required |
Example
config.yaml requires to specify operational_reserve: operational_reserve: activate: true epsilon_load: 0.02 # percentage of load at each snapshot epsilon_vres: 0.02 # percentage of VRES at each snapshot contingency: 400000 # MW
Source code in workflow/scripts/solve_network.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 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 |
|
add_remind_paid_off_constraints(n)
Paid-off components can be placed wherever PyPSA wants but have a total limit.
Add constraints to ensure that the paid off capacity from REMIND is not exceeded across the network & that it does not exceed the technical potential.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
Network
|
the network object to which's model the constraints are added |
required |
Source code in workflow/scripts/solve_network.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
|
add_transmission_constraints(n)
Add constraint ensuring that transmission lines p_nom are the same for both directions, i.e. p_nom positive = p_nom negative
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
Network
|
the network object to optimize |
required |
Source code in workflow/scripts/solve_network.py
extra_functionality(n, _)
Add supplementary constraints to the network model. pypsa.linopf.network_lopf
.
If you want to enforce additional custom constraints, this is a good location to add them.
The arguments opts
and snakemake.config
are expected to be attached to the network.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
Network
|
the network object to optimize |
required |
_
|
dummy for compatibility with pypsa solve |
required |
Source code in workflow/scripts/solve_network.py
freeze_components(n, config, exclude=['H2 turbine'])
Set p_nom_extendable=False for the components in the network. Applies to vre_techs and conventional technologies not in the exclude list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
Network
|
the network object |
required |
config
|
dict
|
the configuration dictionary |
required |
exclude
|
list
|
list of technologies to exclude from freezing. Defaults to ["OCGT"] |
['H2 turbine']
|
Source code in workflow/scripts/solve_network.py
prepare_network(n, solve_opts, config, plan_year, co2_pathway)
Prepare the network for the solver,
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
Network
|
the network object to optimize |
required |
solve_opts
|
dict
|
solving options |
required |
config
|
dict
|
the snakemake configuration dictionary |
required |
plan_year
|
int
|
planning horizon year for which network is solved |
required |
co2_pathway
|
str
|
the CO2 pathway name to use |
required |
Returns:
Type | Description |
---|---|
Network
|
pypsa.Network: network object with additional constraints |
Source code in workflow/scripts/solve_network.py
set_transmission_limit(n, kind, factor, n_years=1)
Set global transimission limit constraints - adapted from pypsa-eur
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
Network
|
the network object |
required |
kind
|
str
|
the kind of limit to set, either 'c' for cost or 'v' for volume or l for length |
required |
factor
|
float or str
|
the factor to apply to the base year quantity, per year |
required |
n_years
|
int
|
the number of years to consider for the limit. Defaults to 1. |
1
|
Source code in workflow/scripts/solve_network.py
solve_network(n, config, solving, opts='', **kwargs)
Perform the optimisation Args: n (pypsa.Network): the pypsa network object config (dict): the configuration dictionary solving (dict): the solving configuration dictionary opts (str): optional wildcards such as ll (not used in pypsa-china)
Returns:
Type | Description |
---|---|
Network
|
pypsa.Network: the optimized network |