Note

You can download this example as a Jupyter notebook or start it in interactive mode.

# Constraining the total capacity per bus and carrier#

In this small example, we limit the nominal capacity of generators of the same production carrier at the same bus.

Therefore, we introduce a column nom_min_{carrier} and nom_max_{carrier} in the buses dataframe. These are then used as lower and upper bounds of generators of the same carrier at the same bus.

[1]:

import pypsa

[2]:

n = pypsa.examples.ac_dc_meshed(from_master=True)

WARNING:pypsa.io:Importing network from PyPSA version v0.17.1 while current version is v0.22.1. Read the release notes at https://pypsa.readthedocs.io/en/latest/release_notes.html to prepare your network for import.


Now add a second wind generator at bus ‘Frankfurt’ and limit the combined capacity.

[3]:

n.add(
"Generator",
"Frankfurt Wind 2",
bus="Frankfurt",
capital_cost=120,
carrier="wind",
p_nom_extendable=True,
)

n.buses.loc[["Frankfurt", "Manchester"], "nom_min_wind"] = 2000
n.buses.loc[["Frankfurt"], "nom_max_wind"] = 2200


We are running the lopf and check whether the constraint is fulfilled.

[4]:

n.lopf(pyomo=False)

print(n.generators.p_nom_opt)

INFO:pypsa.linopf:Prepare linear problem
INFO:pypsa.linopf:Total preparation time: 0.19s
INFO:pypsa.linopf:Solve linear problem using Glpk solver
INFO:pypsa.linopf:Optimization successful. Objective value: -1.38e+07

Generator
Manchester Wind     2000.0000
Manchester Gas         0.0000
Norway Wind          895.3730
Norway Gas            91.0017
Frankfurt Wind       100.0000
Frankfurt Gas        884.0930
Frankfurt Wind 2    2100.0000
Name: p_nom_opt, dtype: float64


Looks good! The generators of carrier ‘wind’ at bus ‘Frankfurt’ are just the limit of 2200 MW.