Skip to content

PyPSA-Eur: A Sector-Coupled Open Optimisation Model of the European Energy System

Notifications You must be signed in to change notification settings

drifter089/pypsa-eur

 
 

Repository files navigation

PyPSA-Eur: A Sector-Coupled Open Optimisation Model of the European Energy System

The model is described in the documentation and in the paper PyPSA.

Devcontainers

For details about dev containers see Dev Containers.

This repository is an attempt to use pre-built images to speed up development. Learn more at the Dev Containers Guide, inspired by the repository kubernetes-devcontainer.

Adding development package to repository

Link to the package: pypsa-eur.

Steps

  1. You need Visual Studio Code installed.
  2. Install Docker: Install Docker.
  3. Install the Dev Containers extension for VS Code: Install the Extension.
  4. Clone this repo and open it in VS Code.
  5. Hit Ctrl+Shift+P to open the command palette in VS Code and search for "Dev Containers". Select "Reopen in Container"
  6. Wait for the image to be downloaded. Opening Dev Container
  7. Once finished, you will be inside the container. Attached Dev Container
  8. Inside the container, you can see the welcome message. Welcome Message
  9. Open the terminal and see that the pypsa-eur environment is pre-configured. Terminal in Dev Container
  10. Navigate to the files to see the solved folders for the electricity tutorial copied from the container. Solved Structure in Dev Container

Debug

Addressing issues like these Stack Overflow.

Here I attempt to propose a debugging guide where we can use Snakemake commands to specify config and stop execution in the middle with debugpy and attach using VS Code debugger.

More detailed guide: VS Code Python Debugging.

These steps can be followed whether you are using the devcontainers or not.

  1. Let's say you have electricity tutorial already ran successfully.
  2. Let's delete the results folder:
sudo rm -r results
  1. Now, if we want to rebuild the results folder and resulting networks in debug mode:

    • First, let's navigate to the 'scripts/solvenetwork.py' reference file solve_network.py.

    • Import debugpy

    debugpy.

    • Add code snippet to stop execution and wait for the debugger debugpy code.
  2. Instead of using this command:

snakemake -call results/test-elec/networks/elec_s_6_ec_lcopt_.nc --configfile config/test/config.electricity.yaml
  1. We have to modify it to use one core only and pass the --debug flag to Snakemake:
snakemake --cores 1 results/test-elec/networks/elec_s_6_ec_lcopt_.nc --configfile config/test/config.electricity.yaml --debug

debug command

  1. Navigate to the "Run and Debug" tab in VS Code and use the debugger attach configuration to launch the debugger, file link launch.json.

    attach config debug

  2. Once launched, the debugger will attach to paused code. From here on, you can add breakpoints to the code and use the debugger UI.

    debugger

Contributing and Support

We strongly welcome anyone interested in contributing to this project. If you have any ideas, suggestions or encounter problems, feel invited to file issues or make pull requests on GitHub.

  • In case of code-related questions, please post on stack overflow.
  • For non-programming related and more general questions please refer to the mailing list.
  • To discuss with other PyPSA users, organise projects, share news, and get in touch with the community you can use the discord server.
  • For bugs and feature requests, please use the PyPSA-Eur Github Issues page.

Licence

The code in PyPSA-Eur is released as free software under the MIT License, see doc/licenses.rst. However, different licenses and terms of use may apply to the various input data, see doc/data_sources.rst.

About

PyPSA-Eur: A Sector-Coupled Open Optimisation Model of the European Energy System

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Python 99.8%
  • Other 0.2%