Commit 39a0a9f2 authored by sp2668's avatar sp2668

installation guide

parent c24c64d2
......@@ -4,3 +4,5 @@
*.synctex.gz
**/dconf/
**/.ipynb_checkpoints/
*.lp
*.slides.html
# Installation Guide
Install `miniconda` (or Anaconda). For instructions for your operating system see
https://conda.io/docs/user-guide/install/index.html
Now create a new environment from the provided `requirements.yml` file. For detailed instructions see
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 commands:
Windows:
```
conda env create -f requirements.yml
activate esm-tutorials
conda list
```
maxOS and Linux:
```
conda env create -f requirements.yml
source activate esm-tutorials
conda list
```
Open a jupyter notebook with the following command:
```
jupyter notebook
```
You should now be ready to do the tutorials :)
name: esm-tutorials
channels:
- conda-forge
- defaults
dependencies:
- jupyter
- matplotlib
- nb_conda
- numpy
- pandas
- python
- pip:
- pypsa
This diff is collapsed.
......@@ -2,22 +2,34 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Energy System Modelling - Solutions to Tutorial II.1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Imports"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"execution_count": 1,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"import numpy as np\n",
......@@ -29,7 +41,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Parameters"
]
......@@ -37,7 +53,11 @@
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"A_w = 0.4\n",
......@@ -49,7 +69,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Functions"
]
......@@ -57,7 +81,11 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"def w(t, phi=0):\n",
......@@ -67,7 +95,11 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"def s(t):\n",
......@@ -77,7 +109,11 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"def l(t):\n",
......@@ -87,7 +123,11 @@
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"def c(gamma):\n",
......@@ -97,7 +137,11 @@
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"def mismatch_a(alpha, t, phi=phi):\n",
......@@ -107,7 +151,11 @@
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"def mismatch_c(alpha, gamma, t):\n",
......@@ -117,7 +165,11 @@
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"def objective_a(alpha):\n",
......@@ -127,7 +179,11 @@
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"def objective_c(alpha):\n",
......@@ -136,7 +192,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Plots"
]
......@@ -144,7 +204,11 @@
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"outputs": [],
"source": [
"x = np.arange(0,1,0.01)"
......@@ -152,7 +216,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"Availability time series"
]
......@@ -160,7 +228,11 @@
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
......@@ -183,7 +255,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"Mismatch"
]
......@@ -191,7 +267,11 @@
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
......@@ -214,14 +294,22 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Solution"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"**(a) What is the seasonal optimal mix $\\alpha$, which minimizes**\n",
......@@ -231,7 +319,11 @@
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"name": "stdout",
......@@ -261,7 +353,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"**(b) How does the optimal mix change if we replace $A_L \\to -A_L$?**"
......@@ -270,7 +366,11 @@
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"A_l *= (-1)"
......@@ -279,7 +379,11 @@
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"name": "stdout",
......@@ -310,7 +414,11 @@
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"A_l *= (-1)"
......@@ -318,7 +426,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"**(c) Now assume that there is a seasonal shift in the wind signal\n",
......@@ -329,7 +441,11 @@
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
......@@ -366,7 +482,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"**(d) A constant conventional power source $C(t) = 1 - \\gamma$ is now introduced. The mismatch then becomes\n",
......@@ -377,7 +497,11 @@
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
......@@ -414,8 +538,9 @@
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
......@@ -429,7 +554,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
"version": "3.6.5"
},
"varInspector": {
"cols": {
......
......@@ -2,14 +2,22 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Energy System Modelling - Solutions to Tutorial II"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"**Imports**"
]
......@@ -17,7 +25,11 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"outputs": [],
"source": [
"import numpy as np\n",
......@@ -29,15 +41,23 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"***\n",
"## Problem II.2"
"## Problem II.1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"**(a) Compile the nodes list and the edge list.**\n",
......@@ -47,7 +67,11 @@
{
"cell_type": "code",
"execution_count": 142,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"nodes = [0, 1, 2, 3, 4, 5]\n",
......@@ -58,7 +82,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"**(b) Determine the order and the size of the network.**"
......@@ -67,7 +95,11 @@
{
"cell_type": "code",
"execution_count": 143,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"N = len(nodes)\n",
......@@ -77,7 +109,11 @@
{
"cell_type": "code",
"execution_count": 144,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"name": "stdout",
......@@ -94,7 +130,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"**(c) Compute the adjacency matrix $A$ and check that it is symmetric.**"
......@@ -103,7 +143,11 @@
{
"cell_type": "code",
"execution_count": 145,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
......@@ -134,7 +178,11 @@
{
"cell_type": "code",
"execution_count": 146,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
......@@ -153,7 +201,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"**(d) Find the $k_n$ of each node $n$ and compute the average degree of the network.**"
......@@ -162,7 +214,11 @@
{
"cell_type": "code",
"execution_count": 147,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
......@@ -183,7 +239,11 @@
{
"cell_type": "code",
"execution_count": 148,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
......@@ -202,7 +262,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"**(e) Determine the incidence matrix $K$ by assuming the links are always directed from smaller-numbered node to larger-numbered node, i.e.\\ from node 2 to node 3, instead of from 3 to 2.**"
......@@ -211,7 +275,11 @@
{
"cell_type": "code",
"execution_count": 150,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
......@@ -241,7 +309,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"**(f) Compute the Laplacian $L$ of the network using $k_n$ and $A$. Remember that the Laplacian can also be computed as $L=KK^T$ and check that the two definitions agree.**"
......@@ -250,7 +322,11 @@
{
"cell_type": "code",
"execution_count": 151,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"D = np.diag(A.sum(axis=1))"
......@@ -259,7 +335,11 @@
{
"cell_type": "code",
"execution_count": 152,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
......@@ -285,7 +365,11 @@
{
"cell_type": "code",
"execution_count": 153,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
......@@ -304,7 +388,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"**(g) Find the diameter of the network by looking at the graph.**"
......@@ -312,14 +400,22 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"By looking: Between nodes $0$ and $3$, f.ex. $0 \\to 1 \\to 2 \\to 3$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"## Problem II.3\n",
......@@ -329,7 +425,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"The linear power flow is given by\n",
"$$p_i = \\sum_j \\tilde{L}_{i,j}\\theta_j \\qquad \\text{and} \\qquad f_l = \\frac{1}{x_l} \\sum_i K_{i,l}\\theta_i, \\qquad \\text{where} \\qquad \\tilde{L}_{i,j}= \\sum_l = K_{i,l}\\frac{1}{x_l} K_{j,l}$$\n",
......@@ -338,7 +438,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"***\n",
"**Read data**"
......@@ -347,7 +451,11 @@
{
"cell_type": "code",
"execution_count": 154,