Skip to content

Conversation

@ebbekyhl
Copy link
Contributor

@ebbekyhl ebbekyhl commented Sep 25, 2025

Changes proposed in this Pull Request

I have seen more and more PyPSA-Eur studies including national targets for CO2 emissions reductions. Some use approaches that might be unhandy to implement in the master branch. But with Linopy this can be done relatively easy, with a small addition to the config file and the solve_network script. Maybe something to consider?

I tested this for UK, and it does the job. I have only tested it for a myopic optimization - needs to be tested for other foresight modes.

Checklist

  • I tested my contribution locally and it works as intended.
  • Code and workflow changes are sufficiently documented.
  • Changed dependencies are added to envs/environment.yaml.
  • Changes in configuration options are added in config/config.default.yaml.
  • Changes in configuration options are documented in doc/configtables/*.csv.
  • Sources of newly added data are documented in doc/data_sources.rst.
  • A release note doc/release_notes.rst is added.

Copy link
Member

@fneum fneum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I agree that this functionality would be great to have. Three thoughts on this:

  1. At the moment, the constraint has many hard-coded elements (e.g. checking for ports of links to "co2 atmosphere" explicitly). This will be hard to maintain in the long run. This could be a prime use case for using the n.optimize.expressions.energy_balance(bus_carrier='co2 atmosphere') module which mirrors sums built in n.statistics.energy_balance() just as linopy expressions. It should also be straightforward to filter by buses of a particular country. Potentially, @FabianHofmann and @lkstrp can give a hint here.

  2. How are cross-border flows of carbon accounted for? How do you deal with buses that contain carbon but are only resolved at system-level (i.e. EU buses). Here, one could also look at PyPSA-DE which also implemented national CO2 budgets (but is equally longer than necessary).

https://github.com/PyPSA/pypsa-de/blob/3766b85e7f6b477f31affd0459024b638cecf4a4/scripts/pypsa-de/additional_functionality.py#L398-L579

  1. The constraint could get the country as a dimension.

Once this is resolved, some work would need to be spent on documenting the feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants