% USEFUL LINKS:
% -------------
%
% - UiO LaTeX guides:          https://www.mn.uio.no/ifi/tjenester/it/hjelp/latex/
% - Mathematics:               https://en.wikibooks.org/wiki/LaTeX/Mathematics
% - Physics:                   https://ctan.uib.no/macros/latex/contrib/physics/physics.pdf
% - Basics of Tikz:            https://en.wikibooks.org/wiki/LaTeX/PGF/Tikz
% - All the colors!            https://en.wikibooks.org/wiki/LaTeX/Colors
% - How to make tables:        https://en.wikibooks.org/wiki/LaTeX/Tables
% - Code listing styles:       https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings
% - \includegraphics           https://en.wikibooks.org/wiki/LaTeX/Importing_Graphics
% - Learn more about figures:  https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions
% - Automagic bibliography:    https://en.wikibooks.org/wiki/LaTeX/Bibliography_Management  (this one is kinda difficult the first time)
%
%                              (This document is of class "revtex4-1", the REVTeX Guide explains how the class works)
%   REVTeX Guide:              http://www.physics.csbsju.edu/370/papers/Journal_Style_Manuals/auguide4-1.pdf
%
%
% COMPILING THE .pdf FILE IN THE LINUX TERMINAL
% ---------------------------------------------
%
% [terminal]$ pdflatex report_example.tex
%
% Run the command twice, always.
%
% When using references, footnotes, etc. you should run the following chain of commands:
%
% [terminal]$ pdflatex report_example.tex
% [terminal]$ bibtex report_example
% [terminal]$ pdflatex report_example.tex
% [terminal]$ pdflatex report_example.tex
%
% This series of commands can of course be gathered into a single-line command:
% [terminal]$ pdflatex report_example.tex && bibtex report_example.aux && pdflatex report_example.tex && pdflatex report_example.tex
%
% ----------------------------------------------------



% \documentclass[english,notitlepage,reprint,nofootinbib]{revtex4-2}  % defines the basic parameters of the document
\documentclass[english,notitlepage,reprint,nofootinbib]{revtex4-2}  % defines the basic parameters of the document
% If you want a single-column, remove "reprint"
\usepackage{silence}
\WarningFilter{revtex4-2}{Repair the float}

% Allows special characters (including æøå)
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

% Note that you may need to download some of these packages manually, it depends on your setup.
% It may be usefult to download TeXMaker, because it includes a large library of the most common packages.

\usepackage{amssymb}  % mathematical symbols (physics imports amsmath)
\usepackage{amsmath}
\usepackage{graphicx}         % include graphics such as plots
\usepackage{xcolor}           % set colors
\usepackage{hyperref}         % automagic cross-referencing
\usepackage{listings}         % display code
\usepackage{subfigure}        % imports a lot of cool and useful figure commands
% \usepackage{float}
%\usepackage[section]{placeins}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{subfigure}
\usepackage{tikz}
\usepackage{cleveref}
\usepackage{siunitx}
\usetikzlibrary{quantikz}
% defines the color of hyperref objects
% Blending two colors:  blue!80!black  =  80% blue and 20% black
\hypersetup{ % this is just my personal choice, feel free to change things
    colorlinks,
    linkcolor={red!50!black},
    citecolor={blue!50!black},
    urlcolor={blue!80!black}}


% ===========================================
\newcommand{\vstat}{V_\mathrm{stat.}}
\newcommand{\vdyn}{V_\mathrm{dyn.}}
\newcommand{\estat}{E_\mathrm{stat.}}
\newcommand{\edyn}{E_\mathrm{dyn.}}
\newcommand{\estatc}[1]{E_{\mathrm{stat.},#1}}
\newcommand{\edync}[1]{E_{\mathrm{dyn.},#1}}

\begin{document}

\title{Accuracy and Stability of Numerical Integration Methods in Penning Trap Simulations}  % self-explanatory
\author{Lars Bogner} % self-explanatory
\date{\today}                             % self-explanatory
\noaffiliation                            % ignore this, but keep it.

%This is how we create an abstract section.
\begin{abstract}
    \textcolor{red}{TODO: ABSTRACT HERE.}
\end{abstract}
\maketitle


% ===========================================
\section{Introduction}
\input{chapters/introduction}

% ===========================================
\section{Methods}\label{sec:methods}
%
\input{chapters/methods}


% ===========================================
\section{Results and discussion}\label{sec:results_and_discussion}
%
\input{chapters/results}

% ===========================================
\section{Conclusion}\label{sec:conclusion}
%
\input{chapters/conclusion}

% ===========================================
\appendix
\section{Electric Field Equations} \label{app:efield_equations}
Here we derive the electric field equations used in \cref{sec:methods}. The electric field following from $\vstat$ defined in \cref{eq:V_stat} is given by
\begin{align}
    \estatc{x} &= -\frac{\partial \vstat}{\partial x} = \frac{V_0}{d^2} x, \\
    \estatc{y} &= -\frac{\partial \vstat}{\partial y} = \frac{V_0}{d^2} y, \\
    \estatc{z} &= -\frac{\partial \vstat}{\partial z} = -\frac{2 V_0}{d^2} z,
\end{align}
for all $|\vec r| < d$ and zero otherwise. The electric field following from $\vdyn$ is simply
\begin{equation}
    \edyn = (1 + f \cos \omega_V t) \cdot \estat.
\end{equation}

\section{Special Case Analytical Solution} \label{app:special_case_analytical_solution}
In the special case of a single particle in the potential $\vstat$, with the inital conditions $\vec{r}(t_0) = (x_0, 0, z_0)$ and $\vec{v}(t_0) = (0, v_0, 0)$, we can derive an analytical solution for the trajectory. The solution for the $z$ component is straightforward
\begin{equation}
    z(t) = z_0 \cos(\omega_z t).
\end{equation}
From the equation system
\begin{align}
    f(0) = A_+ e^{-i \phi_+} + A_- e^{-i \phi_-} &\equiv x_0, \\
    \dot f(0) = -i \omega_+ A_+ e^{-i \phi_+} - i \omega_- A_- e^{-i \phi_-} &\equiv i v_0,
\end{align}
we derive $\phi_\pm = 0$ as $f(0) \in \mathbb{R}$ and therefore $A_+ + A_- = x_0$ and $\omega_+ A_+ + \omega_- A_- = -v_0$. Solving this system of equations for $A_\pm$ we find
\begin{equation}
    A_\pm =\pm \frac{v_0 + \omega_\mp x_0}{\omega_- - \omega_+}.
\end{equation}

% ===========================================
\onecolumngrid
% \bibliographystyle{apalike}
\bibliographystyle{unsrt}
\bibliography{ref}


\end{document}