Skip to content

Instantly share code, notes, and snippets.

@jackjackk
Last active March 26, 2022 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackjackk/f7be6874135acefc629027de2109bdd7 to your computer and use it in GitHub Desktop.
Save jackjackk/f7be6874135acefc629027de2109bdd7 to your computer and use it in GitHub Desktop.

Installing PyPSA-Eur

  1. If you don’t have Anaconda installed, install it from here. This will use up to 6GB of disk space and might take some time. A less heavy alternative is Miniconda.
  2. Download PyPSA-Eur as a zip (and extract it) or using GitHub (if you are familiar with git).
  3. Launch “Anaconda Prompt (Anaconda3)” from the Start Menu if using Windows. On Linux/Mac, open a terminal (making sure conda is available, if not add its path in the PATH environment variable).
  4. If the prompt starts with (base), type
    conda deactivate
        

    press Enter and make sure (base) disappears.

  5. Type
    conda update -n base conda
        

    then press Enter and follow the instructions to update conda (might need Admin rights depending on where Anaconda was installed).

  6. Type
    conda install -n base conda-libmamba-solver
        

    then press Enter and follow the instructions to install a conda setup library faster than the default one.

  7. Go to the path where you unzipped/cloned PyPSA-Eur, e.g.:
    cd "C:\Users\SomeUserName\Documents\pypsa-eur"
        
  8. Type
    conda env create --experimental-solver=libmamba -f envs/environment.yaml
        

    then press Enter and follow the instructions to create the Python environment to use to run PyPSA-Eur.

  9. Type
    conda install -n pypsa-eur -c conda-forge --experimental-solver=libmamba jupyterlab
        

    then press Enter and follow the instructions to install Jupyter Lab (the suggested development environment to run and interact with the model).

  10. Type
    conda install -n pypsa-eur -c gurobi --experimental-solver=libmamba gurobi
        

    then press Enter and follow the instructions to install the Gurobi solver.

  11. Get a free Gurobi academic license here. Then go to your current Gurobi licenses, click on an available license and copy the command that starts with grbgetkey followed by a long hexadecimal key (appearing at the bottom of the page).
  12. Type
    conda activate pypsa-eur
        

    then press Enter to start the PyPSA-Eur Python environment.

  13. Type
    grbgetkey long-hexadecimal-key-copied-from-gurobi-website
        

    then press Enter and follow the instructions to activate the Gurobi key on your computer.

Running Jupyter Lab

  1. Launch “Anaconda Prompt (Anaconda3)” from the Start Menu if using Windows. On Linux/Mac, open a terminal (making sure conda is available, if not add its path in the PATH environment variable). Then type:
    conda activate pypsa-eur
        

    and press Enter to start the PyPSA-Eur Python environment.

  2. If not already located in the path where PyPSA-Eur was placed, cd into it, e.g.
    cd "C:\Users\SomeUserName\Documents\pypsa-eur"
        
  3. Type
    jupyter lab
        

    then press Enter to launch the web interface through which you can interact with the model.

Running the model for the first time

  1. Open Jupyter Lab as explained in section 2.
  2. Right click on the file config.default.yaml then duplicate.
  3. Right click on the duplicated file, then rename it to config.yaml.
  4. Double click on config.yaml to edit it.
  5. Change the line
    clusters: [37, 128, 256, 512, 1024]
        

    to

    clusters: [37]
        
  6. Change the line
    opts: [Co2L-3H]
        

    to

    opts: [Co2L-24H]
        
  7. File -> Save
  8. File -> Close all tabs
  9. From the launcher within Jupyter Lab, launch a new terminal
  10. Type
    snakemake -j1 solve_all_networks
        

    then press Enter to start downloading all the data files and eventually solve the network. This will take some time and use up to ~20GB of space! For a smaller footprint run just the tutorial as explained in the section below.

Running the tutorial configuration

  1. Open Jupyter Lab as explained in section 2.
  2. Right click on the file config.tutorial.yaml then duplicate.
  3. Right click on the duplicated file, then rename it to config.yaml.
  4. Double click on config.yaml to edit it.
  5. Change the line
    name: cbc
        

    to

    name: gurobi
        
  6. File -> Save
  7. File -> Close all tabs
  8. From the launcher within Jupyter Lab, launch a new terminal
  9. Type
    snakemake -j1 solve_all_networks
        

    then press Enter to start downloading all the tutorial data files and eventually solve the network.

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