add_CCL_constraints

Hello everyone! I’m running PyPSA-Eur (specifically a sector-coupled/myopic version) and trying to limit or phase out coal capacities in Germany by certain milestone years (e.g. 8 GW in 2030, 2 GW in 2035, 0 GW in 2045). I want to phase out coal capacity, but coal is modeled as links while add_CCL_constraints only works on generators. This means my CSV limits ((DE, coal) → max=8 GW for 2030) don’t affect coal links. What’s the best way to enforce these capacity constraints if coal is in the links table—should I convert coal to generators, or do I need a separate link-based function like add_CLL_constraints? How have others handled this situation?

PyPSA-Eur currently has a power and sector-coupled version. As you found out, some of the model representation differ and all constraints designed for the power only case are not applicable to the other model. Having generators as links represented is the current go-to approach.

PyPSA-Eur will become more modular and will get refactored soon to make the use easier again. Until then, I would recommend to write your own add_CCL_constraint. I rewrote all nomopyomo constraint in PyPSA-Eur to Linopy. It was straightforward: add Linopy to PyPSA-Eur by pz-max · Pull Request #625 · PyPSA/pypsa-eur · GitHub

Just learn a few days how to debug (here some useful material) and apply the “learning by doing” methodology! If it works, feel free to create a pull request in PyPSA-Eur. Happy coding!