\section{Conclusions, limitations and open perspectives}

In this Chapter I introduced a generalisation of the MOFA model for the principled analysis of large-scale structured datasets. Although we have emphasised single-cell applications, the model remains applicable to bulk datasets. MOFA+ solves some of the limitations of the MOFA model presented in Chapter 3, but a significant number of challenges remain unsolved and could be addressed in future research:

\begin{itemize}
	\item \textbf{Linearity}: this is arguably the major limitation of MOFA. Although it is critical for obtaining interpretable feature weights, this results in a significant loss of explanatory power. Deep generative models have proven successful in modelling complex observations. Their principle is the use of non-linear maps via neural networks to encode the parameters of probability distributions. Among this class of methods, variational autoencoders provide a rigorous and scalable non-linear generalisation of factor models \cite{Ainsworth2018}.

	\item \textbf{Improving the stochastic inference scheme}: a common extension of stochastic gradient descent is the addition of a \textit{momentum} term, which has been widely adopted in the training of artificial neural networks \cite{Zeiler2012,Ning1999}. The idea is to take account of past updates when calculating the present step, using for example a moving average calculation. This has been shown to improve the stability of gradients vectors, thus leading to a faster convergence.

	\item \textbf{Modelling dependencies between groups}: often groups are not independent and have some type of structure among themselves. A clear example are time course experiments. Explicit modelling of these dependencies, when known, could help on model inference and interpretation.

	\item \textbf{Modelling continuous dependencies between samples and/or features}: in the MOFA framework the views and the groups correspond to discrete and non-overlapping sets. An interesting improvement would be to model continuous dependencies using Gaussian Process priors \cite{Casale2018}. A clear application for this is spatial transcriptomics, where one could build a covariance matrix using spatial distances which can then be imposed in the prior distribution of the latent factors (recall that in MOFA and MOFA+ the prior distribution for the factors assumes independence between samples). This would improve the detection of sources of variation with a spatial component.
\end{itemize}


    \filetitle{ispanel}{True for panel VAR objects}{VAR/ispanel}

	\paragraph{Syntax}\label{syntax}

\begin{verbatim}
Flag = ispanel(X)
\end{verbatim}

\paragraph{Input arguments}\label{input-arguments}

\begin{itemize}
\itemsep1pt\parskip0pt\parsep0pt
\item
  \texttt{X} {[} VAR \textbar{} SVAR {]} - VAR object.
\end{itemize}

\paragraph{Output arguments}\label{output-arguments}

\begin{itemize}
\itemsep1pt\parskip0pt\parsep0pt
\item
  \texttt{Flag} {[} \texttt{true} \textbar{} \texttt{false} {]} - True
  if the VAR object, \texttt{X}, is based on a panel of data.
\end{itemize}

\paragraph{Description}\label{description}

\paragraph{Example}\label{example}


%%
%% Template intro.tex
%%

\chapter{Mapping the Night Sky}
\label{cha:astro}

When many people think about astronomy, the first things that pop into their mind are breathtaking
images of the sky like the famous Hubble Deep Field. But pretty images alone are not enough to do
real science. For us to make any meaningful observations about astronomical objects, we need actual
quantitative measurements. This chapter begins with an overview of spectroscopy and photometry, the
two most important tools in optical astronomy used to study the sky (Section \ref{sec:spec}).
We then look at important astronomical concepts like fluxes, magnitudes, colours, and the
equatorial coordinate system (Section \ref{sec:flux}, \ref{sec:mag}, and \ref{sec:map}). This will
give us a better understanding of the SDSS and the VST ATLAS datasets, which are introduced in
Section \ref{sec:datasets}. The chapter ends with a brief discussion on dust extinction, a
potential problem in the SDSS dataset that we shall need to take care of (Section \ref{sec:dust}).

\section{Spectroscopy and Photometry} \index{spectroscopy} \index{photometry}
\label{sec:spec}

Spectroscopy was born when Isaac Newton discovered in 1666 that white light can be split into a
rainbow by passing it through a glass prism. In modern-day astronomy, we use diffraction grating to
disperse light and measure the amount of electromagnetic radiation, or flux, emitted from a
celestial object at small wavelength intervals. As the name implies, we end up with a spectrum,
like the one shown in Figure \ref{fig:vega}. The shape of the spectrum and its absorption lines
allow us to deduce many useful properties about the object such as its temperature and chemical
composition.

Unfortunately, it can be very difficult to take high resolution spectra of faint objects since we
are spreading light thinly across many wavelengths. Photometry gets around this problem by
separating light into fewer groups and thus reducing the wavelength resolution \cite[Chapter
1]{romanishin02}. Specifically we have a set of filters, each of which can be put in front of the
CCD camera to allow only light from certain wavelengths to pass through. Associated with each
filter is a transmission function $T(\lambda)$ that tells us the fraction of light that the filter
will transmit at wavelength $\lambda$. Figure \ref{fig:vega} shows $T(\lambda)$ of the five
bandpasses (u, g, r, i, and z) that are used in the SDSS.

\begin{figure}[tbp]
	\centering \includegraphics[width=\textwidth]{figures/2_astro/vega_filters_and_spectrum}
	\caption[Spectrum of the star Vega and the ugriz bandpasses]{The black curve is the
		spectrum of Vega, the fifth brightest star in the night sky. The spectrum tells us how
		much radiation Vega emits at each wavelength. We also show five transmission functions,
		one for each of the five ugriz filters. The transmission function tells us how much light
		can get through the filter at each wavelength.} \label{fig:vega} \index{Vega}
\end{figure}

\section{Measuring Fluxes} \index{flux}
\label{sec:flux}

When light hits the CCD, all we have initially are counts of photons, one for each pixel.
The first challenge is to assign the photons to distinct objects. Two models are used
in the SDSS, depending on whether we assume the object is an extended source or a point source.

\subsection{Petrosian Flux} \index{flux!Petrosian}
\label{sub:petrosian}

Galaxies are extended-source objects so we need to define an aperture radius, within which
all the photons are added together to obtain the flux of the galaxy. Since galaxies have
poorly defined edges, a consistent method to pick the aperture radius is required.
\shortciteN{blanton01} define a quantity called the Petrosian ratio:
	\begin{IEEEeqnarray*}{lCl}
		\mathfrak{R}_p(r) = \frac{\int_{0.8r}^{1.25r} 2\pi s I(s) \, ds}{\pi (1.25^2 - 0.8^2) r^2}
							\bigg/ \frac{\int_0^r 2\pi s I(s) \, ds}{\pi r^2}
	\end{IEEEeqnarray*}
This is the ratio of the mean local surface brightness over an annulus at $r$ to the mean
surface brightness within $r$. The quantity $I(r)$ is the galaxy surface brightness profile
and can be estimated from the photon count. With this, we define the Petrosian
radius $r_p$ as the radius such that $\mathfrak{R}_p(r_p) = 0.2$. This is one of the features
in the SDSS dataset that will prove to be very useful in distinguishing galaxies from
point-source objects. The aperture radius is then chosen to be $2r_p$ to ensure that almost
all of the light from a typical galaxy is captured. Finally for each bandpass, we can calculate
the corresponding Petrosian flux as
	\begin{IEEEeqnarray*}{lCl}
		f &=& \int_{0}^{2 r_p} 2 \pi s I(s) \, ds
	\end{IEEEeqnarray*}

\subsection{Point Spread Function Fitting} \index{flux!PSF}
\label{sub:psf}

Stars, quasars, and white dwarfs are unresolved point sources so they can be modelled by a point
spread function (PSF). This approach is particularly useful when we examine a dense region like a
globular cluster. In such places, given the amount of overlap, it would be very difficult define an
aperture that includes only photons from an object and excludes all others from the neighbours. In
PSF fitting, we assume that all objects have the same shape, which allows us to fit a Gaussian model
to each of them. We then iteratively vary the position and flux of the objects until the model
produces the observed light distribution \cite[Chapter 10]{palmer01}. The flux estimated by the
converged model is called the PSF flux.

\section{Magnitudes and Colours} \index{magnitude}
\label{sec:mag}

\subsection{Apparent Magnitudes} \index{magnitude!apparent}
\label{sub:apparent}

The fluxes of the brightest and the dimmest objects in the sky can differ by many orders of
magnitudes. This motivates us to take one step further and convert fluxes to inverse hyperbolic sine
(or arsinh) apparent magnitudes:
	\begin{IEEEeqnarray*}{lCl}
		m &=& -\frac{2.5}{\ln(10)} \Bigg[ \arsinh\bigg(\frac{f/f_0}{2b}\bigg) + \ln(a) \Bigg]
	\end{IEEEeqnarray*}
where $f_0$ is the flux of the object with a conventional magnitude of 0 and $a$ is the softening
parameter. A nice feature of this magnitude system is that for bright objects with a high
signal-to-noise ratio, it behaves like a logarithmic scale, i.e. with every decrease of 1 in the
magnitude scale, the object becomes 2.5 times brighter.\footnote{ The reader might wonder why the
	scale works in reverse, with a small magnitude corresponding to more brightness. This is the
	convention created two millennia ago by the Greek astronomer Hipparchus, which, for better or worse,
	has stuck with us ever since.} At the same time, as the flux tends toward zero for fainter objects,
the arsinh function (unlike the log function) ensures that the magnitudes are still well-defined
\cite{lupton99}.

\subsection{Absolute Magnitudes and Colours} \index{magnitude!absolute} \index{colour}
\label{sub:colours}

The problem with apparent magnitudes is their dependence on distance. Objects that are further away
from us are fainter and hence have higher apparent magnitudes. Of course, being further away does
not change anything fundamental about an object like whether it is a star or a galaxy. Thus if we
want to study their intrinsic properties, we need to remove this dependency. One method is to
convert to the absolute magnitude, which is defined as the object's apparent magnitude if it were
exactly 10 parsecs away from Earth:
	\begin{IEEEeqnarray*}{lCl}
		M &=& m - 5 \log_{10} \bigg(\frac{D}{10}\bigg)
	\end{IEEEeqnarray*}
This conversion requires the knowledge of $D$, the actual distance of an object in parsecs. In
practice, it is often difficult to estimate $D$, so we resort to an easier method of taking the
difference between the amount of light received in two bandpasses. For example, the $u -g$ colour is
calculated as
	\begin{IEEEeqnarray*}{lCl}
		m_{u-g} &=& m_u - m_g \\
		        &=& M_u + 5 \log_{10} \bigg(\frac{D}{10}\bigg) -
		            M_g + 5 \log_{10} \bigg(\frac{D}{10}\bigg) \\
		        &=& M_u - M_g
	\end{IEEEeqnarray*}
Note that the conversion factor disappears and the colour does not change with distance. In
addition, the difference between two magnitudes depends on the average slope of the spectrum. Thus
colours measure the general shape of an object's spectrum, which in turn can reveal many useful
properties such as a star's temperature.

\section{Equatorial Coordinate System} \index{equatorial coordinate system}
\label{sec:map}

Imagine a very large celestial sphere \index{celestial sphere} with Earth at its centre. By
projecting onto the inside surface of this sphere, we have a way to specify the position of any
astronomical object. In this thesis, we use the equatorial coordinate system, where an object's
position is specified by two numbers, a right ascension \index{right ascension} (ra) and a
declination \index{declination} (dec). Figure \ref{fig:mollweide} shows the Mollweide projection of
the celestial sphere. We shall use this map throughout the thesis to visualise some results.

\begin{figure}[tbp]
	\centering
	\includegraphics[width=\textwidth]{figures/2_astro/mollweide_map}
	\caption[Mollweide projection of the celestial sphere]{This is the Mollweide projection
		of the celestial sphere under the equatorial coordinate system.
		The red line indicates the plane of the Milky Way. To avoid cluttering, the coordinate labels will not be shown on later maps.}
	\label{fig:mollweide} \index{Mollweide projection}
\end{figure}

The equatorial coordinate system, like any other systems, needs to have a reference point. Here
anything on the celestial sphere that is directly above the Earth's equator will have a declination
of 0\deg. To define a zero point for the right ascension, we use the fact that the centre of the
Sun passes through the plane of the Earth's equator twice a year. The first crossing point usually
happens on 21 March and is called the vernal equinox\index{vernal equinox}. We now define the right
ascension of the vernal equinox to be 0\deg~\cite[Chapter~1]{sparke07}.\footnote{ There is actually
    a slight complication. Since the Earth's rotation axis is not fixed due to
    precession\index{precession}, the ra-dec coordinates of an object relative to the origin will
    actually change slowly over time. Thus we need to also fix a time in which the coordinates are
    measured. In many surveys like the SDSS, 1 January 2000 12:00 Terrestrial Time is chosen as a
    reference point.}

\section{Datasets}
\label{sec:datasets}

We now have all the required background to understand the features in the two datasets used in our
experiments. Below we give a quick overview of what each dataset contains. For more information on
how to obtain them, refer to Appendix \ref{cha:datasets}.

\subsection{SDSS Dataset} \index{SDSS}
\label{sub:sdss}

\begin{figure}[p]
	\centering
	\includegraphics[width=\textwidth]{figures/4_expt1/map_prediction_forest_all}
	\caption[Coverage of the SDSS]{The distribution of the 800 million scanned objects
		in the SDSS: Note that the coverage is not uniform. A darker colour
		corresponds to more objects being scanned in a particular area. The unit
        of the colourbar is the object count in a hexagon.}
	\label{fig:coverage}
\end{figure}

\begin{figure}[p]
    \centering
    \begin{subfigure}{.5\textwidth}
        \centering
        \includegraphics[width=0.99\textwidth]{figures/2_astro/sdss_class_distribution}
        \caption{SDSS Dataset}
        \label{fig:class_dist_sdss}
    \end{subfigure}%
    \begin{subfigure}{.5\textwidth}
        \centering
        \includegraphics[width=0.99\linewidth]{figures/2_astro/vstatlas_class_distribution}
        \caption{VST ATLAS Dataset}
        \label{fig:class_dist_vst}
    \end{subfigure}
    \caption[Distribution of the classes in the SDSS and VST ATLAS datasets]{
        Class distribution of the labelled objects in the SDSS and VST ATLAS datasets: Observe
        that both datasets exhibit the problem of class imbalance. Most objects in the
        SDSS dataset are galaxies, while stars are the dominant class in the VST ATLAS dataset.}
    \label{fig:class_dist}
\end{figure}

The main dataset in our investigation comes from the SDSS, a comprehensive survey of the Northern
Sky that began operation in 2000. This dataset consists of 800 million objects, covering 14,055
square degrees, or about a third of the celestial sphere \cite{alam15}. Figure \ref{fig:coverage}
shows the coverage of the survey. For each object, we are given 11 features:
	\begin{itemize}
		\item The PSF magnitude in each of the five ugriz bands.
		\item The Petrosian magnitude in each of the five ugriz bands.
		\item The Petrosian radius in the r-band.
	\end{itemize}
Only 2.8 million out of the 800 million objects have been spectroscopically classified into three
classes: galaxies, quasars, and stars. From Figure \ref{fig:class_dist_sdss}, we can see that the
number of galaxies is twice that of stars and four times that of quasars. This leads to the
problem of class imbalance. In Chapter \ref{cha:ml} we shall discuss some approaches to minimise
the bias toward the dominant class during classification. Also note that both the labelled and the
unlabelled sets are not random samples of the sky. For example, since astronomers are particularly
interested in studying quasars, these objects are over-represented in the collection.

\subsection{VST ATLAS Dataset} \index{VST ATLAS}
\label{sub:vstatlas}

A second and much smaller dataset comes from a more recent survey, the VST ATLAS. This project aims
to survey 4500 square degrees of the Southern Sky to roughly the same depth as the SDSS
\cite{shanks15}. There are about 35,000 objects in total which have been classified by experts into four
classes: stars, galaxies, quasars, and white dwarfs. For each object, we are provided with 7
features:
	\begin{itemize}
		\item The calibrated magnitude from the r-band.
		\item Four colour indices using the ugriz filters: $u-g$, $g-r$, $r-i$, and $i-z$.
		\item Two colour indices in the infrared: $r-W1$ and $W1-W2$.
	\end{itemize}
The two infrared channels $W1$ and $W2$ are measured by the Wide-field Infrared Survey Explorer
(WISE), one of NASA's space telescopes. These channels will prove useful in distinguishing
between classes. As we can see from Figure \ref{fig:class_dist_vst}, the problem of class
imbalance is even worse in this dataset. For instance, we have 43 times more stars than white
dwarfs. Since research is still on-going, the coordinates of the objects are not yet publicly
available.

\section{Dust Extinction} \index{dust extinction} \index{reddening correction}
\label{sec:dust}

As light travels from its source to us, it can be absorbed and scattered by interstellar dust. The
scattering is especially strong at shorter wavelengths. This means that less of the blue light
arrives on Earth and the object will appear redder than it actually is.

This would not be a big problem if the reddening process were uniform throughout the
celestial sphere, since all the magnitudes and colours will simply shift by a constant
term. Indeed, this is the case with the VST ATLAS, since the field where the objects were
surveyed exhibits no drift in the reddening.
However, the SDSS covers a much larger portion of the sky. As shown in
Figure \ref{fig:reddening}, the reddening varies by quite a bit throughout the field. The
effect is particularly strong in the Milky Way region. Thus we might need to correct the SDSS
magnitudes for dust extinction.

\begin{figure}[tbp]
	\centering
	\includegraphics[width=\textwidth]{figures/2_astro/ebv_map}
	\caption[Galactic reddening map in the SDSS]{Galactic reddening $E_{B-V}$ map in the SDSS:
		A darker colour indicates a greater amount of reddening.}
	\label{fig:reddening}
\end{figure}

Three competing extinction vectors currently exist in the literature. The most popular one for a
long time was created by \citeN{schlegel98}, who used the colours of nearby elliptical galaxies for
calibration. Later, \citeN{schlafly11} made some improvement with new data from the SDSS. Recently,
\citeN{wolf14} investigated quasars in the SDSS and found evidence of non-linearity in the
reddening map. For convenience, let us call the extinction vectors resulted from the above works
SFD98, SF11, and W14, after the authors' initials and year of publication. One interesting
question, which we shall explore in Chapter \ref{cha:expt1}, is whether applying any of these
vectors to the measurements will have any noticeable effect on the performance of the classifiers.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "thesis"
%%% End:


\documentclass[11pt]{article}
\setlength{\parskip}{.08in}
\renewcommand\arraystretch{1.2}
\usepackage{commath}
\usepackage{listings}
\usepackage{hyperref}
\setlength{\parindent}{0in}

\lstdefinestyle{mystyle}{
basicstyle=\fontsize{12}{9}\selectfont\ttfamily
}
\lstset{style=mystyle}

% Added packages
\usepackage{setspace}
\usepackage{enumerate}
\usepackage{bm}
\usepackage{amsmath}
\makeatletter
\renewcommand*\env@matrix[1][\arraystretch]{%
  \edef\arraystretch{#1}%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{*\c@MaxMatrixCols c}}
\makeatother
%\usepackage[dvips, bookmarks, colorlinks=true, plainpages = false,
%citecolor = green, urlcolor = blue, filecolor = blue] {hyperref}
%\usepackage[font=small,format=plain,labelfont=bf,up,textfont=it,up]{caption}

% Set the beginning of a LaTeX document
\usepackage{graphicx}
\graphicspath{ {./images/} }

%\usepackage{endnotes}
%\let\footnote=\endnote

\usepackage{titlesec}
\titleformat{\section}
  {\normalfont\fontfamily{phv}\fontsize{14}{17}\selectfont}{\thesection}{1em}{}

\oddsidemargin 0.25in
\evensidemargin 0.25in

\headheight 0.0in
\headsep 0.0in
\topmargin -0.25in

\textwidth 6.0in
\textheight 9.0in

\paperheight 11.0in
\paperwidth 8.5in

\begin{document}

\title{Analysis of the Ecological Impact of Homo Necrosis}         % Enter your title between curly brackets
\author{Philippe Nadon}

\date{ \today}          % Enter your date or \today between curly brackets
\maketitle

\footnote{Corresponding author: nadon@ualberta.ca}\\[0.5cm]
{\small Faculty of Science, University of Alberta}\\
{\small Camrose, AB, Canada}\\[0.5cm]

\thispagestyle{empty}

%\onehalfspacing
\doublespacing

\begin{abstract}
In this paper a human-zombie model is used to analyze any equilibrium points in the model, and their type and stability. This topic is of great importance due to a growing concern of the suspiciously zombie-like behaviour of university students during exam times.

\end{abstract}

\textbf{Keywords:} Zombies, Homo Necrosis, Humans, Students, Exams, Ecology

\newpage

\setcounter{page}{1}

\section{Introduction}

The equations which model the relation between the population of zombies and humans are as shown below:
\begin{equation}
\dot{H} = aH(1 - H) - bHZ^2
\end{equation}
\begin{equation}
\dot{Z} = bHZ^2 - cH^3Z
\end{equation}

Where $H$, $Z$ are the populations of humans and zombies respectively, $\dot{H}$, $\dot{Z}$ are the rates of change of these populations, $a$ is the coefficient corresponding to the net birth and death rate of humans, $b$ is the coefficient corresponding to the encounter rate of infectious zombies with humans, and $c$ is the encounter rate of a zombie-hunting squad and zombies.

\subsection{Restrictions}
In order for this model to make sense, the following restrictions are applied:
\begin{enumerate}
\item $a$, $b$, $c$ $> 0$, this implies humans are not dying of non-zombie causes faster than they are being born, and that humans are not converting zombies back into humans faster than humans are being converted to zombies.
\item $H,Z \geq 0$, a negative population is nonsense.
\end{enumerate}

\subsection{Terms of Equation}
Let's break down the equation term by term:
\begin{enumerate}
\item $aH(1-H)$:\\
This term represents the positive factor of $\dot{H}$, which is the growth of the human population. Since the growth of a population relies on its current size, the coefficient $a$ is multiplied by $H$. However, there is also a carrying capacity $(1 - H$), where the growth rate of humans begins to slow down as the population approaches a limit. In this model, the limit is represented by 1, which means the human population must be $H$ less than 1, otherwise this model wouldn't work. In fact, $H$ can be considered the ratio of the current human population to the maximum human population.
\item $bHZ^2$:\\
This term represents the rate at which the zombie convert humans. The term $HZ^2$ implies that in order to convert one human it would take two zombies. Keep in mind both $H$ and $Z$ are less than 1, so logically the higher number of zombies required to convert a human, the higher the exponent on the $Z$ variable, and thus the lower the value of this term.\\
Notice also that this term appears both in the human growth rate and zombie growth rate equations, this is because the growth in population of zombies is directly dependant on the death of humans by zombie conversion.
\item $-cH^3Z$:\\
This term represents the rate at which the humans kill zombies. Similarly to the previous term, the $H^3Z$ implies that it takes three humans to kill one zombie.
\end{enumerate}

\section{Equilibrium Points}
Finding equilibrium points will help us find trends in the population change, such as which population values the model will approach and remain at based on initial values.\\
An equilibrium point is a point where the rate of change for all variables is $0$. In the case of this model:
\begin{equation}
aH(1 - H) - bHZ^2 = 0
\end{equation}
\begin{equation}
bHZ^2 - cH^3Z = 0
\end{equation}
At this point, since the rate of change is $0$, the populations will remain at this value (realistically they will only oscillate minutely).

\subsection{Trivial Points}
 For starters, there is the trivial solution of $(H, Z) = (0,0)$. This is trivial because it makes sense that if there are no zombies or humans around then their growth rate will remain 0, since our model does not depict zombies or humans spontaneously growing out of nothing.\\
Another trivial solution would be at $(H, Z) = (1, 0)$. At this point the zombie population would be gone and so they would be unable to convert any more humans. Humans would have reached carrying capacity and would be unable to grow larger but also would have no zombies reducing their population. Thus both the human population and the zombie population would remain constant.\\

\subsection{Non-trivial Points, $H,Z > 0$}
The more interesting equilibrium points we can analyze are the non-trivial points, which are less obvious and require more calculations to find.\\
Let's start by manipulating equations (3) and (4) to obtain the equilibrium points $H_e, Z_e$:
\begin{equation}
aH_e(1 - H_e) - bH_eZ^2 = H_e(a(1 - H_e) - bZ^2) = 0
\end{equation}
\begin{equation}
bH_eZ_e^2 - cH_e^3Z_e = H_e(bZ_e^2 - cH_e^2Z_e) = 0
\end{equation}
since $H,Z > 0$, we can divide $H_e$ on both sides for both equations:\\
From equation (6):
\[bZ_e^2 = cH_e^2Z_e \]
\begin{equation}
Z_e = \frac{c}{b} H_e^2
\end{equation}
Inserting this result in (5):
\begin{equation}
a(1 - H_e) = bZ_e^2 = \frac{c^2}{b}H_e^4
\end{equation}

\section{ Stability of Non-trivial Equilibrium Point}
Now, we will find the Jacobian and then use Matlab to compute the coordinates of the non-trivial equilibrium point, and its stability. This will allow us to find if there is a population size of humans and zombies where neither species is overtaking the other, and whether we will naturally approach this point or one of the two trivial points (extinction of both species or extinction of zombies).

\subsection{Jacobian}
The Jacobian of equations (1) and (2) is defined as the following:

\[
det \abs{
\begin{bmatrix}[1.5]
\frac{d \dot{H}}{dH} && \frac{ d \dot{H} }{ dZ} \\
\frac{d \dot{Z}}{dH} && \frac{ d \dot{Z} }{ dZ} \\
\end{bmatrix}
 - \lambda I}
 =
 det \abs{
\begin{bmatrix}[1.5]
a - 2a H_e - b Z_e^2 && -2b H_e Z_e \\
b Z_e^2 - 3c H_e^2 Z_e && 2b H_e Z_e - c H_e^3 \\
\end{bmatrix}
 - \lambda I}
\]

Substituting for $Z_e$ gives us

\begin{equation}
det \abs{
\begin{bmatrix}[1.5]
a - 2aH_e - \frac{c^2}{b}H_e^4 && -2cH_e^3 \\
\frac{c^2}{b}H_e^4 - 3 \frac{c^2}{b}H_e^4&& 2cH_e^3 - cH_e^3 \\
\end{bmatrix}
 - \lambda I}
 =
 det \abs{
\begin{bmatrix}[1.5]
-aH_e && -2cH_e^3 \\
-2 \frac{c^2}{b} H_e^4 && cH_e^3 \\
\end{bmatrix}
 - \lambda I}
\end{equation}

Finally, evaluating the above equation gives us

\[
(-aH_e - \lambda)(cH_e^3 - \lambda) - (-2 \frac{c^2}{b} H_e^4)(-2cH_e^3)
\]

Which can be simplified to

\begin{equation}
(\lambda + a H_e) (\lambda - c H_e^3 ) - 4 \frac{c^3}{b} H_e^7
\end{equation}

Beyond this point, solving through numerical methods using Matlab will become the preferred tool of choice.

\subsection{ Direction Field}
We can find the direction field for the system of ODEs in equations (7) and (8) by running the following code and plotting it in Matlab:

\begin{lstlisting}[language = Matlab]
global a b c;
a = 1;
b = 1;
c = 1;

function [ret] = hPopRate( H, Z)
global a  b;
ret = a.*H.*(1 - H) - b.*H.*Z.^2;
end

function [ret] = zPopRate( H, Z)
global b c;
ret = b.*H.*Z.^2 - c.*H.^3.*Z;
end

function [] = plotDirectionField()
[H,Z] = meshgrid( 0: 0.01: 1.0, 0: 0.01: 2.0);
quiver( H, Z, hPopRate( H, Z), zPopRate( H, Z));
end
\end{lstlisting}

This code plotted the following direction field:\\
\includegraphics[scale = 0.32]{Q5.png}

From this graph we can estimate the non-trivial equilibrium point to be around $H = 0.7$, which will allow us to use an educated guess to start with when we numerically computer the equilibrium point in the next section.

\subsection{ Non-trivial Coordinates}
Now that we have a vague estimation of the non-trivial equilibrium point, we can compute a far more accurate result using more Matlab code:

\begin{lstlisting}[language = Matlab]
function [ret] = hEqFunc( H)
global a b c;
ret = a.*(1 - H) - c.^2/b.*H.^4;
end

function [ret] = zEqFunc( H_e)
global b c;
ret = c*H_e^2/b;
end

function [H_e, Z_e] = computeCoordinates( guessH)
H_e = fzero( @hEqFunc, guessH);
Z_e = zEqFunc( H_e);
end
\end{lstlisting}

This will tell us at what values of $H$ and $Z$ can we expect a fixed balance between human and zombie populations. After running the computation we received a result of:
\begin{equation}
H = 0.7245, Z = 0.5249
\end{equation}

We can verify by inserting these values back into the equation:
\begin{equation}
\dot{H} = aH(1 - H) - bHZ^2 = 0.7245*(1 - 0.7245) - 0.7245*0.5249^2 = 0
\end{equation}

\begin{equation}
\dot{Z} = bHZ^2 - cH^3Z = 0.7245*0.5249^2 - 0.7245^3*0.5249 = 0
\end{equation}

If you input these values yourself to see if they equal zero, you will be disappointed to find that they don't. This is an expected result of using numerical computation. All computers have a limited amount of memory and processing power, and so the "correct" answer is an answer which is deemed to be accurate enough for your needs. In this case, 4 significant digits is enough accuracy for this paper.

\subsection{ Type and Stability of Equilibrium Point}
Another point of interest is whether or not that point is stable, and what type it is. This will aid us in understanding the behaviour of this model as the human and zombie population changes. Here is the Matlab code which finds the eigenvalues:

\begin{lstlisting}[language = Matlab]
global H_eGuess;
H_eGuess = 0.7;

function [matrixHZ] = makeJacobian()
global a b c H_eGuess;
[H_e, ~] = computeCoordinates( H_eGuess);
matrixHZ = [-a*H_e, -2*c*H_e^3 ; -2*c^2/b*H_e^4, c*H_e^3];
end

function [ eigs] = computeEigenvalues()
matrixHZ = makeJacobian();
eigs = eig( matrixHZ);
end
\end{lstlisting}

After running the computation the answer it found was

\begin{equation}
\lambda_1 = -1.0231, \lambda_2 = 0.6789
\end{equation}

which means the equilibrium point is a saddle point, due to both eigenvalues being real, and only one being less than zero.

\section{Further Tests}
We have determined the type, location, and stability of the non-trivial equilibrium point, but there are still areas which should be analyzed, such as the model's sensitivity to change in initial conditions, and a more visual representation of the equilibrium point by plotting multiple cases with slightly varying initial conditions.

\subsection{Sensitivity of Initial Conditions}
Now we will compare the change in our model's behaviour based on the initial conditions given to it. This will help us understand any form of "butterfly effect" we might get based on the conditions we start with. We will test this by comparing the initial conditions
\[
t0=0.0, H_0=0.1, Z_0=0.357
\]
with
\[
t_0=0.0, H_0=0.1, Z_0=0.358
\]
With step size $h = 0.001$ and number of steps $N=20'000$.

Here is the code which computes and plots the graphs:

\begin{lstlisting}[language = Matlab]
global stepSize numSteps;
stepSize = 0.001;
numSteps = 20000;

plotGraphs( [ 0.0, 0.1, 0.357 ; 0.0, 0.1, 0.358]);

function [retH, retZ, retT] = eulerMethod( h, z, t)
global stepSize;
retH = h + stepSize*hPopRate( h, z);
retZ = z + stepSize*zPopRate( h, z);
retT = t + stepSize;
end

function [] = plotGraphs( initConds)
global numSteps;

for i = 1:( size( initConds, 1))
t=linspace(1,numSteps);
h=linspace(1,numSteps);
z=linspace(1,numSteps);

% First entry
t(1)=initConds(i,1);
h(1)=initConds(i,2);
z(1)=initConds(i,3);

% Euler method
for j = 1:(numSteps-1)
   [h(j+1), z(j+1), t(j+1)] = eulerMethod( h(j), z(j), t(j));
end

% Plotting the solution
plotTitle = [ 'Initial H = ', num2str( h(1)),...
    ', Initial Z = ', num2str( z(1))];
figure('Name', plotTitle,'NumberTitle','off');
plot(t,h,'*');
hold on
plot(t,z,'x');
hold off
end
end
\end{lstlisting}

\newpage
Below we can see the graph corresponding to the initial condition $H = 0.1$, $Z = 0.357$:

\includegraphics[scale = 0.32]{Q81.png}

And below is the graph corresponding to the initial conditions $H = 0.1$, $Z = 0.358$:

\includegraphics[scale = 0.32]{Q82.png}

We can see that with just a slight variation in the initial population of zombies, that our race can either survive and overcome the outbreak of zombies, or we will temporarily overtake them before eventually being overwhelmed. It is interesting to note that the change in the population of zombies seems contrast directly with the change in human population, albeit lagging slightly behind. In both graphs the zombie and human populations initially rise to a higher population, after which the effects of the human population relative to its carrying capacity causes its growth to slow down, and then the two populations begin to directly compete with each other.

\subsection{ Visual of Equilibrium Point}
Lastly before the conclusion, we will create a more visual representation of the saddle-point of our equilibrium, by plotting multiple equations on the same plot, each of which vary by slightly different initial conditions. Below are the code and graphs corresponding to this problem:

\begin{lstlisting}[language = Matlab]
plotPhaseGraphs( [ 0.0, 0.1, 0.357 ; 0.0, 0.1, 0.358 ;...
    0.0, 0.99, 0.64 ; 0.0, 0.99, 0.65]);

function [] = plotPhaseGraphs( initConds)
global numSteps;

for i = 1:( size( initConds, 1))
t=linspace(1,numSteps);
h=linspace(1,numSteps);
z=linspace(1,numSteps);

% First entry
t(1)=initConds(i,1);
h(1)=initConds(i,2);
z(1)=initConds(i,3);

% Euler method
for j = 1:(numSteps-1)
   [h(j+1), z(j+1), t(j+1)] = eulerMethod( h(j), z(j), t(j));
end

% Plotting the solution
plot(z,h,'*');
hold on
end
hold off
end
\end{lstlisting}

\includegraphics[scale = 0.32]{Q9.png}

This plot demonstrates the equilibrium point's instability, since each of the four lines within this plot approach the equilibrium point at $H = 0.7245, Z = 0.5249$, but then turn and move away, thus visually demonstrating that it is a saddle point.

\section{Conclusion}

As the above graphs and calculations have shown, our relation with zombies is unstable, meaning that there is no equilibrium point we will inevitably approach. Rather, the outcome is highly sensitive to the initial conditions presented to this model, meaning that the difference between humans eradicating the zombies, and the zombies converting us all is very fine, and could switch with only a slight oscillation, such as humans suddenly catching a flu, which will slightly decrease our numbers. Predicting an outcome of a zombie apocalypse would be nigh impossible due to the instability of the equilibrium, and the butterfly effect of the initial variables.

\textbf{Make sure to look at and test the source code at \href{https://bit.ly/2TLMNfn}{https://bit.ly/2TLMNfn}}

\end{document}


% This file contains the content for the Introduction
\unnumberedformat	    % Change formatting to that of "Introduction" section
\chapter{Introduction} 	% Do not modify section title
%% Modify below this line %%

The Academy Color Encoding Specification (ACES) defines a common color encoding method using half-precision floating point values corresponding to linear exposure values encoded relative to a fixed set of extended-gamut RGB primaries. Many digital-intermediate color grading systems have been engineered assuming image data with primaries similar to the grading display and a logarithmic relationship between relative scene exposures and image code values.

This document describes a 32-bit single precision floating-point logarithm encoding of ACES known as ACEScct.

ACEScct uses values above 1.0 and below 0.0 to encode the entire range of ACES values. ACEScct values should not be clamped except as part of color correction needed to produce a desired artistic intent.

There is no image file container format specified for use with ACEScct as the encoding is intended to be transient and internal to software or hardware systems, and is specifically not intended for interchange or archiving.

For ACES values greater than 0.0078125, the ACEScct encoding function is identical to the pure-log encoding function of ACEScc. Below this point, the addition of a "toe" results in a more distinct "milking" or "fogging" of shadows when a lift operation is applied when compared to the same operation applied in ACEScc. This difference in grading behavior is provided in response to colorist requests for behavior more similar to that of traditional legacy log film scan encodings.


\documentclass[11pt]{amsart}
\usepackage{geometry}
\geometry{letterpaper}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{tikz}
\usepackage{lscape}
\usetikzlibrary{dsp,fit,positioning}

\input{../util/airfoils.tex}
\input{../util/wing.tex}
\input{../util/coordinate_systems.tex}
\input{../util/control.tex}
\input{crosswind_vector_field.tex}

\newcommand{\qhat}{\hat{q}}
\newcommand{\cbar}{\bar{c}}
\newcommand{\qbar}{\bar{q}}
\newcommand{\cmd}{\mathrm{cmd}}
\newcommand{\ff}{\mathrm{ff}}
\newcommand{\eff}{\mathrm{eff}}
\newcommand{\app}{\mathrm{app}}
\newcommand{\wind}{\mathrm{wind}}
\newcommand{\kite}{\mathrm{kite}}
\newcommand{\nom}{\mathrm{nom}}
\newcommand{\aero}{\mathrm{aero}}
\newcommand{\geom}{\mathrm{geom}}

\begin{document}

\section{Overview}

Crosswind is the power generating mode of flight, where the wing is
flying with attached flow in a direction that is predominately
orthogonal (or across) the wind.

Crosswind flight is divided into two flight modes: normal crosswind
and preparing for transition-out.  The normal crosswind mode is geared
towards generating power, while the preparing for transition-out mode
is geared towards slowing the wing down for a successful
transition-out.

% State diagram showing transitions

The crosswind controller is divided into a sequenece of successively
closed loops with the outer loops controlling power generation through
path placement and mean speed command

A schematic of the loops and conversions is show in Fig .

\begin{equation}
\end{equation}

\section{Power loop}

The optimal airspeed for power generation is:

\begin{equation}
  v_{\kite} = \frac{2}{3} \frac{C_L}{C_{D_{\kite}}} v_{\wind,\perp}
\end{equation}

There are obviously significant variations in airspeed induced by

\begin{eqnarray}
  v_{\kite} &\propto& \frac{C_L}{C_D} v_{\wind, \perp} \\
  t &\propto& (v_{\wind, \perp})^2 \\
  P &\propto& (v_{\wind, \perp})^3 \\
\end{eqnarray}

\begin{figure}[h]
  \begin{tikzpicture}
    \begin{scope}[rotate=30, scale=0.15]
      \draw (10, -4) node[right] {$\vec{x}_g^{\mathrm{path}}$};
      \DrawCoordinateSystem{shift={(5, -4)}, scale=5}
                           {$x_{\mathrm{fp}}$}{$y_{\mathrm{fp}}$}{$z_{\mathrm{fp}}$}
      \draw [<-, line width=2 pt] (3, 8) arc (150:500:3 and 25);
      \DrawWingSide
    \end{scope}
    \draw (-10, -5) -- (0, 0);
    \DrawCoordinateSystem{shift={(-10, -5)}}{$x_g$}{$y_g$}{$z_g$}

    \draw[->, line width=1pt] (-5, 0) -- (-3, 0) node[above] {$v_{\wind}$};
    \draw[->] (-5, 0) node[below left] {$v_{\wind, \parallel}$} --
              ($(-5, 0)!0.95!(-4.5, -0.866)$);
    \draw[->] (-4.5, -0.866) node[below right] {$v_{\wind, \perp}$} --
              ($(-4.5, -0.866)!0.9!(-3, 0)$);
  \end{tikzpicture}
\end{figure}

$\vec{x}_g^{\mathrm{path}}

\section{Path loop}

\begin{tikzpicture}[scale=3]
  \DrawCrosswindVectorField
  \DrawCoordinateSystemDot{scale=0.3}
                          {$y_{\mathrm{fp}}$}{$x_{\mathrm{fp}}$}{$z_{\mathrm{fp}}$}

  \draw [thick, color=black, ->] (-0.707 - 0.1, 0.707) --
                                 (-0.707 + 0.0, 0.707 + 0.3);

  \foreach \R in {0.6, 0.8, ..., 1.4} {
    \draw [color=blue] (-0.707 - 0.1, 0.707)
                   arc (165:90:1)
                   arc (90:{90 - 45/\R}:{\R});
  }
  \draw [color=blue] (-0.707 - 0.1, 0.707)
                 arc (165:90:1)
                 arc (90:70:1.4) node [above=0.5cm, right] {$t_2$}
                 arc (70:58:1.4);
  \draw [thick, color=black] (-0.707 - 0.1, 0.707)
                         arc (165:127:1) node [above=0.5cm, left] {$t_1$}
                         arc (127:90:1);
\end{tikzpicture}

\begin{landscape}

\begin{tikzpicture}[scale=0.6, every node/.style={scale=0.6}]
  \matrix[row sep = 0.5cm, column sep = 1.5cm] {
    \node[dspfilter, dspblock2] (power_manual) {SetPowerManually}; &
    \node[dspfilter, dspblock] (path) {SetPath}; &
    \node[dspfilter, dspblock2] (predictor) {RunPredictor}; &
    \node[dspfilter, dspblock3] (angles) {SetAngles}; &
    \node[dspfilter, dspblock3] (alpha) {ControlAlpha}; \\

    &
    \node[dspfilter, dspblock] (mean_airspeed) {SetMeanAirspeed}; &
    &
    \node[dspfilter, dspblock3] (rates) {SetRates}; &
    \node[dspfilter, dspblock2] (beta) {ControlBeta}; \\

    &
    &
    &
    &
    \node[dspfilter, dspblock2] (teth_roll) {ControlTethRoll}; \\

    &
    &
    &
    \node[dspfilter, dspblock2] (set_airspeed) {SetAirspeed}; &
    \node[dspfilter, dspblock2] (airspeed) {ControlAirspeed}; \\
  };

  \draw[dspconn] ($(power_manual.0)+(0,0.35)$) node[above right]
       {$\mathtt{ele\_tuner}$} -| ++(3,0) |- (path.180);
  \draw[dspconn] ($(power_manual.0)-(0,0.35)$) node[above right]
       {$\mathtt{airspeed\_tuner}$} -| ++(1,0) |- (mean_airspeed.180);

  \draw[dspconn] (path.0) node[above right]
       {$\vec{X}_g^{\mathrm{path\,center}}$} -- (predictor);

  \draw[dspconn] ($(predictor.0)+(0,0.35)$) node[above right]
       {$\kappa_{\mathrm{aero}}$} -| ++(1.6,0) |- (angles.180);
  \draw[dspconn] ($(predictor.0)+(0,-0.35)$) node[above right]
       {$\kappa_{\mathrm{geom}}$} -| ++(1.4,0) |- (rates.180);

  \draw[dspconn] ($(angles.0)+(0,0.7)$) node[above right]
       {$\alpha_{\mathrm{cmd}}$} -| ++(1.8,0) |- (alpha.170);
  \draw[dspconn] (angles.0) node[above right]
       {$\beta_{\mathrm{cmd}}$} -| ++(1.6,0) |- (beta.170);
  \draw[dspconn] ($(angles.0)-(0,0.7)$) node[above right]
       {${\phi_T}_{\mathrm{cmd}}$} -| ++(1.4,0) |- (teth_roll.170);

  \draw[dspconn] ($(rates.0)+(0,0.7)$) node[above right]
       {$p_{\mathrm{cmd}}$} -| ++(2.4,0) |- ($(alpha.180)-(0,0.35)$);
  \draw[dspconn] (rates.0) node[above right]
       {$q_{\mathrm{cmd}}$} -| ++(2.4,0) |- ($(beta.180)-(0,0.35)$);
  \draw[dspconn] ($(rates.0)-(0,0.7)$) node[above right]
       {$r_{\mathrm{cmd}}$} -| ++(2.4,0) |- ($(teth_roll.180)-(0,0.35)$);

  \draw[dspconn] (mean_airspeed.0) node[above right]
       {${\bar{v}_{\mathrm{app}}}$} -| ++(1,0) |- (set_airspeed);
  \draw[dspconn] (set_airspeed.0) node[above right]
       {${{v}_{\mathrm{app}}}$} -| ++(1,0) |- (airspeed);

  % Output commands.
  % Alpha.
  \draw[dspconn] ($(alpha.0)+(0,0.7)$) node[above right] {$\delta_e$} -- ++(2,0) {};
  \draw[dspconn] (alpha.0) node[above right] {$\delta_f$} -- ++(2,0) {};
  \draw[dspconn] ($(alpha.0)-(0,0.7)$) node[above right] {$\tau_y$} -- ++(2,0) {};

  % Beta.
  \draw[dspconn] ($(beta.0)+(0,0.35)$) node[above right] {$\delta_r$} -- ++(2,0) {};
  \draw[dspconn] ($(beta.0)-(0,0.35)$) node[above right] {$\tau_z$} -- ++(2,0) {};

  % Tether roll.
  \draw[dspconn] ($(teth_roll.0)+(0,0.35)$) node[above right] {$\delta_a$} -- ++(2,0) {};
  \draw[dspconn] ($(teth_roll.0)-(0,0.35)$) node[above right] {$\tau_x$} -- ++(2,0) {};

  % Airspeed.
  \draw[dspconn] ($(airspeed.0)+(0,0.35)$) node[above right] {$T$} -- ++(2,0) {};
  \draw[dspconn] ($(airspeed.0)-(0,0.35)$) node[above right] {$\delta_{\mathrm{spoil}}$} -- ++(2,0) {};

  \node[draw, inner xsep = 20pt, inner ysep = 20pt, dashed,
    fit = (alpha) (beta) (teth_roll) (airspeed),
    label = above: {Inner loops}] (inner_loops) {};

  \node[draw, inner xsep = 20pt, inner ysep = 20pt, dashed,
    fit = (angles) (rates) (inner_loops),
    label = above: {State loop}] (state_loop) {};

  \node[draw, inner xsep = 20pt, inner ysep = 20pt, dashed,
    fit = (predictor) (state_loop),
    label = above: {Trajectory loop}] (trajectory_loop) {};

  \node[draw, inner xsep = 20pt, inner ysep = 20pt, dashed,
    fit = (path) (mean_airspeed) (trajectory_loop),
    label = above: {Path loop}] (path_loop) {};

  \node[draw, inner xsep = 20pt, inner ysep = 20pt, dashed,
    fit = (path_loop) (power_manual),
    label = above: {Power loop}] (power_loop) {};

\end{tikzpicture}
\end{landscape}

%% \begin{tikzpicture}
%%   \matrix[row sep = 0.5cm, column sep = 1cm] {
%%     & & &
%%     \node[dspnodeopen, above left] (m05) {$p_{\mathrm{ff}}$}; \\
%%     & & &
%%     \node[dspsquare] (m15) {$k_d$}; \\
%%     \node[dspnodeopen, left] (m20) {$\alpha_{\mathrm{cmd}}$}; &
%%     \node[vdspadder] (m21) {}; &
%%     \node[dspfilter, text width = 2cm] (m22) {$k_p + k_i / s$}; &
%%     \node[dspadder] (m23) {}; &
%%     \node[dspfilter, text width = 2cm] (m24) {Pitch plant}; &
%%     \node[dspnodeopen] (m25) {}; \\
%%     & & &
%%     \node[dspfilter] (m31) {Pitot}; \\
%%   };

%%   \draw[dspconn] (m05) -- (m15);
%%   \draw[dspconn] (m15) -- (m23);
%%   \draw[dspconn] (m20) -- (m21);
%%   \draw[dspconn] (m21) -- node[above] {$\alpha_{\mathrm{err}}$} (m22);
%%   \draw[dspconn] (m22) -- (m23);
%%   \draw[dspconn] (m23) -- node[above] {$\delta_a$} (m24);
%%   \draw[dspconn] (m24) -- node[above] {$\theta$} (m25) |- (m31);
%%   \draw[dspconn] (m25) -- ++(1, 0);
%%   \draw[dspconn] (m31) -| (m21);

%%   \node[draw, inner xsep = 10pt, inner ysep = 20pt, dashed,
%%     fit = (m05) (m21) (m31) (m25),
%%     label = above: {$\alpha$ loop}] {};
%% \end{tikzpicture}

\section{Simple models}

%% \subsection{Roll model}

%% \begin{equation}
%% I_{xx} \ddot{\phi} = \bar{q} A b \left(
%% \frac{b}{2 v} C_{l_p} \dot{\phi} -
%% (C_L z_b / b) \phi + C_{l_{\delta_a}} \delta_a \right)
%% \end{equation}

%% \begin{equation}
%% \frac{\Phi(s)}{\Delta_a(s)} =
%% \frac{C_{l_{\delta_a}}}{(I_{xx} / \bar{q} A b) s^2 - \frac{b}{2 v} C_{l_p} s + C_L z_b/b}
%% \end{equation}

%% \subsection{Pitch model}

%% \begin{equation}
%% \alpha \approx \theta + \dot{z} / v
%% \end{equation}

%% \begin{eqnarray}
%% m_{\mathrm{eff}} \ddot{z} &=& -k_{\mathrm{eff}} z -
%% \bar{q} C_{L_{\alpha}} A (\theta + \dot{z} / v) +
%% \bar{q} C_{Z_q} A \left(\frac{c}{2 v}\right) \dot{\theta} +
%% \bar{q} C_{Z_{\delta_e}} A \delta_e \\
%% I_{yy} \ddot{\theta} &=& -k_{\mathrm{eff}} l_b z +
%% \bar{q} C_{m_{\alpha}} A c (\theta + \dot{z} / v) +
%% \bar{q} C_{m_q} A \left(\frac{c}{2 v}\right) \dot{\theta} +
%% \bar{q} C_{m_{\delta_e}} A c \delta_e
%% \end{eqnarray}

%% \begin{equation}
%% I_{yy} \ddot{\theta} = \bar{q} A c \left(
%% \frac{c}{2 v} C_{m_q} \dot{\theta} + (C_{m_{\alpha}} + C_{L_{\alpha}} (-x_b)/c) \theta +
%% C_{m_{\delta_e}} \delta_e \right)
%% \end{equation}

%% \begin{equation}
%% \frac{I_{yy}}{\rho A (c/2)^3} \ddot{\hat{\theta}} =
%% C_{m_q} \dot{\hat{\theta}} + (C_{m_{\alpha}} + C_{L_{\alpha}} (-x_b)/c) \theta +
%% C_{m_{\delta_e}} \delta_e
%% \end{equation}

%% \begin{equation}
%% \frac{\Theta(s)}{\Delta_e(s)} =
%% \frac{C_{m_{\delta_e}}}{(I_{yy} / \bar{q} A c) s^2 - \frac{c}{2 v} C_{m_q} s - C_{m_{\alpha}}
%% + C_{L_{\alpha}} (-x_b) / c}
%% \end{equation}

%% \begin{equation}
%% \frac{\Theta(s')}{\Delta_e(s')} =
%% \frac{C_{m_{\delta_e}}}{(8 I_{yy} / \rho A c^3) s'^2 - C_{m_q} s' - C_{m_{\alpha}}
%% + C_{L_{\alpha}} (-x_b) / c}
%% \end{equation}

%% $C_{m_{\delta_e}} = -0.044$
%% $C_{m_q} \approx -31$
%% $C_{m_{\alpha}} \approx $
%% $\iota_{yy} = 888$

%% \subsection{Yaw model}

%% \begin{equation}
%% I_{zz} \ddot{\psi} = \bar{q} A b \left(
%% C_{n_r} \dot{\psi} - (C_{n_{\beta}} + C_{Y_{\beta}} (-x'_b) / b) \psi +
%% C_{n_{\delta_r}} \delta_r \right)
%% \end{equation}
%% Note that $\beta$ has the opposite sign convention as $\psi$.  Also
%% $x'_b$ denotes the $x$ position of the bridle point rather than the
%% bridle pivot.

%% \begin{equation}
%% \frac{\Psi(s)}{\Delta_r(s)} =
%% \frac{C_{n_{\delta_r}}}{(I_{zz} / \bar{q} A b) s^2 - C_{n_r} s + C_{n_{\beta}}
%% + C_{Y_{\beta}} (-x'_b) / b}
%% \end{equation}

\subsection{Speed model}

\begin{equation}
m_{\mathrm{eff}} \dot{v} =
\frac{1}{2} \rho v^2 C_L A \sin \theta -
\frac{1}{2} \rho v^2 C_D A \cos \theta +
T \cos \theta
\end{equation}

\begin{eqnarray}
  \sin \theta &=& \frac{v_w}{\sqrt{v_w^2 + v^2}} \\
  \cos \theta &=& \frac{v}{\sqrt{v_w^2 + v^2}} \\
\end{eqnarray}

\begin{eqnarray}
\sin (\theta_0 + \delta \theta) &=&
\frac{v_w}{\sqrt{v_w^2 + (v_0 + \delta v)^2}} \\
&\approx& \sin \theta_0 \left(1 - \frac{v_0 \delta v}{v_0^2 + v_w^2} \right)
\end{eqnarray}

\begin{equation}
\delta \theta = \frac{v_w}{v_0^2 + v_w^2} \delta v
\end{equation}

\begin{eqnarray}
m_{\mathrm{eff}} \delta \dot{v} &=&
\frac{1}{2} \rho (v_0 + \delta v)^2 C_L A \sin (\theta_0 + \delta \theta) \\
&-& \frac{1}{2} \rho (v_0 + \delta v)^2 C_D A \cos (\theta_0 + \delta \theta) \\
&+& T \cos (\theta_0 + \delta \theta)
\end{eqnarray}

\begin{eqnarray}
m_{\mathrm{eff}} \delta \dot{v} &=&
\frac{1}{2} \rho (v_0^2 + 2 v_0 \delta v) C_L A
(\sin \theta_0 + \delta \theta \cos \theta_0) \\
&-& \left(\frac{1}{2} \rho (v_0^2 + 2 v_0 \delta v) C_D A - T \right)
(\cos \theta_0 - \delta \theta \sin \theta_0)
\end{eqnarray}

\begin{eqnarray}
m_{\mathrm{eff}} \delta \dot{v} &=&
\frac{1}{2} \rho v_0^2 C_L A \cos \theta_0 \delta \theta -
\frac{1}{2} \rho v_0^2 C_D A \sin \theta_0 \delta \theta +
T (\cos \theta_0 - \delta \theta \sin \theta_0)
\end{eqnarray}

Assuming $\theta_0$ and $C_D$ are small and linearizing about $T = 0$:
\begin{equation}
m_{\mathrm{eff}} \delta \dot{v} =
-\frac{1}{2} \rho C_L A \cos \theta_0 v_w \delta v +
T \cos \theta_0
\end{equation}

\subsection{Longitudinal dynamics}

\begin{eqnarray}
\gamma &=& \tan^{-1}((\dot{z}_t + v_{\wind}) / \dot{x}_t) \\
&\approx& \frac{\dot{z}_t + v_{\wind}}{\dot{x}_t} \\
&\approx& \frac{v_{\wind}}{v_{\kite}} + \frac{1}{v_{\kite}} \delta \dot{z}_t -
\frac{v_{\wind}}{v_{\kite}^2} \delta \dot{x}_t
\end{eqnarray}

\begin{eqnarray}
\alpha &=& \tan^{-1}((\dot{z}_t + v_{\wind}) / \dot{x}_t) + \theta \\
&\approx& \frac{\dot{z}_t + v_{\wind}}{\dot{x}_t} + \theta \\
&\approx& \frac{v_{\wind}}{v_{\kite}} + \frac{1}{v_{\kite}} \delta \dot{z}_t -
\frac{v_{\wind}}{v_{\kite}^2} \delta \dot{x}_t + \theta
\end{eqnarray}

\begin{eqnarray}
\qbar &=& \frac{1}{2} \rho \left( \dot{x}_t^2 + v_{\wind}^2 \right) \\
&=& \frac{1}{2} \rho \left( (v_{\kite} + \delta \dot{x}_t)^2 + v_{\wind}^2 \right) \\
&\approx& \frac{1}{2} \rho \left( v_{\kite}^2 + v_{\wind}^2 \right) +
\rho v_{\kite} \delta \dot{x}_t
\end{eqnarray}

\begin{eqnarray}
C_L &=& C_{L_0} + C_{L_{\alpha}} \alpha + C_{L_{\hat{q}}} \hat{q} +
C_{L_{\delta_e}} \delta_e \\
C_D &=& C_{D_0} \\
C_m &=& C_{m_0} + C_{m_{\alpha}} \alpha + C_{m_{\hat{q}}} \hat{q} +
C_{m_{\delta_e}} \delta_e
\end{eqnarray}

\begin{eqnarray}
C_L &=& C_{L_0}' + C_{L_{\alpha}} \left( \frac{1}{v_{\kite}} \delta \dot{z}_t -
\frac{v_{\wind}}{v_{\kite}^2} \delta \dot{x}_t + \delta \theta \right) +
C_{L_{\hat{q}}} \hat{q} +
C_{L_{\delta_e}} \delta_e \\
C_D &=& C_{D_0} \\
C_m &=& C_{m_0}' + C_{m_{\alpha}} \left( \frac{1}{v_{\kite}} \delta \dot{z}_t -
\frac{v_{\wind}}{v_{\kite}^2} \delta \dot{x}_t + \delta \theta \right) +
C_{m_{\hat{q}}} \hat{q} +
C_{m_{\delta_e}} \delta_e
\end{eqnarray}

\begin{equation}
\left(
\begin{array}{c}
b_x_t \\
b_z_t
\end{array}
\right)
=
\left(
\begin{array}{cc}
\cos \theta & -\sin \theta \\
\sin \theta & \cos \theta
\end{array}
\right)
\left(
\begin{array}{c}
b_x \\
b_z
\end{array}
\right)
\end{equation}

The full non-linear equations, with the effective mass and spring
approximations, are
\begin{eqnarray}
m_{\eff} \ddot{x}_t &=& \qbar A C_L \sin \gamma -
\qbar A C_D \cos \gamma + T \cos \theta \\
m_{\eff} \ddot{z}_t &=& -\qbar A C_L \cos \gamma -
\qbar A C_D \sin \gamma - k_{\eff} (z_t + b_z_t) - T \sin \theta \\
I_{yy} \ddot{\theta} &=& \qbar A \cbar C_m + k_{\eff} (z_t + b_z_t) b_x_t
\end{eqnarray}

Linearizing these equations about a nominal kite speed, $v_{\kite}$,
and angle-of-attack we find the following linearized model:

\begin{eqnarray}
m_{\eff} \delta \ddot{x}_t &=&
\left(\qbar_0 + \rho v_{\kite} \delta \dot{x}_t \right) A \\
&&\times \left( C_{L_0}' + C_{L_{\alpha}}
\left( \frac{\delta \dot{z}_t}{v_{\kite}} -
\frac{v_{\wind}}{v_{\kite}} \frac{\delta \dot{x}_t}{v_{\kite}} +
\delta \theta \right) + C_{L_{\hat{q}}} \hat{q} + C_{L_{\delta_e}} \delta_e \right) \\
&&\times \left( \frac{v_{\wind}}{v_{\kite}} + \frac{\delta \dot{z}_t}{v_{\kite}} -
\frac{v_{\wind}}{v_{\kite}} \frac{\delta \dot{x}_t}{v_{\kite}} \right) \\
&&- \left(\qbar_0 + \rho v_{\kite} \delta \dot{x}_t \right) A C_D + \delta T
\end{eqnarray}

Removing all second-order terms:
\begin{eqnarray}
\frac{m_{\eff}}{\qbar_0 A} \delta \ddot{x}_t &=&
\left(\frac{\rho v_{\wind} v_{\kite}}{\qbar_0} C_{L_0}' -
\frac{\rho v_{\kite}^2}{\qbar_0} C_D -
C_{L_{\alpha}} \frac{v_{\wind}^2}{v_{\kite}^2} -
C_{L_0}' \frac{v_{\wind}}{v_{\kite}}\right) \frac{\delta \dot{x}_t}{v_{\kite}} \\
&+& \left(C_{L_{\alpha}} \frac{v_{\wind}}{v_{\kite}} + C_{L_0}' \right)
\frac{\delta \dot{z}_t}{v_{\kite}} \\
&+& \frac{v_{\wind}}{v_{\kite}} \left(
C_{L_{\alpha}} \delta \theta + C_{L_{\hat{q}}} \hat{q} + C_{L_{\delta_e}} \delta_e) \\
&+& \delta T /(\qbar_0 A)
\end{eqnarray}

Linearizing about the steady-state speed: $v_{\kite} = (C_{L_0}'/C_D) v_{\wind}$
and removing terms terms that are second-order in $v_{\wind}/v_{\kite}$:
\begin{eqnarray}
\frac{m_{\eff}}{\qbar_0 A} \delta \ddot{x}_t &=&
-C_D \frac{\delta \dot{x}_t}{v_{\kite}} +
\left(C_D C_{L_{\alpha}}/C_{L_0}' + C_{L_0}' \right)
\frac{\delta \dot{z}_t}{v_{\kite}} \\
&+& C_D \left( C_{L_{\alpha}} \delta \theta + C_{L_{\hat{q}}} \hat{q} +
C_{L_{\delta_e}} \delta_e \right) / C_{L_0}' + \delta T /(\qbar_0 A)
\end{eqnarray}

Repeating the same process:
\begin{eqnarray}
m_{\eff} \delta \ddot{z}_t &=&
-\left(\qbar_0 + \rho v_{\kite} \delta \dot{x}_t \right) A \\
&\times& \left( C_{L_0}' + C_{L_{\alpha}}
\left( \frac{\delta \dot{z}_t}{v_{\kite}} -
\frac{v_{\wind}}{v_{\kite}} \frac{\delta \dot{x}_t}{v_{\kite}} +
\delta \theta \right) + C_{L_{\hat{q}}} \hat{q} + C_{L_{\delta_e}} \delta_e \right) \\
&+& -\left(\qbar_0 + \rho v_{\kite} \delta \dot{x}_t \right) A C_D
\left( \frac{v_{\wind}}{v_{\kite}} + \frac{\delta \dot{z}_t}{v_{\kite}} -
\frac{v_{\wind}}{v_{\kite}} \frac{\delta \dot{x}_t}{v_{\kite}} \right) \\
&-& k_{\eff} (\delta z_t + b_x \delta \theta) - \delta T \theta_0
\end{eqnarray}

Removing all second-order terms:

\begin{eqnarray}
\frac{m_{\eff}}{\qbar_0 A} \delta \ddot{z}_t &=&
-\left(\frac{\rho v_{\kite}^2}{\qbar_0} C_{L_0}' -
C_{L_{\alpha}} \frac{v_{\wind}}{v_{\kite}} +
\frac{\rho v_{\kite}^2}{\qbar_0} C_D \frac{v_{\wind}}{v_{\kite}} -
C_D \frac{v_{\wind}}{v_{\kite}}\right)
\frac{\delta \dot{x}_t}{v_{\kite}} \\
&-& \left(C_{L_{\alpha}} + C_D \right) \frac{\delta \dot{z}_t}{v_{\kite}} \\
&-& \frac{k_{\eff}}{\qbar_0 A} \delta z_t - C_{L_{\alpha}} \delta \theta -
C_{L_{\hat{q}}} \hat{q} - C_{L_{\delta_e}} \delta_e
\end{eqnarray}

Repeating for the pitch dynamics:
\begin{eqnarray}
I_{yy} \delta \ddot{\theta} &=&
\left(\qbar_0 + \rho v_{\kite} \delta \dot{x}_t \right) A \cbar \\
&\times& \left( C_{m_0}' + C_{m_{\alpha}} \left( \frac{1}{v_{\kite}} \delta \dot{z}_t -
\frac{v_{\wind}}{v_{\kite}^2} \delta \dot{x}_t + \delta \theta \right) +
C_{m_{\hat{q}}} \hat{q} +
C_{m_{\delta_e}} \delta_e \right) \\
&+& k_{\eff} (z_0 + \delta z_t + b_x \delta \theta + b_z) (b_x - b_z \delta \theta)
\end{eqnarray}

Removing all second-order terms:
\begin{eqnarray}
\frac{I_{yy}}{\qbar_0 A \cbar} \delta \ddot{\theta} &=&
\left( \frac{\rho v_{\kite}^2}{\qbar_0} C_{m_0}' -
C_{m_{\alpha}} \frac{v_{\wind}}{v_{\kite}} \right) \frac{\delta \dot{x}_t}{v_{\kite}} \\
&+& C_{m_{\alpha}} \frac{\delta \dot{z}_t}{v_{\kite}} +
\frac{k_{\eff} b_x}{\qbar_0 A \cbar} \delta z_t \\
&+& \left(C_{m_{\alpha}} +
\frac{k_{\eff} (-z_t_0 b_z + b_x^2 - b_z^2)}{\qbar_0 A \cbar}\right) \delta \theta \\
&+& C_{m_{\hat{q}}} \hat{q} + C_{m_{\delta_e}} \delta_e
\end{eqnarray}

\subsection{Lateral dynamics}

Assume $w << 1$.

\begin{eqnarray}
\mathbf{x} &=& \left[y, \phi, \psi, \dot{y}, \dot{\phi}, \dot{\psi} \right]^T \\
\mathbf{u} &=& \left[\delta_a, \delta_r, \tau_y, \tau_z \right]^T
\end{eqnarray}

\begin{eqnarray}
m (\dot{v} + r u) = \qbar A C_Y + t_y_b \\

\end{eqnarray}

\end{document}


\documentclass[]{AVSSimReportMemo}
\usepackage{AVS}
\usepackage{colortbl}

\newcommand{\ModuleName}{celestialTwoBodyPoint}
\newcommand{\subject}{Guidance Module for Celestial Two Body Point}
\newcommand{\status}{Initial Version}
\newcommand{\preparer}{M. Cols}
\newcommand{\summary}{Generate the attitude reference to satisfy a primary attitude pointing constrain and the best as possible a secondary one.}

\begin{document}

\makeCover

%
% enter the revision documentation here
% to add more lines, copy the table entry and the \hline, and paste after the current entry.
%
\pagestyle{empty}
{\renewcommand{\arraystretch}{2}
\noindent
\begin{longtable}{|p{0.5in}|p{4.5in}|p{1.14in}|}
\hline
{\bfseries Rev}: & {\bfseries Change Description} & {\bfseries By} \\
\hline
Draft & initial copy & M. Cols \\
\hline

\end{longtable}
}

\newpage
\setcounter{page}{1}
\pagestyle{fancy}

\tableofcontents
~\\ \hrule ~\\

\newpage
\section{Module Input and Ouptut}
Table \ref{tab:inputNavTable} shows the input message from the navigation system.
\begin{table}[h!]
	\centering
	\caption{Input Navigation Message}
	\begin{tabular}{|l|l|l|p{3in}|}
		\hline
		\rowcolor{BrickRed}
		\textcolor{white}{Name} & \textcolor{white}{Type} &
		\textcolor{white}{Length} &
		\textcolor{white}{Description}  \\ \hline
		$\leftexp{N}{\bm{r}}_{B/N}$ & double [] & 3 &
		Position vector of the spacecraft body-point with respect to the inertial frame in inertial frame components. \\ \hline
		$\leftexp{N}{\bm{v}}_{B/N}$ & double [] & 3 &
		Velocity vector of the spacecraft body-point with respect to the inertial frame in inertial frame components \\ \hline
	\end{tabular}
	\label{tab:inputNavTable}
\end{table}

Table \ref{tab:inputCelTable} shows the input message from Spice about the main celestial body.
\begin{table}[h!]
	\centering
	\caption{Input Spice Primary Message}
	\begin{tabular}{|l|l|l|p{3in}|}
		\hline
		\rowcolor{BrickRed}
		\textcolor{white}{Name} & \textcolor{white}{Type} &
		\textcolor{white}{Length} &
		\textcolor{white}{Description}  \\ \hline
		$\bm{R}_P$  & double [] & 3 &
		Position vector of the primary celestial object with respect to the inertial frame in inertial frame components . \\ \hline
		$\bm{v}_P$  & double [] & 3 &
		Velocity vector of the primary celestial object with respect to the inertial frame in inertial frame components . \\ \hline
	\end{tabular}
	\label{tab:inputCelTable}
\end{table}

Table \ref{tab:inputSecTable} shows the input message from Spice about the secondary celestial body.
\begin{table}[h!]
	\centering
	\caption{Input Spice Secondary Message}
	\begin{tabular}{|l|l|l|p{3in}|}
		\hline
		\rowcolor{BrickRed}
		\textcolor{white}{Name} & \textcolor{white}{Type} &
		\textcolor{white}{Length} &
		\textcolor{white}{Description}  \\ \hline
		$\bm{R}_S$  & double [] & 3 &
		Position vector of the secondary celestial object with respect to the inertial frame in inertial frame components . \\ \hline
		$\bm{v}_S$  & double [] & 3 &
		Velocity vector of the secondary celestial object with respect to the inertial frame in inertial frame components . \\ \hline
	\end{tabular}
	\label{tab:inputSecTable}
\end{table}

Table \ref{tab:outputTable} shows the Attitude Reference output message of the module Celestial Two Body Point.
\begin{table}[h!]
	\centering
	\caption{Output Attitude Reference Message}
	\begin{tabular}{|l|l|l|p{3in}|}
		\hline
		\rowcolor{BrickRed}
		\textcolor{white}{Name} & \textcolor{white}{Type} &
		\textcolor{white}{Length} &
		\textcolor{white}{Description}  \\ \hline
		$\bm{\sigma}_{R/N}$ & double [] & 3 &
		MRP attitude set of the reference frame with respect to the inertial. \\ \hline
		$\leftexp{N} {\bm{\omega}_{R/N}}$ & double [] & 3 &
		Angular rate vector of the reference frame with respect to the inertial expressed in inertial frame components. \\ \hline
		$\leftexp{N} {\bm{\dot{\omega}}_{R/N}}$ & double [] & 3 &
		Angular acceleration vector of the reference frame with respect to the inertial expressed in inertial frame components. \\ \hline
	\end{tabular}
	\label{tab:outputTable}
\end{table}
\newpage

\section{Reference Frame Definition}
This module computes a reference whose aim is to track the center of a primary target, e.g. pointing the communication antenna at the Earth, at the same time of trying to meet a secondary constraint as best as possible, e.g. a solar panel normal axis pointing the closest in the direction of the Sun.  It is important to note that two pointing conditions in a three-dimensional space compose an overdetermined problem. Thus, the main constraint is always priorized over the secondary one so the former can always be met.\\
Figure~\ref{fig:fig1} shows the case where Mars is the primary celestial body and the Sun is the secondary one. Note that the origin of the desired reference frame $\mathcal{R}$ is the position of the spacecraft.
\begin{figure}[htb]
	\centerline{
	\includegraphics[]{Figures/fig1}
	}
	\caption{Illustration of the restricted two-body pointing reference frame $\mathcal{R}:\{ \hat{\bm r}_{1},\hat{\bm r}_{1}, \hat{\bm r}_{2} \}$ and the inertial frame $\mathcal{N}:\{ \hat{\bm n}_{1},\hat{\bm n}_{1}, \hat{\bm n}_{2} \}$.}
	\label{fig:fig1}
\end{figure}

Assuming knowledge of the position of the spacecraft $\bm{r}_{B/N}$ and the involved celestial bodies, $\bm{R}_{P1}$ and  $\bm{R}_{P2}$ (all of them relative to the inertial frame $\mathcal{N}$ and expressed in inertial frame components), the relative position of the celestial bodies with respect to the spacecraft is obtained by simple subtraction:
\begin{subequations}
	\begin{align}
		 \bm{R}_{P1} =\bm{R}_{P} - \bm{r}_{B/N} \\
		 \bm{R}_{P2} =\bm{R}_{S} - \bm{r}_{B/N}
	\end{align}
\end{subequations}

In analogy, the inertial derivatives of these position vectors are obtained:
\begin{subequations}
	\begin{align}
		 \bm{v}_{P1} &=\bm{v}_{P} - \bm{v}_{B/N} \\
		 \bm{v}_{P2} &=\bm{v}_{S} - \bm{v}_{B/N} \\
		 \bm{a}_{P1} &=\bm{a}_{P} - \bm{a}_{B/N} \\
		 \bm{a}_{P2} &=\bm{a}_{S} - \bm{a}_{B/N}
	\end{align}
\end{subequations}

The normal vector $\bm{R}_{n}$ of the plane defined by $\bm{R}_{P1}$ and $\bm{R}_{P2}$ is computed through:
\begin{equation}
	\bm R_{n} =\bm{R}_{P1} \times \bm{R}_{P2}
\end{equation}
The inertial time derivative of $\bm{R}_n$ is found using the chain differentiation rule:
\begin{equation}
	\bm {v}_{n} = \bm{v}_{P1} \times \bm{R}_{P2} + \bm{R}_{P1} \times \bm{v}_{P2}
\end{equation}
And the second time derivative:
\begin{equation}
	\bm {a}_{n} = \bm{a}_{P1} \times \bm{R}_{P2} + \bm{R}_{P1} \times \bm{a}_{P2}  + 2 \bm{v}_{P1} \times \bm{v}_{P2}
\end{equation}
\subsection{ Special Case: No Secondary Constraint Applicable}
If there is no incoming message with a secondary celestial body pointing condition or if the constrain is not valid, an artificial three-dimensional frame is defined instead. Note that a single condition pointing leaves one degree of freedom, hence standing for an underdetermined attitude problem. A secondary constrain is considered to be invalid if the angle between $\bm{R}_{P1}$ and $\bm{R}_{P2}$ is, in absolute value, minor than a set threshold. This could be the case where the primary and secondary celestial bodies are aligned as seen by the spacecraft. In such situation, the primary pointing axis would already satisfy both the primary and the secondary constraints.

Since the main algorithm of this module, which is developed in the following sections, assumes two conditions, the second one is arbitrarily set as following:
\begin{equation}
		 \bm{R}_{P2} = \bm{R}_{P1} \times \bm{v}_{P1} \equiv  \bm{h}_{P1}
\end{equation}
By setting the secondary constrain to have the direction of the angular momentum vector $ \bm{h}_{P1}$, it is assured that it will always be valid ($\bm{R}_{P1}$ and $\bm{R}_{P2}$ are now perpendicular).
The first and second time derivatives are steadily computed:
\begin{equation}
	\bm{v}_{P2} =  \bm{R}_{P1} \times \bm{a}_{P1}
\end{equation}
\begin{equation}
	\bm{a}_{P2} =  \bm{v}_{P1} \times \bm{a}_{P1}
\end{equation}
\section{Reference Frame Definition}
As illustrated in Figure~\ref{fig:fig1}, the base vectors of the desired reference frame $\mathcal{R}$  are defined as following:
\begin{subequations}
	\begin{align}
		\hat{\bm r}_{1} &= \frac{{\bm R}_{P1}} {|{\bm R}_{P1}|} \\
		\hat{\bm r}_{3} &= \frac{{\bm R}_{n}}{|{\bm R}_{n}|} \\
		\hat{\bm r}_{2} &=  \hat{\bm r}_{3} \times \hat{\bm r}_{1}
	\end{align}
\end{subequations}
Since the position vectors are given in terms of inertial $\mathcal{N}$-frame components, the DCM from the inertial frame $\mathcal{N}$ to the desired reference frame $\mathcal{R}$ is:
\begin{equation}
	[RN] = \begin{bmatrix}
		\leftexp{N}{ \hat{\bm r}_{1}^{T} } \\
		\leftexp{N}{ \hat{\bm r}_{2}^{T} }  \\
		\leftexp{N}{ \hat{\bm r}_{3}^{T} }
	\end{bmatrix}
\end{equation}
\section{Base Vectors Time Derivatives}
The first and second time derivatives of the base vectors that compound the reference frame $\mathcal{R}$ are needed in the following sections to compute the reference angular velocity and acceleration. Several lines of algebra lead to the following sets:
\begin{subequations}
	\begin{align}
		\dot{\hat{\bm{r}}}_1 &= ([I_{3\times3}] - {\hat{\bm{r}}_1}{\hat{\bm{r}}_1}^T)  \frac{{\bm R}_{P1}} {|{\bm R}_{P1}|} \\
		\dot{\hat{\bm{r}}}_3 &= ([I_{3\times3}] - \hat{\bm{r}}_3 \hat{\bm{r}}_3^T)  \frac{{\bm R}_{n}} {|{\bm R}_{n}|} \\
		\dot{\hat{\bm{r}}}_2 &= \dot{\hat{\bm{r}}}_3 \times \bm{r}_1 +  \bm{r}_n  \times \dot{\hat{\bm{r}}}_3
	\end{align}
\end{subequations}

\begin{subequations}
	\begin{align}
		\ddot{\hat{\bm{r}}}_1 &= \frac{1}{|{\bm R}_{P1}|}
		(
		([I_{3\times3}] - {\hat{\bm{r}}_1}{\hat{\bm{r}}_1}^T)  \bm{a}_{P1} -
		2\dot{\hat{\bm{r}}}_1 (\hat{\bm{r}}_1 \cdot \bm{v}_{P1}) -
		\hat{\bm{r}}_1 (\dot{\hat{\bm{r}}}_1 \cdot \bm{v}_{P1})
		) \\
		\ddot{\hat{\bm{r}}}_3 &= \frac{1}{|{\bm R}_{n}|}
		(
		([I_{3\times3}] - {\hat{\bm{r}}_3}{\hat{\bm{r}}_3}^T)  \bm{a}_{n} -
		2\dot{\hat{\bm{r}}}_3 (\hat{\bm{r}}_3 \cdot \bm{v}_{n}) -
		\hat{\bm{r}}_3 (\dot{\hat{\bm{r}}}_3 \cdot \bm{v}_{n})
		) \\
		\ddot{\hat{\bm{r}}}_2 &= \ddot{\hat{\bm{r}}}_3 \times \bm{r}_1 +  \bm{r}_n  \times \ddot{\hat{\bm{r}}}_3 + 2\dot{\hat{\bm{r}}}_3 \cdot \dot{\hat{\bm{r}}}_1
	\end{align}
\end{subequations}

\section{Angular Velocity and Acceleration Descriptions}
Developing some more mathematics, the following elegant expressions of $\bm\omega_{R/N}$ and $\dot{\bm\omega}_{R/N}$ are found:
\begin{subequations}
	\begin{align}
		\bm\omega_{R/N} \cdot \hat{\bm r}_{1}  = \hat{\bm r}_{3} \cdot \dot{\hat{\bm r}}_{2}  \\
		\bm\omega_{R/N} \cdot \hat{\bm r}_{2} = \hat{\bm r}_{1} \cdot \dot{\hat{\bm r}}_{3}\\
		\bm\omega_{R/N} \cdot \hat{\bm r}_{3} = \hat{\bm r}_{2} \cdot \dot{\hat{\bm r}}_{1}
	\end{align}
\end{subequations}
\begin{subequations}
	\begin{align}
		\dot{\bm\omega}_{R/N} \cdot \hat{\bm r}_{1} &=
		\dot{\hat{\bm r}}_{3} \cdot \dot{\hat{\bm r}}_{2} + \hat{\bm r}_{3} \cdot \ddot{\hat{\bm r}}_{2} -  \bm\omega_{R/N} \cdot \dot{\hat{\bm r}}_{1}
		\\
		\dot{\bm\omega}_{R/N} \cdot \hat{\bm r}_{2} &=
		 \dot{\hat{\bm r}}_{1} \cdot \dot{\hat{\bm r}}_{3} + \hat{\bm r}_{1} \cdot \ddot{\hat{\bm r}}_{3} -  \bm\omega_{R/N} \cdot \dot{\hat{\bm r}}_{2}
		\\
		\dot{\bm\omega}_{R/N} \cdot \hat{\bm r}_{3} &=
		\dot{\hat{\bm r}}_{2} \cdot \dot{\hat{\bm r}}_{1} + \hat{\bm r}_{2} \cdot \ddot{\hat{\bm r}}_{1} -  \bm\omega_{R/N} \cdot \dot{\hat{\bm r}}_{3}
	\end{align}
\end{subequations}
Note that $\bm\omega_{R/N} \cdot \hat{\bm r}_{1}$ is the first component of the angular velocity of the reference with respect to the inertial expressed in reference frame components. Hence,
\begin{equation}
	\bm\omega_{R/N}= \leftexp{R}{
		\begin{bmatrix}
			\bm\omega_{R/N} \cdot \hat{\bm r}_{1} \\
			\bm\omega_{R/N} \cdot \hat{\bm r}_{2}  \\
			\bm\omega_{R/N} \cdot \hat{\bm r}_{3}
		\end{bmatrix}
	}
\end{equation}
Similarly for the angular acceleration:
\begin{equation}
	\bm{\dot\omega}_{R/N} = \leftexp{R}{
		\begin{bmatrix}
			\bm{\dot\omega}_{R/N} \cdot \hat{\bm r}_{1} \\
			\bm{\dot\omega}_{R/N} \cdot \hat{\bm r}_{2}  \\
			\bm{\dot\omega}_{R/N} \cdot \hat{\bm r}_{3}
		\end{bmatrix}
	}
\end{equation}
Eventually, in inertial frame components:
\begin{subequations}
	\begin{align}
		\leftexp{N} {\bm\omega_{R/N}} &= [RN] \textrm{ } \leftexp{R} {\bm\omega_{R/N}}
		\\
		\leftexp{N} {\bm{\dot\omega}_{R/N}} &= [RN]  \textrm{ } \leftexp{R} {\bm{\dot\omega}_{R/N}}
	\end{align}
\end{subequations}

\bibliographystyle{unsrt}
\bibliography{references}

\end{document}


\chapter{Results}
\label{Chapter:Results}

We could have some example data:
%
\begin{table}[htb]
	\pgfplotstabletypeset
		[
			header=false,
			display column names={a,$\sigma$,$p_x$,$p_y$,$p_z$},
			every head row/.style={before row=\toprule, after row=\midrule},
			every last row/.style={after row=\bottomrule}
		]
		{\datafolder/example/example_table.txt}
	\mycaption[Parameters of some sort maybe]
		{some text... \lipsum[20]}
\label{Table: example}
\end{table}
%
\lipsum[30]
%

Which leads us to the following tikz figure:
%
\begin{figure}[H]
	\useexternalfile[\tikzfolder]{example}
	\mycaption[some example data]
	{
		caption text... \lipsum[21]
	}
	\label{Fig: example}
\end{figure}
%
\lipsum[31]


\subsection{Binary types and conversions}\label{refobinar}
\index{Overview,binary types}
\index{Overview,conversions}
\index{Binary numbers,overview}
\index{Conversion,overview}
:p.
Most programming environments support the notion of fixed-precision
"primitive" binary types, which correspond closely to the binary
operations usually available at the hardware level in computers.
For the reference implementation, these types are:
:ul.
:li.
\emph{byte, short, int,} and \emph{long} - signed integers
that will fit in 8, 16, 32, or 64 bits respectively
:li.
\emph{float} and \emph{double} - signed floating point
numbers that will fit in 32 or 64 bits respectively.
:li.
\emph{char} - an unsigned 16-bit quantity, holding a Unicode
character
:li.
\emph{boolean} - a 1-bit logical value,
representing :m.0:em. or :m.1:em. ("false" or "true").
:eul.
:p.
Objects of these types are handled specially by the implementation
"under the covers" in order to achieve maximum efficiency; in
particular, they cannot be constructed like other objects - their
value is held directly.  This distinction rarely matters to the NetRexx
programmer: in the case of string literals an object is
constructed automatically; in the case of an :m.int:em. literal, an
object is not constructed.
:p.
Further, NetRexx automatically allows the conversion between the various
forms of character strings in implementations
:fn.
In the reference implementation, these
are :m.String:em., :m.char:em., :m.char[]:em. (an
array of characters), and the NetRexx string type, :m.Rexx:em..
:efn.
and the primitive types.  The "golden rule" that is followed by
NetRexx is that any automatic conversion which is applied must not lose
information: either it can be determined before execution that the
conversion is safe (as in :m.int:em. to :m.String:em.) or it
will be detected at execution time if the conversion fails (as
in :m.String:em. to :m.int:em.).
:p.
The automatic conversions greatly simplify the writing of programs;
the exact type of numeric and string-like method arguments rarely needs
to be a concern of the programmer.
:p.
For certain applications where early checking or performance override
other considerations, the reference implementation of NetRexx provides
options for different treatment of the primitive types:
:ol.
:li.
\texttt{options strictassign} - ensures exact type matching for all
assignments.  No conversions (including those from shorter integers to
longer ones) are applied.  This option provides stricter type-checking
than most other languages, and ensures that all types are an exact match.
:li.
\texttt{options binary} - uses implementation-dependent fixed
precision arithmetic on binary types (also, literal numbers, for
example, will be treated as binary, and local variables will be given
"native" types such as :m.int:em. or :m.String:em., where
possible).
:p.
Binary arithmetic currently gives better performance than NetRexx
decimal arithmetic, but places the burden of avoiding overflows and
loss of information on the programmer.
:eol.
:p.
The options instruction (which may list more than one option) is placed
before the first class instruction in a file; the \texttt{binary}
keyword may also be used on a \texttt{class} or \texttt{method}
instruction, to allow an individual class or method to use binary
arithmetic.
:h4.Explicit type assignment
:p.
You may explicitly assign a type to an expression or variable:
\index{Example,program}
\begin{verbatim}
i=int 3000000  -- 'i' is an 'int' with value 3000000
j=int 4000000  -- 'j' is an 'int' with value 4000000
k=int          -- 'k' is an 'int', with no initial value
say i*j        -- multiply and display the result
k=i*j          -- multiply and assign result to 'k'
\end{verbatim}
:p.
This example also illustrates an important difference between
\texttt{options nobinary} and \texttt{options binary}.  With the former
(the default) the \texttt{say} instruction would display the result
":m.1.20000000E+13:em." and a conversion overflow would be
reported when the same expression is assigned to the variable :m.k:em..
:p.
With \texttt{options binary}, binary arithmetic would be used for the
multiplications, and so no error would be detected; the \texttt{say}
would display ":m.-138625024:em." and the variable :m.k:em.
takes the incorrect result.
:h4.Binary types in practice
:p.
In practice, explicit type assignment is only occasionally needed in
NetRexx.  Those conversions that are necessary for using existing
classes (or those that use \texttt{options binary}) are generally
automatic.
For example, here is an "Applet" for use by Java-enabled
browsers:
\index{Example,applet}
\begin{verbatim}
/* A simple graphics Applet */
class Rainbow extends Applet
  method paint(g=Graphics)  -- called to repaint window
    maxx=size.width-1
    maxy=size.height-1
    loop y=0 to maxy
      col=Color.getHSBColor(y/maxy, 1, 1) -- new colour
      g.setColor(col)                     -- set it
      g.drawLine(0, y, maxx, y)           -- fill slice
    end y
\end{verbatim}
:p.
In this example, the variable :m.col:em. will have
type :m.Color:em., and the three arguments to the
method :m.getHSBColor:em. will all automatically be converted to
type :m.float:em..  As no overflows are possible in this example,
\texttt{options binary} may be added to the top of the program with no
other changes being necessary.


\section{MIDI format}
The Musical Instrument Digital Interface (MIDI) protocol is an industry-standard defined in the early '80s to represent musical information~\cite{midi_history}. It is the most spread binary protocol for communication intended to connect electronic musical instruments such as synthesizers, to a computer for the purpose of recording and editing~\cite{midi_power}. Unlike other formats (.wav or .mp3), MIDI files don't contain any audio by themselves, only the instructions to reproduce it. It allows sending of messages over 16 channels, each of them could be a different instrument.

\subsection{Structure of the MIDI file}
At the top level, MIDI files contain events. Each event consists of two parts: MIDI time and MIDI message. They follow each other in a successive manner as shown in Figure \ref{fig:midi_messages}. The time value represents the time to wait before playing the next message. This method of specification is called delta time($\Delta time$) (Table \ref{table:midi_time}).

\begin{table} [H]
	\centering
	\caption{Understanding event time based on delta time}
	\begin{tabular}{ |c|c|}
		\hline
		$\Delta T$ & Elapsed time until the event \\ \hline
		$t_1 = \Delta T_1 = T_1 - 0$ &  $T_1 = t_1$ \\ \hline
		$t_2 = \Delta T_2 = T_2 - T_1$ & $T_2 = t_1+t_2$\\ \hline
		$t_3 = \Delta T_3 = T_3 - T_2$ & $T_3 = t_1+t_2+t_3$ \\ \hline
		$t_4 = \Delta T_4 = T_4 - T_3$ & $T_4 = t_1+t_2+t_3+t_4$ \\ \hline
		... & ... \\ \hline
	\end{tabular}
	\label{table:midi_time}
\end{table}

\begin{figure}[H]
	\caption[MIDI file messages]{ MIDI file messages }
	\centering
	\label{fig:midi_messages}
	\includegraphics[width=1\textwidth, height=0.9\textheight, keepaspectratio]{"resources/midi_messages"}
\end{figure}

\subsection{MIDI messages}
The main messages of a MIDI file are \textbf{note on} and \textbf{note off}. The former is sent when a key is pressed on the music keyboard. It contains parameters such as the pitch and velocity (i.e. intensity) of the note. When a synthesizer receives this message it starts playing that note until a \textbf{note off} event arrives for that pitch.

\par
The velocity ranges between 1 and 127. It corresponds to the nuances (i.e. dynamics) found in music notation as shown in Figure \ref{fig:midi_velocity}.

\begin{figure}[H]
	\caption[Dynamics and velocity associations]{Dynamics and velocity associations~\cite{midi_dynamics}}
	\centering
	\label{fig:midi_velocity}
	\includegraphics[width=1\textwidth, height=0.9\textheight, keepaspectratio]{"resources/note_velocity"}
\end{figure}


\section{Introduction}
The study of relativistic heavy-ion collisions provides a fruitful playground for physicists to understand many different aspects of high-energy nuclear physics ranging from the resolution of the complex nuclear structure to the highly interesting physics of the Quark-Gluon-Plasma (QGP) providing further insights into to state of the art of our Universe shortly after the Big Bang. \\
A complete treatment of these collision events would need concepts from quantum chromodynamics (QCD), relativistic hydrodynamics and also methods from statistical physics. Here we will focus on the latter since the aim of this seminar is to get insights into the various applications of the concepts presented in the introductory lecture on statistical physics and the previous talks to modern research.\\
For a visualization of the complexity of the physical processes relevant for the study of relativistic heavy-ion collisions have a look at figure \ref{fig:phases} at the beginning of the next page. In this talk we will have a closer look at the initial stages of such events since only a detailed understanding of the relaxation of the out-of-equilibrium initial state into a (hopefully) known equilibrium final state allows further analysis using the well-known techniques from e.\,g. hydrodynamics mentioned before (and displayed in the upper part of the corresponding figure). \newpage
\begin{figure}[t]
\centering
\includegraphics[width = 0.5\textwidth]{figures/rhic_schematic}
\caption[Visualization of the spacetime evolution of the system created in relativistic heavy-ion collisions.]{Visualization of the spacetime evolution of the system created in relativistic heavy-ion collisions. We will focus on the pre-equilibrium phase which is displayed here in the gray area near the origin.\footnotemark }
\label{fig:phases}
\end{figure}
\footnotetext{The figure was taken from B. Hippolyte's slides: \tiny{\url{http://www.nupecc.org/presentations/hippo_mar17.pdf} (23.06.2020)}}