\chapter{ Group Change Detection (GCD) }
 \label{sec:dynamicGCD}
%\section{ Group Change Detection (GCD) Techniques  } \label{Sec:GCD}
Methods for detecting group anomalies were  explored in previous chapters however this Chapter thoroughly describes state-of-the-art Group Change Detection (GCD) techniques.   GCD methods detect  significant changes in statistical properties of a group stochastic process (GSP) which consists of a collection of time series.
 GCD research focuses on a single group over time however it is possible to analyse multiple groups over time which combines the static GAD and dynamic GCD  problem.

We formulate  the GCD problem with a slightly different problem definition to Section \ref{Sec:Problem} and  explicitly write groups as a function of time. % and formulate  the GCD problem as follows.
  Consider a collection of $N'$ stochastic processes  of $V$ dimensions observed over a sequence of discrete times  $\mathcal{T}=\{1,2,\dots,T\}$.  Stochastic processes $n= 1,2,\dots,N'$ are represented by $   \{ (\,{ X}_{nv}(t) \,)_{v=1}^V  : \, t \in \mathcal{T}  \}$.
A group distribution at a fixed time $t$ is associated with the matrix of random variables
\begin{align}
{\bf G}(t)=\big( { X}_{nv}(t)\big)  \in \mathbb{R}^{N' \times V} \label{Gdist}
\end{align}
such that  a GSP  is represented by $\{ {{\bf G}}(t) \}_{t \in\mathcal{T}}$
and the total number of observations is $N= T N^{'} $.
  GCD techniques  are explained  by descriptive components from Section \ref{Sec:Problem}  in  categories of discriminative methods, generative models and hypothesis tests.

\section{ Discriminative: Group Level Events in Time Series (GLETS) }
We refer to the GCD technique proposed by
Chen et al. \cite{GLETS} as Group Level Events in Time Series (GLETS). GLETS is a discriminative method that detects a significant change in a group of time series where group memberships are previously unknown. A group of time series with numerical (discrete or continuous) values is clustered based on a dissimilarity measure given  observations over a reference period. Since GLETS employs a sequential clustering approach, it detects two type of temporal changes;
\begin{enumerate}[(a)]
\item Group formation:  a collection of dissimilar time series exhibit more cohesive structure over a period of time. % with a higher correlation.
\item Group disbanding:  a group of correlated time series splits into multiple subgroups. % behaviours after a certain time period.
\end{enumerate}
%A group of correlated time series is clustered based on Pearson's correlation over a training interval.
The four key components of GLETS are explained as follows.
\begin{enumerate}[1.]
\item Characterisation function $f_1({\bf G}_{train})$: \\
%A training set is assumed to contain information about regular  behaviour of a GSP.
 Suppose training data consists of ${\bf G}_{train}= \{ {\bf G}(t)\}_{t \in [\tau,\tau+a]} $ % contains group observations in the interval $[\tau,\tau+a]$
 where ${\bf G}(t) = \big( X_{nv}(t) \big) \in \mathbb{R}^{N' \times V}$ with $N'$ time series of $V$ dimensions and  $a$ is an appropriate window size chosen by a domain expert. Clustering is based on a dissimilarity metric $d$  over a training interval where   $d({\bf X}_{n}(t),{\bf X}_{n'}(t),[\tau,\tau+a])$ is calculated for all pairs $n,n'\in \{1,2,\dots,N' \}$.  In Chen et al. \cite{GLETS}, the dissimilarity metric $d$ is selected as Pearson's correlation coefficient  for financial data whereas Euclidean distance is applied for a remote sensing application. For example, Euclidean distance between the  $i$th and $j$th series in a time window $[\tau,\tau+a]$ is calculated by
\[d \Big({\bf X}_{n}(t),{\bf X}_{n'}(t),[\tau,\tau+a] \Big) =
\sqrt{ \displaystyle \sum_{t=\tau}^{\tau+a} \big( {\bf X}_{n}(t)-{\bf X}_{n'}(t) \big)^2 }
 \]
A GSP over interval $[\tau,\tau+a]$ is then characterised by the entropy score
\[\displaystyle H({\bf G}_{train}) = -\frac{1}{N}\sum_{n=1}^{N'} \ln \Big(  \frac{1}{N}\sum_{n'=1}^{N'}  \exp\big[-d( {\bf X}_{n}(t),{\bf X}_{n'}(t),[\tau,\tau+a])\,\big ] \Big)  \]
where $d({\bf X}_{n}(t),{\bf X}_{n'}(t),[\tau,\tau+a])$ is a measure of  dissimilarity  between time series ${\bf X}_{n}(t)$ and ${\bf X}_{n'}(t)$  for  $t \in [\tau,\tau+a]$.
%
\item Characterisation function $f_2({\bf G}_{test})$: \\
The function $f_2$ captures the behaviour  of a GSP over a test period of group observations. Group formation and group disbanding are respectively detected by examining  time windows before and after the given training interval.   A group of correlated time series over training interval $[\tau,\tau+a]$ is compared with test set % of group observations  on test periods
   \[ \displaystyle {\bf G}_{test} = \left\{ \begin{array}{ll} \{ {\bf G}(t) \}_{t \in [\tau-a,\tau] } &  \Longleftrightarrow \;  \mbox{Group formation} \\
  \{ {\bf G}(t) \}_{t \in [\tau+a,\tau+2a] } &  \Longleftrightarrow \;
  \mbox{Group disbanding} \end{array} \right. \]
%where $a$ is the window sise of training or test sets.
 For example, a group formation is analysed using a test  characterisation function over $[\tau-a,\tau]$ with
\[ \displaystyle  H({\bf G}_{test})    = -\frac{1}{N}\sum_{n=1}^{N'} \ln \Big(  \frac{1}{N}\sum_{n'=1}^{N'}  \exp\big[-d({\bf X}_{n}(t),{\bf X}_{n'}(t),[\tau-a,\tau])\,\big ] \Big)  \]  Similarly, group disbanding is detected by examining the test period  $[\tau+a,\tau+2a]$.

% The training set is characterised by  $ H({\bf G}_{train}) $.
\end{enumerate}
\begin{enumerate}[3.]
 \item Measure $ \mathcal{D}\big(f_1 ({\bf G}_{train}) , f_2({\bf G}_{test} )\big )$: \\
 A group change is quantified by the relative difference in characterised behaviour of  training and test intervals  with
\[ \displaystyle \frac{ H({\bf G}_{test})}{ H({\bf G}_{train}) }   \]
  where values close to $1$  indicate no significant group deviation  in a GSP.
\end{enumerate}
\begin{enumerate}[4.]
\item Threshold $\epsilon= th$: \\
A threshold  $th$ is selected by domain experts in  Chen et al. \cite{GLETS} to identify test periods that are considerably different from a training set.   A significant temporal change in a GSP is detected when a score for a temporal change is greater than a suitable threshold $th$.
\end{enumerate}
%Poor results are obtained when a chosen threshold is not suitable for a particular dataset.

\section{ Generative: Dynamic Group Latent Anomaly Detection (DGLAD) }
Yu et al. \cite{GLAD} extend the static GLAD model (described in subsection \ref{subs:GLAD}) to the dynamic setting in a method called Dynamic-GLAD or DGLAD. The DGLAD  model provides a solution for both GAD and GCD problems by handling multiple group stochastic processes. When group memberships are not previously known, DGLAD aggregates data instances based on similarity of features as well as pairwise connections.   In Yu et al. \cite{GLAD}, DGLAD detects significant changes in a GSP   with a lower false positive rate than other compared methods.
 A  drawback of the DGLAD model is the requirement for observations recorded over a period of time which is not readily available, especially for network data.

In DGLAD, structural values such as expected number of topics and number of groups  are initially selected by information criteria as previously described for  generative models in Section \ref{Sec:G}. To alleviate  computational burden, DGLAD  assumes that structural  values remain constant throughout the time period of interest. This may be violated in practice as the emergence and dissolution of topics or groups naturally occur over time.  It is also difficult to interpret inferred groups  as DGLAD allows individuals to switch groups   over time.  Thus an appropriate selection of initial structural values and a careful interpretation is recommended when applying the DGLAD model.

DGLAD is explained using four key components as follows.  %introduced in Section \ref{Sec:Problem}.
\begin{enumerate}[1.]
\item Characterisation function $f_1({\bf G}_{train})= \theta_m(t-1)$: \\
Statistical properties of inferred groups are characterised by topic mixtures.  Latent topic variables are inferred for  each time step where the $m$th group at time $t-1$ is characterised by topic mixtures ${\theta}_{m}(t-1)$.
\end{enumerate}

\begin{enumerate}[2.]
\item Characterisation function $f_2({\bf G}_{test})=\theta_m(t)$: \\
%The $m$th group at a specific time point is characterised by the topic proportions $\theta_m(t)$.
To determine if a significant temporal change occurs from time step $t-1$ to $t$, the $m$th group at time $t$ is characterised by topic mixtures ${\theta}_{m}(t-1)$.
  Since multiple time steps are analysed, topic mixtures %$\{ \boldsymbol\theta(1),\dots,  \boldsymbol\theta(T) \} $
 are inferred using an additional particle filtering technique as discussed in Doucet and Johansen \cite{doucet2009tutorial}. This particle filter utilises sequential importance sampling where the transition for topic mixtures over consecutive time steps follows  a multivariate Gaussian distribution with
\begin{equation}
\boldsymbol\theta(t) \,| \, \boldsymbol\theta(t-1) \sim \mathcal{N} \Big(\boldsymbol\theta(t-1), \sigma^2 {\bf I} \Big)  \label{Eqn:Transition}
\end{equation}
where $\sigma^2$ is variance of topic mixtures over groups at the previous time step.  Since the variance-covariance matrix in Equation (\ref{Eqn:Transition}) has off-diagonals with zero entries, any two different groups conditioned on previous observations are assumed to be independent.
\end{enumerate}

\begin{enumerate}[3.]
\item Measure $ \mathcal{D}\big(f_1({\bf G}_{train}), f_2({\bf G}_{test})\big )= || \theta_m(t) -\theta_m(t-1) ||$: \\
Instead of examining likelihood scores, a difference between topic mixtures at consecutive time steps is computed to detect a significant group deviations.   A measure of temporal change in the $m$th group  transitioning from time $t-1$ to $t$ is given by
\[ || \theta_m(t) -\theta_m(t-1) ||  \]
where $|| \cdot ||$ is Euclidean distance.
\end{enumerate}

\begin{enumerate}[4.]
\item   Threshold $\epsilon $ is  selected by domain experts: \\
Similar to other generative models, a threshold is arbitrarily selected based on a small proportion of groups with the highest scores.
 Larger differences between topic mixtures at consecutive time steps indicate relatively  greater temporal change in a GSP.
\end{enumerate}

\section{Hypothesis Test: "What's strange about recent event" (WSARE)}
 Wong et al. \cite{WSARE} propose  WSARE, an  unsupervised method specifically  formulated for analysing an emergency department database.
Numerical and categorical features (such as age and gender) are recorded for each patient admitted to the emergency department. Rules are established from a combination of features to uncover anomalous patterns in different demographic groups.  A significant temporal change in a demographic  group represents a potential disease outbreak where deviating patterns are characterised by higher proportions of daily counts for a demographic group as compared to expected (historical) proportions.  %Solely examining daily counts is not effectively in detecting an outbreak for specific diseases.

\begin{enumerate}[1.]
\item Characterisation function $f_1({\bf G}_{train})=O_{past}$: \\
Firstly a demographic group is identified based on particular rules consisting of one or two features.
%The counts of a demographic group at the current date is compared to past observations  $O_{past}$.
 The regular behaviour is inferred from a training interval  over five to eight weeks prior to the current date. The  aggregated historical count is denoted by $O_{past}$. WSARE evaluates hypotheses based on
\begin{align}
&\mbox{ $H_0:$ Date and rules are independent   \, versus \,  $H_1:$ Date and  rules are not independent  }
\label{Hyp:WSARE}
\end{align}
\end{enumerate}
\begin{enumerate}[2.]
\item Characterisation function $f_2({\bf G}_{test})=O_{today}$: \\  WSARE algorithm detects significant temporal changes in  demographic groups using specific rules. Table  \ref{Ex:WSARE} provides an example of a single feature rule with $\mathtt{Gender} = \mathtt{Male}$  and two feature rule  $\mathtt{Gender} = \mathtt{Male}$ \& $\mathtt{Age} > 70$.
%  WSARE  initially searches for rules with the most significant $p$-values.
  Hypothesis tests in WSARE are based on   counts of emergency department admittance for a particular demographic group  where an observed count for the current date is denoted by $O_{today}$. Given specific rules, the counts $O_{today}$ characterise the behaviour of a GSP at the current test date.

\begin{table}[h]%
\hspace{-5mm}
\tabcolsep=0.2cm
	\renewcommand{\arraystretch}{2.4}
\begin{subtable}{.5\linewidth}
\centering
\scalebox{0.88}{
\begin{tabular}{|c|c|c|cccc }
\hline
  Rule   &    $O_{today}$ & $O_{past}$
  \\ \hline %\\[-2mm]
 $\mathtt{Gender} = \mathtt{Male}$ &
 66 & 503  \\ \hline% \\%[-2mm]
  $\mathtt{Gender} = \mathtt{Female}$ &
  34 & 497  \\%[2mm]
\hline
 \end{tabular}
 }
%\end{center}
 \smallskip
\caption{ A single feature rule.}
   \label{Ex:WSARE1}
\end{subtable}
	\renewcommand{\arraystretch}{2.44}
	\begin{subtable}{.5\linewidth}
	\centering
\scalebox{0.88}{
\begin{tabular}{|c|c|c|cccc }
\hline%\\[-2mm]
  Rule   &    $O_{today}$ & $O_{past}$
  \\ \hline%\\%[-2mm]
 $\mathtt{Gender}   = \mathtt{Male } \; \&  \;  \mathtt{Age} > 70 $ &
 27 & 129   \\ \hline %[-2mm]
  $\mathtt{Gender} = \mathtt{Female} \;\& \; \mathtt{Age} > 70 $ &
  3 & 71  \\%[2mm]
\hline
 \end{tabular}
 }
 \smallskip
\caption{ A two feature rule.}
  \label{Ex:WSARE2}
  \end{subtable}
  %\vspace{-10mm}
  \caption{Examples of counts observed for demographic groups based on one or two feature rules.  }
  \label{Ex:WSARE}
\end{table}

\end{enumerate}
\begin{enumerate}[3.]
\item Measure $ \mathcal{D}\big(f_1 ({\bf G}_{train}) , f_2({\bf G}_{test} )\big )$: \\
%To evaluate the hypothesis   (\ref{Hyp:WSARE}),
WSARE utilises Fisher's exact test where data under the null hypothesis follows a hypergeometric probability.
% with parameters $a,b,c,d $,
%\begin{align}
% P(a,b,c,d) = \displaystyle \frac{ {a+b \choose{a} } { c+d \choose{c} } } { {n' \choose{a+c} } } \label
%\end{align}
%where the total count is $n' = a+b+c+d$.
 A $p$-value is the likelihood that dates  and rules are independent for a demographic group of interest such that extremely low $p$-values indicate that the current counts are significantly different  from  previous observations. Using the hypergeometric probability in Equation (\ref{Eqn:hyperG}),  examples in Table \ref{Ex:WSARE} (a) and  (b) are associated with significant $p$-values  respectively calculated as    \[P(66,503,34,497) \approx  0.0032 \mbox{\, and \,}
P(27,129,3,71) \approx  0.0056
 \]
  Chi-square test for independence can also be applied to Table  \ref{Ex:WSARE} (a) with a resulting $p$-value of 0.00093.
However the example in Table  \ref{Ex:WSARE} (b) does not satisfy the condition that counts $> 5$ for a Chi-square test so  Fisher's exact test  is more appropriate.

WSARE  considers  all possible rules involving a single  feature   then determines if an additional component is significant. In Table \ref{Ex:WSARE}, WSARE initially  detects a significant temporal change for %in the demographic group
 $\mathtt{Gender} = \mathtt{Male}$ but also detects a change in the group with a additional component  $\mathtt{Gender}   = \mathtt{Male } \; \&  \;  \mathtt{Age} > 70 $. Since thousands of hypothesis tests are conducted, %the emergency department database contains thousands of rules,
   $p$-values are adjusted using  a randomisation test based on bootstrap sampling of dates in past records. % A null distribution is generated in a similar way to the bootstrap sampling  approach in ATD from Section \ref{Sec:ATD}.
   The  $p$-value  for observed counts and   the $b$th bootstrap sample are respectively denoted by $\tilde{p}$  and $\tilde{p}_b$. A compensated $p$-value for the $i$th rule is calculated  by
 \begin{equation}
  p_i^* = \displaystyle  \frac{1}{B} \sum_{b=1}^ B I ( \tilde{p}_b > \tilde{p} )
  \label{Eqn:CompensatedP}
\end{equation}
 where $B$ is the number of bootstrap  simulations for the randomisation test.  This reduces potential overfitting with less false discoveries based on estimated $p$-values.
\end{enumerate}
\begin{enumerate}[4.]
\item Threshold $\epsilon=\alpha_{FDR}$: \\
 %which is significant when compared to a $0.$
For a specific current date, the compensated $p$-value   from Equation (\ref{Eqn:CompensatedP}) is evaluated at a significant level  $\alpha$.
When monitoring demographic groups over multiple time steps, a threshold is adjusted to control for the false discovery rate (FDR). A threshold $\alpha_{FDR}$ is calculated by the FDR procedure in  Benjamini  and Hochberg \cite{MultiTest}. Thus a demographic group experiences a significant change if the compensated $p$-value is less than an adjusted significant level $\alpha_{FDR}$.
\end{enumerate}
%A demographic group has a significantly higher count compared to past events if the null hypothesis is rejected at a predetermined significance level.

\section{Hypothesis Test: Multiple Sensor Sequential Detection (MSSD)}
We refer to the method  proposed by  Xie and Siegmund  \cite{xie2013} as Multiple Sensor Sequential Detection (MSSD). MSSD is a sequential technique for detecting change-points in a proportion of sensors in a GSP. MSSD is formulated for continuous real-valued input data and examines the statistical properties of groups based on  location. Since the true times of significant changes in a GSP are unknown,  hypotheses are evaluated at each time step. The goal is to detect group changes as soon as possible but also reduce the number of false positives.

\begin{enumerate}[1.]
\item Characterisation function $f_1({\bf G}_{train})=\{\mu_n(T)\}_{n=1}^{N'}$: \\
Observations from each stochastic process in a GSP  are assumed to be mutually independent and normally distributed with zero mean and unit variance before a change-point occurs. MMSD then tests whether there is a significant change  in the mean of the $n$th series at time $\tau$,
\[ H_0: \mu_n(\tau)= 0  \mbox{ for all } n=1,2,\dots, N' \mbox{ \, versus \,  } H_1: \mu_n(\tau) > 0 \mbox{ for } n \in \mathsf{S}  \]
 where $\mathsf{S}$  denotes the set of time series affected by a change-point at time $\tau$.
%  The function $f_1$ characterises
   Group observations ${\bf G}_{train} =\{ {\bf G} ({t}) \}_{t=1}^T$ over  training interval  $[1,T] $ are characterised by  set of means  $\{\mu_n(T)\}_{n=1}^{N'}$ where
% A training sequence is then characterised by the where
the $n$th mean is estimated by
$   \mu_n(T) =\frac{1}{T} \sum_{t=1}^T   X_{n} (t) $.
 %A cumulative statistic for the $n$th series is calculated by   \[ R_{T n} = T\mu_n(T) %\sum_{t=1}^T   X_{t n}
%  \]
% for $n=1,\dots, N$
% The statistical property  of the GSP over all of the observed stochastic processes is characterised by $\{ R_{T n} \}_{n=1}^N$.
\end{enumerate}
%
\begin{enumerate}[2.]
\item Characterisation function $f_2({\bf G}_{test}) = \{\mu_n(\tau) \}_{n=1}^{N'}$: \\
Since the true times of significant change are usually unknown, a variety of time values  $\tau$ are analysed. In a sequential fashion,  the test set ${\bf G}_{test} =\{ {\bf G} ({t}) \}_{t=1}^\tau$ is examined for time steps  $\tau=1,2,\dots,T$. The function $f_2$ characterises the behaviour of a GSP over $[1,\tau]$ by the set of means  $\{\mu_n(\tau)\}_{n=1}^{N'}$ where  the $n$th mean is
$  \mu_n(\tau) =\frac{1}{\tau} \sum_{t=1}^\tau   X_{ n}(t) $.
% The GSP over a test period is characterised by $\{ R_{\tau n} \}_{n=1}^N$.
\end{enumerate}
%
\begin{enumerate}[3.]
\item Measure $ \mathcal{D}\big(f_1 ({\bf G}_{train}) , f_2({\bf G}_{test} )\big )$: \\
Xie and Siegmund  \cite{xie2013} propose multiple ways to measure a significant group deviation at time $\tau$. %MMSD compares  two sets of observations in a similar way to CUSUM approachs that are explained in  Polunchenko  and Tartakovsky \cite{Polunchenko2012}.
One particular metric $ (T-\tau)^{-1/2}  \big( T \mu_n(T) - \tau \mu_n(\tau) \big) $ directly measures the change in the mean value of the $n$th time series from training period $[1,T]$ and test interval $[1,\tau]$.
% that compares means of training and test period for the $n$th time series %$\{\mu_n(T) \}_{n=1}^N$ and  test set $\{ \mu_n(\tau) \}_{n=1}^N$
It is assumed that a significant change occurs in a proportion $p_0 = |\mathsf{S}|/N \in (0,1]$ of time series in a GSP.
 To incorporate information of proportions, MSSD calculates a global log-likelihood for measuring a group deviation in a GSP  with
\begin{align}
  Z_{\tau,T}=\sum_{n=1}^{N'} g\Big( \frac{   T \mu_n(T) - \tau \mu_n(\tau)  } {(T-\tau)^{1/2}}
 \, , \, p_0  \Big) \label{Eqn:Z} %\\ & \mbox{ \nonumber
\end{align}
where
$ g(u,p_0)= \ln \big(1-p_0+p_0 \exp[(u^+)^2/2] \,\big)$ and $u^+=\max(0,u)$. The initial selection of proportion $p_0$ also influences subsequent results.
If a significant change is known to only affect a small number of stochastic processes in a GSP then  instead of the measure in Equation (\ref{Eqn:Z}), a maximum statistic is more appropriate with
\[ \Big( (T-\tau)^{-1/2}  \max_{1 \le n \le N'}
\big( T \mu_n(T) - \tau \mu_n(\tau) \big)^+ \Big)^2/2
\]
%We are also able to consider extreme behaviours of the proportion of stochastic processes in a GSP.
% % the probability function in Equation (\ref{Eqn:Z}) reduces to $ g(u,p_0)=  (u^+)^2/2 $. On the other hand if an identical change occurs in a large proportion of sensors with $p_0 \approx 1  $ then $ g(u,p_0)=  (u^+)^2/2 $.
\end{enumerate}
\begin{enumerate}[4.]
\item Threshold $\epsilon = b $: \\
% a significant group deviation  in a GSP
Firstly average run length is  the expected duration before a false detection when no real change occurs whereas expected delay detection is the time lag  before a true change-point is identified.
MMSD calculates a threshold based on minimising the expected delay detection whilst constraining the average run length.  The threshold value for $b$ is selected  to satisfy optimisation criteria as further  described in Xie and Siegmund  \cite{xie2013}. Thus a significant change at time $\tau $ occurs in a proportion $p_0$ of time series in a GSP  if the test statistic from Equation (\ref{Eqn:Z}) is greater than an estimated threshold with $Z_{\tau,T}>b$.
%A threshold is selected in order to identify test groups that are considerably different from the behaviours from a training set.
%$E [Z_{0,T}]$
\end{enumerate}


\section{DAG}

%%%%%%%%%%%%%%%
\begin{frame}{DAG}
  \begin{center}
    no back edge $\iff$ DAG $\iff$ $\exists$ topo. ordering
  \end{center}

  \begin{block}{Topo. sorting algorithm by Tarjan(probably), 1976}
    DFS on digraph, $u \to v$:
    \begin{itemize}
      \item \textcolor{red}{no} back edge: $\text{f}[u] < \text{f}[v]$
      \item others: $\text{f}[u] > \text{f}[v]$
    \end{itemize}

    \[ u \to v \Rightarrow \text{f}[u] > \text{f}[v] \]
    \[ u \to v \Rightarrow u \prec v \]

    \begin{center}
      Topo. sorting: sort vertices in \textcolor{blue}{\emph{decreasing}} order of their \textcolor{blue}{\emph{finish}} times.
    \end{center}
  \end{block}
\end{frame}
%%%%%%%%%%%%%%%
\begin{frame}{Digraph as DAG}
  \begin{exampleblock}{Digraph as DAG \pno{3.4.6}}
    \begin{theorem}
      Every digraph is a dag of its SCCs.
    \end{theorem}
  \end{exampleblock}

  \begin{alertblock}{Remark.}
    \begin{itemize}
      \item SCC algorithm
      \item SCC: reachability/connectivity equivalence class
      \item two tiered structure of digraphs
    \end{itemize}
  \end{alertblock}
\end{frame}
%%%%%%%%%%%%%%%
\begin{frame}{Kahn's toposort algorithm}
  \begin{exampleblock}{Kahn's toposort algorithm (1962) \pno{3.4.19}}
    \begin{itemize}
      \item queue for source vertices ($\text{in}[v] = 0$)
      \item repeat: dequeue $v$, delete it, output it
    \end{itemize}
  \end{exampleblock}

  \begin{block}{Solution.}
    \begin{lemma}
      Every DAG has at least one source and at least one sink vertex.
    \end{lemma}
  \end{block}

  \begin{alertblock}{Remark}
    DFS on DAG:
    \begin{itemize}
      \item $\argmax_{v} f(v)$ $\Rightarrow$ source (used in SCC algorithm)
      \item $\argmin_{v} f(v)$ $\Rightarrow$ sink
    \end{itemize}
  \end{alertblock}
\end{frame}
%%%%%%%%%%%%%%%
\begin{frame}{Hamiltonian path in DAG}
  \begin{exampleblock}{Hamiltonian path in DAG \pno{3.4.16}}
    \begin{itemize}
      \item DAG $G$
      \item path visiting each vertex once
    \end{itemize}
  \end{exampleblock}

  \begin{block}{Solution.}
    \begin{itemize}
      \item general digraph: NP-hard
      \item dag: $\exists$ HP $\iff$ $\exists!$ topo. ordering
	\begin{itemize}
	  \item $\Leftarrow$: By contridiction. $\exists u \sim v: u \nrightarrow v$; swap
	\end{itemize}
    \end{itemize}

    Algorithm:
    \begin{itemize}
      \item toposort, check edges
      \item the Kahn toposort algorithm
    \end{itemize}
  \end{block}
\end{frame}
%%%%%%%%%%%%%%%
\begin{frame}{Semi-connected DAG}
  \begin{definition}{Semi-connected digraph}
    $\forall u,v: u \leadsto v \lor v \leadsto u$
  \end{definition}

  \begin{exampleblock}{Semi-connected DAG \pno{3.4.21 (c) + (d)}}
    To test whether a DAG is semi-connected.
  \end{exampleblock}

  \begin{block}{Solution.}
    \begin{center}
      dag: $\exists$ HP $\iff$ $\exists!$ topo. ordering $\iff$ semi-connected
    \end{center}

    \begin{proof}
      \begin{itemize}
	\item $\Leftarrow$: by contradiction; total order ($\forall u,v: u \prec v \lor v \prec u$)
	\item $\Rightarrow$: $\exists HP$
      \end{itemize}
    \end{proof}
  \end{block}
\end{frame}
%%%%%%%%%%%%%%%
\begin{frame}{Minimum cost reachable}
  \begin{exampleblock}{Minimun cost reachable \pno{3.4.22}}
    Compute $\text{cost}[u] = \min \set{\text{cost}[v] \mid u \leadsto v}$.
  \end{exampleblock}

  \begin{block}{Solution.}
    \begin{itemize}
      \item dag: reverse topo. ordering
	\begin{itemize}
	  \item backtracking: $\text{cost}[u] = \min_{u \to v} \set{\text{cost}[v]}$
	\end{itemize}
      \item digraph: dag of scc
    \end{itemize}
  \end{block}
\end{frame}
%%%%%%%%%%%%%%%
\begin{frame}{Line up}
  \begin{exampleblock}{Line up \pno{3.4.29}}
    \begin{itemize}
      \item $i$ hates $j$: $i \prec j$
      \item $i$ hates $j$: $\# i < \# j$
    \end{itemize}
  \end{exampleblock}

  \begin{block}{Solution.}
    $i$ hates $j$: $i \to j$;
    \begin{itemize}
      \item DAG?
      \item longest path; critical path
      \end{itemize}
  \end{block}
\end{frame}
%%%%%%%%%%%%%%%
\begin{frame}{One-to-all reachability}
  \begin{exampleblock}{One-to-all reachability \pno{3.4.28}}
    \begin{itemize}
      \item given $v: v \leadsto^{?} \forall u$
      \item $\exists? v: v \leadsto \forall u$
    \end{itemize}
  \end{exampleblock}

  \begin{block}{Solution.}
    \begin{itemize}
      \item DFS/BFS
      \item SCC; $\exists!$ source vertex $v$ $\iff$ $v \leadsto \forall u$
	\begin{proof}
	  \begin{itemize}
	    \item $\Rightarrow$: By contradiction. $\exists u: v \nrightarrow u \land \text{in}[u] > 0 \Rightarrow \exists u' \to u \land v \nrightarrow u'$. Cycle.
	    \item $\Leftarrow$: (1) source (2) $\exists !$
	  \end{itemize}
	\end{proof}
    \end{itemize}
  \end{block}
\end{frame}
%%%%%%%%%%%%%%%


\section{Air Velocity}
Did you ever feel the wind blow? Most probably. That's what we will be calculating here. How hard the wind will blow. This is noted as velocity, how fast something moves.

\subsection{Equation of State and the Incompressible Atmosphere}
The equation of state relates one or more variables in a dynamical system (like the atmosphere) to another. The most common equation of state in the atmosphere is the ideal gas equation as
described by \autoref{eq:ideal gas} \cite{idealGas}. The symbols in that equation represent:

\begin{itemize}
    \item $p$: The gas pressure (\si{Pa}).
    \item $V$: The volume of the gas (\si{m^3}).
    \item $n$: The amount of moles in the gas (\si{mol}).
    \item $R$: The Gas constant as defined in \autoref{sec:gas constant} (\si{JK^{-1}mol^{-1}}) \cite{idealGas}.
    \item $T$: The temperature opf the gas ($K$).
\end{itemize}

If we divide everything in \autoref{eq:ideal gas} by $V$ and set it to be unit (in this case, set it to be exactly $1$ \si{m^3}) we can add in the molar mass in both the top and bottom parts of
the division as show in \autoref{eq:gas unit}. We can then replace $\frac{nm}{V}$ by $\rho$ the density of the gas (\si{kgm^{-3}}) and $\frac{R}{m}$ by $R_s$ the specific gas constant (gas
constant that varies per gas in \si{JK^{-1}mol^{-1}}) as shown in \autoref{eq:state gas}. The resulting equation is the equation of state that you get that most atmospheric physicists use when
talking about the atmosphere \cite{simon}.

\begin{subequations}
    \begin{equation}
        pV = nRT
        \label{eq:ideal gas}
    \end{equation}
    \begin{equation}
        p = \frac{nR}{V}T = \frac{nmR}{Vm}T
        \label{eq:gas unit}
    \end{equation}
    \begin{equation}
        p = \rho R_sT
        \label{eq:state gas}
    \end{equation}
\end{subequations}

The pressure is quite important, as air moves from a high pressure point to a low pressure point. So if we know the density and the temperature, then we know the pressure and we can work out
where the air will be moving to (i.e. how the wind will blow). In our current model, we know the atmospheric temperature but we do not know the density. For simplicities sake, we will now assume
that the atmosphere is Incompressible, meaning that we have a constant density. Obviously we know that air can be compressed and hence our atmosphere can be compressed too but that is not
important enough to account for yet, especially considering the current complexity of our model.

The code that corresponds to this is quite simple, the only change that we need to make in \autoref{eq:state gas} is that we need to replace $T$ by $T_a$, the temperature of the atmosphere. As
$T_a$ is a matrix (known to programmers as a double array), $p$ will be a matrix as well. Now we only need to fill in some values. $\rho = 1.2$\cite{densityAir}, $R_s = 287$\cite{specificGasConstantAir}.

\subsection{The Momentum Equations} \label{sec:momentum}
The momentum equations are a set of equations that describe the flow of a fluid on the surface of a rotating body. For our model we will use the f-plane approximation. The equations corresponding
to the f-plane approximation are given in \autoref{eq:x momentum} and \autoref{eq:y momentum} \cite{momentumeqs}. Note that we are ignoring vertical movement, as this does not have a significant
effect on the whole flow. All the symbols in \autoref{eq:x momentum} and \autoref{eq:y momentum} mean:

\begin{itemize}
    \item $u$: The east to west velocity (\si{ms^{-1}}).
    \item $t$: The time (\si{s}).
    \item $f$: The coriolis parameter as in \autoref{eq:coriolis}.
    \item $v$: The north to south velocity (\si{ms^{-1}}).
    \item $\rho$: The density of the atmosphere (\si{kgm^{-3}}).
    \item $p$: The atmospheric pressure (\si{Pa}).
    \item $x$: The local longitude coordinate (\si{m}).
    \item $y$: The local latitude coordinate (\si{m}).
\end{itemize}

If we then define a vector $\bar{u}$ as $(u, v, 0)$, we can rewrite both \autoref{eq:x momentum} as \autoref{eq:x momentum laplace}. Here $\nabla u$ is the gradient of $u$ in both $x$ and $y$
directions. Then if we write out $\nabla u$ we get \autoref{eq:x momentum final}. Similarly, if we want to get $\delta v$ instead of $\delta u$ we rewrite \autoref{eq:y momentum} to get
\autoref{eq:y momentum laplace} and \autoref{eq:y momentum final}.

\begin{subequations}
    \begin{equation}
        \frac{Du}{Dt} - fv = -\frac{1}{\rho} \frac{\delta p}{\delta x}
        \label{eq:x momentum}
    \end{equation}
    \begin{equation}
        \frac{Dv}{Dt} - fu = -\frac{1}{\rho} \frac{\delta p}{\delta y}
        \label{eq:y momentum}
    \end{equation}
    \begin{equation}
        \frac{\delta u}{\delta t} + \bar{u} \cdot \nabla u - fv = -\frac{1}{\rho}\frac{\delta p}{\delta x}
        \label{eq:x momentum laplace}
    \end{equation}
    \begin{equation}
        \frac{\delta v}{\delta t} + \bar{u} \cdot \nabla v - fu = -\frac{1}{\rho}\frac{\delta p}{\delta y}
        \label{eq:y momentum laplace}
    \end{equation}
    \begin{equation}
        \frac{\delta u}{\delta t} + u\frac{\delta u}{\delta x} + v\frac{\delta u}{\delta y} - fv = -\frac{1}{\rho}\frac{\delta p}{\delta x}
        \label{eq:x momentum final}
    \end{equation}
    \begin{equation}
        \frac{\delta v}{\delta t} + u\frac{\delta v}{\delta x} + v\frac{\delta v}{\delta y} - fu = -\frac{1}{\rho}\frac{\delta p}{\delta y}
        \label{eq:y momentum final}
    \end{equation}
\end{subequations}

With the gradient functions defined in \autoref{alg:gradient x} and \autoref{alg:gradient y}, we can move on to the main code for the momentum equations. The main loop is shown in
\autoref{alg:stream3}. Do note that this loop replaces the one in \autoref{alg:stream2v2} as these calculate the same thing, but the new algorithm does it better.

\begin{algorithm}
    $S_{xu} \leftarrow \texttt{gradient\_x}(u, lan, lon)$ \;
    $S_{yu} \leftarrow \texttt{gradient\_y}(u, lan, lon)$ \;
    $S_{xv} \leftarrow \texttt{gradient\_x}(v, lan, lon)$ \;
    $S_{yv} \leftarrow \texttt{gradient\_y}(v, lan, lon)$ \;
    $S_{px} \leftarrow \texttt{gradient\_x}(p, lan, lon)$ \;
    $S_{py} \leftarrow \texttt{gradient\_x}(p, lan, lon)$ \;
    \For{$lat \leftarrow 1$ \KwTo $nlat - 1$}{
        \For{$lon \leftarrow 0$ \KwTo $nlon$}{
            $u[lan, lon] \leftarrow u[lan, lon] + \delta t \frac{-u[lan, lon]S_{xu} - v[lan, lon]S_{yu} + f[lan]v[lan, lon] - S_{px}}{\rho}$ \;
            $v[lan, lon] \leftarrow v[lan, lon] + \delta t \frac{-u[lan, lon]S_{xv} - v[lan, lon]S_{yv} - f[lan]u[lan, lon] - S_{py}}{\rho}$ \;
        }
    }
    \caption{Calculating the flow of the atmosphere (wind)}
    \label{alg:stream3}
\end{algorithm}

\subsection{Improving the Coriolis Parameter}
Another change introduced is in the coriolis parameter. Up until now it has been a constant, however we know that it varies along the latitude. So let's make it vary over the latitude. Recall
\autoref{eq:coriolis}, where $\Theta$ is the latitude. Coriolis ($f$) is currently defined in \autoref{alg:gradient}, so let's replace it with \autoref{alg:coriolis}.

\begin{algorithm}
    \SetAlgoLined
    $\Omega \leftarrow 7.2921 \cdot 10^{-5}$ \;

    \For{$lat \leftarrow -nlat$ \KwTo $nlat$}{
        $f[lat] \leftarrow 2\Omega \sin(lat \frac{\pi}{180})$ \;
    }
    \caption{Calculating the coriolis force}
    \label{alg:coriolis}
\end{algorithm}

\subsection{Adding Friction}
In order to simulate friction, we multiply the speeds $u$ and $v$ by $0.99$. Of course there are equations for friction but that gets complicated very fast, so instead we just assume that we
have a constant friction factor. This multiplication is done directly after \autoref{alg:stream3} in \autoref{alg:stream4v1}.

\subsection{Adding in Layers}
With adding in atmospheric layers we need to add vertical winds, or in other words add the $w$ component of the velocity vectors. We do that by editing \autoref{alg:stream3}. We change it to
\autoref{alg:velocity}. Here we use gravity ($g$) instead of the coriolis force ($f$) and calculate the change in pressure. Therefore we need to store a copy of the pressure before we do any
calculations. This needs to be a copy due to aliasing \footnote{Aliasing is assigning a different name to a variable, while it remains the same variable. Take for instance that we declare a
variable $x$ and set it to be $4$. Then we say $y \leftarrow x$, which you might think is the same as saying they $y \leftarrow 4$ but behind the screen it is pointing to $x$. So if $x$ changes,
then so does $y$.}

\begin{algorithm}
    $S_{xu} \leftarrow \texttt{gradient\_x}(u, lan, lon)$ \;
    $S_{yu} \leftarrow \texttt{gradient\_y}(u, lan, lon)$ \;
    $S_{xv} \leftarrow \texttt{gradient\_x}(v, lan, lon)$ \;
    $S_{yv} \leftarrow \texttt{gradient\_y}(v, lan, lon)$ \;
    $S_{px} \leftarrow \texttt{gradient\_x}(p, lan, lon)$ \;
    $S_{py} \leftarrow \texttt{gradient\_y}(p, lan, lon)$ \;
    \For{$lat \leftarrow 1$ \KwTo $nlat - 1$}{
        \For{$lon \leftarrow 0$ \KwTo $nlon$}{
            \For{$layer \leftarrow 0$ \KwTo $nlevels$}{
                $u[lan, lon, layer] \leftarrow u[lat, lon, layer] + \delta t \frac{-u[lat, lon, layer]S_{xu} - v[lat, lon, layer]S_{yu} + f[lat]v[lat, lon, layer] - S_{px}}{\rho}$ \;
                $v[lan, lon, layer] \leftarrow v[lat, lon, layer] + \delta t \frac{-u[lat, lon, layer]S_{xv} - v[lat, lon, layer]S_{yv} - f[lat]u[lat, lon, layer] - S_{py}}{\rho}$ \;
                $w[lan, lon, layer] \leftarrow w[lat, lon, layer] - \frac{p[lat, lon, layer] - p_o[lat, lon, layer]}{\delta t\rho[lat, lon, layer]g}$ \;
            }
        }

    $p_o \leftarrow copy(p)$ \;
    }
    \caption{Calculating the flow of the atmosphere (wind)}
    \label{alg:velocity}
\end{algorithm}


\chapter{Aerodynamic Characteristics}

\section{Aerodynamic Characteristics Approximation}

\subsection{Lift Coefficient Approximation}

\begin{figure}[h!]
  \centering
  \includegraphics[width=120mm]{eps/approx_cz.eps}
  \caption{Lift coefficient approximation}
\end{figure}

Following approximation is used to get lift coefficient for the full range of angle of attack. \cite{NASA-TM-102267}

Lift coefficient is given by the following expressions:
\begin{multline}
  C_L =
  -
  \frac{
    \left( \alpha + \alpha_{L2} \right)
    \left( \alpha + \frac{\pi}{2} \right)
  }
  {
    \left( \alpha_{L1} - \alpha_{L2} \right)
    \left( \alpha_{L1} - \frac{\pi}{2} \right)
  } C_{L1}
  -
  \frac{
    \left( \alpha + \alpha_{L1} \right)
    \left( \alpha + \frac{\pi}{2} \right)
  }
  {
    \left( \alpha_{L2} - \alpha_{L1} \right)
    \left( \alpha_{L2} - \frac{\pi}{2} \right)
  } C_{L2} \\
  \mathrm{~for~} -\frac{\pi}{2} \leq \alpha \leq - \alpha_{L1}
\end{multline}
\begin{align}
  C_L &=
  \frac{ C_{L1} - C_{Ls} }{ \alpha_{L1} - \alpha_{Ls} }
  \left( \alpha + \alpha_{Ls} \right) - C_{Ls}
  \mathrm{~for~} - \alpha_{L1} < \alpha \leq - \alpha_{Ls} \\
  C_L &= \frac{C_{Ls}}{\alpha_{Ls}} \alpha
  \mathrm{~for~} - \alpha_{Ls} < \alpha < \alpha_{Ls} \\
  C_L &=
  \frac{ C_{L1} - C_{Ls} }{ \alpha_{L1} - \alpha_{Ls} }
  \left( \alpha - \alpha_{Ls} \right) + C_{Ls}
  \mathrm{~for~} \alpha_{Ls} \leq \alpha < \alpha_{L1}
\end{align}
\begin{multline}
  C_L =
  \frac{
    \left( \alpha - \alpha_{L2} \right)
    \left( \alpha - \frac{\pi}{2} \right)
  }
  {
    \left( \alpha_{L1} - \alpha_{L2} \right)
    \left( \alpha_{L1} - \frac{\pi}{2} \right)
  } C_{L1}
  +
  \frac{
    \left( \alpha - \alpha_{L1} \right)
    \left( \alpha - \frac{\pi}{2} \right)
  }
  {
    \left( \alpha_{L2} - \alpha_{L1} \right)
    \left( \alpha_{L2} - \frac{\pi}{2} \right)
  } C_{L2} \\
  \mathrm{~for~} \alpha_{L1} \leq \alpha \leq \frac{\pi}{2}
\end{multline}

\subsection{Drag Coefficient Approximation}

Following approximation is used to get drag coefficient for the full range of angle of attack. \cite{NASA-TM-102267} Drag coefficient is assumed to be symmetric.

\begin{figure}[h!]
  \centering
  \includegraphics[width=120mm]{eps/approx_cx.eps}
  \caption{Drag coefficient approximation}
\end{figure}

Drag coefficient is given by the following expressions:
\begin{multline}
  C_D =
  \frac{
    \left( \alpha^2 - \alpha_{D2}^2 \right)
    \left( \alpha^2 - \alpha_{D1}^2 \right)
  }
  {
    \alpha_{D1}^2 \alpha_{D2}^2
  } C_{D0}
  +
  \frac{
    \left( \alpha^2 - \alpha_{D2}^2 \right) \alpha^2
  }
  {
    \left( \alpha_{D1}^2 - \alpha_{D2}^2 \right) \alpha_{D1}^2
  } C_{D1}
  +
  \frac{
    \left( \alpha^2 - \alpha_{D1}^2 \right) \alpha^2
  }
  {
    \left( \alpha_{D2}^2 - \alpha_{D1}^2 \right) \alpha_{D2}^2
  } C_{D2} \\
  \mathrm{~for~} -\alpha_{D2} \leq \alpha \leq \alpha_{D2}
\end{multline}
\begin{multline}
  C_D =
  \frac{
    \left( \alpha - \alpha_{D3} \right)
    \left( \alpha - \alpha_{D4} \right)
    \left( \alpha - \frac{\pi}{2} \right)
  }
  {
    \left( \alpha_{D2} - \alpha_{D3} \right)
    \left( \alpha_{D2} - \alpha_{D4} \right)
    \left( \alpha_{D2} - \frac{\pi}{2} \right)
  } C_{D2}
  \\
  +
  \frac{
    \left( \alpha - \alpha_{D2} \right)
    \left( \alpha - \alpha_{D4} \right)
    \left( \alpha - \frac{\pi}{2} \right)
  }
  {
    \left( \alpha_{D3} - \alpha_{D2} \right)
    \left( \alpha_{D3} - \alpha_{D4} \right)
    \left( \alpha_{D3} - \frac{\pi}{2} \right)
  } C_{D3}
  +
  \frac{
    \left( \alpha - \alpha_{D2} \right)
    \left( \alpha - \alpha_{D3} \right)
    \left( \alpha - \frac{\pi}{2} \right)
  }
  {
    \left( \alpha_{D4} - \alpha_{D2} \right)
    \left( \alpha_{D4} - \alpha_{D3} \right)
    \left( \alpha_{D4} - \frac{\pi}{2} \right)
  } C_{D4}
  \\
  +
  \frac{
    \left( \alpha - \alpha_{D2} \right)
    \left( \alpha - \alpha_{D3} \right)
    \left( \alpha - \alpha_{D4} \right)
  }
  {
    \left( \frac{\pi}{2} - \alpha_{D2} \right)
    \left( \frac{\pi}{2} - \alpha_{D3} \right)
    \left( \frac{\pi}{2} - \alpha_{D4} \right)
  } C_{D5}
  \\
  \mathrm{~for~} -\frac{\pi}{2} \leq \alpha < -\alpha_{D2}
  \mathrm{~and~} \alpha_{D2} < \alpha \leq \frac{\pi}{2}
\end{multline}

Data available in \cite{NACA-TN-3361} and \cite{SheldahiKlimas1981} can be used to approximate aerodynamic characteristics outside linear range of the lift.

\section{Finite Wing Aerodynamic Characteristics}

Aerodynamic characteristics of the finite wing can be estimated within linear range of the lift.

Lift curve slope is given as follows: \cite{Corke2003}
\begin{equation}
  \frac{dC_L}{d\alpha}
  =
  \frac{
    2\pi A
  }
  {
    2
    +
    \sqrt{ 4 + A^2 \left( 1 + \tan^2 \Lambda_{t/c} \right) }
  }
\end{equation}

The finite wing lift coefficient within linear range is given by the following formula: \cite{Corke2003}
\begin{equation}
  C_L = C_{L \alpha = 0} + \frac{dC_L}{d \alpha} \alpha
\end{equation}

The finite wing maximum lift coefficient is given by: \cite{Raymer1992}
\begin{equation}
  C_{L,max} = 0.9 C_{L,max \infty} \cos \Lambda_{t/c}
\end{equation}

The finite wing drag coefficient is given as follows. \cite{Corke2003}
\begin{equation}
  C_D = C_{D0} + \frac{C_L^2}{\pi A e}
\end{equation}

\section{Horizontal Tail Incidence}

Equilibrium of moments acting on an aircraft is given by the following equation:
\begin{equation}
  \label{eq-aero-equilibrium-moments}
  r_{CG} mg + \frac{1}{2} \rho V^2 S \hat c C_m
  =
  l_h \frac{1}{2} \rho V^2 S_h C_{L,h}
\end{equation}

Horizontal stabilizer lift coefficient is given as follows:
\begin{equation}
  \label{eq-aero-lift-coef-stab-h}
  C_{L,h}
  =
  \left(
    \alpha + i_h - \alpha \frac{\partial \epsilon}{\partial \alpha}
  \right)
  \frac{d C_{L,h}}{d \alpha}
\end{equation}

Where downwash derivative is given as: \cite{Paturski09}
\begin{equation}
  \frac{\partial \epsilon}{\partial \alpha}
  =
  \frac{2a}{\pi A}
\end{equation}

Substituting equation (\ref{eq-aero-lift-coef-stab-h}) into (\ref{eq-aero-equilibrium-moments}) gives:
\begin{equation}
  r_{CG} mg + \frac{1}{2} \rho V^2 S \hat c C_m
  =
  l_h \frac{1}{2} \rho V^2 S_h
  \left(
  \alpha + i_h - \alpha \frac{\partial \epsilon}{\partial \alpha}
  \right)
  \frac{d C_{L,h}}{d \alpha}
\end{equation}

Solving this equation for horizontal tail incidence angle gives:
\begin{equation}
  \label{eq-aero-incidence-angle}
  i_h =
  \frac{ 2 r_{CG} mg + \rho V^2 S \hat c C_m }
  { l_h \rho V^2 S_h \cfrac{d C_{L,h}}{d \alpha} }
  -
  \alpha \left( 1 - \frac{\partial \epsilon}{\partial \alpha} \right)
\end{equation}

Equilibrium of forces acting on an aircraft in level flight is given by the following equation:
\begin{equation}
  \label{eq-aero-equilibrium-forces}
  mg = \frac{1}{2} \rho V^2 S C_L
\end{equation}

Aircraft lift coefficient is given as follows:
\begin{equation}
  \label{eq-aero-lift-coef}
  C_L = C_{L0} + \alpha \frac{d C_L}{d \alpha}
\end{equation}

Substituting equation (\ref{eq-aero-lift-coef}) into (\ref{eq-aero-equilibrium-forces}) gives:
\begin{equation}
  mg = \frac{1}{2} \rho V^2 S
  \left( C_{L0} + \alpha \frac{d C_L}{d \alpha} \right)
\end{equation}

Solving this equation for angle of attack gives:
\begin{equation}
  \label{eq-aero-angle-of-attack}
  \alpha =
  \frac{ 2mg - \rho V^2 S C_{L0} }{ \rho V^2 S \cfrac{d C_L}{d \alpha} }
\end{equation}

Substituting equation (\ref{eq-aero-angle-of-attack}) into (\ref{eq-aero-incidence-angle}) gives:
\begin{equation}
  i_h =
  \frac{ 2 r_{CG} mg + \rho V^2 S \hat c C_m }
  { l_h \rho V^2 S_h \cfrac{d C_{L,h}}{d \alpha} }
  -
  \frac{ 2mg - \rho V^2 S C_{L0} }
  { \rho V^2 S \cfrac{d C_L}{d \alpha} }
  \left( 1 - \frac{\partial \epsilon}{\partial \alpha} \right)
\end{equation}

\section{Critical Angle of Attack}

Equilibrium of forces acting on an aircraft in level flight is given by the following equation:
\begin{equation}
  mg = \frac{1}{2} \rho V^2 \left( S C_L + S_h C_{L,h} \right)
\end{equation}

As conventional configuration airplanes have horizontal stabilizer negative incidence angle, it is assumed that horizontal stabilizer is within its lift linear range when maximum lift coefficient is reached.
\begin{equation}
  mg = \frac{1}{2} \rho V^2
  \left[
    S C_L
    +
    S_h \left(
      \alpha_{cr} + i_h
      -
      \alpha_{cr} \frac{\partial \epsilon}{\partial \alpha}
    \right)
    \frac{d C_{L,h}}{d \alpha}
  \right]
\end{equation}

Solving this equation for the maximum lift coefficient gives:
\begin{equation}
  \label{eq-aero-lift-coef-max-1}
  C_{L,max} =
  \frac{
    mg - \cfrac{1}{2} \rho V_{stall}^2 S_h
    \left(
      \alpha_{cr} + i_h
      -
      \alpha_{cr} \cfrac{\partial \epsilon}{\partial \alpha}
    \right)
    \cfrac{d C_{L,h}}{d \alpha}
  }
  {
    \cfrac{1}{2} \rho V_{stall}^2 S
  }
\end{equation}

Assuming that maximum lift coefficient is within linear range:
\begin{equation}
  \label{eq-aero-lift-coef-max-2}
  C_{L,max} =  C_{L0} + \alpha_{cr} \frac{d C_L}{d \alpha}
\end{equation}

Substituting equation (\ref{eq-aero-lift-coef-max-2}) into (\ref{eq-aero-lift-coef-max-1}) gives:
\begin{equation}
  C_{L0} + \alpha_{cr} \frac{d C_L}{d \alpha} =
  \frac{
    mg - \cfrac{1}{2} \rho V_{stall}^2 S_h
    \left(
      \alpha_{cr} + i_h
      -
      \alpha_{cr} \cfrac{\partial \epsilon}{\partial \alpha}
    \right)
    \cfrac{d C_{L,h}}{d \alpha}
  }
  {
    \cfrac{1}{2} \rho V_{stall}^2 S
  }
\end{equation}

Solving this equation for critical angle of attack gives
\begin{equation}
  \label{eq-aero-alpha-critical}
  \alpha_{cr} =
  \frac{
    2mg - \rho V_{stall}^2
    \left(
      S_h i_h \cfrac{d C_{L,h}}{d \alpha}
      +
      S C_{L0}
    \right)
  }
  {
    \rho V_{stall}^2
    \left[
      S \cfrac{d C_L}{d \alpha}
      +
      S_h \left( 1 - \cfrac{\partial \epsilon}{\partial \alpha} \right)
      \cfrac{d C_{L,h}}{d \alpha}
    \right]
  }
\end{equation}


\title{\bf Light I}

\section{Basics \& Nomenclature}

In astrophysical parlance, the {\it specific intensity} $I_\nu$ is the
flux of electromagnetic energy across a surface from a particular
direction, per unit area, per unit solid angle, per unit time, per
unit frequency. The specific intensity can also be expressed per unit
wavelength, and denoted in this case $I_\lambda$. For example, units
may be erg s$^{-1}$ cm$^{-2}$ Hz$^{-1}$ arcsec$^{-2}$ or erg s$^{-1}$
cm$^{-2}$ \AA$^{-1}$ arcsec$^{-2}$.  The term {\it surface brightness}
is often also used to denote the specific intensity.

The quantities $I_\nu$ and $I_\lambda$ are related:
\begin{eqnarray}
I_\nu(\nu) |{\rm d}\nu| &=& I_\lambda(\lambda = c/\nu) |{\rm
  d}\lambda| \cr
I_\nu(\nu) &=& \left|\frac{{\rm d}\lambda}{{\rm d}\nu}\right|
I_\lambda = \frac{c}{\nu^2} I_\lambda(\lambda = c/\nu) \cr
I_\lambda(\lambda) &=& \left|\frac{{\rm d}\nu}{{\rm d}\lambda}\right|
I_\nu = \frac{c}{\lambda^2} I_\nu(\nu = c/\lambda).
\end{eqnarray}

A {\it flux density} $f_\nu$ or $f_\lambda$ is the integral of the
specific intensity through the surface integrated over a range of
directions:
\begin{equation}
f_\nu = \int {\rm d}\Omega I_\nu \cos\theta.
\end{equation}
A special unit for flux density (mostly in use in radio astronomy) is
the Jansky, which is $10^{-23}$ erg s$^{-1}$ cm$^{-2}$
Hz$^{-1}$. Sometimes the flux density is also called the {\it spectral
  energy distribution}.

The electromagnetic wave can also be expressed in terms of
photons. The energy of photons correspond to a wavelength of light:
\begin{equation}
E_\nu = h\nu
\end{equation}

If an emitting object is moving along the line-of-sight to the
observer, the photon's wavelengths are shifted by a factor $(1+z)$
where $z$ is the redshift:
\begin{eqnarray}
\lambda_{\rm obs}  &=& (1+z) \lambda_{\rm emit} \cr
\nu_{\rm obs}  &=& \frac{\nu_{\rm emit}}{1+z}
\end{eqnarray}
The specific intensity and the flux is also altered by this
motion. Under both special and general relativity, the photon density
in phase space is conserved. From this it can be calculated that:
\begin{equation}
  \label{eq:sb_dimming}
  I_{\lambda, {\rm obs}} \dd\lambda_{\rm obs} =
  \frac{I_{\lambda, {\rm emit}} \dd\lambda_{\rm emit}}{(1+z)^4}
\end{equation}
At small velocities, $z \approx v/c$, but at higher velocities
relativistic corrections are important.

A {\it luminosity} is defined as the total energy emitted from some
source per unit time per unit frequency (or wavelength). It has
typical units of erg s$^{-1}$ Hz$^{-1}$ or erg s$^{-1}$
\AA$^{-1}$. For isotropically emitting sources, the total luminosity
is related to the observed flux as:
\begin{equation}
\label{eq:luminosity_distance}
f_\nu = \frac{L_\nu}{4\pi D^2}
\end{equation}
where $D$ is the distance to the source.

In a cosmological context (relevant at 100s of Mpc distance or so
depending on the required precision), there is not a single
well-defined distance to a source. The directly observable quantity is
the redshift $z$, associated with the Universe's expansion. In this
case $D$ must be the {\it luminosity distance}, sometimes denoted
$D_L$, defined to satisfy Equation \ref{eq:luminosity_distance}; its
relation to redshift depends on the cosmological parameters
(see \citealt{hogg99cosm}). The flux dependence on distance in
standard, general relativity-based cosmology is a combination of the
dependence of the angular size on distance times the surface
brightness dimming effect.

An analogous quantity, the {\it angular diameter distance} $D_A(z)$,
can be defined that satisfies the relation for small angles:
\begin{equation}
\theta = \frac{s}{D_A}
\end{equation}
where $s$ is a physical size of an object and $\theta$ is the angular
size of that object when observed at redshift $z$.

The flux density or specific intensity can only be measured at some
finite resolution in wavelength or frequency. In optical astronomical
parlance, a common expression of resolution is:
\begin{equation}
R = \frac{\lambda}{\Delta \lambda}
\end{equation}
where $\Delta \lambda$ is the full-width half maximum (FWHM) of the
line spread function (the Green's function response of the system to a
point source).

Optical and infrared instruments that measure the wavelength
dependence of the flux density through dispersal of the light (with
diffraction gratings or prisms in the optical) are typically known as
spectrographs. Existing instruments range in resolution from $R\sim
20$ to $R>100,000$.  At higher energies, in addition to dispersal
techniques, X-ray detectors and position sensitive proportional
counters also often have intrinsic energy sensitivity.  Radio
receivers separate signals into frequencies electronically.

Imaging instruments with wavelength-dependent sensitivity (either due
to the detector or through a band pass filter) can also measure the
wavelength dependence of the flux density or specific
intensity. Typically, this is performed more coarsely at about $R\sim
5$, though narrow band systems reach $R\sim 50$ or more (typically
though not quite always requiring one exposure per filter).

In the optical and infrared the use of such coarse band pass filters
means that the interpretation of the measurements at high precision
requiring knowing the band pass very well. A full interpretation of
the measurement involves also a model of the flux density. The
observations are usually interpreted as the ratio between the signal
received from the object to the signal that would have been received
by some standard source.

This quantity is termed a {\it maggie} and depends on the band
pass. It can be expressed in terms of a model for $f_\nu$ or
$f_\lambda$ of the object and $g_\nu$ or $g_\lambda$ of the standard
source:
\begin{eqnarray}
  \mu_b &=&
  \frac{\int {\rm d}\nu (f_\nu(\nu)/\nu) R_b(\nu)}
       {\int {\rm d}\nu (g_\nu(\nu)/\nu) R_b(\nu)} \cr
       &=&
  \frac{\int {\rm d}\lambda f_\lambda(\lambda) \lambda R_b(\lambda) }
       {\int {\rm d}\lambda g_\lambda(\lambda) \lambda R_b(\lambda)}
\end{eqnarray}
where $R(\lambda)$ or $R(\nu)$ is the contribution of a photon
entering Earth's atmosphere (or the aperture of a space telescope) to
the output signal of the instrument in band $b$. This formula is the
same for photon-counting and energy-counting devices, though note that
for the latter instrumentalists typically report a definition of
$R(\lambda)$ or $R(\nu)$ which is the contribution of an amount of
energy to the signal rather than that of a photon; therefore the
$R(\lambda)$ or $R(\nu)$ so defined needs to be transformed into
per-photon units.

Typical choices of $g_\nu$ are the spectrum of Vega (which is only
known to a few percent accuracy in the optical and near-infrared) and
the AB system of $g_\nu = 3631$ Jy (the flux density of Vega near 5500
\AA).  All absolute measurements are based on standards whose flux
densities are thought to be known, but only rarely by comparing
directly to Vega (which is too bright) and never to an AB source (they
don't exist). Relative measurements can be calibrated fairly precisely
independently of absolute calibration, though for broad band passes
the colors of the sources need to be accounted for.

The classical astronomical {\it magnitude} is defined as:
\begin{equation}
m = -2.5 \log_{10} \mu
\end{equation}
The bright end of this system corresponds roughly to the original
magnitude system developed by astronomers in the ancient world.

The luminosity is often expressed as the {\it absolute magnitude},
which is defined as the magnitude the object would have were it at
rest with respect to us, at 10 pc distance. For non-cosmologically
distant objects (within a few 10s of Mpc) this can be expressed as:
\begin{equation}
M = m - 5 \log_{10} \left(\frac{D}{10 {\rm ~pc}}\right) = m - {\rm DM}
\end{equation}
where DM is defined as the distance modulus.

At cosmological distances, two effects are important. First, $D$ must
be the luminosity distance. Second, the observed band pass corresponds
to a different part of the rest frame spectrum of the object for each
different redshift $z$. This effect is known as the $K$-correction,
defined as:
\begin{equation}
M = m - {\rm DM} - K(z; f_\lambda)
\end{equation}
Basically the $K$-correction accounts for the ratio of the observed to
rest frame flux given the shape of the flux density
$f_\lambda(\lambda)$ (it does not depend on the amplitude). It is
common at low redshifts to $K$-correct from the observed bandpass to
the same band pass in the rest frame. However, at higher redshift it
can be more stable to $K$-correct to a bandpass with a closer
effective wavelength to that observed. \citet{hogg02c} describes the
mathematical definition of the $K$-correction in all such cases.

\section{Commentary}

While the magnitude system was originally used for convenience in
calibration over a large dynamic range in brightness, it retains its
usefulness because of its encapsulation of the response function
$R(\lambda)$.  Sometimes measurements of $\mu$ are expressed in terms
of $f_{\lambda, {\rm eff}}$ at some choice of $\lambda_{\rm eff}$
(e.g. by just multiplying an AB maggie by 3631 Jy and using some
average effective wavelength of the filter), but for broad band passes
either $f_{\lambda, {\rm eff}}$ or $\lambda_{\rm eff}$ is a strong
function of the actual, often unknown $f_\lambda(\lambda)$. $\mu$ and
$m$ do not suffer from this dependence (though interpreting them
physically still can only be done by accounting for the filter curve
and a model for $f_\lambda(\lambda)$).

$K$-corrections depend on knowing the flux density itself, or at least
its wavelength dependence. To estimate that wavelength dependence
requires having a measurement or model. Thus, the $K$-correction is
naturally an uncertain quantity.

\section{Important numbers}

\begin{itemize}
\item $h\nu \sim 1$ eV for $\lambda \sim 1.2$ $\mu$m.
\item $\nu \sim 300$ THz for $\lambda \sim 1$ $\mu$m.
\item $\nu \sim 30$ GHz for $\lambda \sim 1$ cm.
\item $\nu \sim 1$ GHz for $\lambda \sim 1$ m.
\item $m_{V, {\rm Vega}} \sim 0$ mag.
\item $M_{V, \odot} \sim 5$ mag.
\end{itemize}

\section{Key References}

\begin{itemize}
  \item
    \href{http://adsabs.harvard.edu/abs/2000asqu.book.....C}{
    {\it Allen's Astrophysical Quantities},
      \citet{cox00a}}, Chapter 5
  \item
    \href{http://adsabs.harvard.edu/abs/1999astro.ph..5116H}{
    {\it Distance measures in Cosmology},
      \citet{hogg99cosm}}
  \item
    \href{http://adsabs.harvard.edu/abs/2002astro.ph.10394H}{
    {\it The $K$-correction},
      \citet{hogg02c}}
\end{itemize}

\section{Order-of-magnitude Exercises}

\begin{enumerate}
\item If Vega is about 8 parsecs away and has $m_V \sim 0$, how far
  away would it be visible through the deepest images from the Hubble
  Space Telescope ($m_V\sim 30$)?

\begin{answer}
  The magnitude difference of 30
    corresponds to a factor of $10^{12}$ in luminosity. Using Equation
    \ref{eq:luminosity_distance}, this translates to $10^6$ in
    distance. So Vega-like stars are visible (in principle) to about 8
    Mpc. In practice, if such stars were in another galaxy, it is very
    difficult to resolve them from the other stars in the galaxy; if
    they were free-floating between galaxies there are still a high
    density of 30th magnitude galaxies causing confusion in the image.
\end{answer}

\item Estimate the number of photons per second that enter your eye
    per second in visible light (4000--7000 \AA) from a star with
  magnitude $\sim 6$ (about the faintest visible at a dark
  site). Assume a nighttime pupil diameter of 5 mm.

\begin{answer}
In this wavelength range, Vega and AB magnitudes are about the same at
the precision necessary here, so we don't have to worry about which
version we are dealing with. So:
\begin{equation}
f_\nu \sim (3631 \mathrm{~Jy}) 10^{-0.4 m} \sim 14 \mathrm{~Jy} = 1.4 \times
10^{-22} \mathrm{~erg} \mathrm{~cm}^{-2} \mathrm{~s}^{-1} \mathrm{~Hz}^{-1}
\end{equation}
The flux density in the visible should be $f_\nu \Delta\nu$ where:
\begin{equation}
\Delta\nu = c \left(\frac{1}{4000 \mathrm{~\AA}} -
\frac{1}{7000 \mathrm{~\AA}}\right) \sim 320 \mathrm{~THz},
\end{equation}
and thus $f \sim 4\times 10^{-8}$ erg cm$^{-2}$ s$^{-1}$. Each photon
has an energy (assuming $\lambda = 5500$ \AA):
\begin{equation}
E = h\nu = (6.62\times
10^{-27} \mathrm{~erg~Hz}^{-1})( \mathrm{550~THz}) \sim 4 \times
10^{-12} \mathrm{~erg}.
\end{equation}
So the flux of photons is:
\begin{equation}
\frac{\dot N}{A} = \frac{f_\nu \Delta\nu}{h\nu} \sim
10^4 \mathrm{~s}^{-1} \mathrm{~cm}^{-2}.
\end{equation}
If $A \sim \pi r^2 \sim 0.2$ cm$^2$ then $\dot N \sim 2000$ s$^{-1}$.
\end{answer}

\item How much does surface brightness dimming change the magnitudes
  per square arcsecond for a galaxy at redshift $z\sim 1$?

\begin{answer}
The specific intensity integrated over all wavelengths is reduced by
$(1+z)^4$. In magnitudes this is:
\begin{equation}
\Delta m = 2.5 \log_{10} (1+z)^4 = 10 \log_{10} (1+z) \sim
3 \mathrm{~mag}
\end{equation}
\end{answer}
\end{enumerate}

\section{Analytic Exercises}

\begin{enumerate}
\item For a Gaussian line spread function with a standard deviation
  $\sigma$, what is the FWHM?

\begin{answer}
The FWHM is twice the distance from the peak to the point halfway down
the peak, so it is determined by:
\begin{equation}
\exp\left(- ({\rm FWHM} / 2)^2 / 2 \sigma^2\right) = 0.5.
\end{equation}
Solving for the FWHM yields:
\begin{equation}
{\rm FWHM} = 2 \sqrt{2\ln 2} \sigma \approx 2.35 \sigma
\end{equation}
\end{answer}
\item Prove Equation \ref{eq:sb_dimming}, based on the fact that
  photon density in phase space is conserved.

\begin{answer}[Author: Trey Jensen]
Beginning with the photon particle distribution, $f(x,p,t)$, we know
that subject only to cosmic expansion, the number of photons will be
conserved,
\begin{equation}
\dd N =f(x,p,t)\dd V \dd^3 p.
\end{equation}
If we rewrite the right hand side in the suggestive manner,
\begin{equation}
f(x,p,t)p^2\dd x \dd A \dd p \dd \Omega,
\end{equation}
where $\dd A$ is the area element, $\dd \Omega$ the solid angle
element of momenta (direction of propagation), then we see this can be
written with the specfic intensity in mind. The specific intensity is
the flux of energy through a surface per area, per solid angle, per
time, per frequency. We can get an infinitesimal number of photons
via,
\begin{equation}
 \dd N =\frac{I_\nu}{E} \dd A \dd \Omega  \dd t \dd \nu.
\end{equation}
Equating these two equations of $\dd N$, and because we have massless
particles, $p=E=h\nu$, then using the fact that $\dd x / \dd t = c$:
\begin{equation}
    I_\nu=f(x,p,t)h^{4} \nu^3 c
\end{equation}
In the FRW metric, frequency $\nu$ scales inversely with $a(t)$ (this
can also be derived from the geodesic equation of a photon). Thus,
inspecting the above equation,
\begin{equation}
    I_\nu\propto a(t)^{3} = \frac{1}{(1+z)^3}.
\end{equation}
Then if we consider the integral of $I_\nu$:
\begin{equation}
    I_{\nu, \rm obs} \dd\nu_{\rm obs}  =
    \frac{1}{(1+z)^4} I_{\nu, \rm emit} \dd\nu_{\rm emit}
\end{equation}
and similar for $I_\lambda$.
\end{answer}

\item Based on Equation \ref{eq:sb_dimming}, how is the angular
  diameter distance related to the luminosity distance?

\begin{answer}
The angular diameter distance must satisfy:
\begin{equation}
\label{eq:da}
D_A = \frac{s}{\theta}
\end{equation}
Take a uniform surface brightness sphere of radius $s$. The flux
density must satisfy two equalities:
\begin{equation}
f_\nu = \frac{L_\nu}{4\pi D_L^2} = I_\nu \pi \theta^2.
\end{equation}
Using Equation \ref{eq:sb_dimming} and \ref{eq:da}, the second equality
implies:
\begin{equation}
\frac{L_\nu}{4\pi D_L^2} = I_\nu \pi \theta^2 = \frac{I_{\nu, 0} \pi
s^2}{(1+z)^4 D_A^2}.
\end{equation}
Then using $L=4\pi s^2 I_{\nu, 0}$ we find:
\begin{equation}
D_L = (1+z)^2 D_A
\end{equation}
\end{answer}
\end{enumerate}

\section{Numerics and Data Exercises}

\begin{enumerate}
\item Retrieve a spectrum of a star, a quasar, and a galaxy from the
  Sloan Digital Sky Survey. Plot each of them. These spectra are given
  in $f_\lambda$ (per-\AA) units. Convert one them to $f_\nu$
  (per-Hertz) and plot it. Smooth one of them in $f_\lambda$ with a
  Gaussian corresponding to $R\sim 1000$ and plot it.
\item Plot $D_L$ versus $z$ based on the equations found
  in \citet{hogg99cosm}, for a flat $\Lambda$CDM cosmology with
  $\Omega_m = 0.3$ and $H_0 = 70$ km s$^{-1}$ Mpc$^{-1}$. Determine
  where the difference in inferred luminosity of an object, relative
  to assuming $D_L = cz / H_0$, would reach 1\%.
\item Download the filter curve for the SDSS $g$ and $r$
  bands. Calculate the observed $g$ and $r$ band magnitudes
  corresponding to a galaxy spectrum (say for some galaxy with $z \sim
  0.15$ or greater). Note that this won't necessarily be the same as
  the magnitudes measured from the images, since the spectra are taken
  through 2- or 3-arcsec diameter fibers. Calculate the rest-frame
  $g-r$ color, and also what the $K$-correction would be for galaxies
  with this SED in the $r$-band between about $z\sim 0$ and $z\sim
  0.25$. Download the photometric data for a sample of galaxies
  between about $z\sim 0$ and
  $0.25$. Plot their $g-r$ colors versus redshift, together with the
  predicted colors of the galaxy you have a spectrum of.
\item The \href{http://www.mpia.de/THINGS}{THINGS survey} maps a
  number of nearby galaxies in 21-cm radio emission, mapping a
  hyperfine transition in hydrogen. Download the data on the galaxy
  NGC 2403 and estimate its rotation velocity at the furthest
  measurable points (it is all right to do this by eyeballing rather
  than a detailed fit).
\item Using the ROSAT all sky survey (for example
  at \href{http://www.xray.mpe.mpg.de/cgi-bin/rosat/rosat-survey}{this
  web site}), find an X-ray image of the center of the galaxy NGC
  1068. Compare this to the X-ray image of the center of the galaxy
  NGC 3992. Use the hardest (highest energy) band available from the
  Position Sensitive Proportional Counter (PSPC) images
\end{enumerate}

\bibliographystyle{apj}
\bibliography{exex}


\documentclass[11pt,a4paper]{article}
\usepackage[vmargin=15mm,hmargin=20mm]{geometry}     % margins
\usepackage{natbib}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{bm}
\usepackage[colorlinks=true,allcolors=blue]{hyperref}
\setlength{\parskip}{\baselineskip}
\DeclareMathOperator{\sech}{sech}

\title{\texttt{mw\_poisson}: Mathematical Background}
\author{A. P. Naik}
\date{July 2020}

\begin{document}

\maketitle

This document details some of the mathematics underpinning the \texttt{mw\_poisson} package, and provides further references. \texttt{mw\_poisson} is a python-3 package providing a Poisson solver for the (axisymmetric) Milky Way potential, essentially a vectorised, python alternative to \href{https://github.com/PaulMcMillan-Astro/GalPot}{GalPot}.

The Poisson solver is based on the method described in \citet{Dehnen1998}, designed for the solution of Poisson's equation in the context of an axisymmetric discoid mass distribution.

The parameterisation of the Milky Way density profile is the empirical model of \citet{McMillan2017}. As well as the best-fitting model of \citet{McMillan2017}, other parameter values for the various components can also be adopted, including some 'meta-parameters' such as the slope of the dark matter halo.

\section{Spheroid-Disc Decomposition}

Given some model for the density distribution $\rho(\bm{x})$ of our Galaxy, our goal is to calculate the corresponding gravitational potential $\Phi(\bm{x})$ by solving Poisson's equation
\begin{equation}
    \nabla^2 \Phi = 4\pi G \rho.
\end{equation}
One way to go about this would be to perform a direct spherical harmonic expansion. However, such methods can be slow to converge if a component is strongly confined to the disc plane. Fortunately, \citet{Dehnen1998} describe an alternative method that can be employed in such circumstances, provided the density distribution is axisymmetric. In a nutshell, the potential is decomposed into an analytic disc-plane component, plus another component that needs to be calculated numerically. This latter component is less strongly confined to the disc plane, and so the spherical harmonic expansion method is more effective.

For the method to work, we require that $\rho(\bm{x})$ can be written as a linear combination of various discoid and spheroid components, i.e.
\begin{equation}
    \rho = \sum_i \rho_{d,i} + \sum_j \rho_{s,j},
\end{equation}
where the spheroids $\rho_{s,j}$ need not be spherically symmetric, just not too strongly confined to the disc plane. The discoid components $\rho_{d,i}$ must be separable, i.e. it can be written as
\begin{equation}
\label{E:rho_disc}
    \rho_{d,i}(R,z) = \Sigma_i(R)\zeta_i(z),
\end{equation}
where the normalisation is such that
\begin{equation}
\label{E:zeta_norm}
    \int_{-\infty}^{-\infty} \zeta(z) dz = 1.
\end{equation}

Then, the potential can be written as
\begin{equation}
    \Phi = \Phi_\mathrm{ME} + \Phi_\mathrm{disc},
\end{equation}
where $\Phi_\mathrm{disc}$ can be written analytically as
\begin{equation}
    \Phi_\mathrm{disc} = 4\pi G \sum_i \Sigma_i(r)H_i(z),
\end{equation}
and $H(z)$ is a function that satisfies $H''(z) = \zeta(z)$ and $H'(0)=H(0)=0$. Note that the argument of $\Sigma$ here is the spherical radius $r$ rather than the cylindrical radius $R$.

Meanwhile, the other component $\Phi_\mathrm{ME}$ solves a new Poisson equation
\begin{equation}
\label{E:PoissonME}
    \nabla^2 \Phi_\mathrm{ME} = 4\pi G \rho_\mathrm{ME},
\end{equation}
where the `density' is given by
\begin{equation}
\label{E:rho_ME}
    \rho_\mathrm{ME} \equiv \sum_i \left[\left(\Sigma_i(R)-\Sigma_i(r)\right)\zeta_i(z) - \Sigma_i''(r)H_i(z) - \frac{2}{r}\Sigma_i'(r)\left(H_i(z) + zH_i'(z)\right)\right] + \sum_j \rho_{s,j}.
\end{equation}
As required, this is less strongly confined to the disc-plane than the true density (e.g., $\rho_\mathrm{ME}=0$ in the disc-plane). Thus, a spherical harmonic expansion for will converge quickly on a solution for Eq. (\ref{E:PoissonME}). This spherical harmonic method is the subject of the next section.

\section{Spherical Harmonic Solver}

According to \citet[][Eq. 2.95]{Binney2008}, a gravitational potential $\Phi$ can be expanded in terms of spherical harmonics $Y_l^m$ as
\begin{equation}
\label{E:phi_sh_full}
    \Phi(r, \theta, \phi) = - 4\pi G \sum_{l=0}^\infty \sum_{m=-l}^l \frac{Y_l^m(\theta,\phi)}{2l+1}\left(r^{-l-1}\int_0^r dr' r'^{l+2} \rho_{lm}(r')+ r^l\int_r^\infty dr' r'^{1-l} \rho_{lm}(r') \right),
\end{equation}
where the density coefficient $\rho_{lm}(r)$ relates to a given density distribution $\rho(\bm{x})$ via
\begin{equation}
\label{E:rholm}
    \rho_{lm}(r) \equiv \int_0^\pi d\theta \sin(\theta) \int_0^{2\pi} d\phi Y_l^{m*}(\theta,\phi)\rho(r, \theta, \phi).
\end{equation}
Note that $Y_l^{m*}$ is the complex conjugate of $Y_l^{m}$.

Because $Y_l^{m*} \propto e^{-i m \phi}$, if an axisymmetric density distribution is assumed then the $\phi$ integral in Eq. (\ref{E:rholm}) vanishes for $m \neq 0$. The expression for the gravitational potential (\ref{E:phi_sh_full}) then simplifies to
\begin{equation}
    \Phi(r, \theta) = - 4\pi G \sum_{l=0}^\infty \frac{Y_l^0(\theta)}{2l+1}\left(r^{-l-1}\int_0^r dr' r'^{l+2} \rho_{l0}(r')+ r^l\int_r^\infty dr' r'^{1-l} \rho_{l0}(r') \right).
\end{equation}

Finer resolution is required in the central regions the galaxy than at larger distances, so it is convenient to instead use $q \equiv \ln r$ as the coordinate in the radial integration. Then,
\begin{equation}
    \Phi(r, \theta) = - 4\pi G \sum_{l=0}^\infty \frac{Y_l^0(\theta)}{2l+1}\left(r^{-l-1}\int_0^{\ln r} dq e^{(l+3)q} \rho_{l0}(q)+ r^l\int_{\ln r}^\infty dq e^{(2-l)q} \rho_{l0}(r') \right).
\end{equation}

To calculate $\Phi(r, \theta)$ numerically, one can construct a regular coordinate grid in $q$ and $\theta$, i.e., using \texttt{python}-indexing: $q \rightarrow \{q_0, q_1, q_2, ..., q_{M-1}\}$ and $\theta \rightarrow \{\theta_0, \theta_1, \theta_2, ..., \theta_{N-1}\}$, respectively with constant grid spacings $h_q$ and $h_\theta$. The $\theta$ grid spans $0$ to $\pi$, while $q$ is bounded by some minimum and maximum radius chosen by hand, ensuring the full dynamic range of the galaxy is captured. Converting the integrals to discrete sums, one then obtains
\begin{equation}
    \Phi(r_i, \theta_j) = - 8\pi^2 G h_q h_\theta \sum_{l=0}^\infty \frac{Y_l^0(\theta_j)}{2l+1} C_i^l,
\end{equation}
\begin{equation}
    C_i^l \equiv r_i^{-l-1}\sum_{a=0}^{i}\sum_b e^{(l+3)q_a} Y_l^{0*}(\theta_b) \sin(\theta_b) \rho(r_a, \theta_b) + r_i^l\sum_{a=i+1}^{M-1}\sum_b e^{(2-l)q_a} Y_l^{0*}(\theta_b) \sin(\theta_b) \rho(r_a, \theta_b).
\end{equation}
Of course in practice, one must truncate the sum over $l$ at some value.

\section{Parametric Models}

\subsection{Spheroid}

For the spheroidal components of the galaxy (e.g. bulge, halo), the program assumes the following axisymmetric form for the density profile:
\begin{equation}
\label{E:rho_spheroid}
    \rho_s(R,z) = \frac{\rho_0}{\left(\frac{r'}{r_0}\right)^\beta\left(1+\frac{r'}{r_0}\right)^\alpha}e^{-\left(\frac{r'}{r_\mathrm{cut}}\right)^2},
\end{equation}
where $r' \equiv \sqrt{R^2 + (z/q)^2}$. The profile is thus specified by six parameters: the normalisation $\rho_0$, the outer slope $\alpha$, the inner slope $\beta$, the scale radius $r_0$, the cutoff radius $r_\mathrm{cut}$, and the flattening $q$.

An arbitrary number of such spheroids, with different parameter combinations can be included in the Poisson solver. Various commonly-used density profiles can be recovered from Eq. (\ref{E:rho_spheroid}) after some parameter specification. For instance, the NFW profile corresponds to $\beta=1, \alpha=2, r_\mathrm{cut}=\infty, q=1$.

\citet{McMillan2017} use an axisymmetric Bissantz-Gerhard model for the Milky Way bulge, and an NFW profile for the dark matter halo. The best-fitting parameter values of these are reproduced in the table below.

\begin{center}
    \begin{tabular}{l c c c c c c}\toprule[1.5pt]
    Component & \multicolumn{6}{c}{Parameter} \\
              & $\rho_0$                & $\alpha$ & $\beta$ & $r_0$   & $r_\mathrm{cut}$ & $q$ \\
              & $M_\odot/\mathrm{pc}^3$ & -        & -       & kpc     & kpc              & -   \\ \midrule[0.5pt]
    Bulge     & 98.351                  & 1.8      & 0       & 0.075   & 2.1              & 0.5 \\
    Halo      & 0.00853702              & 2        & 1       & 19.5725 & $\infty$         & 1   \\ \bottomrule[1.5pt]
    \end{tabular}
\end{center}

\subsection{Disc}

According to Eq. (\ref{E:rho_disc}), the disc density profile is specified by two functions, the radial surface density $\Sigma(R)$ and the vertical profile $\zeta(z)$. For $\Sigma(R)$, the program assumes a `holed' exponential disc, i.e.
\begin{equation}
    \Sigma(R) = \Sigma_0 e^{-x},
\end{equation}
where $x \equiv R_h/R+ R/R_0$, $\Sigma_0$ is the density normalisation, and $R_0$ and $R_h$ are respectively the scale radius and radius of the central hole. Equation \ref{E:rho_ME} requires expressions for the first and second derivatives of $\Sigma$. These are given by
\begin{align}
    \Sigma'(R)  & = -\frac{\Sigma_0}{R_0} e^{-x} \left(1 - \frac{R_h R_0}{R^2}\right) ,\\
    \Sigma''(R) & = \frac{\Sigma_0}{R_0^2} e^{-x} \left[\left(1 - \frac{R_h R_0}{R^2}\right)^2 - \frac{2R_h R_0^2}{R^3}\right] .
\end{align}

Meanwhile, for the vertical profile $\zeta(z)$, the program can optionally adopt either an exponential or a sech\textsuperscript{2} profile. In the former case,
\begin{equation}
    \zeta(z) = \frac{1}{2z_0}e^{-\frac{|z|}{z_0}},
\end{equation}
where $z_0$ is the scale height of the disc. Note that the factor $1/2z_0$ ensures that Eq. (\ref{E:zeta_norm}) is satisfied, i.e. $\zeta$ is properly normalised. The corresponding functions $H(z)$ function and its first derivative $H'(z)$ are given by
\begin{align}
    H(z)  & = \frac{z_0}{2} \left(e^{-\frac{|z|}{z_0}} - 1 + \frac{|z|}{z_0}\right), \\
    H'(z) & = \frac{z}{2z_0} \left(1 - e^{-\frac{|z|}{z_0}}\right).
\end{align}
It can be verified that $H''(z) = \zeta(z)$ and $H'(0)=H(0)=0$.

For the sech\textsuperscript{2} profile, these functions are instead given by the following expressions, which also satisfy the various requirements:
\begin{align}
    \zeta(z) & = \frac{1}{4z_0}\sech^2\left(\frac{z}{2z_0}\right),\\
    H(z)     & = z_0 \ln\left(\cosh\left(\frac{z}{2z_0}\right)\right), \\
    H'(z)    & = \frac{1}{2} \tanh\left(\frac{z}{2z_0}\right).
\end{align}

Thus, the disc density is specified by the choice of vertical profile and four parameters: $\Sigma_0, R_0, R_h$, and $z_0$. As with the spheroids above, an arbitrary number of such discs with different parameter combinations can be included in the calculation.

The Milky Way model of \citet{McMillan2017} incorporates four disc components: neutral and molecular hydrogen discs, and thin and thick stellar discs. The best-fitting parameters (and vertical shapes) of these discs are reproduced in the table below.

\begin{center}
    \begin{tabular}{l l c c c c}\toprule[1.5pt]
    Component          & Vertical Profile & \multicolumn{4}{c}{Parameter} \\
                       &                  & $\Sigma_0$              & $R_0$   & $R_h$ & $z_0$ \\
                       &                  & $M_\odot/\mathrm{pc}^2$ & kpc     & kpc   & pc    \\ \midrule[0.5pt]
    Thin               & Exponential      & 895.679                 & 2.49955 & 0     & 300   \\
    Thick              & Exponential      & 183.444                 & 3.02134 & 0     & 900   \\
    HI                 & $\sech^2$        & 53.1319                 & 7       & 4     & 85    \\
    H\textsubscript{2} & $\sech^2$        & 2179.95                 & 1.5     & 12    & 45    \\ \bottomrule[1.5pt]
    \end{tabular}
\end{center}

\bibliographystyle{mnras}
\bibliography{library}

\end{document}


\section{Homogenization Approach}

The main objective of up-scaling DEM simulations is to be able to describe the  behavior of the discontinuous medium in terms of a more computationally efficient continuum model. The homogenization algorithms used herein to determine the average stress-strain behaviour, $\left<\boldsymbol{\sigma}\right>$-$\left<\boldsymbol{\epsilon}\right>$, of the REV from the microscale displacements $\mathbf{u}^m$, strain $\boldsymbol{\epsilon}^m$, and stresses $\boldsymbol{\sigma}^m$ are based on the methods developed by D'Addetta et al. \citet{daddetta_particle_2004} and Wellmann et al. \citet{wellmann_homogenization_2008}. In this homogenization process, the resultant inter-block contact forces and block displacement from the DEM simulations are converted to average stresses and strains.

For the homogenization procedure to yield meaningful results, it should be applied to a Representative Elementary Volume (REV). The exact size of the REV depends on the geometry and mechanical properties of the DEM model. For the homogenization approach to hold, the REV of size $d$ within a system with a characteristic length $D$ and consisting of blocks with a characteristic diameter $\delta$, must satisfy scale separation: $D\gg d\gg\delta$ \citep{wellmann_homogenization_2008}.

In the following sections, all deformations are assumed to be small, such that there is no need to differentiate between the deformed and undeformed configurations.

We begin by defining a $L\times L$ square DEM simulation domain over which mixed-boundary conditions will be applied. The REV is taken as a circular domain of radius $R$, $2R<L$.  The REV is taken to be a subdomain of the actual DEM simulation domain to eliminate any boundary effects.  As will be seen below, it is convenient to take the boundary of the domain used for homogenization as a slightly large domain encompassing the REV boundary. The boundary of the homogenization domain, denoted as $\Gamma_h$, is defined by the outer edges of the deformable blocks, i.e., the cohesive/contact surfaces between deformable blocks, which intersect a circle of radius $R$ located in the center of the DEM simulation domain. Let the homogenization domain, the domain bounded by $\Gamma_h$, be denoted by $\Omega_h$. These definitions are illustrated in Figure \ref{fig:homoarea} for a $10$m $\times$ $10$m DEM domain, where the deformable blocks are defined through a Voronoi tessellation. The radius of the REV domain is $2.5$m.  It can be seen that the actual domain used for homogenization is non-circular and larger than the REV domain.


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

\marginpar{Tuesday\\ 2020-8-18, \\ compiled \\ \today}

This parametric equation is expressed with respect to the principal axes of the ellipse; if we want to write in a different coordinate system which is obtained from a rotation of the principal axes we must use the rotation matrix
%
\begin{align}
\left[\begin{array}{c}
x \\
y
\end{array}\right]
=
\left[\begin{array}{cc}
\cos \chi  & -\sin \chi   \\
\sin \chi  &  \cos \chi
\end{array}\right]
\left[\begin{array}{c}
x' \\
y'
\end{array}\right]
\,;
\end{align}
%
if we make \(x'\) and \(y'\) explicit we can find
%
\begin{align}
x &= A \cos \beta \cos \chi \cos \omega t + A \sin \beta \sin \chi \sin \omega t \\
y &= A \cos \beta \sin \chi \cos \omega t - A \sin \beta \cos \chi \sin \omega t
\,.
\end{align}

The expressions for \(x\) and \(y\) and the ones for \(E_x\) and \(E_y\) are quite similar: we must identify
%
\begin{align}
\xi_1 \cos \phi_1 &= A \cos \beta \cos \chi \\
\xi_1 \sin \phi_1 &= A \sin \beta \sin \chi \\
\xi_2 \cos \phi_2 &= A \cos \beta \sin \chi \\
\xi_2 \sin \phi_2 &= -A \sin \beta \cos \chi
\,,
\end{align}
%
which means that the electric field rotates in the shape of an ellipse, which is tilted about the \(x\), \(y\) axes by an angle \(\chi \).

\subsubsection{Stokes parameters}

From these four equations, we find that (after working through the simplifications of the trigonometric functions)
%
\begin{align}
\xi_1^2 + \xi_2^2 &= A^2 \overset{\text{def}}{=} I \\
\xi_1^2 - \xi_2^2 &= A^2 \cos 2 \beta \cos 2 \chi  \overset{\text{def}}{=} Q \\
2 \xi_1 \xi_2 \cos(\phi_1 - \phi_2 ) &= A^2 \sin 2 \chi \cos 2 \beta \overset{\text{def}}{=} U \\
2 \xi_1 \xi_2 \sin(\phi_1 - \phi_2 ) &= A^2 \sin 2 \beta \overset{\text{def}}{=} V
\,,
\end{align}
%
where we defined the \textbf{Stokes parameters} \(I\), \(Q\), \(U\) and \(V\).\footnote{They can also be expressed as the difference of the square modulus of the electric field with respect to three bases (corresponding to the three Pauli matrices): one Cartesian (for \(Q\), \(\sigma _z\)) one Cartesian rotated by \SI{45}{\degree} (for \(U\), \(\sigma _x\)) and one circular (for \(V\), \(\sigma _y\)).} They completely describe the state of an elliptically polarized monochromatic wave.

We can reverse their definitions as
%
\begin{align}
A &= \sqrt{I}  \\
\sin 2 \beta &= \frac{V}{I} \\
\tan 2 \chi &= \frac{U}{Q}
\,.
\end{align}

Now let us discuss the meaning of these parameters. Since \(A = \xi_0 \), \(I = \xi_0^2\), while the energy flux is given by
%
\begin{align}
S = \frac{c}{4 \pi } \xi_0^2 = \frac{c}{4 \pi } I
\,.
\end{align}

So, the parameter \(I\) is directly proportional to the energy flux.
The major axes of the polarization ellipse are \(2A \cos \beta \) and \(2 A \sin \beta \) respectively; therefore their ratio \(\tan \beta \) measures the eccentricity of the ellipse, and the ratio \(V/I\) can be used to recover \(\beta \).

The ratio \(U/Q\) describes the orientation  of the ellipse with respect to the \(x\), \(y\) axes.
If the wave is linearly polarized then  \(V =0 \) (this is a degenerate case for our description); if \(V > 0\) the polarization  is left-handed, while if \(V< 0\) the polarization is right-handed.

If we have \(U = Q = 0\), this corresponds to circular polarization.

The ellipse is fully determined by three numbers (\(\beta \), \(\chi \), \(A\)): why are there 4 Stokes parameters? They cannot all be independent if this is the case\dots

In fact, they are connected by the relation
%
\begin{align}
I^2= Q^2 + V^2+ U^2
\,.
\end{align}

The reason we use four parameters instead of just three is that this line of reasoning only holds for perfectly polarized monochromatic waves: in the general case, for partially polarized radiation, we have
%
\begin{align}
I^2 \geq Q^2 + V^2 + U^2
\,.
\end{align}

For completely \emph{un}polarized light we have \(Q = V = U = 0\).

A useful property is that these parameters are \textbf{additive}: the superposition of waves with different Stokes parameters can be the described by the sum of the Stokes parameters, as \(I _{\text{total}} = \sum _{k} I_k\) and so on.

This suggests that we write them in a vector:
%
\begin{align}
\vec{S} = \left[\begin{array}{c}
I \\
Q \\
U \\
V
\end{array}\right]
\,.
\end{align}

In general, we can decompose radiation which is partially polarized into a completely unpolarized part and a completely polarized part:
%
\begin{align}
\vec{S} = \underbrace{\left[\begin{array}{c}
I - \sqrt{Q^2+V^2+U^2} \\
0 \\
0 \\
0
\end{array}\right]}_{\text{unpolarized}}
+
\underbrace{\left[\begin{array}{c}
\sqrt{Q^2+V^2+U^2} \\
Q \\
U \\
V
\end{array}\right]}_{\text{polarized}}
\,.
\end{align}

This allows us to define the \textbf{polarization degree}: the fraction of the radiation which is polarized, calculated as
%
\begin{align}
\Pi_{L} = \frac{I _{\text{polarized}}}{I} = \frac{\sqrt{Q^2+U^2+V^2}}{I}
\,,
\end{align}
%
which is measurable with an instrument.

\subsubsection{Electromagnetic potentials}

We can express the electric and magnetic fields through the scalar and vector potentials \(\phi \) and \(\vec{A}\):
%
\begin{align}
\vec{B} = \vec{\nabla} \times \vec{A}
\qquad \text{and} \qquad
\vec{E} = - \vec{\nabla} \phi - \frac{1}{c} \pdv{\vec{A}}{t}
\,.
\end{align}

In terms of these potentials Maxwell's equations read
%
\begin{align}
\nabla^2 \phi - \frac{1}{c^2} \pdv[2]{\phi }{t} &= - 4 \pi \rho \\
\nabla^2 \vec{A} - \frac{1}{c^2} \pdv[2]{\vec{A}}{t} &= - \frac{4 \pi }{c} \vec{j}
\,.
\end{align}

The potentials are redundant, we can impose some conditions on them while still being able to describe any physical system. One we can impose is the \emph{Lorentz gauge}:
%
\begin{align}
\vec{\nabla} \cdot \vec{A} + \frac{1}{c} \pdv{\phi }{t} = 0
\,,
\end{align}
%
under which we can get a formal solution for the potentials in terms of the charge and current densities:
%
\begin{align}
\phi (\vec{r}, t) &= \int \frac{[ \rho ]}{\abs{\vec{r} - \vec{r}'}} \dd[3]{r'} \\
\vec{A} (\vec{r}, t) &= \frac{1}{c} \int \frac{[ \vec{j} ]}{\abs{\vec{r} - \vec{r}'}} \dd[3]{r'}
\,.
\end{align}

The square brackets are a notation meaning that the densities must be evaluated at the \emph{retarded time} \(t - \abs{\vec{r} - \vec{r}'} / c\).
This accounts for the finite speed of the propagation of light.

\subsubsection{Radiation from moving charges}

Consider a particle of mass \(m\) and charge \(q\) moving along a path described by the vector \(\vec{r}_0 (t)\). The charge and current densities will then be
%
\begin{align}
\rho (\vec{r}, t) &= q \delta (\vec{r} - \vec{r}_0(t)) \\
\vec{j} (\vec{r}, t) &= q \underbrace{\dv{\vec{r}_0}{t}}_{\vec{u}(t)} \delta (\vec{r} - \vec{r}_0(t))
\,.
\end{align}

From these expressions we can calculate the potentials generated by the moving charge. Let us introduce the relative radius \(\vec{R} = \vec{r} - \vec{r}_0\) and its corresponding unit vector \(\vec{n} = \vec{R} / \abs{\vec{R}}\).

The potentials will then be
%
\begin{align}
\phi = \qty[\frac{q}{kR}] \qquad \text{and} \qquad
\vec{A} = \qty[\frac{q \vec{n}}{ckR}]
\,,
\end{align}
%
where \(k = 1 - \vec{n} \cdot \vec{u} / c\), while \(R = \abs{\vec{R}}\).
These are called the \textbf{Liénard-Wiechert} potentials.
From them we can perform the differentiation in order to recover the fields, which will be called the Liénard-Wiechert fields.
The final expressions for the fields are
%
\begin{align}
\vec{E} (\vec{r}, t) &= q \qty[\frac{(\vec{n} - \vec{\beta}) (1- \beta^2)}{ k^3 R^2}] + \frac{q}{c} \qty[\frac{\vec{n}}{k^3R} \times \qty((\vec{n} - \vec{\beta}) \times \dot{\vec{\beta}})] \\
\vec{B}(\vec{r}, t) &= \qty[\vec{n} \times \vec{E}]
\,,
\end{align}
%
where \(\vec{\beta} = \vec{u} / c\).
The important thing to notice here is that there are two contributions to the electric field: one goes as \(R^{-2}\) and is called the \textbf{Coulomb field} \(\vec{E}_c\) and the other goes as \(R^{-1}\) and is called the \textbf{radiation field} \(\vec{E}_r\).

Now we will discuss the radiation field mainly. Since the magnetic field can be found by taking a product with the electric field, we can make the same decomposition there.

The radiation field \(\vec{E}_r\) must be perpendicular to \(\vec{n}\), and so must be \(\vec{B}_r\). So, they form an orthogonal triple.

Let us consider some simple cases.

\subsubsection{Nonrelativistic charge}

Let us first suppose that the particle is moving slowly, \(\abs{u}/ c = \abs{\beta } \ll 1 \): this means that \(\abs{\vec{n} - \beta } \sim 1\) and also \(k \sim 1\).

With these simplifications we find that the ratio of the magnitudes of the two components of the electric field is
%
\begin{align}
\frac{E_r}{E_c} \sim \frac{R \dot{u}}{c^2}
\,.
\end{align}

If the characteristic time across which the velocity of the particle changes is \(\tau \), then we have \(\dot{u} \sim u / \tau\).
This time \(\tau \) will be associated with a characteristic frequency \(\nu = 1 / \tau \) and a characteristic wavelength \(\lambda = c / \nu \).
\todo[inline]{\dots and this is the wavelength of the emitted radiation? is this always the case? it does not seem that obvious}

Then we will get
%
\begin{align}
\frac{E_r}{E_c} \sim \frac{R u \nu }{c^2} \sim \frac{R u}{\lambda c}
\,,
\end{align}
%
so we can see that if
%
\begin{align}
\frac{R}{\lambda } \lesssim 1
\,
\end{align}
%
then we have \(E_r / E_c \lesssim u /c\). This defines an inner region around the emitter for which the Coulomb field dominates; outside it the radiation field dominates.

Typically, we are far enough from the emitters of radiation so that the radiation field dominates.
Then, under the assumption \(\beta \ll 1\) we have
%
\begin{align}
\vec{E}_r = \frac{q}{Rc^2} \qty[\vec{n} \times \qty(\vec{n} \times \dot{\vec{u}})]
\qquad \text{and} \qquad
\vec{B}_r = \qty[\vec{n} \times \vec{E}_r]
\,.
\end{align}

\end{document}