Commit 27b4a8b7 authored by Fabian Neumann's avatar Fabian Neumann

update for summer term 2019 session

parent 379abd90
# Download # Python Tutorials
You can download the tutorials with `git` with the following command (it should In the tutorials we will repeatedly work with the programming language Python. If you are unfamiliar with the language, you might find the following tutorials useful.
be public):
``` The [Python notebook based notes of Robert Johansson](http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/tree/master/) are a
comprehensive kick starter.
* [Lecture 0](http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-0-Scientific-Computing-with-Python.ipynb) covers installation and getting ready.
* [Lecture 1](http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-1-Introduction-to-Python-Programming.ipynb)
zooms through most basic general python control structures (only
brush over it and stop reading early, i.e. if you read the word
`classes` you already know too much).
* [Lecture 2](http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-2-Numpy.ipynb) is the most important and closely connected to the exercises.
* You might as well stop now, but if you are hooked, have a look at [Lecture 3](http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-3-Scipy.ipynb) for more physics and [Lecture 4](http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-4-Matplotlib.ipynb) for prettier graphs.
Further reference material of help is are the website-books http://python-course.eu/ (English), http://python-kurs.eu/ (German); especially of interest might be the [pandas](http://www.python-course.eu/pandas.php) bit in the end, which will make the exercises a breeze at the expense of yet another package to learn.
# Downloading Tutorial Material
You can download the tutorials with `git` with the following command:
```bash
cd /path/where/your/tutorial/folder/should/be
git clone https://git.scc.kit.edu/sp2668/esm_tutorials.git git clone https://git.scc.kit.edu/sp2668/esm_tutorials.git
``` ```
or or
``` ```bash
cd /path/where/your/tutorial/folder/should/be
git clone git@git.scc.kit.edu:sp2668/esm_tutorials.git git clone git@git.scc.kit.edu:sp2668/esm_tutorials.git
``` ```
if you have `ssh` setup at `git.scc.kit.edu`.
Alternatively, you can download the tutorials as compressed zip-file from Alternatively, (not as nice as description above) you can download the tutorials as compressed zip-file from
https://git.scc.kit.edu/sp2668/esm_tutorials/-/archive/master/esm_tutorials-master.zip https://git.scc.kit.edu/sp2668/esm_tutorials/-/archive/master/esm_tutorials-master.zip
# Installation Guide # Installation Guide
**Make sure to follow these steps BEFORE the first tutorial (The wireless WILL **If you happen to come across this before the tutorials start,
be spotty with so many heavy users and we'll loose precious tutorial time)!** you may already want to follow the installation instructions already to get started right away.**
We'll be using `Python` in the tutorials. If you are unfamiliar with `Python`, [this](http://introtopython.org/) is a great start, but a quick Google search on `Python` tutorials will give you millions of great alternatives.
Install `miniconda` (or Anaconda). For instructions for your operating system We recommend using the package manager and environment management system `conda` to install the packages we need.
see https://conda.io/docs/user-guide/install/index.html
Now create a new environment from the provided `requirements.yml` file. For Install [`miniconda`](https://conda.io/docs/user-guide/install/index.html) (or Anaconda). For instructions for your operating system
detailed instructions see see https://conda.io/docs/user-guide/install/index.html.
https://conda.io/docs/user-guide/tasks/manage-environments.html#creating-an-environment-from-an-environment-yml-file
Open a terminal. Creating the environment requires the following set of Create a new `conda` environment from the provided `environment.yaml` file with the following set of commands:
commands. They take time and have to download several packages!
Windows: Windows:
``` ```bash
conda env create -f requirements.yml conda env create -f requirements.yml
activate esm-tutorials activate esm-tutorials
``` ```
macOS and Linux: macOS and Linux:
``` ```bash
conda env create -f requirements.yml conda env create -f requirements.yml
conda activate esm-tutorials
```
On some older Linux installations the last command can be instead
```bash
source activate esm-tutorials source activate esm-tutorials
``` ```
Open a jupyter notebook with the following command in the tutorial folder (where your notebooks are): For detailed instructions see
https://conda.io/docs/user-guide/tasks/manage-environments.html#creating-an-environment-from-an-environment-yml-file.
It will take some time!
With the `conda` environment installed and activated, open a jupyter notebook/lab with the following command in the tutorial folder (where your notebooks are):
```bash
cd /path/where/your/tutorial/folder/should/be
cd esm-tutorials
jupyter lab
``` ```
or
```bash
cd /path/where/your/tutorial/folder/should/be
cd esm-tutorials
jupyter notebook jupyter notebook
``` ```
......
...@@ -3,20 +3,29 @@ channels: ...@@ -3,20 +3,29 @@ channels:
- conda-forge - conda-forge
- defaults - defaults
dependencies: dependencies:
- python
# notebooks
- jupyter - jupyter
- matplotlib - jupyterlab
- basemap
- nb_conda - nb_conda
# utilities
- numpy - numpy
- scipy - scipy
- networkx
- pandas - pandas
- python
- scikit-learn
- pyomo
- xarray - xarray
- netcdf4 - netcdf4
- bottleneck - networkx
- matplotlib
- yaml
# optimisation
- pyomo
- scikit-learn
- glpk - glpk
- pip: - ipopt
- pypsa
# power system analysis
- pypsa
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -4,7 +4,17 @@ ...@@ -4,7 +4,17 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# Energy System Modelling - Tutorial I.2" "# Energy System Modelling - Tutorial I.2\n",
"\n",
"Karlsruhe Institute of Technology, Institute for Automation and Applied Informatics\n",
"***"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> **Note:** This can actually be solved analytically. First try without coding."
] ]
}, },
{ {
...@@ -22,7 +32,7 @@ ...@@ -22,7 +32,7 @@
"\n", "\n",
"$$\\omega = \\frac{2\\pi}{T} $$\n", "$$\\omega = \\frac{2\\pi}{T} $$\n",
"$$T = 1 \\text{ year}$$\n", "$$T = 1 \\text{ year}$$\n",
"$$ A_W = 0.4 $$ $$ A_S = 0.75 $$ $$ A_L = 0.1 $$\n" "$$ A_W = 0.4 $$ $$ A_S = 0.75 $$ $$ A_L = 0.1 $$"
] ]
}, },
{ {
...@@ -279,7 +289,7 @@ ...@@ -279,7 +289,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.4" "version": "3.7.3"
}, },
"varInspector": { "varInspector": {
"cols": { "cols": {
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
%===================================================================== %=====================================================================
The following data are made available to you on the course home The following data are made available to you on the course home
page\footnote{\url{https://nworbmot.org/courses/esm-2018/}}: page\footnote{\url{https://nworbmot.org/courses/esm-2019/}}:
\begin{verbatim} \begin{verbatim}
de_data.csv, gb_data.csv, eu_data.csv, (wind.csv, solar.csv, load.csv). de_data.csv, gb_data.csv, eu_data.csv, (wind.csv, solar.csv, load.csv).
\end{verbatim} \end{verbatim}
...@@ -194,27 +194,4 @@ The time series are normalized to ...@@ -194,27 +194,4 @@ The time series are normalized to
Analogously to (a), find the optimal mix \(\alpha\) as a function of \(0 \leq \gamma \leq 1\), which minimizes \(\expect{\Delta^2}\). Analogously to (a), find the optimal mix \(\alpha\) as a function of \(0 \leq \gamma \leq 1\), which minimizes \(\expect{\Delta^2}\).
\end{enumerate} \end{enumerate}
\pagebreak
%=============== ======================================================
\paragraph{Remarks -- Introductions to Python}~\\
%=====================================================================
In the tutorials we will repeatedly work with the programming language Python. If you are unfamiliar with the language, you might find the following tutorials useful.\\
The Python notebook based notes of Robert Johansson are a
comprehensive kick starter\footnote{\url{http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/tree/master/}}.
\begin{itemize}
\item
\href{http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-0-Scientific-Computing-with-Python.ipynb}{Lecture~0} covers installation and getting ready.
\item
\href{http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-1-Introduction-to-Python-Programming.ipynb}{Lecture~1}
zooms through most basic general python control structures (only
brush over it and stop reading early, i.e. if you read the word
\verb+classes+ you already know too much).
\item \href{http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-2-Numpy.ipynb}{Lecture~2} is the most important and closely connected to the exercises.
\item You might as well stop now, but if you \emph{are} hooked, have a look at \href{http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-3-Scipy.ipynb}{Lecture~3} for more physics and \href{http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-4-Matplotlib.ipynb}{Lecture~4} for prettier graphs.
\end{itemize}
Further reference material of help is are the website-books \url{http://python-course.eu/} (english), \url{http://python-kurs.eu/} (german); especially of interest might be the \href{http://www.python-course.eu/pandas.php}{pandas} bit in the end, which will make the exercises a breeze at the expense of yet another package to learn.
\end{document} \end{document}
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
} }
}, },
"source": [ "source": [
"# Energy System Modelling - Solutions to Tutorial II" "# Energy System Modelling - Tutorial II"
] ]
}, },
{ {
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
} }
}, },
"source": [ "source": [
"***\n",
"**(a) Compile the nodes list and the edge list.**\n", "**(a) Compile the nodes list and the edge list.**\n",
"> **Remark:** While graph-theoretically both lists are unordered sets, let's agree on an ordering now which can serve as basis for the matrices in the following exercises: we sort everything in ascending numerical order, i.e. node 1 before node 2 and edge (1,2) before (1,4) before (2,3)." "> **Remark:** While graph-theoretically both lists are unordered sets, let's agree on an ordering now which can serve as basis for the matrices in the following exercises: we sort everything in ascending numerical order, i.e. node 1 before node 2 and edge (1,2) before (1,4) before (2,3)."
] ]
...@@ -142,6 +141,13 @@ ...@@ -142,6 +141,13 @@
"> In graph theory and computer science, an adjacency matrix is a square matrix used to represent a finite graph. The elements of the matrix indicate whether pairs of vertices are adjacent or not in the graph." "> In graph theory and computer science, an adjacency matrix is a square matrix used to represent a finite graph. The elements of the matrix indicate whether pairs of vertices are adjacent or not in the graph."
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Adjacency Matrix:"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 5,
...@@ -154,12 +160,12 @@ ...@@ -154,12 +160,12 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[ 0., 1., 0., 0., 0., 0.],\n", "array([[0., 1., 0., 0., 0., 0.],\n",
" [ 1., 0., 1., 0., 1., 1.],\n", " [1., 0., 1., 0., 1., 1.],\n",
" [ 0., 1., 0., 1., 1., 0.],\n", " [0., 1., 0., 1., 1., 0.],\n",
" [ 0., 0., 1., 0., 1., 0.],\n", " [0., 0., 1., 0., 1., 0.],\n",
" [ 0., 1., 1., 1., 0., 1.],\n", " [0., 1., 1., 1., 0., 1.],\n",
" [ 0., 1., 0., 0., 1., 0.]])" " [0., 1., 0., 0., 1., 0.]])"
] ]
}, },
"execution_count": 5, "execution_count": 5,
...@@ -177,6 +183,13 @@ ...@@ -177,6 +183,13 @@
"A" "A"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check for symmetry:"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 6,
...@@ -226,7 +239,7 @@ ...@@ -226,7 +239,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([ 1., 4., 3., 2., 4., 2.])" "array([1., 4., 3., 2., 4., 2.])"
] ]
}, },
"execution_count": 7, "execution_count": 7,
...@@ -426,7 +439,7 @@ ...@@ -426,7 +439,7 @@
"***\n", "***\n",
"## Problem II.2\n", "## Problem II.2\n",
"\n", "\n",
"If you map the nodes to `0=DK, 1=DE, 2=CH, 3=IT, 4=AT,5=CZ` the network represents a small part of the European electricity network (albeit very simplified). In the repository, you can find the power imbalance time series for the six countries for January 2017 in hourly MW in the file `imbalance.csv`. They have been derived from physical flows as published by [ENTSO-E](https://transparency.entsoe.eu/transmission-domain/physicalFlow/show)" "If you map the nodes to `0=DK, 1=DE, 2=CH, 3=IT, 4=AT, 5=CZ` the network represents a small part of the European electricity network (albeit very simplified). In the repository, you can find the power imbalance time series for the six countries for January 2017 in hourly MW at `./data/imbalance.csv`. They have been derived from physical flows as published by [ENTSO-E](https://transparency.entsoe.eu/transmission-domain/physicalFlow/show)"
] ]
}, },
{ {
...@@ -456,7 +469,7 @@ ...@@ -456,7 +469,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 14,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
...@@ -561,13 +574,13 @@ ...@@ -561,13 +574,13 @@
"2017-01-01 04:00:00 -526.15 5695.72 -3924.43 -646.2 -3393.12 2794.18" "2017-01-01 04:00:00 -526.15 5695.72 -3924.43 -646.2 -3393.12 2794.18"
] ]
}, },
"execution_count": 13, "execution_count": 14,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"imbalance = pd.read_csv('imbalance.csv', index_col=0, parse_dates=True)\n", "imbalance = pd.read_csv('data/imbalance.csv', index_col=0, parse_dates=True)\n",
"imbalance.head()" "imbalance.head()"
] ]
}, },
...@@ -611,7 +624,7 @@ ...@@ -611,7 +624,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 15,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
...@@ -624,7 +637,7 @@ ...@@ -624,7 +637,7 @@
"array([ 3486.25, -3403.37, -97.5 , -2867.33, 2961.68])" "array([ 3486.25, -3403.37, -97.5 , -2867.33, 2961.68])"
] ]
}, },
"execution_count": 14, "execution_count": 15,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -635,7 +648,7 @@ ...@@ -635,7 +648,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 16,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
...@@ -649,7 +662,7 @@ ...@@ -649,7 +662,7 @@
" -1590.03761905, 725.68619048])" " -1590.03761905, 725.68619048])"
] ]
}, },
"execution_count": 15, "execution_count": 16,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -672,7 +685,7 @@ ...@@ -672,7 +685,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 22,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
...@@ -686,7 +699,7 @@ ...@@ -686,7 +699,7 @@
" -307.72047619, -712.94095238, -405.22047619, -2315.72380952])" " -307.72047619, -712.94095238, -405.22047619, -2315.72380952])"
] ]
}, },
"execution_count": 16, "execution_count": 22,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -705,12 +718,14 @@ ...@@ -705,12 +718,14 @@
}, },
"source": [ "source": [
"***\n", "***\n",
"**(b) Determine the average flow on each link for January 2017 and draw it as a directed network**" "**(b) Determine the average flow on each link for January 2017 and draw it as a directed network**\n",
"\n",
"> **Hint:** You may want to make use of the function `np.vstack`."
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 18,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
...@@ -723,7 +738,7 @@ ...@@ -723,7 +738,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": 19,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
...@@ -736,7 +751,7 @@ ...@@ -736,7 +751,7 @@
"(8, 744)" "(8, 744)"
] ]
}, },
"execution_count": 18, "execution_count": 19,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -747,7 +762,7 @@ ...@@ -747,7 +762,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 20,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
...@@ -761,7 +776,7 @@ ...@@ -761,7 +776,7 @@
" 421.1171115 , -277.47351895, -698.59063044, -1698.48293331])" " 421.1171115 , -277.47351895, -698.59063044, -1698.48293331])"
] ]
}, },
"execution_count": 19, "execution_count": 20,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -788,7 +803,7 @@ ...@@ -788,7 +803,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.4" "version": "3.7.3"
}, },
"nav_menu": {}, "nav_menu": {},
"toc": { "toc": {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"import numpy.linalg\n", "import numpy.linalg\n",
"import pandas as pd\n", "import pandas as pd\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"plt.style.use('bmh')\n",
"%matplotlib inline" "%matplotlib inline"
] ]
}, },
...@@ -32,14 +33,13 @@ ...@@ -32,14 +33,13 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"***\n", "***\n",
"## Problem II.2" "## Problem II.1"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"***\n",
"**(a) Compile the nodes list and the edge list.**\n", "**(a) Compile the nodes list and the edge list.**\n",
"> **Remark:** While graph-theoretically both lists are unordered sets, let's agree on an ordering now which can serve as basis for the matrices in the following exercises: we sort everything in ascending numerical order, i.e. node 1 before node 2 and edge (1,2) before (1,4) before (2,3)." "> **Remark:** While graph-theoretically both lists are unordered sets, let's agree on an ordering now which can serve as basis for the matrices in the following exercises: we sort everything in ascending numerical order, i.e. node 1 before node 2 and edge (1,2) before (1,4) before (2,3)."
] ]
...@@ -75,6 +75,27 @@ ...@@ -75,6 +75,27 @@