% NB: use pdflatex to compile NOT pdftex.  Also make sure youngtab is
% there...

% converting eps graphics to pdf with ps2pdf generates way too much
% whitespace in the resulting pdf, so crop with pdfcrop
% cf. http://www.cora.nwra.com/~stockwel/rgspages/pdftips/pdftips.shtml




\documentclass[10pt]{beamer}
%\usetheme[everytitleformat=uppercase]{m}
\usetheme[everytitleformat=regular]{m}
\usepackage[absolute,overlay]{textpos}
\usepackage{booktabs}
\usepackage[utf8]{inputenc}

\usepackage{tikz}

\usepackage[official]{eurosym}

\usepackage[scale=2]{ccicons}


%use this to add space between rows
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}


\newcommand{\R}{\mathbb{R}}
\newcommand{\mb}[1]{{\mathbf #1}}

\def\l{\lambda}
\def\m{\mu}
\def\d{\partial}
\def\cL{\mathcal{L}}
\def\co2{CO${}_2$}

\def\mw{\text{ MW}}
\def\mwh{\text{ MWh}}
\def\gw{\text{ GW}}
\def\gwh{\text{ GWh}}
\def\emwh{\text{ \euro/MWh}}
\def\bemwh{\text{ [\euro/MWh]}}

\newcommand{\ubar}[1]{\text{\b{$#1$}}}



% for sources http://tex.stackexchange.com/questions/48473/best-way-to-give-sources-of-images-used-in-a-beamer-presentation

\setbeamercolor{framesource}{fg=gray}
\setbeamerfont{framesource}{size=\tiny}


\newcommand{\source}[1]{\begin{textblock*}{4cm}(8.0cm,8.0cm)
    \begin{beamercolorbox}[ht=0.5cm,right]{framesource}
        \usebeamerfont{framesource}\usebeamercolor[fg]{framesource} Source: {#1}
    \end{beamercolorbox}
\end{textblock*}}

\usepackage{hyperref}


%\usepackage[pdftex]{graphicx}


\graphicspath{{graphics/}}

\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.jpg}



\def\goat#1{{\scriptsize\color{green}{[#1]}}}



\let\olditem\item
\renewcommand{\item}{%
\olditem\vspace{5pt}}

\title{Electricity Markets: Summer Semester 2016, Lecture 6}
%\subtitle{---}
\author{
  Tom Brown, Mirko Schäfer
}

\institute{
  Frankfurt Institute of Advanced Studies (FIAS), Goethe-Universit\"at Frankfurt \\
  FIAS Renewable Energy System and Network Analysis (FRESNA) \\
  \\
  \url{{brown, schaefer}@fias.uni-frankfurt.de}
}


\date{23th May 2016}


\titlegraphic{%
  \vspace{7cm}
    \includegraphics[width=4cm]{FIAS-logo}
}

\begin{document}

\maketitle

\begin{frame}{'Homework'}
We have some flexibility for the later lectures and will try to adjust the topics according to your interests.
As homework, please send us by next week \alert{three questions} you would like us to cover in these lectures.\\
\vspace{0.5cm}
Examples could be 'How was the electricity system in Japan structured before the Fukushima incident? What has changed?', 'When and how was the EEG in Germany implemented? How did it change over time?', 'What is the role of hydro power in todays electricity system?',etc.\\
\vspace{0.5cm}
  \url{{brown, schaefer}@fias.uni-frankfurt.de}

\end{frame}

\begin{frame}

  \frametitle{Table of Contents}
  \setbeamertemplate{section in toc}[sections numbered]
  \tableofcontents[hideallsubsections]
\end{frame}



\section{Recap: Efficient market operation in a multi-node system with constrained transmission: KKT}


\begin{frame}{Optimising a multi-node system}

  We want answers to the following questions:
  \begin{enumerate}
  \item What is the most efficient configuration of production and consumption when there are transmission constraints between nodes?
  \item How should the market price be set at each node to guarantee that decentralised actors reach a system-optimal solution?
    \item How does this fit in the Karush-Kuhn-Tucker framework?
  \end{enumerate}

\end{frame}

\begin{frame}{Recap of optimisation for a single node}


  Without transmission we maximised the total economic welfare, the
  sum of the consumer and the producer surplus for consumers with
  consumption $Q_i^B$ and generators generating with rate $Q_i^S$:
  \begin{align*}
    \max_{\{Q_i^B\}, \{Q_i^S\}}\left[ \sum_i U_i (Q_i^B)  -  \sum_i C_i (Q_i^S) \right]
  \end{align*}
  subject to the supply equalling the demand in the balance constraint:
  \begin{align*}
    \sum_i Q_i^B -  \sum_i Q_i^S  = 0 \hspace{1cm} \leftrightarrow \hspace{1cm} \l
  \end{align*}
  where $\l$ gave us the market price.

  How do we then extend this scheme to multiple nodes with transmission constraints inbetween?

  Answer: Maximise the combined sum of welfare at each node while implementing transmission constraints.
\end{frame}


\begin{frame}{Nodal benefit function}

  Suppose at \alert{node $k$} there are some consumers and generators
  $i\in N_{k}$, with generation $Q_{i}^S$ and consumption $Q_{i}^B$.

  We define the \alert{benefit function} $B_k(Z_k)$ of node $k$ as follows:
 \begin{align*}
    B_k(Z_k) = \max_{\{Q_i^B,Q_i^S\}}  \left[
    \sum_{i\in N_k} U_i (Q_i^B)  -  \sum_{i\in N_{k}} C_i (Q_i^S)
    \right]
 \end{align*}
 where we have introduced a new variable $Z_k$ for the total nodal
 power imbalance (supply - demand) at the node
 \begin{align*}
Z_k - \sum_{i\in N_k} Q_i^S + \sum_{i\in N_k} Q_i^B=0 \hspace{1cm}
 \leftrightarrow \hspace{1cm} \lambda_k
  \end{align*}

The optimisation of the benefit function $B_k(Z_k)$ yields the optimal dispatch for the consumers and generators at node $k$ under the constraint that this dispatch leads to a net injection $Z_k$ at this node.

The parameter $\lambda_k$ gives the change in the objective function when we relax the respective constraint - i.e. the marginal price at this node.

\end{frame}


\begin{frame}{Full optimisation problem}

 Note: the values of the $Z_k$ are not yet fixed by the scheme. Now we fix the values by maximising total economic welfare given constraints for the nodal injections (determined by the transmission constraints):
 \begin{align*}
    &\max_{\{Z_k\}}  \left[
    \sum_k B_k(Z_k)
    \right]
 \end{align*}
 subject to
 \begin{align*}
   \sum_k Z_k =  0 &\hspace{1cm} \leftrightarrow &  \l \\
   h_\ell(\{Z_k\}) \leq d_\ell & \hspace{1cm} \leftrightarrow &  \m_\ell
  \end{align*}
  with
   \begin{align*}
    & B_k(Z_k) = \max_{\{Q_i^B,Q_i^S\}}  \left[
    \sum_{i\in N_k} U_i (Q_i^B)  -  \sum_{i\in N_{k}} C_i (Q_i^S)
    \right]\\
    & \text{subject to }
     Z_k -  \sum_{i\in N_k} Q_i^S + \sum_{i\in N_k} Q_i^B=0  \hspace{1cm} \leftrightarrow \hspace{1cm} \l_k
  \end{align*}
\end{frame}

\begin{frame}{Optimal dispatch for two-nodes}
  We now return to our two-node example.
We have a flow on the single transmission line $F = Z_1 = -Z_2$ restricted by $|F| \leq K$.

  The optimal dispatch is given by
  \begin{align*}
    &\max_{\{Z_1,Z_2\}}  \left[
   B_1(Z_1) + B_2(Z_2)
    \right]\\
    &\text{subject to }
     Z_1 + Z_2 =  0 \hspace{1cm} \leftrightarrow \hspace{1cm} \l \\
     &\text{subject to }
     Z_1  \leq K  \hspace{1cm} \leftrightarrow \hspace{1cm} \bar{\m}\\
     &\text{subject to }
     -Z_1  \leq K \hspace{1cm} \leftrightarrow \hspace{1cm} \ubar{\m}
  \end{align*}
  with
   \begin{align*}
    & B_k(Z_k) = \max_{\{Q_i^B,Q_i^S\}}  \left[
    \sum_{i\in N_k} U_i (Q_i^B)  -  \sum_{i\in N_{k}} C_i (Q_i^S)
    \right]\\
    & \text{subject to }
     Z_k -  \sum_{i\in N_k} Q_i^S + \sum_{i\in N_k} Q_i^B=0  \hspace{1cm} \leftrightarrow \hspace{1cm} \l_k
  \end{align*}
\end{frame}

\begin{frame}{KKT analysis}
  Considering the single total optimisation over all variables $Q_i^B, Q_i^S, Z_k$, we get from stationarity
  \begin{align*}
    \frac{\d \cL}{d Q_i^B} & \Rightarrow   U_i'(Q_i^B) - \l_k = 0 \\
    \frac{\d \cL}{d Q_i^S} & \Rightarrow   -C_i'(Q_i^S) + \l_k = 0 \\
    \frac{\d \cL}{d Z_1} & \Rightarrow   \l -  \l_{1} - \bar{\m} + \ubar{\m} = 0 \\
    \frac{\d \cL}{d Z_2} & \Rightarrow   \l -  \l_{2} = 0
  \end{align*}
  and from complementary slackness:
  \begin{align*}
    \bar{\m}(K-Z_1) = 0\\
    \ubar{\m}(K+Z_1) = 0
  \end{align*}

\end{frame}


\begin{frame}{Our three cases}
  For a solution where typically $\l_2^* \geq \l_1^*$ we have:

  For the separate markets ($K = 0$):
  \begin{align*}
    F = Z_1^* = -Z_2^* = 0, \l_1^* \neq \l_2^*, \bar{\m}^*  = \l_2^* - \l_1^*, \ubar{\m}^* = 0
  \end{align*}

  For the constrained markets ($K = 400$):
  \begin{align*}
    F = Z_1^* = -Z_2^* = 400, \l_1^* \neq \l_2^*, \bar{\m}^*  = \l_2^* - \l_1^*, \ubar{\m}^* = 0
  \end{align*}

  For the unconstrained markets ($K = \infty$):
  \begin{align*}
    F = Z_1^* = -Z_2^* = 933, \l_1^* = \l_2^*, \bar{\m}^*  = 0, \ubar{\m}^* = 0
  \end{align*}

\end{frame}

\section{Representing network constraints in meshed networks}

\begin{frame}{Full optimisation problem}

We fix the values $Z_k$ (nodal imbalances) by maximising total economic welfare given constraints for the nodal injections (determined by the transmission constraints):
 \begin{align*}
    &\max_{\{Z_k\}}  \left[
    \sum_k B_k(Z_k)
    \right]
 \end{align*}
 subject to
 \begin{align*}
   \sum_k Z_k =  0 &\hspace{1cm} \leftrightarrow &  \l \\
   h_\ell(\{Z_k\}) \leq d_\ell & \hspace{1cm} \leftrightarrow &  \m_\ell
  \end{align*}
  with
   \begin{align*}
    & B_k(Z_k) = \max_{\{Q_i^B,Q_i^S\}}  \left[
    \sum_{i\in N_k} U_i (Q_i^B)  -  \sum_{i\in N_{k}} C_i (Q_i^S)
    \right]\\
    & \text{subject to }
     Z_k -  \sum_{i\in N_k} Q_i^S + \sum_{i\in N_k} Q_i^B =0 \hspace{1cm} \leftrightarrow \hspace{1cm} \l_k
  \end{align*}
\end{frame}

\begin{frame}{Network constraints}

In the full optimisation problem the network constraints are included via the terms
\begin{align*}
h_{l}(\{ Z_{k}\} \leq d_l) ~.
\end{align*}
Here $Z_k$ are the nodal imbalances (the injection pattern) and $d_{l}$ are thermal capacity limits (often written as $K_l$). The functions $h_{l}$ relate the injection pattern (node properties) to the transmission constraints by giving the respective power flow (line properties).\\

What is the structure of the functions $h_{l}(\{Z_k\})$ for general network topologies?

\end{frame}


\begin{frame}{Beyond two nodes: radial networks}

  In a \alert{radial} network there is only one path between any two nodes on the network.

  The power flow is a simple function of the nodal power imbalances.

  \includegraphics[width=7cm]{radial}

  \source{Biggar \& Hesamzadeh}
\end{frame}


\begin{frame}{Beyond two nodes: meshed networks}

  In a \alert{meshed} network there are at least two nodes with multiple paths between them.

  The power flow is now a function of the impedances in the network.

  \includegraphics[width=7cm]{meshed}

  \source{Biggar \& Hesamzadeh}
\end{frame}

\begin{frame}{The DC Load Flow model}
Modelling the power flows in the transmission grid accurately requires to solve the physical AC equations, which is complicated.\\

For stable network operation, the DC Load Flow model is a reasonable approximation. In this model, the power flow $F_{l}$ over a link $l$ is a \alert{linear function} of the nodal imbalances $Z_{k}$:
\begin{align*}
F_{l} = \sum_{k} H_{lk} Z_k~,
\end{align*}
or in matrix notation (with $\mb{F}$ the vector of power flows, and $\mb{Z}$ the injection pattern)
\begin{align*}
\mb F = \mb{H}\mb{Z}~.
\end{align*}
The matrix $\mb{H}$ is denoted as the \alert{power transfer distribution factors (PTDF) matrix}. It is calculated from the topology of the network and the physical properties of the connections (impedance) via Kirchhoff's Current and Voltage law (KCL, KVL).
\end{frame}

\begin{frame}{Some degrees of freedom for the PTDF matrix}
For a \alert{balanced injection pattern} the nodal imbalances sum up to zero:
\begin{align*}
\sum_{k} Z_{k} = 0~.
\end{align*}
For balanced injection patterns we have some degrees of freedom for the PTDF matrix entries:
\begin{align*}
F_{l} &= \sum_{k}\left(H_{lk} + c_{l} \right) Z_{k}\\
&= \sum_{k} H_{lk}Z_k + c_{l} \left(\sum_{k} Z_{k}\right)\\
& = \sum_{k} H_{lk}Z_k~.
\end{align*}
Adding the constant $c_{l}$ to all entries of row $l$ does not change the result, that is instead of the PTDF matrix $H_{lk}$ we can also use the PTDF matrix $H_{lk} + c_{l}$ with arbitrary values of $c_{l}$.
\end{frame}

\begin{frame}{The reference node}
From any PTDF matrix $H_{lk}$ we can construct a PTDF matrix $H^{(n)}_{lk}$ which has zero entries $H^{(n)}_{ln}=0$ in row $n$:
\begin{align*}
H^{(n)}_{lk} = H_{lk} - H_{ln}~.
\end{align*}
In this case node $n$ is denoted as the \alert{reference node}.

\end{frame}

\begin{frame}{Example: Two nodes}
One line with label $l=1$ from node $1$ to node $2$, which have nodal imbalances $Z_{1}$ and $Z_{2}$. Choose node $2$ as the reference node. The PTDF matrix is a $1\times 2$ matrix with entries
\begin{align*}
\mb{H} = 1\to 2
\begin{pmatrix}
1 & 0
\end{pmatrix}
\end{align*}
The power flow on line $1$ is calculated as
\begin{align*}
F_{1} &= H_{11}Z_{1} + H_{12}Z_{2}\\
&= Z_{1}~.
\end{align*}
\end{frame}
    
\begin{frame}{Example: Three nodes I}
\begin{columns}[c]
\column{.5\textwidth}
Reference node $3$.
\begin{align*}
\mb{H} = 
\begin{matrix}
1\to 3 \\
2\to 3\\
\end{matrix}
\begin{pmatrix}
1 & 0 & 0 \\
0 & 1 & 0 
\end{pmatrix}
\end{align*}
Power flows:
\begin{align*}
F_{1\to 3} &= Z_1\\
F_{2\to 3} &= Z_2
\end{align*}
\column{.5\textwidth}
  \includegraphics[width=4cm]{3nodes1}
\end{columns}
\end{frame}

\begin{frame}{Example: Three nodes II}
\begin{columns}[c]
\column{.5\textwidth}
Reference node $3$.
\begin{align*}
\mb{H} = 
\begin{matrix}
1\to 2 \\
1\to 3 \\
2\to 3
\end{matrix}
\begin{pmatrix}
1/3 & -1/3 & 0 \\
2/3 & 1/3 & 0 \\
1/3 & 2/3 & 0
\end{pmatrix}
\end{align*}
Power flows:
\begin{align*}
F_{1\to 2} &= \frac{1}{3}\left(Z_1 - Z_2\right)\\
F_{1\to 3} &= \frac{1}{3}\left(2Z_1 + Z_2\right)\\
F_{2\to 3} &= \frac{1}{3}\left(Z_1 + 2 Z_2\right)
\end{align*}
\column{.5\textwidth}
  \includegraphics[width=4cm]{3nodes2}
  \end{columns}
\end{frame}

\begin{frame}{Example: Three nodes III}
Remark: Different line impedances (reactances) change the PTDF matrix and thus the power flow!\\
\begin{columns}[c]
\column{.5\textwidth}
\begin{align*}
\mb{H} = 
\begin{matrix}
1\to 2 \\
1\to 3 \\
2\to 3
\end{matrix}
\begin{pmatrix}
2/5 & -1/5 & 0 \\
3/5 & 1/5 & 0 \\
2/5 & 4/5 & 0
\end{pmatrix}
\end{align*}
Power flows:
\begin{align*}
F_{1\to 2} &= \frac{1}{5}\left(2Z_1 - Z_2\right)\\
F_{1\to 3} &= \frac{1}{5}\left(3Z_1 +Z_2\right)\\
F_{2\to 3} &= \frac{2}{5}\left(Z_1 + 2Z_2\right)
\end{align*}
\column{.5\textwidth}
  \includegraphics[width=4cm]{3nodes3}
  \end{columns}
\end{frame}

\begin{frame}{Transmission constraints}
Thermal limits as transmission constraints for the optimisation problem can be represented as general inequality constraints:
\begin{align*}
 h_{l}(\{Z_{k}\}) \leq d_{l}~.
\end{align*}
In our treatment, we model these constraints as capacity limits, that is as upper boundaries for the power flow on a link:
\begin{align*}
F_{l}(Z_k) &\leq K_{l}\\
-F_{l}(Z_k) & \leq K_{l}
\end{align*}
Using the PTDF matrix, this reads
\begin{align*}
\left[\sum_k H_{lk} Z_k \right] &\leq K_{l}\\
-\left[\sum_k H_{lk} Z_k \right] &\leq K_{l}
\end{align*}
\end{frame}

\begin{frame}{Feasible injections}

The \alert{set of feasible injections} represents the collection of all balanced injection patterns $\{ Z_k\}$ which satisfy the transmission constraint equations
\begin{align*}
\left[\sum_k H_{lk} Z_k \right] &\leq K_{l}\\
-\left[\sum_k H_{lk} Z_k \right] &\leq K_{l}
\end{align*}
\end{frame}

\begin{frame}{Example: Three nodes I}
\begin{columns}[c]
\column{.4\textwidth}
Reference node $3$.
\begin{align*}
\mb{H} = 
\begin{matrix}
1\to 3 \\
2\to 3\\
\end{matrix}
\begin{pmatrix}
1 & 0 & 0 \\
0 & 1 & 0 
\end{pmatrix}
\end{align*}
Power flows:
\begin{align*}
F_{1\to 3} &= Z_1\\
F_{2\to 3} &= Z_2
\end{align*}
Capacity limits:
\begin{align*}
K_{1\to 3} &= 10\mw\\
K_{2\to 3} &= 20\mw\\
\end{align*}
\column{.6\textwidth}
\centering
  \includegraphics[width=6cm]{feasible1.pdf}\\
  \vspace{1cm}
  \includegraphics[width=2cm]{3nodes1}
\end{columns}
\end{frame}

\begin{frame}{Example: Three nodes II}
\begin{columns}[c]
\column{.4\textwidth}
Reference node $3$.
\begin{align*}
\mb{H} = 
\begin{matrix}
1\to 2 \\
1\to 3 \\
2\to 3
\end{matrix}
\begin{pmatrix}
1/3 & -1/3 & 0 \\
2/3 & 1/3 & 0 \\
1/3 & 2/3 & 0
\end{pmatrix}
\end{align*}
Power flows:
\begin{align*}
F_{1\to 2} &= \frac{1}{3}\left(Z_1 - Z_2\right)\\
F_{1\to 3} &= \frac{1}{3}\left(2Z_1 + Z_2\right)\\
F_{2\to 3} &= \frac{1}{3}\left(Z_1 + 2Z_2\right)
\end{align*}
Capacity limits:
\begin{align*}
(K_{1\to 2}, K_{2\to 3}, K_{1\to 3}) = (10,20,10)\mw
\end{align*}
\column{.6\textwidth}
\centering
  \includegraphics[width=6cm]{feasible2.pdf}\\
  \vspace{1cm}
  \includegraphics[width=2cm]{3nodes2}
\end{columns}
\end{frame}

\begin{frame}{Full optimisation problem}

We fix the values $Z_k$ (nodal imbalances) by maximising total economic welfare given constraints for the nodal injections (determined by the transmission constraints):
 \begin{align*}
    &\max_{\{Z_k\}}  \left[
    \sum_k B_k(Z_k)
    \right]
 \end{align*}
 subject to
 \begin{align*}
   \sum_k Z_k =  0 &\hspace{1cm} \leftrightarrow &  \l \\
   \pm \left[ \sum_{k}H_{\ell k}Z_k\right] \leq K_\ell & \hspace{1cm} \leftrightarrow &  \bar{\m}_\ell, \ubar{\m}_\ell
%   -\left[ \sum_{k}H_{\ell k}Z_k\right] \leq K_\ell & \hspace{1cm} \leftrightarrow &  \ubar{\m}_\ell
  \end{align*}
  with
   \begin{align*}
    & B_k(Z_k) = \max_{\{Q_i^B,Q_i^S\}}  \left[
    \sum_{i\in N_k} U_i (Q_i^B)  -  \sum_{i\in N_{k}} C_i (Q_i^S)
    \right]\\
    & \text{subject to }
     Z_k -  \sum_{i\in N_k} Q_i^S + \sum_{i\in N_k} Q_i^B =0 \hspace{1cm} \leftrightarrow \hspace{1cm} \l_k
  \end{align*}
\end{frame}

\section{Example: Efficient market operation in a 3-node system with constrained transmission}

\begin{frame}{An exemplary 3-node system}
\centering
  \includegraphics[width=9cm,angle=0,origin=c]{kirschen_figure}\\
\source{Kirschen and Strbac}
\end{frame}

\begin{frame}{An exemplary 3-node system}
Example taken from Kirschen and Strbac, Chapter 6.
%\begin{columns}[c]
%\column{0.4\textwidth}
  \begin{table}[!t]
    \begin{tabular}{ccc}
      \toprule
        Generator & Capacity & Marginal cost\\
        & (MW) & (\euro/MWh)\\
      \midrule
      A & 140 & 7.5\\
      B & 285 & 6\\
      C & 90 & 14\\
      D & 85 & 10\\
%\midrule\\
\bottomrule
        Line & Reactance & Capacity\\
        & (p.u.) & (MW)\\
      \midrule
      $1\to 2$ & 0.2 & 126\\
      $1\to 3$ & 0.2 & 250\\
      $2\to 3$ & 0.1 & 130\\
      \bottomrule
    \end{tabular}
  \end{table}
%\column{.6\textwidth}
 % \includegraphics[width=5cm]{kirschen_figure}\\
%\end{columns}
\end{frame}

\begin{frame}{Power flows and feasible injections}
\begin{columns}[c]
\column{.4\textwidth}
  \includegraphics[width=3cm]{3nodes4}
\begin{align*}
\mb{H} = 
\begin{matrix}
1\to 2 \\
1\to 3 \\
2\to 3
\end{matrix}
\begin{pmatrix}
2/5 & -1/5 & 0 \\
3/5 & 1/5 & 0 \\
2/5 & 4/5 & 0
\end{pmatrix}
\end{align*}
Power flows:
\begin{align*}
F_{1\to 2} &= \frac{1}{5}\left(2Z_1 - Z_2\right)\\
F_{1\to 3} &= \frac{1}{5}\left(3Z_1 +Z_2\right)\\
F_{2\to 3} &= \frac{2}{5}\left(Z_1 + 2Z_2\right)
\end{align*}
\column{.5\textwidth}
  \includegraphics[width=5.2cm]{feasible_example1}\\
  \includegraphics[width=5.2cm]{feasible_example2}
  \end{columns}
\end{frame}

\begin{frame}{Economic dispatch}
\begin{columns}[c]
\column{.5\textwidth}
Market price: $\lambda= 7.5\emwh$
\begin{align*}
Q^S_A &= 125\mw\\
Q^S_B &= 285\mw\\
Q^S_C &= 0\mw\\
Q^S_D &=0\mw
\end{align*}
  \includegraphics[width=5.2cm]{feasible_example3}\\
$Z_1 = 360\mw, Z_2=-60\mw$.
\column{.5\textwidth}
\begin{align*}
K_{1\to 2} &= 126\mw\\
K_{1\to 3} &= 250\mw\\
K_{2\to 3} &= 130\mw
\end{align*}
\begin{align*}
F_{1\to 2} &= \frac{1}{5}\left(2Z_1 - Z_2\right)=156\mw\\
F_{1\to 3} &= \frac{1}{5}\left(3Z_1 +Z_2\right)=204\mw\\
F_{2\to 3} &= \frac{2}{5}\left(Z_1 + 2Z_2\right)=96\mw
\end{align*}
\end{columns}
\end{frame}

\begin{frame}{Economic redispatch}
\begin{columns}[c]
\column{.5\textwidth}
\begin{align*}
Q^S_A &= 125\mw \to Q^S_A = 50\mw \\
Q^S_B &= 285\mw \to Q^S_B = 285\mw\\
Q^S_C &= 0\mw \to Q^S_C = 0\mw\\
Q^S_D &=0\mw \to Q^S_D = 75\mw
\end{align*}
Redispatch cost: $187.5$ \euro/h
  \includegraphics[width=5.2cm]{feasible_example4}\\
$Z_1 = 275\mw, Z_2=-60\mw$.
\column{.5\textwidth}
\begin{align*}
K_{1\to 2} &= 126\mw\\
K_{1\to 3} &= 250\mw\\
K_{2\to 3} &= 130\mw
\end{align*}
\begin{align*}
F_{1\to 2} &= \frac{1}{5}\left(2Z_1 - Z_2\right)=126\mw\\
F_{1\to 3} &= \frac{1}{5}\left(3Z_1 +Z_2\right)=159\mw\\
F_{2\to 3} &= \frac{2}{5}\left(Z_1 + 2Z_2\right)=66\mw
\end{align*}
\end{columns}
\end{frame}

\begin{frame}{Nodal prices}
The \alert{nodal marginal price} is equal to the minimal system cost of supplying an additional megawatt of load at this node.
\begin{columns}[c]
\column{.5\textwidth}
\begin{align*}
Q^S_A &= 50\mw \\
Q^S_B &= 285\mw\\
Q^S_C &= 0\mw\\
Q^S_D &=75\mw
\end{align*}
Nodal prices:
\begin{align*}
\lambda_1 &= c_A = 7.5\emwh\\
\lambda_3 &= c_D =  10 \emwh\\
\lambda_2 &= 1.5\times c_D - 0.5\times c_A = 11.25\emwh
\end{align*}
\column{.5\textwidth}
\begin{align*}
K_{1\to 2} &= 126\mw\\
K_{1\to 3} &= 250\mw\\
K_{2\to 3} &= 130\mw
\end{align*}
\begin{align*}
F_{1\to 2} &= \frac{1}{5}\left(2Z_1 - Z_2\right)=126\mw\\
F_{1\to 3} &= \frac{1}{5}\left(3Z_1 +Z_2\right)=159\mw\\
F_{2\to 3} &= \frac{2}{5}\left(Z_1 + 2Z_2\right)=66\mw
\end{align*}
\end{columns}
\end{frame}

\begin{frame}{Nodal prices}
Economic operation of the three-node system using nodal pricing.
  \begin{table}[!t]
    \begin{tabular}{lrrrr}
      \toprule
        & Node 1 & Node 2 & Node 3 & System\\
      \midrule
Consumption (MW) & 50 & 60 & 300 & 410\\
Production (MW) & 335 & 0 & 75 & 410\\
Nodal marginal price (\euro/MWh) & 7.5 & 11.25 & 10 & -\\
Consumer payments (\euro/h) & 375 & 675 & 3000 & 4050 \\
Generator revenue (\euro/h) & 2512.5 & 0 & 750 & 3262.5\\
Congestion rent (\euro/h) & & & & 787.5\\
\bottomrule
    \end{tabular}
  \end{table}
\end{frame}

\begin{frame}{Nodal prices}
Congestion rent:
 \begin{table}[!t]
    \begin{tabular}{lrrrr}
      \toprule
        Connection & Flow  & 'From' price & 'To' price & Surplus\\
         &  (MW) &  (\euro/MWh) & (\euro/MWh) & (\euro/h)\\
      \midrule
$1\to 2$ & 126 & 7.5 & 11.25 & 427.5\\
$1\to 3$ & 159 & 7.5 & 10 & 397.5\\
$2\to 3$ & 66   & 11.25 & 10 & -82.5\\
Total & & & & 787.5\\
\bottomrule
    \end{tabular}
  \end{table}
Note the counter-intuitive flow from node $2$ (higher price) to node $3$ (lower price)!
\end{frame}

\begin{frame}{Example slightly changed}
The \alert{nodal marginal price} is equal to the minimal system cost of supplying an additional megawatt of load at this node.
\begin{columns}[c]
\column{.5\textwidth}
\begin{align*}
Q^S_A &= 47.5\mw \\
Q^S_B &= 285\mw\\
Q^S_C &= 0\mw\\
Q^S_D &=77.5\mw
\end{align*}
Nodal prices:
\begin{align*}
\lambda_1 &= c_A = 7.5\emwh\\
\lambda_3 &= c_D =  10 \emwh\\
\lambda_2 &= 2\times c_A - 1\times c_D = 5\emwh
\end{align*}
\column{.5\textwidth}
\begin{align*}
K_{1\to 2} &= 126\mw\\
K_{1\to 3} &= 250\mw\\
K_{2\to 3} &= \mathbf{65}\mw
\end{align*}
\begin{align*}
F_{1\to 2} &= \frac{1}{5}\left(2Z_1 - Z_2\right)=125\mw\\
F_{1\to 3} &= \frac{1}{5}\left(3Z_1 +Z_2\right)=157.5\mw\\
F_{2\to 3} &= \frac{2}{5}\left(Z_1 + 2Z_2\right)=65\mw
\end{align*}
\end{columns}
The nodal marginal price at node $2$ is lower than the marginal cost of any generator!
\end{frame}

\begin{frame}{Negative nodal prices}
%{\centering
\begin{center}
  \includegraphics[width=8cm,angle=0,origin=c]{harris}
\source{Harris}
\end{center}
Generator A has marginal costs 60\euro/MWh, generator B has marginal costs 30\euro/MWh. The line between E and D is constrained to $25$ MW.\\
The additional load of 10 MW at node E \alert{reduces} the system cost by \\300 \euro/h, so $\lambda_E=-30\emwh$!
\end{frame}

\begin{frame}{Nodal prices for Germany}
  \centering
  \includegraphics[width=9cm]{lmp.png}
  \source{PyPSA \\(Python for Power System Analysis)}
\end{frame}

\section{Application: Flow Based Market Coupling}
\begin{frame}{ENTSO-E}
  \centering
  \includegraphics[width=9cm]{entsoe.pdf}
  \source{ENTSO-E}
\end{frame}

\begin{frame}{Available Transfer Capacity}
  \centering
  \includegraphics[width=11cm]{atc}
  \source{Van den Bergh, Boury, Delarue}
\end{frame}

\begin{frame}{Flow Based Market Coupling}
  \centering
  \includegraphics[width=11cm]{fbmc}
  \source{Van den Bergh, Boury, Delarue}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}{Copyright}


  Unless otherwise stated the graphics and text is Copyright
  \copyright Tom Brown and Mirko Sch\"{a}fer, 2016.

  We hope the graphics borrowed from others have been attributed
  correctly; if not, drop a line to the authors and we will correct
  this.

  The source \LaTeX, self-made graphics and Python code used to
  generate the self-made graphics are available on the course website:

  \url{http://fias.uni-frankfurt.de/~brown/courses/electricity_markets/}

  The graphics and text for which no other attribution are given are licensed under a
  \href{http://creativecommons.org/licenses/by-sa/4.0/}{Creative Commons
  Attribution-ShareAlike 4.0 International License}.

  \begin{center}\ccbysa\end{center}

\end{frame}

\end{document}
