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.

We start with importing a small example network.

import pypsa
n = pypsa.examples.ac_dc_meshed(from_master=True) network from PyPSA version v0.17.1 while current version is v0.22.1. Read the release notes at to prepare your network for import. network has buses, carriers, generators, global_constraints, lines, links, loads

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

    "Frankfurt Wind 2",

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.


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
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.