Description
Renewable Energy System Project: Modelling Energy Systems with PyPSA
1. PyPSA (Python for Power System Analysis) is written in Python 3 so the first thing that you need to do is to install Python 3 on your computer.
2. If you have never used Python before, there are many good courses online. I can recommend the followings https://www.edx.org/course/introduction-to-python-for-data-science-3 https://www.edx.org/es/course/using-python-for-research
Datacamp also offers free courses, including practical exercises that might be useful for you. See, for instance:
https://www.datacamp.com/courses/intro-to-python-for-data-science
3. Python is a programing language. Packages are built using this language, e.g., pandas, numpy, pypsa.
When we are writing a piece of code, we can benefit from functions that are included in packages previously developed by other people. To do that we need to (a) install that package in our computer and (b) import it in our script. One easy way of using Python is through Anaconda because it allows a simple way of installing the packages that we need. Anaconda is available for Windows, Mac OS X and GNU/Linux. You can install it from the following link.
https://docs.anaconda.com/anaconda/install/
4. We can create an environment to include a group of packages. Open the Anaconda navigator, select “Environments” and create a new environment with a new name (Figure 1). Select Python 3.7 when you create the new environment.
5. Now, you can install PyPSA in your new environment. The window on the right shows the installed packages.
Add the channel conda-forge. Selected the option “All” and look for PyPSA. Select the package and “Apply”. (Figure 2).
Alternative way: Click on the “play/pause” button present on the environment name
Click “Open terminal” from your environment
In terminal type “conda config –add channels conda-forge” (Figure 3)
In terminal type “conda install pypsa” (Figure 4)
Additional installing instruction for PyPSA installation on other systems can be found in:
https://www.pypsa.org/doc/installation.html
6. PyPSA passes optimisation problems to an external solver. We use Gurobi as solver and we need to get a license for that.
To install Gurobi: Click on the “play/pause” button present on the environment name
Click “Open terminal” from your environment
In terminal type “conda config –add channels http://conda.anaconda.org/gurobi” (Figure 5)
In terminal type “conda install gurobi” (Figure 6)
Now, you need to get an academic license to use Gurobi, follow the instruction in the link. You will need to register and log in to get a license.
https://www.gurobi.com/downloads/free-academic-license/
7. Install also the packages named pandas and matplotlib, we will used them to read data from csv files and to plot data.
8. You have the PyPSA documentation available in the following link.
https://www.pypsa.org/doc/index.html
9. The first thing that we will do is to run a very simple case to test that everything is working properly.
We will be using a Jupyter notebook for this. Jupyter notebooks are documents in which we can include both code and text (to explain the code). Hence, they are very useful to learn new programs and to show examples.
Save the Jupyter notebook named “testing.ipynb” to your computer. Select “Home” in Anaconda, install and launch Jupyter notebook and open the file.
Follow the instruction in “testing.ipynb” to check that everything is working.
10. Now we can start with the real exercise. The description is included in the Jupyter notebook named “RES_project.ipynb”
List of common errors and solutions
• Error associated with importing matplotlib and pillow package
Error description: The test notebook works fine, but you get an error when importing the matplotlib package in the project notebook.
Solution: Click on the “play/pause” button present on the environment name
Click “Open terminal” from your environment
In terminal type ” conda uninstall pillow ”
In terminal type ” pip install pillow ”
• When trying to install pypsa, you receive an error because you don’t have administrator privileges.
Open Anaconda with Administrator privileges, and then create the environment, install pypsa and follow the other instructions. (The solution does not work if the environment has been previously created without Administrator privileges)
Figure 1. Creating a new environment in Anaconda.
Figure 2. Installing PyPSA in the new environment named “env_pypsa”.
Figure 3. Adding the conda-forge channel using the terminal.
Figure 4. Installing PyPSA in the new environment using the terminal.
Figure 5. Adding the channel to the new environment to install Gurobi.
Figure 6. Installing Gurobi in the new environment.
Figure 7. Installing Gurobi academic license in your computer.
Reviews
There are no reviews yet.