\documentclass[main.tex]{subfiles}

\begin{document}
In this final chapter, we discuss the results of applying our theory to the SciGRID dataset. We would like to reiterate that this data is aggregated from different sources, most of which are \emph{not} physical measurements, but `educated guesses'.

With this in mind, we proceed with our analysis, not necessarily with the goal of providing accurate operational advice for German grid operators, but to demonstrate that the model can be applied to real-world transmission networks. By studying a representative dataset, we can study the strengths and weaknesses of the model. Finally, we hope that this model will provide \emph{qualitative insight} into the complex behaviour of grid failures, not specific to this dataset.

\section{SciGRID data}
The SciGRID dataset needs to be translated into the language of our model. It contains more information than we need, and it is not yet in the desired format.

\subsection{Structure}
\emph{(A more detailed analysis of dataset properties is available on the GitHub repository.)}

Before any processing, we find that the SciGRID network (obtained from \texttt{PyPSA} example code, the exact dataset used by \cite{Nesti2018emergentfailures}) contains 585 buses, 1423 generators (of all sources) and 489 loads. It also contains 38 storage units (all are pumped hydroelectric), but these were excluded from our analysis.\footnote{More specifically, they were used in solving the OPF problem, but their initial charge was set to zero.} There are 852 transmission lines in the dataset, at possible voltage levels $220 \, \si{\kilo\volt}$ and $380 \, \si{\kilo\volt}$, and there are 96 transformers (between these two voltages). Transmission lines have per-kilometre estimates for admittance, from which the total admittance can be deduced.

\subsubsection{Voltages}
In our model, we \emph{normalise} the grid voltage. To do so, we multiply all line admittances by the \emph{square} of their operating voltages, after which all voltages can be assumed to be $1$, and a unit of current is proportional to a unit of transmitted power. Of the 585 buses, 192 are part of one of the 96 \emph{voltage pairs}: these are two buses at the same location, with the same name (except for the voltage suffix), connected via a transformer. By merging these pairs, we find 489 geographically unique buses, at normalised voltage. From now on, we will refer to these (possibly merged) buses as the buses of the network: $n=489$, $\mathcal{N} = \range{489}$.

\subsubsection{Loads}
There is exactly 1 load connected to each bus. In reality, there are of course thousands of loads connected to a bus: the load in the dataset is the \emph{aggregated} load at that bus. We have hourly time series (\ie amount of $\si{\mega\watt}$ being consumed) for each node in the year 2011, which only includes active power consumption.

\subsubsection{Generators}
Generators are connected to the geographically closest bus, and there is at most one generator per bus of each type.\footnote{In order of installed capacity: \emph{Wind Onshore} ($37\,\si{\giga\watt}$), \emph{Solar} ($37\,\si{\giga\watt}$), \emph{Hard Coal} ($25\,\si{\giga\watt}$), \emph{Gas} ($24\,\si{\giga\watt}$), \emph{Brown Coal} ($21\,\si{\giga\watt}$), \emph{Nuclear} ($12\,\si{\giga\watt}$), \emph{Run of River} ($4\,\si{\giga\watt}$), \emph{Other} ($3\,\si{\giga\watt}$), \emph{Wind Offshore} ($3\,\si{\giga\watt}$), \emph{Oil} ($2.7\,\si{\giga\watt}$), \emph{Waste} ($1.6\,\si{\giga\watt}$), \emph{Storage Hydro} ($1.4\,\si{\giga\watt}$), \emph{Multiple} ($0.15\,\si{\giga\watt}$) and \emph{Geothermal} ($32\,\si{\mega\watt}$).} This means that generation is \emph{aggregated}: multiple generators of the same type are combined into one. There are 489 solar generators, 488 onshore wind generators and 5 offshore wind generators. Offshore wind generators are connected to buses at the north coast of Germany. This means that every bus houses stochastic generation. Their geographic distribution is shown in Figure~\ref{fig:solarwind}.

\subsubsection{Lines}
Line voltages and admittances are normalised as described above. For each line, we have the names of the two original buses that it connects, which can easily be converted to the new bus collection.

During the study of cascading failures, we found that the network contains \emph{parallel lines}: lines that connect the same pairs of buses. In some cases, there are up to four different lines that are all parallel. When examining these cases on OpenStreetMap, we find that there are indeed parallel lines in the physical network. This is reflected by the \emph{lengths} of parallel lines, as given by SciGRID: these are not the great-circle distances between buses, but rather the distance measured along the line (which makes some turns and bends).

Because our model only holds for \emph{digraphs}, which cannot have parallel lines, we \emph{combine} parallel lines by summing their (voltage normalised) admittances, and summing their thresholds.\footnote{The results regarding the kernel of $\FRT$, and the Optimised method for analysis cascading failures, break down without this property.} \cite{Nesti2018emergentfailures} do not mention this anomaly, and use the original set of lines. For comparison, we computed some results for both versions of the network, and found the results to be somewhat similar, in general. Because we did not consider the case of parallel lines in our model, combining parallel lines in the dataset seems like the \emph{correct} choice.

Of the 852 original lines, there are 705 unique links between original buses before normalising voltages, and there are 695 unique links between buses. There are never two parallel lines with opposite orientation. These 695 lines were used in our model, and will be referred to as simply the \emph{lines} of the network: $m = 695$.

\subsection{State}
Our dataset contains hourly values for load and stochastic (wind and solar) generation for the year 2011. Deterministic generation is estimated using the OPF algorithm, as implemented by \texttt{PyPSA} \citep{PyPSA}, a Python package designed for this purpose. Following common practice, we first multiply all line thresholds by a \define{contingency factor}: $0.70$. This forces the optimisation process to leave a safety margin at every line, and also accounts for the error of using the DC approximation. Figure~\ref{fig:nominalflowandinjection} shows the resulting injection at 1 January 2011 at 11:00. Line currents can then be computed using the LPF.

\begin{figure}[ht]
    \centering
    \includegraphics[width=.6\textwidth]{img/nominal_flow_and_injection.pdf}
    \caption{
    \label{fig:nominalflowandinjection}Nominal line flow during 11:00-12:00, as fraction of line capacity. Node size represents net power injection. When generation exceeds load, the injection is positive (green), otherwise negative (greyish blue). \emph{Compare with Figure 1a of \cite{Nesti2018emergentfailures}.}}
\end{figure}

\section{Bus covariance}
As discussed in Section~\ref{sec:persistentforecast}, we estimate the bus covariance matrix from historical errors in our forecast. We find \emph{high} covariances among nodes, which we expected from our preliminary analysis. Because renewable generation data is extrapolated directly from (coarse) weather data, the generation series of nearby buses are almost identical.

The covariance of buses, calculated using the difference series, is visualised in Figure \ref{fig:buscov}.
\begin{figure}[ht]
    \centering
    \includegraphics[width=\textwidth]{img/bus_correlation_123_fullcov_day_and_night.pdf}
    \caption{
    \label{fig:buscov}Covariance of all buses, relative to the circled bus. Dot size represents normalised covariance. (Normalised using installed renewable capacity at the node.)}
\end{figure}

\section{Line covariance}
By incorporating bus covariances in our model (which result from correlated weather), we hope to find new structure in the line covariances.
To assess the effect of estimating bus covariances, we compare three possible bus covariance matrices:
\begin{enumerate}
	\item \emph{The identity matrix}: all bus injections are independently Gaussian distributed with the same variance. (They are almost IID, but their means differ.)
	\item \emph{The diagonal of estimated variances}: all bus injections are independently Gaussian distributed, but their variances and means differ.
	\item \emph{The estimated covariances}: the vector of bus injections is (multivariate) Gaussian distributed. All bus injections are, in general, dependent on each other, and their variances and means differ.
\end{enumerate}

It is well known that local changes to the grid structure have long-range effects. For example, \cite{Witthaut2013} showed that \emph{adding} a new line to a heavily congested, but stable network can cause the failure of another line, possibly far away from the added line.\footnote{The counter-intuitive fact that adding a line, or increasing the impedance of existing lines, can make a network \emph{more} congested, is known as \define{Braess' Paradox}. Similarly, some line failures can be \emph{prevented} by switching off other lines in the network.% See Figure~\ref{fig:braess} for a minimal example.
} This is reflected in our model by the fact that line currents have non-zero covariance, even when bus injections are independently distributed. (In this case, $\mat{\Sigma}_{\mat{f}} = \mat{F}\mat{I}\mat{F}^* = \mat{F}\mat{F}^*$, which is generally not a diagonal matrix.) Figure~\ref{fig:linecov1} and Figure~\ref{fig:linecov2} show the covariances of all lines, relative to a chosen line. We see that covariance is generally high for lines that are close, but there are some clear exceptions. There seems to be a general trend that lines are highly (positively or negatively) correlated when they are close, and \emph{oriented in the same direction} (\eg East-West) as the chosen line.
%
%\begin{figure}[ht]
%\centering
%\includegraphics[width=\textwidth]{img/braesstekening.png}
%\caption{\label{fig:braess} PLACEHOLDER: An example of Braess' Paradox. A network transporting $5$ units of power from left to right; all lines have the same admittance, and threshold $3$. On the left, one line (lower right) is overloaded. When this line fails, all power will travel through the upper branch, causing it to overload as well, leaving the network disconnected. If instead, the \emph{lower left} line is switched off, the flow of power will be more evenly distributed, and no line will overload. Of course, this example also illustrates how adding a line could lead to overloads.}
%\end{figure}

\begin{figure}[ht]
\begin{subfigure}{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{img/flow_correlation_387_iid_and_justvar_and_fullcov.pdf}
    \caption{Covariances relative to line 387.}\label{fig:linecov1}
\end{subfigure}
\begin{subfigure}{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{img/flow_correlation_651_iid_and_justvar_and_fullcov.pdf}
    \caption{Covariances relative to line 651.}\label{fig:linecov2}
\end{subfigure}
    \caption{Covariance of all lines, relative to the enlarged line. Normalised using installed renewable capacity. Signs (red or green) can be chosen arbitrarily. Absolute covariance is therefore proportional to color \emph{saturation}.}
\end{figure}

The covariance of a random pair of lines is relatively high when their physical separation (measured either in kilometres or in graph distance) is low. Because weather is correlated, even at high distance, using the bus full covariance might result in higher covariances between lines with high separation. (This was concluded by \cite{Nesti2018emergentfailures}.)

Using a different bus covariance matrix will likely result in a overall increase or decrease of line covariances. Note, however, that scaling the covariance matrix \emph{uniformly} does change absolute overload probabilities, but it does not change the \emph{ranking} of most vulnerable lines, and it does not change most likely injection: a uniform factor in $\mat{\Sigma}_p$ disappears in Equation (\ref{eq:mostlikelyinjection}).

This makes it difficult to compare the three bus covariance matrices, as any absolute difference in line covariance should be ignored. Instead, we will examine the covariance of two lines, \emph{relative to their own variances}. This way, the effect of any absolute, proportional increase in covariance is avoided. First, let us choose a number of lines, and examine the covariances of all other lines with the chosen line, relative to its variance.

In particular, we are interested in the decay of covariance over distance. \cite{Jung2016} studied the decay of the Line Addition Distribution Factor (difference in flow after adding a line) over distance, also using the SciGRID network. This is not the same as covariance, of course, but both are measures of the \emph{global effect} of local changes in flow. They first determined the largest 2-connected component of the network, and removed all other lines from the model. In the remaining network, they studied the 880 possible additions of short new lines, and found a general \emph{exponential} decay of change in currents as a function of graph distance.

To study the decay of covariance, we collect the geographical separation and covariance (resulting from the three possible bus covariance matrices) of $10^5$ random pairs of lines in the network. Because of power flow physics, these covariances are highly spread out. However, when averaging the covariances in groups of $25 \, \si{\kilo\metre}$ (Figure~\ref{fig:linecovdecay}), we find are able to see the differences in decay.

\begin{figure}
\centering
\includegraphics[width=\textwidth]{img/covariance_linepairs_with_average.pdf}
\caption{\label{fig:linecovdecay} For $10^5$ random pairs of lines, the covariance and distance (between line centres) is shown, for three possible bus covariance matrices. The averages (over $25 \, \si{\kilo\metre}$) show that correlated buses increase long-range correlations in line flows. Covariances are normalised using average line variance.}
\end{figure}

By doing so, we find an important result. When we model bus injections to be uncorrelated (first two graphs in Figure~\ref{fig:linecovdecay}), we find \emph{some} correlation in line flows, which are due to power flow physics.\footnote{As an example, consider the $n$-loop network. Here, two neighbouring lines are highly correlated, since they always transmit roughly the same amount of power. (The difference is the amount of power injected at their common node.)} On average, these correlations decrease as the distance between two lines increases, as shown by the red line.\footnote{We might expect this decay to be \emph{exponential} (based on the work of \cite{Jung2016}, for example), but this is not the case.}
On the other hand, when we include \emph{covariances among bus injections} in our model (last graph in Figure~\ref{fig:linecovdecay}), we find a \emph{relative increase in long-distance correlations of line flows}, compared to the uncorrelated case. This is one of the main results of \cite{Nesti2018emergentfailures}, which they demonstrate only on the $n$-loop network. Figure~\ref{fig:linecovdecay} validates that the result also holds for the SciGRID network.

Curiously, in the range $25\,\si{\kilo\meter}$ - $150\,\si{\kilo\meter}$, the average correlation of line flows \emph{increases} with higher line distances. The reason for this phenomenon is unclear, but one could investigate this further by examining line pairs of these short distances individually.

%\begin{figure}
%    \centering
%    \includegraphics[width=.4\textwidth]{img/load.png}
%    \caption{PLACEHOLDER: The load distribution of Germany at ???.}
%    \label{fig:loaddistribution}
%\end{figure}
%
\begin{figure}
    \centering
    \includegraphics[width=\textwidth]{img/installed_stochastic_capacity.pdf}
    \caption{Installed stochastic capacity per source: wind onshore, wind offshore, solar.}
    \label{fig:solarwind}
\end{figure}

\section{Most vulnerable lines}
Using the nominal injection at 1 January, 11:00, we compute the failure probability of each line. The 30 most vulnerable lines are given in Table~\ref{tab:results} (first two columns) and their positions are given in Figure~\ref{fig:nomflow_stdev_overload}. In the SciGRID dataset, lines are not numbered randomly. Rather, we find that two consecutive line numbers often correspond to two lines that are in close proximity. In the case of lines 651 and 652, for example, the two lines are connected in \emph{series}. As a consequence of power flow physics, their line flows highly correlated.

We identify the same vulnerable lines as \cite{Nesti2018supplemental}, but the ranking is different. This can be attributed to two differences in approach. First, we have combined parallel lines,\footnote{all 30 most vulnerable lines were not part of a parallel combination} which changes the vulnerability order significantly. It is unclear why this changes the result. For comparison, the ranking that we get \emph{without} combining parallels was also computed, which is more similar that of \cite{Nesti2018supplemental}. The second major difference is the use of a different covariance matrix, although it is reassuring to see that the same lines are identified.

\subsection{Properties of vulnerable lines}
As can clearly be seen in Table~\ref{tab:results}, most lines that are vulnerable to emergent failures are nominally being used at 70\% percent of their capacity. (This is exactly the \emph{contingency factor} used in the LOPF calculation.) This is explained by the low standard deviations of line flows. In fact, when we scale the covariance matrix uniformly by a factor close to zero, this effect is exaggerated.\footnote{This is a \emph{large deviations} result of the normal distribution: if we have $X \, \sim \, \gaussdistr(0, \sigma^2)$, then the marginal distribution of $X \, \mid \, X \geq 1$ becomes increasingly concentrated around $1$ as $\sigma$ tends towards zero. See \eg \cite{Touchette2011}.}

The 10 most vulnerable lines are not significantly long or short. They average $43\,\si{\kilo\meter}$ (SD $30 \,\si{\kilo\meter}$), compared to $36\,\si{\kilo\meter}$ (SD $35 \,\si{\kilo\meter}$) for \emph{all} lines in the network. From Figure~\ref{fig:nomflow_stdev_overload} we can make the interesting observation that vulnerable lines are generally oriented radially towards the \emph{Ruhr}, a density populated area in western Germany.

Vulnerable lines have significantly lower thresholds. On average, the 10 most vulnerable lines can transmit $554 \, \si{\mega\watt}$ (SD $219 \, \si{\mega\watt}$), while the grid-wide average is $1385 \, \si{\mega\watt}$ (SD $1052 \, \si{\mega\watt}$). Indeed, a change in injection has an \emph{absolute} effect on line flows; lines with low thresholds that are operating at the contingency limit (70\%) need only a small amount of additional power to overload.

There is a difference in line \emph{impedance}: $3.9 + 18.9i \, \si{\ohm}$ (SD $3.3 + 12.5i \, \si{\ohm}$) compared to the average of all lines, $2.0 + 12.0i \, \si{\ohm}$ (SD $2.6 + 13.6i \, \si{\ohm}$). This higher reactance means that vulnerable lines have higher \emph{susceptance}, making them more sensitive to changes in node voltages. Grid operators have some control over these values, and lowering the line reactance might make these lines less vulnerable. To study these questions further, we need to also take \emph{reactive power} into account, which we omitted in the DC approximation.

\begin{figure}
    \centering
    \includegraphics[width=\textwidth]{img/nomflow_stdev_trueoverloadprob_labeled.pdf}
    \caption{Visualisation of $\bm{\mu}_{\mathbf{f}}$, $\bm{\Sigma}_{\mathbf{f}}$ and $(\PROB\left[|\mel{f}_l| \geq 1 \right])_{l \in \range{m}}$ at 1 January, 11:00. The 20 most vulnerable lines are labelled.}
    \label{fig:nomflow_stdev_overload}
\end{figure}

\section{Most likely injection}
In addition to the failure probability, we compute the most likely injection to cause that failure using Theorem~\ref{thm:mostlikelyinjection}. The reader is invited to examine these injections themselves using Interactive~Figure~\ref{ifig:master}. The most likely fluctuation of three lines is given in Figure~\ref{fig:MLfluctuation1}. As expected, we find that vulnerable lines (most likely) fail due to small fluctuations in the injection, while robust lines only fail because of extreme, highly unrealistic fluctuations.

\begin{figure}[ht]
\begin{subfigure}{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{img/ML_fluctuation_with_bus_cov.pdf}
    \caption{Taking bus covariances into account.}\label{fig:MLfluctuation1}
\end{subfigure}
\begin{subfigure}{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{img/ML_fluctuation_without_bus_cov.pdf}
    \caption{Using only bus variances, with no covariance.}\label{fig:MLfluctuation2}
\end{subfigure}
    \caption{The most likely fluctuation given the failure of lines 251 (1.60\% overload probability), 651 (9.56\%) and 102 ($< 10^{-15}$). By including bus covariances (top), we find the most likely fluctuation to be more spread out. Zero-sum correction (distributive slack) is not applied.}\label{fig:MLfluctuation}
\end{figure}

\subsection{Geographic distribution of fluctuations}
In general, the most likely fluctuation is not concentrated at the two endpoints of the line, but rather, it consist of small, grid-wide fluctuations. This is due to high bus covariances, but also due to power flow physics. To examine the contribution of bus covariances, we also compute the most likely injection using only the diagonal of bus variances, see Figure~\ref{fig:MLfluctuation2}. For these three lines, we find that the fluctuations are indeed more evenly distributed when bus covariances are taken in account.

To study this hypothesis more objectively, we need a measure of how `spread out' the fluctuation is. One possibility is to use the \emph{standard deviation} of the 489 entries of a fluctuation: when a fluctuation is more evenly distributed (geographically), we expect the standard deviation of individual fluctuations to be lower. When computing these values for the 50 most vulnerable lines, we find no significant result: the average of the 50 standard deviations in fluctuations is $22.0\,\si{MW}$ (SD $6.5\,\si{MW}$) for correlated buses and $22.6\,\si{MW}$ (SD $9.5\,\si{MW}$) for uncorrelated buses. Taking a lower number of lines does not improve the result. Curiously, when \emph{all} lines are considered (including the 584 lines with negligible overload probability\footnote{\ie less than $10^{-15}$, the numerical margin of error in our case}), the average standard deviation is actually \emph{higher} with correlated buses: $1245\,\si{MW}$ (SD $9244\,\si{MW}$) versus $418\,\si{MW}$ (SD $1036\,\si{MW}$) for uncorrelated buses. However, because we are mainly interested in the most vulnerable lines, we will leave this anomaly for what it is. Regarding the first 50 lines, it seems like a different approach is needed, and we are unable to confirm our hypothesis.

\subsection{Bus extensions}
Since we did not incorporate the \emph{installed stochastic capacity} in our model, it is possible that the predicted most likely injection dictates that some buses are generating more stochastic power than what is installed. To evaluate this problem, we retrieve the total amount of installed stochastic capacity for each bus from our dataset (taking the sum of solar and wind). For a given point in time, the generation values then tell us how much a bus can fluctuate upwards (more generation) and downwards.

Given a most likely injection, we can compute whether the fluctuation at each bus is within the possible bounds, and if not, by how much the bounds must be extended for the most likely injection to be possible. In Table~\ref{tab:results}, the number of buses that needs to be extended is given, along with the total amount of extended capacity. For simplicity, we make no distinction between an extension upwards or downwards. An extension upwards means that more solar panels or wind turbines would be needed for the injection to be possible.\footnote{This implies an inaccuracy in our dataset.} An extension downwards is harder to justify, but one could say that it means that the amount of stochastic generation \emph{before} the fluctuation must have been higher, replacing non-stochastic generation at that node.

For the most vulnerable lines, we find that the \emph{number} of extended buses can be quite high, but the total amount of addition capacity is low, in general. For reference, buses in the network have an average installed capacity of $76\,\si{\mega\watt}$ (solar); $82\,\si{\mega\watt}$ (wind).
%
%\towrite{twee problemen: geen distr. slack meegenomen, geen onderscheid meer tussen zon en wind}
%
%\towrite{het geeft vooral een mankement van het model aan: de grenzen zouden meegenomen moeten worden in de most likely injection}

\subsection{Cascades}
Using the most likely injection, we simulate the resulting cascade. The results for all lines are given in Interactive~Figure~\ref{ifig:master}. The number of lines that either failed jointly with the initial failure, or failed during the subsequent cascade, is also given in Table~\ref{tab:results}. This extends the result of \cite{Nesti2018supplemental}, which only provides the failure probability. We find that among the 10 most vulnerable lines (at 11:00),
only the failures of lines 298, 25 and 645 result in a power island. We will discuss these lines in more detail in Section~\ref{sec:evolution}, but for now, we note that these failures quickly result a power island. (For 298 and 645, this happens the first stage.) At this point, our model becomes unreliable (see Section~\ref{sec:discussioncasc}).

\begin{figure}[ht]
\renewcommand\figurename{Interactive Figure}
\begin{subfigure}{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{img/master_with_cov_251.pdf}
    \caption{Assumed failure of line 251.}\label{ifig:master251}
\end{subfigure}
%
\begin{subfigure}{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{img/master_with_cov_197.pdf}
    \caption{Assumed failure of line 197.}\label{ifig:master197}
\end{subfigure}
%
    \caption{Simulated cascade stages after one assumed emergent failure. Node sizes represent the most likely injection. Long cascade sequences are truncated.
\vspace{.5em}
\newline
\emph{This figure is \textbf{interactive}: to view animated cascade simulations for all lines of the network, visit \href{https://fonsp.com/grid}{\texttt{fonsp.com/grid}}.}
}\label{ifig:master}
\end{figure}
\begin{figure}[ht]
\renewcommand\figurename{Interactive Figure}
\ContinuedFloat
\begin{subfigure}{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{img/master_with_cov_182.pdf}
    \caption{Assumed failure of line 182.}\label{ifig:master182}
\end{subfigure}
%
    \caption{(continued).}\label{ifig:mastercont}
\end{figure}

\subsection{Evolution of line vulnerabilities}\label{sec:evolution}
Of course, the method above can be applied to any nominal injection, not just the injection at 1 January, 11:00. By applying the method to every hour of the first day, we find 24 different rankings, one of which is given in Table~\ref{tab:results}. This allows us to not only identify lines that are vulnerable at a given point in time, but to find lines that are a \emph{consistent vulnerability}, based on the general use of the transmission network.

Instead of providing 23 additional tables, we have summarised the results of a full day in Figure~\ref{fig:evolution_vulnerabilities}. Here, we see that some lines (like 337) are only vulnerable at one point during the day, while others (298 and 54) have a consistently high overload probability. There is a clear distinction between daytime and night-time, since the time of day determines which covariance matrix is used in the calculation. In fact, this highlights how a change in covariance influences results: some lines are only vulnerable because of the covariances brought upon by solar generation, while others are relatively unaffected.

A most striking result is that the overload probabilities of 25 and 298 are perfectly \emph{constant} for sustained periods, and both are likely to cause a cascade, resulting in an average of 108 and 76 failures, respectively. When examining these two lines in more detail, we find that both are \emph{branches out of the network towards coastal cities of the North Sea}, with high-capacity offshore wind generation. These generators were operating at full capacity during the studied day,\footnote{according to our dataset} which would cause a constant\footnote{except for the local energy usage, which is relatively small} power injection. Because the lines are \emph{branches} out of the larger graph, the flow through the line is exactly equal to the power injection at its end, and therefore constant.

Regarding the subsequent cascades of these two lines, it seems like our model falls short of giving an accurate redistribution of flow, due to the singularity caused by their removal. (No flow redistribution exists that would not change the injection.)

\begin{figure}[ht]
\begin{subfigure}{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{img/evolution_overload_probs_3.pdf}
    \caption{All lines that are, at any time during the day, among the 3 most vulnerable lines.}\label{fig:evolution_vulnerabilities_3}
\end{subfigure}
\begin{subfigure}{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{img/evolution_overload_probs_3_20.pdf}
    \caption{All lines that are, at any time during the day, among the 20 most vulnerable lines.}\label{fig:evolution_vulnerabilities_3_20}
\end{subfigure}
    \caption{\label{fig:evolution_vulnerabilities}Evolution of absolute failure probabilities during 1 January 2011. Dot sizes represent final number of lost lines after the most probable cascade.}
\end{figure}

\begin{figure}[ht]
    \centering
    \includegraphics[width=\textwidth]{img/evolution_overload_probs_3_20_IID.pdf}
    \caption{For reference, the same as Figure~\ref{fig:evolution_vulnerabilities_3_20}, but computed using \emph{uncorrelated} injections.}\label{fig:evolution_vulnerabilities_3_20_IID}
\end{figure}
%
%\begin{table}
%\input{tables/top20lines.tex}
%\caption{TODO}
%\label{tab:top20old}
%\end{table}

\begin{table}
\vspace{-1.5cm}
\centerline{
\input{tables/results.tex}
}
\vspace{1cm}
\caption{The 30 most vulnerable lines at 1 January, 11:00. For each line, we have the absolute overload probability and the mean and standard deviation of line saturation. For the most likely injection, the total change (fluctuation) in injection is given, and the number of buses for which renewable generation would need to be extended for the most likely injection to be possible. \protect\newline
The number of failed lines in each cascade stage is shown. Stages in parentheses correspond to a disconnected network. (The first number is greater than $1$ when there are \emph{joint failures}.) The final column states whether the last cascade stage is disconnected (\ie whether a power island emerged).
}
\label{tab:results}
\end{table}

\section{Discussion}
\subsection{Cascading failures}\label{sec:discussioncasc}
Following \cite{Nesti2018emergentfailures}, we identify the lines most vulnerable to emergent failures, and we give the absolute overload probabilities (first two columns of Table~\ref{tab:results}). We extend the original result by also stating the (most likely) total fluctuation and the sequence of cascades. Additionally, we asses the final stage of the cascade (\ie the \emph{severity} of the emergent failure) using the final number of failed lines, and we determine whether a power island emerged in the process. These results are given in the table.

This allows us to make the important observation that most vulnerable lines do \emph{not} result in a severe cascade of failures. This means that the network will remain operational after the emergent failure, and once the nefarious fluctuation has passed, the failed line can be operational again. For some vulnerable lines, our model does predict a significant amount of cascaded failures. However, when looking at these cases individually, we find that they are all lines that branch out of the network, quickly resulting in a power island. After the power island occurred, the simulated cascades are likely erroneous. We suspect that the emergent failure of these lines will indeed cause a power island to form, but that the remainder of the network will remain operational.

\subsection{Power islands}\label{sec:discussionpowerislands}
The Optimised method computes redistributed flows efficiently, and its derivation (Section \ref{sec:optimisedmethod}) provides us with a more intuitive understanding of flow redistribution. Examining results for individual lines (\eg see Interactive Figure \ref{ifig:master}) shows realistic results. Yet, as the analyses of lines 25 and 298 demonstrate, the method is likely erroneous when the network becomes \emph{disconnected} after the line removal(s), \ie when a power island occurs.

In fact, in its original form \citep{Ronellenfitsch2017}, the optimised method is only defined when the network remains connected.
While this is a limitation of the Optimised method, it is, more generally, a limitation of using DC approximated power flow. In this approximation, we assume the network to be in a \emph{state of equilibrium}: generation matches load exactly.

In our case, the use of a stochastic injection means that we generally do not have a zero-sum injection, contracting the assumption. This contradiction is usually justified using the concept of (distributive) slack: an overall increase or decrease in generation will occur (to compensate for the non-zero net injection), without changing the line flows.

Yet, when studying cascading failures, we are looking at a time frame much shorter than the time it takes to reach equilibrium.
This shorter time scale generally requires an analysis of an entirely different nature: this is the study of \emph{transient stability}, which is far beyond the scope of this thesis.

Overall, a better understanding of the physics that underlie line failures is required to study cascading failures, especially in cases where power islanding occurs.

\subsection{Previous work \citep{Nesti2018emergentfailures}}\label{sec:discussionnesti}
This thesis was inspired by the model and case study of \cite{Nesti2018emergentfailures}. While many of the future research topics proposed by this article remain open, we have been able to independently verify their results. While our model is based on the original, there are some fundamental differences between the two. Therefore, the differences in our results provide valuable insight into the accuracy of either model.

There are two important modifications that we chose to make to the original model. First of all, our model does not use ARMA forecasting, but a much simpler \emph{persistent forecast} as placeholder. For wind generation series, the resulting covariance matrices turn out to be very similar. We cannot comment on the similarity in solar covariances, as we were unable to reproduce these results.

A second difference is the use of a different method for computing the redistributed flow, which is based on \cite{Ronellenfitsch2017}. There is no clear practical benefit to using the Optimised method, except for computational cost. Still, our use of this method has led to the insight that a DC approximated model is not well-suited for disconnected networks, when a large power imbalance exists among connected islands.
%Although these problems can be justified using the notion of \emph{distributive slack} TODO

This Optimised method requires the network to be a \emph{digraph}, which does not allow for parallel lines to exist. For this reason, we have combined parallel lines in our network, taking their physical properties into account. Strangely, this increases the discrepancy between the line flows computed by the LPF, and those given by the OPF algorithm. This effect could be investigated further by studying smaller test networks.

\subsubsection{Evaluation of results}
We performed a careful analysis of the results that follow from the SciGRID application, identifying new problems in the model of \cite{Nesti2018emergentfailures}. For example, we find that for almost all lines, the most likely power injection requires an extension of stochastic capacity at multiple buses. For some lines, this extension is relatively small, and it does not invalidate the result. For other lines, a significant extension is needed. We suspect that the required extensions will be much greater when analysing a point in time when renewable generation is already high. A better understanding of the origin of our dataset is needed to evaluate the significance of this problem.

This problem could be addressed \emph{within the framework of our model} by imposing additional conditions on the most likely injection. In its current form, the problem of finding the most likely injection is an optimisation problem with \emph{linear boundary conditions} (as given in the proof of Theorem~\ref{thm:mostlikelyinjection}). Because the boundary conditions can be written as a \emph{half-plane in $\mathbb{R}^n$}, we were able to derive a closed form solution. We could include the upper and lower limits of stochastic generation as addition linear conditions, which will likely make a closed-form solution unobtainable. Instead, non-linear optimisation methods could be used to find the most likely injection, given these additional conditions.\footnote{In fact, if we use this more general method to find the most likely injection, we could enforce the power injection to have zero sum by imposing one additional linear condition: $\sigma (\mat{p}) = 0$. Although this would solve the problem of having a most likely injection with non-zero sum, there is no physical argument for this imposing this condition.} See \cite{Chertkov2011} for a study using this approach.

\subsection{Future}
There are many aspects of this analysis that could be studied in more detail; some are mentioned throughout this chapter. Regarding our case study, the first shortcoming that could be addressed is the fact that we have only thoroughly looked at data of January 1$^{st}$. Like \cite{Nesti2018emergentfailures}, most of our results are computed for the nominal injection at 11:00. Additionally, we have computed our main result for the remaining 23 hours of the day, which includes hours where the \emph{night} covariance matrix is used (see Figure~\ref{fig:evolution_vulnerabilities}).
While we can directly compute results for the remaining days of January and the remaining months of 2011, we have not yet analysed these results.

While our dataset provides an interesting case study, it does have some limitations. First of all, the dataset does not consist of physical measurements: it is constructed by combining various data sources, most of which are in turn the obtained from modelling. Because of the numerous steps needed to construct our final dataset, it is hard to quantify the inaccuracy of our results.

Crucially, our dataset does not allow us to \emph{verify our results}, since it is \emph{too coarse} to contain fluctuations, and it provides no historical data on line failures. High-resolution stochastic generation datasets do exist, possibly for all nodes of a realistic transmission network. However, to the best of our knowledge, no dataset exist that contains continuous measurements of line currents and overloads.

Many smaller datasets exists that can be analysed using our methods. Most notably, the \emph{IEEE test networks} can be extended with fictional stochastic generation, as demonstrated by \cite{Nesti2018emergentfailures} and \cite{Chertkov2011}. These smaller networks would allow us to more easily inspect the behaviour of individual lines in the network. Another way to construct a smaller network could be to take a \emph{subsection} of the SciGRID network.

%\towrite{
%
%Verschillen:
%- economie
%
%
%Kritiek op nesti:
%
%- ze nemen een contingency factor van 0.7 bij de OPF (arbitrair) maar voor de analyse van cascades niet. (toch?)
%
%- non-zero injection problem
%
%
%Of course, this has the same shortcoming as the model used by \cite{Nesti2018emergentfailures} (it ), but it
%
%Although these ARMA models are fairly involved, they do not actually provide an accurate forecast.TODOfootnote{\cite{Nesti2018emergentfailures} also express this fact in their article, and note that it is only the forecast \emph{error} that is relevant in our analysis.} Using ARMA models seems unnecessarily complicated
%}
%
%

\clearpage
\end{document}


\documentclass[main.tex]{subfiles}
\begin{document}

\chapter{Accretion}

\section{Bondi accretion}

\marginpar{Tuesday\\ 2020-10-27, \\ compiled \\ \today}

We now start discussing the interaction of a compact object with its environment.
Black holes are intrinsically black, however we can see them through their interactions with the surrounding medium.

A neutron star might have a temperature of the order \(T \sim \num{e6} \divisionsymbol\SI{e7}{K}\); we know that the flux is given by \(F = \sigma T^{4}\), so the emitted luminosity is calculated by
%
\begin{align}
L = 4 \pi R^2 \sigma T^{4} \sim \SI{e31}{erg /s}
\,,
\end{align}
%
which comes out to be \emph{very small}, due to the fact that the radius is very small compared to a star.
For comparison, the Sun has a luminosity of around 100 times more.

A compact object's gravitational pull, however, induces \emph{accretion}: material falls onto the object, heating up.
We will consider spherical accretion, the simplest geometrical situation.
It is not fully realistic, however it can be used to model the real case.
We assume to have a point-like object of mass \(M\), and we make some other assumptions:
\begin{enumerate}
    \item spherical symmetry;
    \item stationarity;
    \item the accreting matter can be treated as a gas: this is not obvious, since it means that collisions are efficient enough to couple the temperatures of the gas, or equivalently the mean free path \(\lambda _c\) should be much smaller than the radius \(r\);\footnote{This is not easily verified in astrophysical scenarios, magnetic fields make it easier for it to happen.}
    \item the accreting matter is a perfect gas which can be treated adiabatically;
    \item the accreting matter is non-self-gravitating: the total mass of gas surrounding the BH, \(m\), is much smaller than \(M\);
    \item we will use Newtonian gravity, although the general-relativistic way to treat this is not very hard.\footnote{For the GR and non-ideal fluid version see my Bachelor's thesis \cite[]{tissinoRelativisticNonidealFlows2019}.}
\end{enumerate}

Under these hypotheses, the problem is called \textbf{Bondi-Hoyle accretion}, and old problem in astrophysics, dating back to the fifties \cite[]{bondiSphericallySymmetricalAccretion1952}.
The final treatment of accretion onto a BH was done in 1991 \cite[]{nobiliSphericalAccretionBlack1991}.

This is very much a toy model: adiabaticity precludes the production of radiation. However, we shall see how the conditions might be relaxed.

The first equation is the continuity equation, whose physical meaning is rest mass conservation.
The velocity field is denoted as \(u(r)\).
The quantity \(4\pi r_2^2 \rho (r_2) u(r_2 )\) is the rate of mass crossing the surface of radius \(r_2 \).
If there are no sources nor sinks of mass, this expression should be equal for another choice of radius \(r_1 \).
Then, in general we can write
%
\begin{align}
4 \pi r^2 \rho (r) u(r ) = \dot{M} = \const
\,.
\end{align}

The Euler equation, coming from the conservation of momentum, reads
%
\begin{align}
\dv{u}{t} = \text{force per unit mass} = - \frac{1}{\rho } \dv{P}{r} - \frac{GM}{r^2}
\,.
\end{align}

The total time derivative of the velocity can be written as
%
\begin{align}
\dv{u}{t} = \underbrace{\pdv{u}{t}}_{= 0} + \pdv{u}{r} \dv{r}{t}
= \pdv{u}{r} u
\,
\end{align}
%
by stationarity. Then the Euler equation reads
%
\begin{align}
u \pdv{u}{r} + \frac{1}{\rho } \dv{P}{r} + \frac{GM}{r^2} = 0
\,,
\end{align}
%
which we can integrate: it becomes
%
\begin{align}
\frac{1}{2} u^2 + \int \frac{\dd{P}}{\rho } - \frac{GM}{r} = \const
\,,
\end{align}
%
which is Bernoulli's theorem, the conservation of energy. It is slightly different from the usual form because we are considering a compressible flow; this is a gas, and it definitely can be compressed.
This is our second conservation law.
We need a third equation: an equation of state, which we can derive from our assumption of adiabaticity, \(P = K \rho^{\Gamma }\), a polytropic EoS.

Luckily, we have managed to integrate already, so we do not have ODEs anymore: we are left with a simple algebraic system.
If we introduce the isentropic speed of sound,\footnote{There are other kinds of speed of sound, depending on the kind of perturbation.} \(a^2 = (\pdv*{P}{\rho })_s = k \Gamma \rho^{\Gamma -1}\) (calculated at constant entropy, but since we assumed adiabaticity this is not an additional assumption).

Also, the pressure differential reads \(\dd{P} = k \Gamma \rho^{-1} \dd{\rho }\), so
%
\begin{align}
\frac{1}{2} u^2 + \int \frac{k \Gamma \rho^{\Gamma -1}}{\rho } \dd{\rho } - \frac{GM}{r} &= \const  \\
\frac{1}{2} u^2 + \frac{a^2}{\Gamma -1} - \frac{GM}{r} &= \const
\,.
\end{align}

This can be solved together with the continuity equation. What is this constant? We can calculate it for an arbitrary \(r\), since it is always the same. We choose \(r \to \infty \), so we get
%
\begin{align}
\frac{1}{2} u^2 + \frac{a^2}{\Gamma -1} - \frac{GM}{r}
&= \frac{1}{2} u^2_{\infty } + \frac{a^2_{\infty }}{\Gamma -1}
\,,
\end{align}
%
where \(u_\infty \) and \(a_\infty \) are the velocity and speed of sound very far from the source. What can we say about them?
A special case we can consider is \(u_\infty  = 0\): the gas at infinity is at rest, it has no bulk motion with respect to the black hole.
We now need to replace \(\rho \) in the continuity equation with something in terms of the sound speed: we know that \(a^2 = k \Gamma \rho^{\Gamma -1}\), so
%
\begin{align}
\rho = \qty(\frac{a^2}{k \Gamma })^{1 / (\Gamma -1)}
\,.
\end{align}

We can calculate this at infinity: \(\rho _\infty \) is then given in terms of \(a_\infty \).
Taking the ratio of the two expressions, we get
%
\begin{align}
\frac{\rho }{\rho _\infty } = \qty(\frac{a}{a_\infty })^{2 / (\Gamma -1)}
\,.
\end{align}

Inserting this into the continuity equation we get
%
\begin{align}
4 \pi r^2 \rho _\infty \qty(\frac{a}{a_\infty })^{ 2 / (\Gamma -1)} u = \dot{M}
\,.
\end{align}

There are several constants appearing, but only the two variables \(u(r)\) and \(a(r)\).
What can we say about the constants? \(\dot{M}\) is called the \emph{mass accretion rate}. The other two constants are \(a_\infty \) and \(\rho _\infty\).
One might think that we would need to specify all three of the constants: this is, however, not the case. Only two of these constants are actually independent. Fixing \(a_\infty \) and \(\rho _\infty \) constrains \(\dot{M}\) to a single value, an \emph{eigenvalue} of the problem.

Let us select a fixed value of \(r = \overline{r}\). Then, the two equations are just functions of \(u\) and \(a\). The Euler equation looks like
%
\begin{align}
\frac{1}{2} u^2 + \frac{a^2}{\Gamma -1} = \const
\,,
\end{align}
%
an ellipse (of which we consider only a quarter, with \(u>0\), \(a>0\)).
The continuity equation, instead, is in the form
%
\begin{align}
u \propto  \dot{M} a^{- \frac{2}{\Gamma -1}}
\,.
\end{align}

This is a part of a hyperbola. The two may cross in zero, one or two points. In order for a solution to exist there needs to be at least one intersection.
Changing \(\dot{M}\) moves the hyperbola. We get a single \(\dot{M}\) so that the two curves cross at a single point.
For now, we can surely say that \(\dot{M}\) cannot be chosen to have any value, since we must have at least an intersection.

We can apply a similar kind of reasoning by changing \(\overline{r}\) instead of \(\dot{M}\).
We can connect these solutions: curves in the \((u, a)\) plane, parametrized by \(\overline{r}\).
The intersections always lie on opposite sides of the \(u = a\) line, which corresponds to the sonic condition.
One solution is always supersonic, one is always subsonic.

The solution which is always supersonic has \(u_\infty > a > 0\), which is not good for us.
The subsonic solution might then work: however, if the central mass is a BH, then the speed at which the matter crosses the horizon is the speed of light, and surely \(c > a\).\footnote{The largest physically possible speed of sound is \(c / \sqrt{3}\), achieved for ultrarelativistic matter.}

This argument shows that we need a transsonic solution: we need a radius \(r_s\) at which the two curves are tangent to one another.
If we fix this, we get two solutions, only one of which has \(u_\infty = 0\).
The opposite solution could describe a transsonic stellar wind.
The consequence of this is that there is a single acceptable value for \(\dot{M}\), providing us with a radius so that the two curves are tangent.

This yields a fixed \(\dot{M} (\rho _\infty , a_\infty )\).
We can get more information by going back to the differential form of the equations of motion:
%
\begin{align}
4 \pi r^2 \rho u &= \dot{M}  \\
u \pdv{u}{r} + \frac{1}{\rho } \dv{P}{r} + \frac{GM}{r^2} &= 0
\,.
\end{align}

We can write the Euler equation as
%
\begin{align}
u \pdv{u}{r} &= - \frac{1}{\rho } \dv{P}{\rho } \dv{\rho }{r} - \frac{GM}{r^2}   \\
u \pdv{u}{r} &= - \frac{a^2}{\rho } \dv{\rho }{r } - \frac{GM}{r^2}
\,.
\end{align}

We can also find a differential form of the continuity equation:
%
\begin{align}
r^2 \rho u = \frac{\dot{M}}{4 \pi  } \implies
\dv{u}{r} = - \frac{2u}{r} - \frac{u}{\rho } \dv{\rho }{r}
\,,
\end{align}
%
which we can substitute into the Euler equation:
%
\begin{align}
-2 \frac{u^2}{r} - \frac{u^2}{\rho } \dv{\rho }{r}
&= - \frac{a^2}{\rho } \dv{\rho }{r} - \frac{GM}{r^2}  \\
(a^2 - u^2) \frac{1}{\rho } \dv{\rho }{r} &= \frac{2u^2}{r} - \frac{GM}{r^2}  \\
\dv{\log \rho }{r} &= \frac{1}{a^2 - u^2} \qty[\frac{2u^2}{r} - \frac{GM}{r^2}]
\,,
\end{align}
%
but we want there to exist a point at which \(a = u\): therefore, the denominator vanishes, meaning that if we do not want the derivative of the log-density to diverge we must have
%
\begin{align}
2 u^2 (r_s) = \frac{GM}{r_s}
\,,
\end{align}
%
and \(u (r_s) = a( r_s)\).

This ensures that there is no divergence at the transsonic point.
This is a \emph{regularity condition}, imposed at a \emph{critical point}.

\end{document}


% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode

% This is a simple template for a LaTeX document using the "article" class.
% See "book", "report", "letter" for other types of document.

\documentclass[11pt]{article} % use larger type; default would be 10pt

\usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX)

%%% Examples of Article customizations
% These packages are optional, depending whether you want the features they provide.
% See the LaTeX Companion or other references for full information.

%%% PAGE DIMENSIONS
\usepackage{geometry} % to change the page dimensions
\geometry{a4paper} % or letterpaper (US) or a5paper or....
% \geometry{margin=2in} % for example, change the margins to 2 inches all round
% \geometry{landscape} % set up the page for landscape
%   read geometry.pdf for detailed page layout information

\usepackage{graphicx} % support the \includegraphics command and options

% \usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent

%%% PACKAGES
\usepackage{booktabs} % for much better looking tables
\usepackage{array} % for better arrays (eg matrices) in maths
\usepackage{paralist} % very flexible & customisable lists (eg. enumerate/itemize, etc.)
\usepackage{verbatim} % adds environment for commenting out blocks of text & for better verbatim
\usepackage{subfig} % make it possible to include more than one captioned figure/table in a single float
% These packages are all incorporated in the memoir class to one degree or another...
\usepackage{amsmath}
\usepackage{amssymb}
%%% HEADERS & FOOTERS
\usepackage{fancyhdr} % This should be set AFTER setting up the page geometry
\pagestyle{fancy} % options: empty , plain , fancy
\renewcommand{\headrulewidth}{0pt} % customise the layout...
\lhead{}\chead{}\rhead{}
\lfoot{}\cfoot{\thepage}\rfoot{}

%%% SECTION TITLE APPEARANCE
\usepackage{sectsty}
\allsectionsfont{\sffamily\mdseries\upshape} % (See the fntguide.pdf for font help)
% (This matches ConTeXt defaults)

%%% ToC (table of contents) APPEARANCE
\usepackage[nottoc,notlof,notlot]{tocbibind} % Put the bibliography in the ToC
\usepackage[titles,subfigure]{tocloft} % Alter the style of the Table of Contents
\renewcommand{\cftsecfont}{\rmfamily\mdseries\upshape}
\renewcommand{\cftsecpagefont}{\rmfamily\mdseries\upshape} % No bold!

%%% END Article customizations

%%% The "real" document content comes below...

\title{Homework based on Chapter 5\\
Computational Probability and Statistics \\
CIS 2033, Section 002}
\author{}
\date{} % Activate to display a given date or no date (if empty),
         % otherwise the current date is printed

\begin{document}
\maketitle

\section{Part 1 (Due: 9:00 AM, Friday, Feb. 13, 2015)}

\paragraph*{\bf Question 1} Let $X$ be a continuous random variable with probability density function\\
\begin{align*}
f(x) = \left\lbrace
\begin{array}{ll}
\frac{7}{8} & \text{for } -\frac{1}{2} \leq x \leq \frac{1}{2} \\
& \\
\frac{1}{16} & \text{for } 3 \leq x \leq 5 \\
& \\
0 & \text{elsewhere.}
\end{array}
\right.
\end{align*}

\subparagraph*{a.} Draw the graph of $f$.
\subparagraph*{b.} Determine the distribution function of $F$ of $X$, and draw its graph.

\paragraph*{\bf Question 2} The probability density function $f$ of a continuous random variable $X$ is given by:
\begin{align*}
f(x) = \left\lbrace
\begin{array}{ll}
C(4x - 2x^2)  & \text{for } 0 \leq x \leq 2 \\
0 & \text{elsewhere.}
\end{array} \right.
\end{align*}

\subparagraph*{a.} Compute $c$.
\subparagraph*{b.} Compute the distribution function $F$ of $X$.
\subparagraph*{c.} Compute $F(1)$ and $P(X>1)$
\vspace{8em}
\section{Part 2 (Due: 11:59 PM, Tuesday, Feb. 17, 2015)}
\paragraph*{\bf Question 3}Suppose we choose arbitrarily a point from the square with corners at $(2, 1), (3, 1), (2, 2), (3, 2)$. The random variable $A$ is the area of the triangle with its corners at $(2, 1), (3, 1)$ and the chosen point.

\subparagraph*{a.} What is the largest area $A$ that can occur, and what is the set of points for which $A \leq \frac{1}{4}$ ?
\subparagraph*{b.} Determine the distribution function $F$ of $A$.
\subparagraph*{c.} Determine the probability density function $f$ of $A$.
\paragraph*{\bf Question 4}
Compute the median of an $Exp(3)$ distribution.
\paragraph*{\bf Question 5}
 Compute the median of a $Par(1)$ distribution.
\newpage

\section*{\bf Appendix}
\paragraph*{5.1} Let $X$ be a continuous random variable with probability density function\\
\begin{align*}
f(x) = \left\lbrace
\begin{array}{ll}
\frac{3}{4} & \text{for } 0 \leq x \leq 1 \\
& \\
\frac{1}{4} & \text{for } 2 \leq x \leq 3 \\
& \\
0 & \text{elsewhere.}
\end{array}
\right.
\end{align*}

\subparagraph*{a.} Draw the graph of $f$.
The Probability density function is in Figure~\ref{Fig:ch0501a}.
\begin{figure}[h!]
\centering
\includegraphics[width=3in, height=1.5in]{ch0501a}
\caption{Probability density function $f$.}
\label{Fig:ch0501a}
\end{figure}

\subparagraph*{b.} Determine the distribution function of $F$ of $X$, and draw its graph.
We first show how to compute the distribution function,
\begin{enumerate}
\item If $a < 0$, then
\begin{align*}
F(a) = & \int_{-\infty}^a 0 dx  \\
& =  0
\end{align*}
\item If $0 \leq a < 1$, then
\begin{align*}
F(a) = & \int_{-\infty}^0 0 dx + \int_{0}^a \frac{3}{4} dx \\
& = 0 + \left[\frac{3x}{4}\right]_{0}^a \\
& = \frac{3a}{4}
\end{align*}
\item If $1 \leq a < 2$, then
\begin{align*}
F(a) = & \int_{-\infty}^0 0 dx + \int_{0}^1 \frac{3}{4} dx + \int_{1}^a 0 dx \\
& = 0 + \left[\frac{3x}{4}\right]_{0}^1 + 0  \\
& = \frac{3}{4}
\end{align*}
\item If $2 \leq a < 3$, then
\begin{align*}
F(a) = & \int_{-\infty}^0 0 dx + \int_{0}^1 \frac{3}{4} dx + \int_{1}^2 0 dx + \int_{2}^a \frac{1}{4} dx \\
& = 0 + \left[\frac{3x}{4}\right]_{0}^1 + 0 + \left[ \frac{x}{4} \right]_{2}^a \\
& = 0 + \frac{3}{4} + 0 + (\frac{a}{4} - \frac{2}{4}) \\
& = \frac{a+1}{4}
\end{align*}
\item If $3 \leq a$, then
\begin{align*}
F(a) = & \int_{-\infty}^0 0 dx + \int_{0}^1 \frac{3}{4} dx + \int_{1}^2 0 dx + \int_{2}^a \frac{1}{4} dx + \int_{3}^a 0 dx \\
& = 0 + \left[\frac{3x}{4}\right]_{0}^1 + 0 + \left[ \frac{x}{4}\right]_{2}^3 + 0 \\
& = 0 + \frac{3}{4} + 0 + (\frac{3}{4} - \frac{2}{4}) + 0 \\
& = 1
\end{align*}
\end{enumerate}

We then plot the distribution function $F(X)$ in Figure~\ref{Fig:ch0501b}.
\begin{figure}[h!]
\centering
\includegraphics[width=3in, height=1.5in]{ch0501b}
\caption{Distribution function $F(X)$.}
\label{Fig:ch0501b}
\end{figure}

\paragraph*{5.5} The probability density function $f$ of a continuous random variable $X$ is given by:
\begin{align*}
f(x) = \left\lbrace
\begin{array}{ll}
cx + 3  & \text{for } -3 \leq x \leq -2 \\
 & \\
3- cx  & \text{for }  2 \leq x \leq 3 \\
 & \\
0 & \text{elsewhere.}
\end{array} \right.
\end{align*}

\subparagraph*{a.} Compute $c$. \\
There are two properties for a given probability density function $f$:
\begin{align*}
& f(x) \geq 0,  \text{ for } -\infty \leq x  \leq \infty \\
& \int_{-\infty}^{\infty} f(x) dx = 1
\end{align*}
\begin{align*}
\int_{-\infty}^{\infty} f(x) \text{d}x & = \int_{-\infty}^{-3} 0 \text{d}x + \int_{-3}^{-2} (cx + 3) \text{d}x + \int_{2}^3 (3-cx) \text{d}x + \int_{3}^{\infty} 0 \text{d} x \\
& = 0 +  \left[ \frac{cx^2}{2}+3x\right]_{-3}^{-2} + 0 + \left[ 3x - \frac{cx^2}{2}\right]_{2}^3 + 0 \\
& = 0 + \left(\left( \frac{c(-2)^2}{2} + 3(-2) \right) -\left( \frac{c(-3)^2}{2} + 3(-3) \right) \right) + 0 + \left( \left(3(3)-\frac{c3^2}{2} \right) - \left(3(2) - \frac{c2^2}{2} \right) \right) \\
& = 0 + \frac{4c}{2} - 6 - \frac{9c}{2} + 9 + 0 + 9 - \frac{9c}{2} - 6 + \frac{4c}{2} \\
& = 6 -5c = 1 \\
& \Longrightarrow  \\
c & = 1
\end{align*}

\subparagraph*{b.} Compute the distribution function of $X$.
Given $c=1$, the probability density function is
\begin{align*}
f(x) = \left\lbrace
\begin{array}{ll}
x + 3  & \text{for } -3 \leq x \leq -2 \\
 & \\
3- x  & \text{for }  2 \leq x \leq 3 \\
 & \\
0 & \text{elsewhere.}
\end{array} \right.
\end{align*}

\begin{enumerate}
\item If $a < -3$, then
\begin{align*}
F(a)   & = \int_{-\infty}^a 0 \text{d} x  \\
& = 0
\end{align*}
\item If $-3 \leq a < -2$, then
\begin{align*}
F(a) & = \int_{-\infty}^{-3} 0 \text{d} x + \int_{-3}^a (x+3) \text{d} x \\
& = 0 + \left[ \frac{x^2}{2} + 3x\right]_{-3}^{a} \\
& = 0 + \left( \frac{(a)^2}{2} + 3(a)\right) - \left( \frac{(-3)^2}{2} + 3(-3) \right) \\
& = 0 + (\frac{a^2}{2}+3a) - (\frac{9}{2} - 9) \\
& = \frac{a^2+6a+9}{2} \\
& = \frac{(a+3)^2}{2}
\end{align*}
\item If $-2 \leq a < 2$, then
\begin{align*}
F(a) & = \int_{-\infty}^{-3} 0 \text{d} x + \int_{-3}^{-2} (x+3) \text{d} x + \int_{-2}^{a} 0 \text{d} x\\
& = 0 + \left[ \frac{x^2}{2} + 3x\right]_{-3}^{-2} + 0 \\
& = 0 + \left( \frac{(-2)^2}{2} + 3(-2)\right) - \left( \frac{(-3)^2}{2} + 3(-3) \right)  + 0\\
& = 0 + (2-6) - (\frac{9}{2} - 9)  + 0\\
& = \frac{1}{2}
\end{align*}
\item If $2 \leq a < 3$, then
\begin{align*}
F(a) & = \int_{-\infty}^{-3} 0 \text{d} x + \int_{-3}^{-2} (x+3) \text{d} x + \int_{-2}^{2} 0 \text{d} x + \int_{2}^a (3-x) \text{d} x\\
& = 0 + \left[ \frac{x^2}{2} + 3x\right]_{-3}^{-2} + 0 + \left[3x - \frac{x^2}{2} \right]_{2}^a \\
& = 0 + \left( \frac{(-2)^2}{2} + 3(-2)\right) - \left( \frac{(-3)^2}{2} + 3(-3) \right) + 0 + \left( \left(3a-\frac{a^2}{2} \right) - \left( 3(2) - \frac{2^2}{2}\right) \right) \\
& = 0 + (2-6) - (\frac{9}{2} - 9) + 0 + \left( 3a - \frac{a^2}{2} -4 \right) \\
& = 0 + \frac{1}{2} + 0 + \frac{6a - a^2 -8}{2} \\
& = \frac{6a - a^2 -7}{2}
\end{align*}
\item If $3 < a$, then
\begin{align*}
F(a) & = \int_{-\infty}^{-3} 0 \text{d} x + \int_{-3}^{-2} (x+3) \text{d} x + \int_{-2}^{2} 0 \text{d} x + \int_{2}^3 (3-x) \text{d} x + \int_{3}^a 0 \text{d} x \\
& = 0 + \left[ \frac{x^2}{2} + 3x\right]_{-3}^{-2} + 0 + \left[3x - \frac{x^2}{2} \right]_{2}^3 + 0 \\
& = 0 + \left( \frac{(-2)^2}{2} + 3(-2)\right) - \left( \frac{(-3)^2}{2} + 3(-3) \right) + 0 + \left( \left(3(3)-\frac{3^2}{2} \right) - \left( 3(2) - \frac{2^2}{2}\right) \right) + 0 \\
& = 0 + (2-6) - (\frac{9}{2} - 9) + 0 + \left( 3(3) - \frac{3^2}{2} -4 \right)  + 0\\
& = 0 + \frac{1}{2} + 0 + \frac{6\times 3 - 3^2 -8}{2} \\
& = 1
\end{align*}
\end{enumerate}
We then plot the distribution function $F(X)$ in Figure~\ref{Fig:ch0505b},
\begin{figure}[h!]
\centering
\includegraphics[width=3in, height=1.5in]{ch0505b}
\caption{Distribution function $F(X)$.}
\label{Fig:ch0505b}
\end{figure}
\end{document}


\title{\bf Active Galactic Nuclei \& Quasars}

\section{Basics}

Every massive galaxy contains supermassive black hole ($M> 10^5$
$M_\odot$) at its center (\citealt{kormendy13a}). In cases that gas is
accreting onto the black hole, these can emit copious luminosity and
are referred to as {\it active galactic nuclei}. Their total
luminosities can be from $10^{40}$ to $10^{47}$ erg s$^{-1}$, in the
brighter cases outshining the rest of the galaxy.

The prevailing understanding of the structure of the emitting region
is known as the {\it unification model} (\citealt{antonucci93a,
netzer15a}). An accretion disk a few hundred Schwarschild radii in
size emits a thermal {\it continuum} in the UV and optical, as well as
in the X-rays. The accretion can power an outflowing {\it jet} visible
in synchroton in the radio. Surrounding the accretion disk is a {\it
broad line region} a few pc in size, consisting of dense clouds
($n>10^4$ cm$^{-3}$); the Doppler broadening of these clouds orbiting
the center of the galaxy is 1000s of km s$^{-1}$. Outside that region
is a {\it narrow line region} a few hundred pc in size, also
consisting of clouds but of lower density, and with a Doppler
broadening of 100s of km s$^{-1}$. In between is a dusty region,
possibly toroidal in shape, but in any case causing some the broad
line region to be heavily extincted along at least some lines of
sight. This picture was developed to explain the various observational
classes of active galactic nuclei, as explained below.

There is an array of nomenclature associated with quasars. Below
luminosities of around $10^{44}$ erg s$^{-1}$ they are known as {\it
Seyfert galaxies}. If broad line emission is visible, they are known
as {\it Type 1}, and if it is not they are known as {\it Type 2};
there are also intermediate types occasionally defined. Depending on
their radio flux, Seyferts and quasars can be {\it radio-loud} or not.

\subsection{Black hole accretion}

Active galactic nuclei are powered by accretion. Matter accreting
loses energy (and necessarily angular momentum) through some form of
viscosity. This orbital energy loss heats the gas and the energy can
be emitted radiatively. This process can proceed until the material
reaches the innermost stable circular orbit, at $3r_S$, at which point
the material does not need to lose energy to fall directly into the
black hole. We quantify the efficiency of this process as a fraction
$\epsilon$ of the rest mass energy ($mc^2$). The luminosity of the
active galactic nucleus is then $\epsilon \dot M$, if $\dot M$ is the
mass accretion rate. As shown in the exercises, the maximum efficiency
of this process for a non-spinning black hole is about $\epsilon \sim
0.06$; it may be up to about 0.29 for a spinning black hole.

Regardless of the mass accretion rate, the luminosity is limited by
the fact that if the luminosity is too high, outward radiation
pressure on the surrounding material will prevent inward flow due to
gravitational accelerations. The exercises derive this {\it Eddington
  limit}:
\begin{equation}
L_{\rm Edd} = \frac{4\pi G c m_p}{\sigma_T} \approx 1.26 \times
10^{38} \left(\frac{M_{\rm BH}}{M_\odot}\right) \mathrm{~erg~s}^{-1}
\end{equation}
This limit implies that to reach $L\sim 10^{44}$ erg s$^{-1}$ requires
a black hole with a mass at least $10^6$ $m_\odot$. Although this
limit only strictly applies in spherical symmetry, estimates of black
hole masses often imply luminosities of $0.01$--$0.1 L_{\rm
Edd}$. Sometimes the Eddington limit is expressed as a mass accretion
limit assuming some $\epsilon$, but of course for a lower $\epsilon$
the mass accretion rate can be higher.

If accreting gas has angular momentum, it will naturally form a disk
of gas. The gas will experience viscosity. If the disk is Keplerian,
this viscosity will naturally transport angular moment outward. The
loss of angular momentum and the conversion of energy to heat allows
the accretion. The disk may be optically thick and geometrically thin
(\citealt{shakura73a}). It can be shown in this case that the
temperature profile will be:
\begin{equation}
  T(r) = \left(\frac{3 c^6}{64\pi G^2 \sigma_{SB}}\right)^{1/4}
    \left(\frac{r}{r_S}\right)^{-3/4} {\dot m}^{1/4} M^{-1/2}
\end{equation}
The global resulting spectrum is the sum of the blackbody spectrum
from all the radii. Generally, the spectrum will be hotter for lower
mass black holes, or for more rapidly accreting black holes. AGN in
this mode typically have $L>0.01 L_{\rm Edd}$.

X-rays arise from the accretion disk. In AGN, the thermal continuum
only provides substantial X-rays in the soft regime ($<2$ keV). The
higher energy X-rays are thought to arise from a coronal layer
surrounding a thin accretion disk, similar to the solar corona. This
hot corona can in principle be as hot as the virial
temperature. Through inverse Compton scattering, it converts the disk
continuum radiation into hard X-rays, extending in a power law
spectrum $f_\nu \propto \nu^{-2}$ up to 100 keV.

However, a thin disk is not the only conceivable outcome for the
accretion. An alternative possibility is that the disk (or some part
of it) does not efficiently radiate the energy dissipated, in which
case the disk can thicken. The resulting {\it advection dominated
accretion flow} or {\it radiatively inefficient accretion flow}
transports the thermal energy produced directly into the black hole
through accretion, and thus is less efficient at turning gravitational
energy into radiation (\citealt{narayan05a}). Theoretical models favor
the creation of jets in this scenario, collimated by the inner edge of
the thick disk formed.

\subsection{Jet}

In many systems, the accretion drives a jet of ionized gas outwards,
in some cases hundreds of kpc in length.  The jets often end in lobed
structures.  This jet is visible in the radio through synchrotron
radiation with a power law spectrum. The radiating electrons are
highly relativistic. The synchrotron radiation can be visible at
higher frequencies, up through the optical.  X-ray emission can be
visible as well, which comes from thermal emission in the inner hot
disk, but also from comptonization of the radio synchrotron light by
the hot, diffuse coronal gas of the disk. The radio spectra have a
variety of shapes which depend on the electron energy distribution and
self-absorption.

The jets are typically moving at a high fraction of the speed of
light, based on observed motions of features in the jets when resolved
in the radio and optical. This causes the radiation to be beamed
strongly along the jet axis; the $(1+z)^4$ effect of this blue or
redshifting on the surface brightness causes the jet toward us to be
detectable more often than the jet away from us.

The beaming can cause the inferred luminosity of the source to be
extremely high if it is observed along the beam. This phenomenon is
known as a {\it blazar}. The beamed synchrotron emission can overwhelm
the ultraviolet-optical line and continuum emission, resulting in a
pure power law continuum in the optical. This phenomenon is referred
to as a {\it BL Lac} after the archetypal case. These sources are
typically highly variable. If some line emission remains, the galaxy
is known as an {\it optically violent variable (OVV)} star.

\subsection{Broad line region}

Many quasars and AGN exhibit broad emission lines with Doppler widths
of order $10^4$ km s$^{-1}$. These velocities imply a distance of a
few hundred Schwarzschild radii from the central black hole, which
translates into about 0.01 pc for a $10^8$ $M_\odot$ black
hole. Forbidden lines are not seen in these regions, which implies a
high electron density, and from the presence of semiforbidden lines we
infer $n_e \sim 10^{10}$ cm$^{-3}$. The ionization stages present
imply temperatures of $2\times 10^4$ K. With the density, temperature,
and volume implied by these numbers, total emission from the gas then
can be used to infer the filling factor, which is at the very most
$f\sim 0.1$. From the total actual luminosity compared to the ionizing
continuum flux, it can be inferred that the solid angle covered by the
clouds is about 10\%. These considerations lead to the picture of the
broad line region as a large number of dense clouds surrounding the
central black hole and its accretion disk.

\subsection{Narrow line region}

Essentially all quasars and AGN exhibit narrow optical emission lines,
with widths of hundreds of km s$^{-1}$ (typically broader than
observed for non-AGN emission lines) indicating a region of a few
hundred pc. The narrow line region can be resolved in many cases, and
often has a biconical shape. The emitting lines include forbidden
lines, with line ratios indicating densities of $n\sim 10^4$ cm$^{-3}$
and temperatures of around 15,000 K. Like the broad line region, the
filling factor can be shown to be low ($\sim 0.01$) by comparing the
density, temperature, and volume to the total emission.

Narrow forbidden lines are also excited in gas ionized by
star-formation, hot evolved stars, and (more rarely) shocks. Emission
line ratios can be used to distinguish the nature of the ionization
source. The classic set of ratios are those published by Baldwin,
Phillips, \& Terlevich (BPT), the most commonly used of which is
considering [NII]/H$\alpha$ versus [OIII]/H$\beta$. The choices of
emission line ratios are partly motivated by the desire to combine
lines near the same wavelength, whose spectrophotometric and internal
reddening correction errors will partly or mostly cancel. Seyfert
galaxies have relatively high [NII]/H$\alpha$ and very high
[OIII]/H$\beta$. As shown in the exercises, the [OIII]/H$\beta$ ratio
is a good indicator of the ionization parameter.

A separate class of galaxies in the BPT diagram are low ionization
galaxies, sometimes called LINERs, which have high [NII]/H$\alpha$ but
lower [OIII]/H$\beta$. Although some of these galaxies have active
galactic nuclei, their emission is considerably more extended than
that of the Seyferts and appears inconsistent with being ionized by a
central source.

\subsection{Dusty torus}

Many galaxies exhibit narrow line AGN emission but no broad line or
continuum emission in the optical and ultraviolet. However, the narrow
line region must be ionized by some continuum. Furthermore, some
galaxies have strong nuclear infrared emission. We believe that in
these cases, the broad line and continuum regions are obscured by dust
along our line of sight, which is in some anisotropic distribution
such that along other lines of sight they would be visible. Usually
this is described as a torus, but that specific geometry isn't
necessary. To explain the observations, the dusty region should be
larger that the broad line region, but smaller than the narrow line
region. The most direct evidence for this hypothesis is the
observation of broad lines in the polarization spectrum of narrow line
AGN (see \citealt{antonucci93a}). The broad line region light is being
scattered and polarized by gas in the narrow line region. These
observations demonstrate that the dusty region does not obscure in all
directions.

\subsection{Variability}

Quasars and active galactic nuclei are variable on time scales of a
few weeks and above. Typically, the variability is anticorrelated with
luminosity, with larger amplitude variability for less luminous
objects. The variability in the continuum, which is likely due to
accretion disk activity, typically occurs on shorter time scales for
higher wavelengths, likely reflecting the dynamical time scale of the
location of the emission.  The line emission variability can be shown
to lag the continuum, and the delay can be used to determine the
radius of emission of the lines, and combined with their Doppler
shifts, an estimate of the black hole mass; this technique is known as
{\it reverberation mapping}. Occasionally even on a
year-to-decade time scale active galactic nuclei and quasars have been
known to turn off rapidly; the continuum and broad line emission
disappears, but the narrow line emission (which extends for hundreds
of lightyears) remains. This phenomenon is known as {\it changing
look}.

From the demographics and clustering of optically-bright quasars it is
known that they are not in that state all of the time. From these
considerations, {\it duty cycle} of quasars is estimated to be
relatively short (order 10\%). Thus over long time scales (likely tens
of millions of years) all quasars must turn on and off.

\subsection{Luminosity function and evolution}

The overall luminosity function can be converted into a black hole
growth rate. The dependence of this growth rate on redshift is
strong; the peak of black hole growth inferred is at $z\sim 2$--3
(\citealt{shankar09a}), with a steep decline after $z\sim 1$ and
before $z\sim 3$. This growth rate evolution approximately follows the
similar pattern of star formation rate density over cosmic time.

% \section{Commentary}

\section{Important numbers}

\begin{itemize}
\item $L_{\rm Edd} = 1.5 \times 10^{38} M_{\rm BH} / M_\odot {\rm
~erg~s}^{-1}$
\end{itemize}

\section{Key References}

\begin{itemize}
  \item
    \href{https://ui.adsabs.harvard.edu/abs/2015ARA%26A..53..365N/abstract}
    {{\it Revisiting the Unified Model of Active Galactic Nuclei
      (\citealt{netzer15a})}}
  \item {\it Active Galactic Nuclei}
\end{itemize}

\section{Order-of-magnitude Exercises}

\begin{enumerate}
\item Estimate the maximum efficiency of converting mass energy
    into emission for a non-rotating black hole of mass $M$.

\begin{answer}
In order to fall deeper into a potential well, matter has to lose
orbital energy and that energy is available for emission. In the case
of a black hole, once it reaches the innermost stable circular orbit
at $3r_s$, it can simply fall in without any further energy loss.

Using a Newtonian approximation, the orbital energy is $E = K + U =
-U/2$. From infinity to $3r_s$ implies an energy loss per unit mass of
$GM/6r_sc^2 = 1 / 12$, implying a maximum conversion efficiency of
$\sim 0.08$. In a general relativistic calculation, the real energy
available is slightly smaller than this ($\sim 0.06$).

For a spinning black hole, the efficiency can be considerably higher.
\end{answer}

\item Estimate efficiency of accretion
\item Estimate hottest gas in continuum
\item What is virial tempereature near disk
\item Doppler velocities to sizes
\item Critical density of CIII] and OIII
\item Estimate filling factor of BLR, NLR
\item Estimate duty cycle
\end{enumerate}

\section{Analytic Exercises}

\begin{enumerate}
\item Eddington luminosity
\item Temperature profile of accretion disk
\item Relationship between energy distribution and synchrotron
\item Superluminal motion
\item Relativistic Beaming
\item Polarization
\end{enumerate}

\section{Numerics and Data Exercises}

\begin{enumerate}
\item Quasar SEDs
\item Quasar variability
\item Densities from line ratios
\item Temperatures from line ratios
\item OIII/Hbeta and ionization parameter
\item resolved spectroscopy of AGN
\end{enumerate}

\bibliographystyle{apj}
\bibliography{exex}