% 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[official]{eurosym}

\usepackage[scale=2]{ccicons}


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


\newcommand{\R}{\mathbb{R}}

\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 4}
%\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{2th May 2016}


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

\begin{document}

\maketitle


\begin{frame}

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

\section{Transmission and distribution networks}

\begin{frame}{Transmission and distribution networks}

Electricity usually is not consumed where it is produced, so it has to be transported via \alert{transmission} and \alert{distribution networks}.

Transmission networks: Transport large volumes of electric power over relatively long distances.

Distribution networks: Take power from the transmission network and deliver it to a large number of end points in a certain geographic area.

\end{frame}

\begin{frame}{Transmission and distribution networks}

  \centering
  \includegraphics[width=6cm]{powergrid.jpg}
  
  \source{VKU}
\end{frame} 
 
 \begin{frame}{European Transmission Grid}

  \centering
  \includegraphics[width=8cm]{ENTSOE_grid.png}
    \source{ENTSO-E}

\end{frame} 
 

\begin{frame}{Transmission and distribution networks in Germany}
  \centering
  \includegraphics[width=9cm]{verteilnetz.pdf}
  
  \source{BMWi}

%Four \alert{Transmission System Operators}: Amprion [partially: RWE], Tennet TSO [past: E.ON], 50 Hertz Transmission [past: Vattenfall], Transnet BW [EnBW]) 

%888 \alert{Distribution System Operators}: RWE, EnBW, E.ON, Vattenfall, Stadtwerke, regional companies
  
\end{frame}

\begin{frame}{Transmission and distribution networks in Germany}
  \centering
  \includegraphics[width=10cm]{tso_dso.png}
  
  \source{Agora Energiewende / RAP}
  
\end{frame}



\begin{frame}{TSOs in Germany}

  \centering
  \includegraphics[width=6cm]{tsos_germany.png}
  
  \source{Wikipedia (Francis McLloyd)}

\end{frame}

\begin{frame}{Transmission grid near Frankfurt}

  \centering
  \includegraphics[width=6cm]{hvgrid_ffm.png}
  
  \source{ENTSO-E}

\end{frame}

\begin{frame}{Frankfurts DSO}

  \centering
  \includegraphics[width=6cm]{NRM.pdf}
  
  \source{NRM Netzdienste Rhein-Main}
NRM Netzdienste Rhein-Main (subsidiary company of Mainova)

\end{frame}


\begin{frame}{Power grids and electricity markets}

The (physical) balancing of supply and demand has to respect the \alert{network constraints} of the system. These constraints have to be implemented by the \alert{system operator}, but to some extent can also be included into the \alert{market design}.

Transmission and distribution networks are (almost?) natural monopolies, which leads to substantial \alert{market power}. These networks are typically state owned, cooperatives or heavily regulated (many interesting problems with respect to incentives, tariffs, etc.).

Network expansion is part of the \alert{long-term} efficient operation of the system. Note the interdependency between network and generation investment.

\end{frame}


\section{Representing network constraints}
 
\begin{frame}{Physical limits on networks}

{\bf Thermal limits:} Relate to the \alert{maximum amount of power} which can be transmitted via a transmission line.

{\bf Voltage stability limits}: Relate to the supply of reactive power to keep the system voltage close to a specific level.

{\bf Dynamic and transient stability limits:} Relate to the stability of the system frequency, and the stability of the synchronized operation of the generators.

\end{frame}

\begin{frame}{Representing transmission networks}

{\bf Terminology:} We represent the transmission grid as an network, consisting of \alert{nodes} and \alert{links}. The nodes may represent individual generators, groups of generators and consumers, whole geographic regions or just a point where different transmission lines meet. The links represent transmission lines, or more generally the possibility to transfer electric power between the respective nodes connected to the respective link.

\centering
  \includegraphics[width=4cm]{line-loading.png}
  
  \source{PyPSA}

\end{frame}

\begin{frame}{Basic implementation of thermal limits}

A link $l$ connecting two nodes allows to transport electrical power as a \alert{power flow} $F_{l}$ from one node to the other.

We implement the thermal limits on a line $l$ as the \alert{capacity} $K_{l}$, which gives the upper limit of power flow $F_{l}$ on $l$:
\begin{align*}
F_{l} & \leq K_{l}\\
-F_{l} & \leq K_{l}
\end{align*}

This looks just like another constraint for KKT. Unfortunately, the power flows $F_{l}$ are usually not free parameters, but are connected via physical laws from the generation and consumption pattern ${Q_{i}^S,Q_{i}^B}$ at the nodes. 

\end{frame}

\section{Efficient dispatch in a two-node system with constraints}

\begin{frame}{Example}
[The following example is taken from the book by Strbac and Kirschen.]

Consider two nodes representing regions, each with different total demand, using different types of generators:

{\bf First node:} Fixed demand $Q_{1}^B=500\mw$. The (inverse) supply function for the generators is given by
\begin{align*}
\pi_1 = MC_1 =  10 + 0.01 Q_1\bemwh
\end{align*}

{\bf Second node:} Fixed demand $Q_{2}^B=1500\mw$. The (inverse) supply function for the generators is given by
\begin{align*}
\pi_2 = MC_2 = 13 + 0.02 Q_2\bemwh
\end{align*}

For simplicity we assume that at both nodes the total generation limit is $5\gw$.

{\bf Transmission line} from node $1$ to node $2$ with capacity $K$.

\end{frame}

\begin{frame}{Example: Separate markets}

{\bf Transmission capacity $K=0$:}

{\bf First node:} Fixed demand $Q_{1}^B=500\mw$. The competitive price is
\begin{align*}
\lambda_1 = MC_1(Q_{1}^B) = 10 + 0.01\times 500 = 15\bemwh
\end{align*}

{\bf Second node:} Fixed demand $Q_{2}^B=1500\mw$. The competitive price is
\begin{align*}
\lambda_2 = MC_2(Q_{2}^B) = 13 + 0.02\times 1500 = 43\bemwh
\end{align*}

\end{frame}

\begin{frame}{Example: Separate markets}

  \centering
  \includegraphics[width=8cm]{strbac_separate_markets.pdf}
  
\end{frame}

\begin{frame}{Example: Single market}

{\bf Transmission capacity $K=\infty$:}

There is now a total demand $Q^B = Q_{1}^B + Q_2^B$, leading to a single market clearing price $\lambda$. The generators at node 1 and node 2 adjust their output such that
\begin{align*}
MC_1(Q_1) = MC_2(Q_2) = \lambda,
\end{align*}
under the constraint that
\begin{align*}
Q_1 + Q_2 = Q^B
\end{align*}
This leads to $Q_1 = 1433\mw$, $Q_2=567\mw$, and $\l = 24.33\emwh$.

\end{frame}

\begin{frame}{Example: Single market}

  \centering
  \includegraphics[width=8cm]{strbac_single_market.pdf}
  
\end{frame}




\begin{frame}{Example: Single market}

The power flow $F$ from node $1$ to node $2$ is given by
\begin{align*}
F &= \left(Q_{1}-Q_{1}^B\right) = - \left(Q_{2}-Q_{2}^{B}\right)\\
& = \left(1433 - 500\right)\mw  = - \left(567 - 1500\right)\mw \\
&= Z_1 = - Z_2\\
&= 933 \mw
\end{align*}
with $\{Z_1, Z_2\}=\{933\mw, -933\mw\}$ denoted as the \alert{injection pattern}.

From the balancing condition it follows $Z_1 + Z_2 =0$. We call a node with $Z>0$ a \alert{source}, and a node with $Z<0$ a \alert{sink}.

If $Z_1 > Z_2$, we have a flow from node $1$ to node $2$, if $Z_2 >Z_1$, we have a flow from node $2$ to node $1$ (source to sink).

\end{frame}

\begin{frame}{Example: Single market}
  \ra{1.1}
  \begin{table}[!t]
    \begin{tabular}{lrr}
      \toprule
        & Separate markets &  Single market \\
      \midrule
      $Q_1^B$ [MW] & 500 & 500 \\
      $Q_1$ [MW] & 500 & 1433 \\
      $Z_1$ [MW] & 0 & +933 \\
      $\l_1$ [\euro/MWh] & 15 & 24.33 \\
$Q_2^B$ [MW] & 1500 & 1500 \\
     $ Q_2$ [MW] & 1500 & 567 \\
      $Z_2$ [MW] & 0 & -933 \\
      $\l_2$ [\euro/MWh] & 43 & 24.33 \\
      $F_{1\to 2}$ [MW] & 0 & 933\\ 
      $\sum_{i}\lambda_{i}\times Q_i$ [\euro] & 72000 & 48660\\
      $\sum_{i}\lambda_{i}\times Q_i^B$ [\euro] & 72000 & 48660 \\
      \bottomrule
    \end{tabular}
  \end{table}
  
  \end{frame}
  
\begin{frame}{Another example: Separate markets}

Consider two nodes representing two regions with different total demand, using different types of generators:

{\bf First node:} Fixed demand $Q_{1}^B=200\mw$, one type of generators with marginal costs $c_1=10\emwh$ and total generation limit $\hat Q_1=300\mw$.

{\bf Second node:} Fixed demand $Q_{2}^B=300\mw$, one type of generators with marginal costs $c_2=30\emwh$ and total generation limit $\hat Q_2=400\mw$.

{\bf Transmission line} from node $1$ to node $2$ with capacity $K$.

{\bf Optimal dispatch:}

The generators at node $1$ provide $200\mw$ to the consumers at node $1$. Depending on the capacity of the transmission line, they export a power flow $F$ between zero and $100\mw$ to the consumers at node $2$. The generators at node $2$ provide the remaining consumption at node $2$, that is $300\mw - F$.
\end{frame}

 \begin{frame}{Another example: Separate markets}

{\bf Capacity $K=0$:} 

First node generators produce the entire supply of consumers at node 1, $Q_1=200\mw$, but cannot export to node 2. Second node generators provide the entire supply of consumers at node 2, $Q_3=200\mw$.  The competitive price at node 1 is $\lambda_1=10\emwh$, at node 2 it is $\lambda_2=30\emwh$.
 
Total cost to consumers: $200\mw \times 10\emwh + 300\mw \times 30\emwh = 11000$ \euro.\\
Generators at node 1: Revenue $200\mw \times 10\emwh = 2000$ \euro.
Generators at node 2: Revenue $300\mw \times 30\emwh = 9000$ \euro.
\end{frame}

\begin{frame}{Another example with two nodes, separate markets}

  \centering
  \includegraphics[width=8cm]{simple_separate_markets.pdf}
  
\end{frame}


\begin{frame}{Another example: Single market}

{\bf Capacity $K=\infty$:} 

First node generators produce at the limit, $Q_1=300\mw$, second node generators provide the remaining $Q_2=200\mw$. The power flow is $100\mw$. The competitive price at both nodes is $\lambda=30\emwh$.
 
Total cost to consumers: $500\mw \times 30\emwh = 15000$ \euro.\\
Generators at node 1: Revenue $300\mw \times 30\emwh = 9000$ \euro.
Generators at node 2: Revenue $200\mw \times 30\emwh = 6000$ \euro.

Due to the particular structure of the supply curves and the inelastic demand, market coupling has led to a higher price.
\end{frame}

\begin{frame}{Another example: Single market}

  \centering
  \includegraphics[width=8cm]{simple_single_market.pdf}
  
\end{frame}
  
\begin{frame}{Back to the first example}
Two nodes representing two regions, each with different total demand, using different types of generators:

{\bf First node:} Fixed demand $Q_{1}^B=500\mw$. The (inverse) supply function for the generators is given by
\begin{align*}
\pi_1 = MC_1 =  10 + 0.01 Q_1\bemwh
\end{align*}

{\bf Second node:} Fixed demand $Q_{2}^B=1500\mw$. The (inverse) supply function for the generators is given by
\begin{align*}
\pi_2 = MC_2 = 13 + 0.02 Q_2\bemwh
\end{align*}

For simplicity we assume that at both nodes the total generation limit is $5\gw$.

{\bf Transmission line} from node $1$ to node $2$ with capacity \alert{$K=400\mw$}.

\end{frame}  

\begin{frame}{Example: Constrained single market}

  \centering
   \includegraphics[width=5cm]{strbac_separate_markets.pdf}
  \includegraphics[width=5cm]{strbac_single_market.pdf}\\
  \includegraphics[width=5cm]{strbac_constrained_market.pdf}
  
\end{frame}

\begin{frame}{Example: Constrained market}

{\bf Transmission capacity $K=400\mw$:}

The transmission capacity is less than the power flow occuring for a single market with unconstrained transmission. The (cheaper) generators at node 1 export power until the line is \alert{congested}. The (more expensive) generators then cover the remaining load at node 2.

\begin{align*}
MC_1(Q_1^B+K) = \lambda_1\\
MC_2(Q_2^B-K) = \lambda_2
\end{align*}
This leads to $Q_1 = 900\mw$, $\l_1 = 19\emwh$, $Q_2=1100\mw$, and $\l_2 = 35\emwh$.

\end{frame}

\begin{frame}{Example: Constrained market}

  \centering
  \includegraphics[width=8cm]{strbac_constrained_market.pdf}
  
\end{frame}

\begin{frame}{Example: Constrained market}
  \ra{1.1}
  \begin{table}[!t]
    \begin{tabular}{lrrr}
      \toprule
        & Separate markets &  Single market & Constrained market \\
      \midrule
      $Q_1^B$ [MW] & 500 & 500 & 500 \\
      $Q_1$ [MW] & 500 & 1433 & 900 \\
      $Z_1$ [MW] & 0 & +933 & +400\\
      $\l_1$ [\euro/MWh] & 15 & 24.33 & 19 \\
$Q_2^B$ [MW] & 1500 & 1500 & 1500 \\
     $ Q_2$ [MW] & 1500 & 567 & 1100\\
      $Z_2$ [MW] & 0 & -933 & -400\\
      $\l_2$ [\euro/MWh] & 43 & 24.33 &  35 \\
      $F_{1\to 2}$ [MW] & 0 & 933 & 400\\ 
      $\sum_{i}\lambda_{i}\times Q_i$ [\euro] & 72000 & 48660 &  55600  \\
      $\sum_{i}\lambda_{i}\times Q_i^B$ [\euro] & 72000 & 48660 & 62000 \\
      \bottomrule
    \end{tabular}
  \end{table}
  
  \end{frame}
  
\begin{frame}{Locational marginal pricing}
Due to the congestion of the transmission line, the marginal cost of producing electricity is different at node 1 and node 2. The competitive price at node 2 is higher than at node 1 -- this corresponds to \alert{locational marginal pricing}, or \alert{nodal pricing}.

Since consumers pay and generators get paid the price in their local market, in case of congestion there is a difference between the total payment of consumers and the total revenue of producers -- this is the \alert{merchandising surplus} or \alert{congestion rent}, collected by the market operator. For each line it is given by the price difference in both regions times the amount of power flow between them:
\begin{align*}
\text{Congestion rent =}\:\Delta \lambda\times F
\end{align*}


\end{frame}


\begin{frame}{Spoiler: LMP in a meshed network}

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

\begin{frame}{Redispatch}
Another way to handle congestion is to correct the single market outcome retrospectively using \alert{redispatch}. Consider the previous example with line capacity $K=400\mw$.

Single market result: $Q_1=1433\mw$, $Q_2=567\mw$, market price $\lambda=24.33\emwh$, power flow $933\mw$.

System operator has to adjust the dispatch:
\begin{align*}
\Delta Q_1 = -533\mw\\
\Delta Q_2 = +533\mw
\end{align*}
\end{frame}
  
\begin{frame}{Redispatch}

  \centering
  \includegraphics[width=8cm]{strbac_redispatch.pdf}\\

\raggedright
Cost of redispatch: $0.5\times(35-19)\times 533 = 4264\bemwh$

\end{frame}  

\begin{frame}{Redispatch vs. Nodal pricing}

  \centering
  \includegraphics[width=5cm]{strbac_redispatch.pdf}\hspace{0.5cm}
  \includegraphics[width=5cm]{strbac_constrained_market.pdf}\\
\vspace{1cm}
\raggedright
Note that the cost of dispatch for the generators is identical for redispatch (left) and nodal pricing (right).

\end{frame}  

\begin{frame}{Redispatch in Germany}

  \centering
  \includegraphics[width=11cm]{redispatch_germany_1.png}
  \source{Bundesnetzagentur/\\
  Bundeskartellamt}

\end{frame}

\begin{frame}{Redispatch in Germany}

  \centering
  \includegraphics[width=5.5cm]{redispatch_germany_2.png}
  \source{Bundesnetzagentur/\\
  Bundeskartellamt}

\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}
