\section{Siamese Multi-Object Tracking and Embedding}
\label{sec:SiamMOTandFeatureEmb}

% ##############################################################################
\subsection{Motivation}

One of our experiments involved an end-to-end training of the \gls{siammot} together with a custom head aimed at embeddings based on \gls{roi}-pooled features for the object \gls{bbox}. The goal was to force the training process into extracting features that are not only satisfactory for detection and tracking but also do contain the necessary information to create embeddings for \gls{reid} purposes during the inference. We strived for simplicity by extending the processing pipeline without altering the existing infrastructure.

During research related to our Siamese tracking survey~\cite{ondrasovic2021siamese}, we noticed one work where the exemplar features were projected using \gls{gap} into an embedding space consisting of fewer dimensions~\cite{li2020figsiam}. The embedding vector was produced using the feature tensor representing the kernel for the cross-correlation operation. More concretely, let the extracted features be represented by an $8 \times 8 \times 256$ tensor. Then, the \gls{gap} along the channel dimension would produce a $1 \times 1 \times 256$ tensor, which could then be further flattened into a single $256$D vector. In the end, the obtained vector was $l_2$-normalized and thus projected onto a unit hypersphere. In the work of Li~\etal{}~\cite{li2020figsiam}, these embedding vectors were exploited for template updating and for combining multiple templates within a pool of size $n$ in an exponential fashion.

This observation led us to the following hypothesis. Given the fact the Siamese exemplar features do contain some, although probably not sufficient information for pure object \gls{reid}, would it be possible to map them further using a non-linear function to produce embedding vectors that could serve for \gls{reid}? Such features are just a learned template, therefore, some notion of similarity needs to be already built into it.

% ##############################################################################
\subsection{Feature Embedding Head Architecture}

% ------------------------------------------------------------------------------
\begin{figure}[!t]
    \centering
    \includegraphics[width=\linewidth]{figures/siamese_tracking/siammot_feature_emb_training.pdf}
    \caption[Embedding-enhanced \gls{siammot} architecture]{Our extension (shown in red) to the underlying \gls{siammot} architecture that incorporates vector embeddings to the end-to-end training. This diagram shows the pipeline that is used during the training, not inference.}
    \label{fig:SiamMOTWithEmbeddings}
\end{figure}
% ------------------------------------------------------------------------------

As for the vector embedding computation, we attached an \gls{femb} head (\tabletext{}~\ref{tab:FeatureEmbeddingHead}) after the \gls{roi}-pooling phase of the backbone features (\figtext{}~\ref{fig:SiamMOTWithEmbeddings}). This ensured fixed tensor shapes and allowed us to process the very same features that the object detector and Siamese tracker utilized, too. Simply put, for every proposal made for a particular frame, we looked at the delineated \gls{bbox} through the lens of \gls{roi}-pooling to extract its features. We simply reused the extracted exemplar features. Later on, we processed these features using our newly devised \gls{femb} head to produce \gls{femb}. The resulting embeddings were subjected to the triplet loss computation with all the necessary operations such as various types of hard negative mining.

\begin{table}[!t]
    \centering
    \begin{tabular}{lll}
        \toprule
        \textbf{layer}    & \textbf{tensor shape}        & \textbf{parameters no.} \\
        \midrule
        input             & $\sbrackets{B, 128, 15, 15}$ & $0$                     \\
        \midrule
        conv $3 \times 3$ & $\sbrackets{B, 128, 13, 13}$ & $147\ 456$              \\
        ReLU              & $\sbrackets{B, 128, 13, 13}$ & $0$                     \\
        \midrule
        conv $3 \times 3$ & $\sbrackets{B, 256, 11, 11}$ & $294\ 912$              \\
        ReLU              & $\sbrackets{B, 256, 11, 11}$ & $0$                     \\
        \midrule
        flatten           & $\sbrackets{B, 30976}$       & $0$                     \\
        linear            & $\sbrackets{B, 1024}$        & $31\ 720\ 448$          \\
        \midrule
        $l_2$-normalize   & $\sbrackets{B, 1024}$        & $0$                     \\
        \bottomrule
                          & \textbf{total}               & $32\ 162\ 816$          \\
        \cline{2-3}
    \end{tabular}
    \caption[\gls{femb} head]{Our custom \gls{femb} head that we used to process backbone-extracted features to produce embedding vectors. It is built from two convolutional layers separated by a \gls{relu} nonlinearity followed by a fully connected layer that produces a $1024$ dimensional feature embedding. The batch size dimension is given by $B$ in the tensor shape. Since each embedding vector is normalized to unit length, we avoided learning biases throughout the whole network.}
    \label{tab:FeatureEmbeddingHead}
\end{table}

% ##############################################################################
\subsection{Training Phase}

The training phase was altered by adding another loss function to the sum of already existing three losses from the original model. In particular, the general \gls{siammot} loss function defined in \eqtext{}~\ref{eq:SiamMOTGeneralLoss} was reformulated as
\begin{equation}
    \label{eq:SiamMOTFeatureEmbLoss}
    \lossf = l_{rpn} + l_{detect} + l_{motion} + l_{emb}.
\end{equation}
The $l_{emb}$ loss incorporated a triplet loss (\eqtext{}~\ref{eq:TripletLoss},~p.~\pageref{eq:TripletLoss}). We also experimented with a contrastive loss (\eqtext{}~\ref{eq:ContrastiveLoss},~p.~\pageref{eq:ContrastiveLoss}), but the effect was detrimental in every aspect as expected, so we will not discuss it any further.

As we remarked in \sectiontext{}~\ref{sec:LatentSpacesAndEmbeddings},~p.~\pageref{sec:LatentSpacesAndEmbeddings}, aimed at latent spaces and embeddings, it is crucial to adopt appropriate sample mining strategies when using the triplet loss. The rationale is that for the training to keep progressing, the model needs to encounter harder and harder triplets to generate sufficient learning signals. To this end, we went for the semi-hard triplet mining strategy (\eqtext{}~\ref{eq:BatchHardMining},~p.~\pageref{eq:BatchHardMining}). However, we struggled with collapsing embeddings~\cite{levi2021rethinking}. This phenomenon happens when the embedding training forces the model to project all the features onto a single point in the embedding space, thus incurring the loss equal to the used margin. We claim that the use of semi-hard negative mining produced triplets that were too difficult. Since we used all the \gls{rpn} proposals to generate triplets, one may imagine that there would always be proposals covering only some small part of the object, making it problematic for the network to learn the concept of ``similarity'' and ``difference'' if it only processes very hard images. Nevertheless, these situations are very common in margin-based losses~\cite{levi2021rethinking}. The computed loss is so high that it is more suitable for the model to map all the features onto a single point. To remedy this, we implemented a batch-all online mining strategy (\eqtext{}~\ref{eq:BatchAllLossFunction},~p.~\pageref{eq:BatchAllLossFunction}), which stabilized the training.

We recommend first utilizing the batch-all mining strategy during the training, and then proceeding to a batch-hard strategy after a certain point. However, this approach would be time-consuming to find the right hyperparameters. There are many open questions, such as how to mine the \gls{rpn} proposals in a better way or how to set the margin value. Loss functions aimed at object \gls{reid} are notoriously cumbersome to train. We implemented the entire mining algorithm followed by the loss computation in a \gls{gpu}-only fashion for fast execution and easy integration into the pipeline.

% ##############################################################################
\subsection{Inference Phase}

\subsubsection{Feature-based Non-Maximum Suppression}
\label{sssec:FeatureNonMaximumSuppression}

Salscheider~\cite{salscheider2020featurenms} proposed an extended \gls{nms} algorithm that incorporates a distance between feature embeddings dubbed as \featurenms{} (\algtext{}~\ref{alg:FeatureNMS}). Considering our idea introduced above, we had to encompass the vector embeddings into the solver reasoning. In the beginning, we came up with a solution that exactly copied the one the mentioned author proposed. That provided further justification for attempting to implement the algorithm and test it in practice. The advantage is that this approach is restricted to the inference phase, thus experimenting with it does not require model re-training.

\def\threshlower{\tau_{\text{lower}}}
\def\threshupper{\tau_{\text{upper}}}
\def\threshsim{\delta}

We assume the reader is acquainted with the \gls{nms} algorithm (\sectiontext{}~\ref{ssec:NonMaximumSuppression},~p.~\pageref{ssec:NonMaximumSuppression}). Here we repeat the same definitions for clarity. Let $\mset{B} = \cbrackets{\vect{b}_1, \vect{b}_2, \dots, \vect{b}_n}$ be a set of $n$ region proposals described by $n$ \glspl{bbox}. Scores for each detection are contained in a set $\mset{S} = \cbrackets{s_1, s_2, \dots, s_n}$, where $s_i$ denotes a detection score for the $i$-th box, $\vect{b_i}$. This time, we are also going to need the associated feature embedding vectors with each \gls{bbox}, represented by a set $\mset{E} = \cbrackets{\vect{e}_1, \vect{e}_2, \dots, \vect{e}_n}$. Let $\mset{B}_{fnms}$ be  the set of filtered proposal instances from the set $\mset{B}$ produced by the \featurenms{} algorithm. The distinction in parameters is the following. The original algorithm requires only one threshold for the maximum allowed portion of the overlap between regions. The \featurenms{} requires three parameters discussed below.
\begin{itemize}
    \item A minimum threshold $\threshlower$ denoting a boundary below which the two objects are deemed as different. This value should be low, for example, $0.2$, which means that if the \gls{iou} between the two objects is less than $0.2$, then the two instances should be treated as different objects.
    \item A maximum threshold $\threshupper$ denoting a boundary above which the two objects are considered identical. Unlike the $\threshlower$, this value should be high, \egtext{}, $0.8$, indicating that if the \gls{iou} of the two object instances surpasses this threshold, then it should be the same object. The \gls{bbox} with the lower confidence is discarded.
    \item A threshold $\threshsim$ is used as a decision boundary between the embedding vectors. This threshold should reflect a measure of similarity. If the adopted measure of similarity falls below $\threshsim$, then the two objects are different, otherwise, they are considered the same. This value of $\threshsim$ is used only if the two conditions above do not hold.
\end{itemize}

\begin{algorithm}[t]
    \caption[\featurenms{} algorithm]{\featurenms{} algorithm.}
    \label{alg:FeatureNMS}
    \begin{algorithmic}[1]
        \Function{Feature-NMS}{$\mset{B}$, $\mset{S}$, $\mset{E}$, $\threshlower$, $\threshupper$, $\threshsim$}

        \State $\mset{B}_{fnms}$ $\gets$ $\emptyset$
        \Comment{initialize the output (filtered) set of region proposals}

        \While {$\mset{B} \neq \emptyset$}
        \Comment{loop until all the proposals are processed}

        \State $m \gets \underset{i \in \cbrackets{1, 2, \dots, \msetsize{S}}}{\argmax{}} \mset{S}$
        \Comment{find an index of a proposal with the highest score}

        \State $\mset{B} \gets \mset{B} - \vect{b}_m$, $\mset{S} \gets \mset{S} - s_m$, $\mset{E} \gets \mset{E} - \vect{e}_m$
        \Comment{remove the proposal}

        \State $\mset{B}_{fnms} \gets \mset{B}_{fnms} \cup \vect{b}_m$
        \Comment{save the proposal with the highest score}

        \For{$i \gets 1$ to $\msetsize{B}$}
        \Comment{iterate through remaining proposals}

        \If{\Call{iou}{$\vect{b}_m$, $\vect{b}_i$} $\geq \threshlower$}
        \Comment{above the lower-bound threshold}

        \If{\Call{iou}{$\vect{b}_m$, $\vect{b}_i$} $\geq \threshupper$}
        \Comment{above the upper-bound threshold}

        \State $\mset{B} \gets \mset{B} - \vect{b}_i$, $\mset{S} \gets \mset{S} - s_i$, $\mset{E} \gets \mset{E} - \vect{e}_i$
        \Comment{remove the proposal}

        \Else

        \If{\Call{similarity}{$\vect{e}_m$, $\vect{e}_i$} $\geq \threshsim$}
        \Comment{similarity above threshold}
        \State $\mset{B} \gets \mset{B} - \vect{b}_i$, $\mset{S} \gets \mset{S} - s_i$, $\mset{E} \gets \mset{E} - \vect{e}_i$
        \Comment{remove the proposal}
        \EndIf

        \EndIf
        \EndIf
        \EndFor
        \EndWhile

        \State \Return $\mset{B}_{fnms}$
        \EndFunction
    \end{algorithmic}
\end{algorithm}

% ##############################################################################
\subsection{Experimental Evaluation and Discussion}

The proposed embedding-based enhancement was evaluated against the baseline model without the \gls{femb} head. For a fair comparison, we made sure that the hyperparameters were identical to the greatest possible extent. We only had to alter the batch size and the learning rate. Since the triplet loss requires the computation of a large number of triplets, especially the batch-all strategy, we had to decrease the batch size and employ \gls{ga} to avoid crashes due to not having enough \gls{gpu} \gls{vram} available.

We can tell that this experiment was also detrimental to the tracker's performance. We conjecture that it was solely caused by the introduction of the \gls{femb} head itself. Our ablation study also demonstrated that joint training with the \gls{femb} head harmed the tracker, even if the original solver was adopted during the evaluation. This raises the question of potential task/feature conflict between the heads. We venture to claim there is an inherent incompatibility between the detection, tracking, and \gls{reid} tasks, despite the existence of a recently published work Lu~\etal{}~\cite{lu2020retinatrack}, who developed their \retinatrack{} tracker. Their framework exploited the base visual object detector called a \retinanet{}~\cite{lin2018focal} and then added, in principle, a very similar head as we did to produce embeddings. However, there are obvious architectural differences between the two trackers in terms of how the inference phase is executed.

\begin{table}[!t]
    \centering
    \begin{tabular}{llllll}
        \toprule
        \textbf{\gls{femb} head} & \textbf{solver} & \textbf{MOTA} & \textbf{MOTP} & \textbf{precision} & \textbf{recall} \\
        \midrule
                                 & original        & $0.7416$      & $0.1478$      & $0.9454$           & $0.7896$        \\
        \checkmark               & \featurenms{}   & $0.6861$      & $0.1568$      & $0.9166$           & $0.7574$        \\
        \checkmark               & original        & $0.6882$      & $0.1568$      & $0.9184$           & $0.7574$        \\
        \bottomrule
    \end{tabular}
    \caption[The effect of \gls{femb} head inclusion]{Demonstration that introduction of the \gls{femb} head causes a feature conflict on the level of backbone before the \gls{roi}-pooling operation. The effect is clearly visible since the \featurenms{} algorithm is only part of the inference phase. Both the object detection and the tracking head are ``parallel'' to the \gls{femb} head, however, training with the \gls{femb} head and then avoiding it during the inference considerably reduces the tracker's accuracy. The last two rows are practically identical in terms of \gls{clear} evaluation.}
    \label{tab:OrigSolverVsFeatureNMS}
\end{table}

To see the aforementioned feature conflict, one of the key takeaways from this trial, \tabletext{}~\ref{tab:OrigSolverVsFeatureNMS} shows that training the model with the \gls{femb} head and then evaluating it without the \featurenms{} algorithm, \ietext{}, using the original solver algorithm (\figtext{}~\ref{fig:SiamMOTOnlineSolver}), resulted in a drastically reduced tracker's accuracy. The reason is that the \gls{roi}-pooled features were trained in a conflicting way, therefore no task was served satisfactorily. Having trained the model and then omitting the \gls{femb} head completely during the testing should not dramatically affect ``parallel heads''. However, once the entire end-to-end model tries to accommodate for the triplet, object detection, and tracking loss functions, the conflicting nature of these tasks manifests itself in a negative fashion. This table shows the best models given by the combination of \gls{mota} and \gls{motp} metrics. All models were trained with \gls{ga} using batch size of $32 = 16 \times 2$ with $256$ object proposals. The relatively big batch size was dictated by the unstable nature of the triplet loss training.

Although this extension is not appropriate for practical usage unless further modifications are devised, we still wanted to evaluate the impact on inference speed in terms of \gls{fps} for comparison with the next experiment. It can be seen that the reduction in the tracker's speed is noticable. Specifically, the original model inference runs on average at $26.49$ \gls{fps}, whilst the \fembmodel{} version achieves $18.57$ \gls{fps}, resulting in reduction speed of about $30$\% (more in \tabletext{}~\ref{tab:InferenceSpeedComparison},~p.~\pageref{tab:InferenceSpeedComparison}).

\subsubsection{``Unfairness'' between the detection and re-identification}

There is a recent publication~\cite{zhang2021fairmot} by Zhang~\etal{} that discusses the notion of ``fairness'' between detection and \gls{reid}. According to their empirical evidence, there are multiple levels of ``unfairness''. This term was used to describe a situation in which the importance of either \gls{reid} or the detection task is lessened. We would like to emphasize the recency of this work (the end of $2021$) since several of their remarks and conclusions coincide with ours. Had this paper been published before conducting our experiments, we would have taken a different path, or at least we would have striven to find another way to incorporate the embeddings into an end-to-end pipeline. The aforementioned work, among other things, introduces a joint tracker that effectively circumvents the obstacles related to conflicting tasks. This framework avoids the use of anchor proposals and is based on \gls{centernet}~\cite{zhou2019centernet} object detector.

They argue that the \gls{reid} task may become overlooked if the embedding vectors are produced solely from the \gls{roi}-pooled regions, as in our case. Consequently, the detection task becomes central in terms of influence upon the loss function since generating embedding vectors on incorrect \glspl{bbox} is meaningless. Thus, the bias to produce accurate object proposals is inescapable.

Next, a problem arises when one anchor corresponds to multiple identities, which is an obstacle we have already mentioned (\sectiontext{}~\ref{ssec:SiamMOTAndReIDDiscussion}). As a result, the extracted features are not optimal in terms of their accuracy as well as discriminative representativeness. To remedy this, features should be extracted at a single point, \ietext{}, at the estimated object centers (hence the use of \gls{centernet}), instead of region proposals.

An analogical problem is when multiple anchors correspond to one identity. A high overlap in terms of \gls{iou} directs the model to estimate the same identity for nearby anchors. But, even a small perturbation may result in falling below a specific threshold and the anchors become marked as belonging to different objects. This situation is very common as proposals are generated on the feature level (a coarse representation due to downsampling), and not on the pixel level.

Another inherent problem when merging object detection and \gls{reid} is feature conflict. We have highlighted numerous times the significance of multi-layer feature fusion. However, not all tasks benefit from this approach equally. In particular, object detection utilizes high-level features to estimate object classes and locations, whereas the \gls{reid} is more prone to utilizing low-level features owing to their discriminative power. For that reason, it is important to balance the loss optimization.

Last but not least, the feature dimension poses another source of imbalance. The authors remarked that learning lower-dimensional features for the \gls{reid} is better than higher-dimensional. In our research, we thought the opposite is true. High-dimensional embedding vectors notably harm the object detection accuracy due to the competition between the two tasks. The number of feature dimensions for detection is usually very low (compared to $1024$D or $2048$D embedding vectors). We adopted high-dimensional vector embeddings in conjunction with the usual low-dimensional detector features, thereby further exacerbating the rivalry. The rationale behind proposing to use, \egtext{}, $64$D embedding vectors, is that the \gls{mot} task executes just a few one-to-one matchings between two consecutive frames. However, there is a tacit assumption of having all objects sufficiently visible, as this work did not cover occlusion handling and their benchmark evaluations were not specifically targeted at full object occlusion, which is a path worth exploring. Nonetheless, the proposed framework achieved \gls{sota} performance among \gls{mot} approaches, surpassing the competitive frameworks by a large margin.


\section{Daevana}\label{race:daevana}
Daevana are a very tall and muscular race of lesser giant-kin that live in small clans and call the savage wilderness of Northern Knorkalith, but especially the island of Lonereach, their home.\\
Daevana mature at the age of 10, and live to be around 60.\\
At their best, Daevana are loyal, helpful and friendly.\\
At their worst, Daevana are temperamental, boastful and unpredictable.\\
Every Daevana starts with a \textbf{Strength increased by 2}.\\
Also, their \textbf{Vitality is increased by 1}\\
However, their \textbf{Intellect is reduced by 2}\\
Additionally, their Daevana's \textbf{Empathy is reduced by 1}\\
Daevana are especially brutish. \textbf{When they make a strength-based melee attack roll, they add 1d6 to the damage.}
Also, their survival in savage lands has made them especially resilient.
\textbf{When they gain a level in "Increase Health", they can roll twice and take the higher result.}\\
Lastly, Daevana have an \textbf{increased Damage reduction against cutting, piercing and blunt by +1.}\\
Daevana start the game with 25 Health, 30 Stamina and 15 Mana.


% This is an example for a `Introduction'.
% To generate the final document, run latex, build and quick build commands
% on the skeleton-thesis file not this one.

\chapter{Introduction}\label{chapters:Introduction}
%\vspace{-7mm}

While seemingly small objects, nuclei and their interactions can play an enormous role across a wide swath of energy and spatial scales.
From understanding the abundance of elements produced in astrophysical events to providing a general description of quantum many-body equilibration, the deceptively simple study of two colliding nuclei can be illuminating.
Even the more traditionally aligned investigations that are associated with nuclear reactions (such as superheavy element and neutron-rich nuclei formation) acts as a foundation for other areas of physics to piece together an understanding of the physical world.

Leaving aside the fact that nuclei are made of protons and neutrons, the dynamics of interacting quantum systems alone is of extreme interest to researchers from varied fields.
This is due to the striking fact that most quantum many-body systems (no matter the specific systems and particles that compose their structure) exhibit the same general features as atomic nuclei.
That is to say that studying the fusion, transfer, equilibration, vibrations, etc. of nuclear systems can provide vital insight into analogous studies in interactions between cold atoms or molecules -- systems which are several orders of magnitude larger than the few femtometers (fm) of interest to nuclear physicists.

\section{The nuclear many-body problem (in a nutshell)}

\begin{figure}[t]
	\includegraphics[width=\textwidth]{../Figures/intro_figs/ReidForce2.jpg}
	\caption{An example nucleon-nucleon potential from the Reid model~\citep{reid1968} of the nuclear force. Note the characteristic exponential decay in the attractive tail, as well as the strong repulsion that tends toward infinity at $R\approx0.7$. Figure from~\citep{bdushaw}.}
	\label{fig:reid}
\end{figure}

The specific subbranch of nuclear physics this thesis focuses on is the realm of low-energy nuclear physics.
At this level, relativistic effects are typically neglected and the nuclei are modeled as collections of protons and neutrons interacting with each other to form a bound system.
The force felt by the nucleons themselves is an artifact of the strong interaction, mediated primarily by the exchange of virtual pions with an effective range of about~$1$~fm.
Through further contributions by vector mesons (principally rho and omega), a complicated model of interacting nucleons can be built that depends on not only a nucleon's charge and distance, but also on its spin and angular momentum as well.
An example channel of the Reid potential~\citep{reid1968} is shown in Fig.~\ref{fig:reid}.
Extensive effort has been placed in modeling nuclei using such an interaction (see ~\citep{wiringa1995} for another popular choice of an N-N potential), though this \textit{ab initio} approach is not numerically feasible for large nuclei or for simulating dynamical interactions between nuclei.
It is for this reason that alternate approaches to modeling finite nuclei have been pursued throughout the field's history.

One such approach is that of the mean-field method which, simply stated, assumes that each nucleon moves freely through an average field made up of contributions from all the other nucleons.
This independent particle approximation is extremely powerful because it reduces a series of N-body self interactions to a simple sum over each individual particle.
%in the mean-field.
%A schematic image is shown in Fig.~\ref{fig:meanfield}.
While many takes on the mean-field idea have been pursued over time, the foundation of the current work was formulated in 1928 when Hartree developed the self-consistent field method~\citep{hartree1928}.
This was further extended for antisymmetric systems by Fock to form the more complete Hartree-Fock method that has been used since~\citep{fock1930}.
The term "self-consistent" used above refers to the fact that the effective Hamiltonian of the system depends on the single particle wave functions themselves, thus requiring the problem to be solved iteratively.
One common approach is to choose an initial guess of Gaussian wave packets for the first step and then a minimization procedure is followed to obtain the ground state solution for the nucleus.
Despite having a general purpose algorithm for self-consistently solving the static many-body quantum problem, the method wasn't widely adopted until computational abilities were readily available due to the large matrices involved in larger systems paired with the iterative nature of the problem.

While the Hartree-Fock method provides a general purpose, robust numerical algorithm, it is only useful for studying static properties of nuclei.
To obtain a time-dependent theory based on the mean-field approximation, one may proceed in several ways\footnote{For a more complete description of the various approaches to deriving TDHF (including a path integral formulation, many-body perturbation theory, the Balian-V\'en\'eroni variational principle, etc) see~\citep{simenel2018}.} though we will focus on the derivation by minimization of the Dirac action.
As it's vital to all chapters of this thesis and reveals much about the approximations and limitations of the theory, I will cover the derivation in detail.
First, consider the Dirac action from $t_0$ to $t_1$,
\begin{equation}
S\equiv S_{t_0,t_1}[\Psi] = \int_{t_0}^{t_1}dt \langle \Psi(t) | \left(i\hbar\frac{d}{dt}-\hat{H}\right)|\Psi(t)\rangle.
\end{equation}
For a generic many-body wave function, $|\Psi(t)\rangle$, the stationary solution of the action will simply be the Schr\"odinger equation, thus we impose that the many-body wave function is a Slater determinant of independent particle states $|\phi_i(t)\rangle$ to obtain
\begin{equation}
S_{t_0,t_1}[\Psi] = \int_{t_0}^{t_1}dt \left(\sum_{i=1}^{N} \langle\phi_i(t)|i\hbar\frac{d}{dt}|\phi_i(t)\rangle-\langle\phi_i(t)|\hat{H}|\phi_i(t)\rangle\right).
\end{equation}
This can be simplified further by defining the quantity $\sum_{i=1}^{N}\langle\phi_i(t)|\hat{H}|\phi_i(t)\rangle$ as an energy density functional (EDF), $E[\rho(t)]$.
Now, by varying with respect to single particle states we may impose the stationarity of the action
\begin{equation}
\frac{\delta S}{\delta\langle\phi_i(t)|}=i\hbar\frac{d}{dt}|\phi_i(t)\rangle - \int_{t_0}^{t_1}dt' \frac{\delta E[\rho(t)]}{\delta\langle\phi_i(t)|} = 0,
\end{equation}
with the final step being to utilize the chain rule in the EDF integral and define a final quantity, the single particle Hamiltonian, $h[\rho(t)]=\frac{\delta E[\rho(t)]}{\delta\rho(t)}$.
Collecting all of this, we are left with our final TDHF equation
\begin{equation}
i\hbar\frac{d}{dt}|\phi_i(t)\rangle = h[\rho(t)]|\phi_i(t)\rangle.
\label{eq:tdhf}
\end{equation}
By examining the form of the TDHF equations, we see that we have a description of the time evolution for each state, $i$, in the system.
Furthermore, the single particle Hamiltonian has a dependence on $\rho(t)$ and thus on the wave functions themselves.
This is in line with the self consistency feature of static Hartree-Fock mentioned above, and thus in the time propagation procedure densities from a half time step are typically used for stability.

\begin{figure}[t]
	\includegraphics[width=\textwidth]{../Figures/intro_figs/paths.png}
	\caption{A schematic depiction of the stationary path chosen for the TDHF evolution.\hfill\null}
	\label{fig:paths}
\end{figure}

An extremely important feature of the TDHF method comes about by restricting ourselves to the stationary path from $t_0$ to $t_1$, namely that we recover only a single path in time.
This is at odds with a fully quantum picture of a many-body system evolving in time where multiple paths have some probability of occurring.
Figure~\ref{fig:paths} shows a schematic explanation of this choice.
It is for this reason that TDHF is described as a semi-classical theory and only recovers the most probable event in a time evolution.
Beyond this, the derivation required us to consider fully independent particles, just as assumed in the Hartree-Fock method, meaning that many-body correlations will not be considered.
As will be seen later in this thesis, these (and other) limitations require extensions to the base theory to uncover features in nuclear reactions that are absent with the present formulation.
Despite the theoretical shortcomings of the approach, pure TDHF calculations have been extremely successful in reproducing experimental data over its history.

One final point of interest to note from the derivation above is the appearance of a density dependent single particle Hamiltonian in Eq.~\ref{eq:tdhf}.
As this Hamiltonian was derived by varying an EDF by the density, it allows one to skip a standard representation of the interaction between nucleons as a one or two-body potential and write down the EDF directly.
This is now the standard approach in mean-field, low-energy nuclear physics and there are various forms and fits of functionals that are in active use such as Skyrme and Gogny~\citep{skyrme1956,decharge1980}.
In practice, the nuclear EDF also depends on other quantities such as the probability current, spin density, spin-current density, and so on.
The interaction used in the results presented in the current work are of the Skyrme type and the specific EDFs are noted in the individual chapters' method sections.
%This approach is justified by the Hohenberg-Kohn theorems which prov~\citep{hohenberg1964}

The specific mean-field and beyond mean-field approaches to each project presented in this work are discussed in their respective chapters, though a general, brief word should be said about the validity of the mean-field method as it applies to atomic nuclei.
As the nucleus is traditionally thought of as a densely packed collection of nucleons, the primary assumption that individual protons and neutrons can travel freely in the nucleus is a bit counter intuitive.
It turns out, however, that the Pauli exclusion principle between nucleons ensures that the particles will remain at an average distance exceeding their radius at low energies~\citep{ring1980}.
Even at finite collision energies, the mean free path of nucleons in the nucleus is several times that of the nuclear radius, implying that a so-called hard-core collision is unlikely.
This means that the average potential felt by the nucleons in the nucleus will be around the minimum of a model potential like the one shown in Fig.~\ref{fig:reid}.
Should one go to higher collision energies, the mean-field approximation begins to break down and may misrepresent the outcome of such reactions.

\section{Nuclear dynamics}

\begin{figure}[t]
	\includegraphics[width=\textwidth]{../Figures/intro_figs/timescale.png}
	\caption{The general timescales of nuclear reactions from quasielastic scattering through fusion and subsequent decay.}
	\label{fig:timescale}
\end{figure}

Our focus is now turned to the dynamics of nuclear physics at low collision energies as predicted by TDHF.
Broadly speaking, for two incoming nuclei with their own distinct numbers of protons and neutrons, one could expect to see a large number of possible outcomes depending on factors such as the orientation of the incoming nuclei, the distance off the collision axis, and the energy between the two fragments.
What is seen experimentally will be some complex combination of initial configurations, however.
The typical technique employed to investigate a given system is then to perform a large number of calculations across the configuration space in an attempt to understand what is happening systematically as you change any initial quantity.
It is for this reason that one must take care to check the full parameter space in order to make authoritative statements on the physics at play in reactions, especially when comparing to experimental data.

The usual method of classifying nuclear reactions is by the length of time that the fragments stay in contact\footnote{The specific definition of contact varies from work to work, though it is typically stated as when the density in the neck region between the nuclei is around half the saturation density, $\rho=0.08$.} before coming apart again.
Of course, if the fragments stay together indefinitely this is interpreted as a fusion event in TDHF.
Though the timescales and definition of reaction channels are fluid, they may be roughly divided into categories as is shown in Fig.~\ref{fig:timescale}.
For reasons mentioned in the previous section TDHF is capable of investigating reaction mechanisms from the far left of the chart up through compound nucleus formation (around $10^{-20}-10^{-19}$s in Fig.~\ref{fig:timescale}).
Any subsequent events after a fused system is formed, like fission or the evaporation of a particle, will not occur in a TDHF calculation and must be dealt with using a separate technique.

\begin{figure}[t]
	\includegraphics[width=\textwidth]{../Figures/intro_figs/48Ca249BkEvolution_tr.png}
	\caption{A typical density evolution for a quasifission reaction. The system presented is $^{48}$Ca$+^{249}$Bk and the figure is taken from~\citep{godbey2020}.}
	\label{fig:qf}
\end{figure}

As an example case, a typical set of contours from a benchmark quasifission reaction may be seen in Fig.~\ref{fig:qf}.
In this reaction, as is common in quasifission, the initially mass asymmetric system collides and begins to exchange a substantial amount of energy and mass before rotating and forming two new nuclei as they separate.
As mentioned before, the nuclei produced in such a reaction will depend on the initial configuration, and substantial effort has been expended to understand the production rates of nuclei via these sorts of reactions.
From the image it is clear that the dynamics governing the outcome of a nuclear collisions depend on much more than the incoming number of particles, hence the sophisticated tools required to study these processes.

\section{Summary}

Through use of state-of-the-art many-body methods this thesis explores nuclear reactions through both theoretical development and extensions of the base theories, as well as through systematic, comprehensive studies of nuclei.
Each chapter either focuses on a specific aspect of nuclear reactions or attempts to exhaustively characterize a given system.
In Chapter~\ref{chapters:chapter_2}, I discuss the development of a new extension to explore the role of transfer in the initial stages of the collision on fusion.
The basis of the technique is described and then select applications are presented to demonstrate the applicability to generic nuclear systems.
Chapter~\ref{chapters:chapter_3} meanwhile continues to focus on fusion, though via a more basic aspect.
Specifically, a method is developed to directly show the impact of the Pauli exclusion principle on heavy ion collisions at low energies.

Chapters~\ref{chapters:chapter_4} and~\ref{chapters:chapter_5} turn away from the development of new extensions to TDHF and instead look into the effect of the Skyrme tensor interaction on fusion for multiple systems.
Similar to this is Chapter~\ref{chapters:chapter_6} which studies fusion cross sections of \textsuperscript{12}C+\textsuperscript{12}C both above and below the fusion barrier.
This study also represents an effort to make extremely precise fusion calculations be checking the effect of numerical changes on the results.

Finally, the last two chapters are largely devoted to transfer studies for two systems of nuclei.
Chapter~\ref{chapters:chapter_7} utilizes direct TDHF collisions to study fragment production in $^{48}$Ca+$^{249}$Bk reactions.
Due to the deformed nature of $^{249}$Bk, a complete sweep of angles was performed to paint the fullest picture yet of quasifission in TDHF.
While also a study of transfer, Chapter~\ref{chapters:chapter_8} goes beyond TDHF to look at fluctuations about the mean field to uncover the correlations that are missing in the base theory.
This system, as did the one before, requires a large amount of computation due to the deformed initial states and the added cost of the beyond TDHF method.

\clearpage


% !Mode:: "TeX:UTF-8"

\documentclass[11pt, a4paper]{article}
%\usepackage{xltxtra,fontspec,xunicode}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{breqn}
\usepackage{autobreak}
\usepackage{braket,mleftright}
\usepackage{amsfonts}
\usepackage[section]{placeins}
\usepackage{float}
\usepackage{siunitx}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{mwe}
\usepackage{indentfirst}
\usepackage{caption}
\usepackage{physics}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{algorithm}% http://ctan.org/pkg/algorithm
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx

\geometry{top=1in, bottom=1in, left=1in, right=1in}
%\linespread{1.5}

\DeclareMathOperator*{\argmax}{argmax}
\DeclareMathOperator*{\argmin}{argmin}

\newcommand{\degc}{$\,^\circ$C}

\begin{document}

\title{Work Report}
\author{Zhuoran Qiao}
\date{\today}

\maketitle

\section{Introduction}

\paragraph{1} Developed a genetic algorithm based approach to simulate kinetics of co-transcriptional folding.
\paragraph{2} Tested effect of folding rate variation on folding population dynamics and $p_{unbound}$.

\section{Progress}
\subsection{Framework}
Various algorithms or programs have been developed to predict RNA folding pathway ultilizing force-field based simulations and multiple coarse grained energy landscape sampling methods built on Markov state model. Those present methods have succeeded in revealing multiscale dynamic events during RNA folding, however are either designed for only predicting
annealing dynamics or limited to RNA segments with length up to hundred bases. To quantitatively predict folding dynamics coupled with transcription,
we developed a genetic algorithm and chemical Master equation based approach, which is capable of capturing kilobase level kinetics.
 Our method is built on two following assumptions:
\paragraph{1} All populated RNA secondary structures (SS) are linkage of locally optimal or sub-optimal structures at various folding sites;
\paragraph{2} Global structural rearrangement of a partial RNA segment is permitted only if it's folding to the optimal SS on that segment.
\\

Formally, we denote a domain $D_{A,\,B}$ as a segment between base $A$ and $B$ that all contacts on that segment are local. For simplicity, we denote \textbf{foldon}
as domains with optimal secondary structures: $D^{foldon}_{A,\,B} = \text{MFE(sequence[A,B])}$. Note that $'.'$ is a trival example of foldon.
Our assumption 1 can be rewritten as
\begin{equation}
  D_{A,\,B} = D^{foldon}_{A, i_1} \oplus D^{foldon}_{i_1, i_2} \oplus ... \oplus D^{foldon}_{i_n, B}
\end{equation}
Where $\oplus$ represents a link operation. Note that all structural information of $D_{A,\,B}$ is encoded by the sequential representation $[A,\, i_1,\, ...,\, i_n,\, B]$;
 as a foldon is also a linkage of smaller foldons, there could be multiple way to represent $D_{A,\,B}$. Here we introduce \textbf{Irreducible Foldon Representation} (IFR) to be the
 sequential representations for which linkage of every adjacent foldons is not another foldon: $\forall k,\, D^{foldon}_{i_k, i_{k+1}} \oplus D^{foldon}_{i_{k+1}, i_{k+2}} \neq D^{foldon}_{i_{k}, i_{k+2}}$.
 Then the sufficient and necessary condition for structural rearrangement is

\begin{center}
  $\langle D^{u}_{A,\,B} | \hat{\mathbf{T}} | D^{v}_{A,\,B} \rangle \neq 0$ if and only if $\exists\, i,\,j$ satisfies

  $i,\,j \in D^{u}_{A,\,B}$.IFR, $i,\,j \in D^{v}_{A,\,B}$.IFR;

  $D^{u}_{A,\,i} = D^{v}_{A,\,i},\, D^{u}_{j,\,B} = D^{v}_{j,\,B}$;

  $D^{u}_{i,\,j} = D^{foldon}_{i,\,j}$ or $D^{v}_{i,\,j} = D^{foldon}_{i,\,j}$.

  Then $\langle D^{u}_{A,\,B} | \hat{\mathbf{T}} | D^{v}_{A,\,B} \rangle = \langle D^{u}_{i,\,j} | \hat{\mathbf{T}} | D^{v}_{i,\,j} \rangle$.
\end{center}

\subsection{Folding pathway identification \& Rate calculation} \label{section:rate}

Given two domains between which rearrangement is allowed, the task is to compute forward and backward rate constant
linking each other. Multiple methods to rigorously calculate the maximum likelihood during RNA folding have been reported;
here we proposed a computationally feasible approach: the forward free energy barrier is estimated by sum up all free energy associated
with old stacks unzipping and new loop forming; then rate constant $k_{uv} = \langle D^{u}_{A,\,B} | \hat{\mathbf{T}} | D^{v}_{A,\,B} \rangle $ is calculated by Arrhenius approximation $k_{uv} = k_0 \exp[-\frac{1}{RT}(\Delta G^{Stack}_{u}+\Delta G^{Loop}_{v})]$. 'New' and 'old' helices are identified by comparing elementary domains (defined as domains that cannot be decomposed to smaller valid domains) between reactant and product domains; identical elementary domains are excluded.

\subsection{Algorithm procedure}

During every iterative elongation step, an active species pool of strands with unique SS and diffrent population is updated. New candidate strands $D^{Candidate}_{0,\, L+\Delta L}$ with
length $L+\Delta L$ are generated by a recombination
process: for every old strand $D^{Strand}_{0, \text{ L}}$, all indices in its IFR is identified as possible rearrangement site, then its child strands is generated by linking partial domains
$D^{Strand}_{0, \text{ Site}}$ with a foldon $D^{foldon}_{\text{Site}, L+\Delta L}$ that terminated at $L+\Delta L$.

We assume that elongation will not change the inital population distribution
of secondary structures: child strands with the exact parental SS on $[0, L]$ ($D^{child}_{0, L+\Delta L} = D^{strand}_{0, L} \oplus D^{foldon}_{L, L+\Delta L}$) will also inherit the population of their parents.

After structual generation the rate matrix among all candidate strands within the new active species pool is calculated (see part \ref{section:rate}). Then the population
distribution of strands after elongation is computed by propagate the chemical master equation.

For the sake of computational efficiency, we introduce a cutoff $N $ as the size limit of the active species pool. After each elongation step, we impose a selection sweep on all active
strands; species with top $N $ fitness is reserved. In the current edition, we simply used population as the fitness function. Population of remaining strands within
the active pool is renormalized after selection.

Pseudocodes of the whole simulation procedure are as follows (Algorithm \ref{algorithm:1}):

\begin{algorithm}
  \begin{algorithmic}[1]
    \State Initalize ActivePool
    \While{$\text{sequence length} > \text{current length }$}
      \State $\text{OldPool} \gets \text{ActivePool }$
      \State $\text{renew ActivePool }$
      \State $\text{Current length} \gets \text{Current length} + dL$
      \State $\text{dt} \gets dL / k_T$ \Comment{Transcription time}
      \For{$\text{left boundary} \in \text{\{0, dL, 2dL, ..., Current length - dL\}}$}\Comment{Get all new foldons}
        \State $D^{foldon}_{\text{left boundary}, \text{ Current length}} \gets \text{numpy.mfe(sequence[left boundary, Current length]})$
      \EndFor
      \For{$\text{Strand} \in \text{OldPool }$}\Comment{Recombination}
        \For{$\text{Site} \in \text{Strand.IFR }$}
          \State $D^{Candidate}_{0,\text{Current length}} \gets D^{Strand}_{0, \text{ Site}} \oplus D^{foldon}_{\text{Site}, \text{ Current length}}$
          \If {$D^{Candidate}_{0,\text{Current length}} \in \text{ActivePool }$}
            \State $\text{update $D^{Candidate}_{0,\text{Current length}}$.IFR}$
          \Else
            \State $\text{add $D^{Candidate}_{0,\text{Current length}}$ to ActivePool}$
          \EndIf
          \If {$\text{site} = \text{Current length} - dL$}
            \State $\langle \text{ActivePool}.\textbf{population}\,|D^{Candidate}_{0,\text{Current length}}\rangle \gets \langle \text{OldPool}.\textbf{population}\,|D^{Strand}_{0, \text{ Site}}\rangle$
          \EndIf
        \EndFor
      \EndFor
      \For{$D^{\text{u}}_{0,\text{Current length}} \neq D^{\text{v}}_{0,\text{Current length}} \in \text{ActivePool}$}\Comment{Calculate new rate matrix}
        \State $\text{calculate  } D^{u}_{\text{rearrange}} ,\ D^{v}_{\text{rearrange}}$\Comment{Find all helices involved in rearrangement}
        \State $\langle D^{u}_{\text{rearrange}} | \hat{\mathbf{T}} |D^{v}_{\text{rearrange}} \rangle \gets k_0 \exp(-\frac{1}{RT}(\Delta G^{Stack}_{u}+\Delta G^{Loop}_{v}) )$
      \EndFor
      \State $\langle \text{ActivePool}.\textbf{population}\,|\, \gets \langle \text{ActivePool}.\textbf{population}\,|\, \exp(t\times\hat{\mathbf{T}}) $\Comment{Master equation}
      \State $\text{reserve top $N$ populated strands in ActivePool}$\Comment{Selection}
      \State $\text{renormalize }\langle \text{ActivePool}.\textbf{population}\,|$
    \EndWhile
  \end{algorithmic}
\caption{Co-transcriptional folding elongation procedure}\label{algorithm:1}
\end{algorithm}

\subsection{Results}

The only remaining free parameter to be determined is $k_0/k_T$, the ratio of pre-exponential factor in Arrhenius rate formulation and trancription rate ($nt\cdot s^{-1}$). I tuned $k_0/k_T$ from $10^{1}$ to $10^{15}$ and obtained the data for $k_0/k_T=\infty$ by calculate stationary distribution ($\frac{1}{Q}\exp(-G_i)$) after every elongation step for strand i in active pool.

\paragraph{Population analysis} For folA-WT four predominant local folding motifs within SD sequence are identified. Figure \ref{fig:local_foldings} shows exemplary secondary structures containing these motifs; figure \ref{fig:populations} shows evolution of these structure motifs during co-transcriptional folding with different $k_0/k_T$. Identical motifs are marked by the same color as in figure \ref{fig:local_foldings}. Surprisingly we noticed that when $k_0/k_T=\infty$, exchange between dominant motifs is very frequent at early stage of transcription, indicating the sensitivity of local structures on long-range contacts, and dependence of motif predominance on the limited timescale for folding.

\begin{figure*}
    \centering
    \begin{subfigure}[b]{0.475\textwidth}
   		\centering
    	\includegraphics[width=\textwidth]{folding_example_purple}
    	\caption[]%
   		{{\small Motif 1}}
    	\label{fig:mean and std of net14}
    \end{subfigure}
   	\hfill
    \begin{subfigure}[b]{0.475\textwidth}
   		\centering
   		\includegraphics[width=\textwidth]{folding_example_blue}
    	\caption[]%
    	{{\small Motif 2}}
   		\label{fig:mean and std of net24}
   	\end{subfigure}
   	\vskip\baselineskip
   	\begin{subfigure}[b]{0.475\textwidth}
    	\centering
    	\includegraphics[width=\textwidth]{folding_example_red}
   		\caption[]%
   		{{\small Motif 3}}
    	\label{fig:mean and std of net34}
    \end{subfigure}
   	\quad
   	\begin{subfigure}[b]{0.475\textwidth}
   		\centering
    	\includegraphics[width=\textwidth]{folding_example_grey}
    	\caption[]%
   		{{\small Motif 4}}
   		\label{fig:mean and std of net44}
   	\end{subfigure}
    \caption[ Exemplary ss containing folding motifs within folA-WT Shine-Dalgarno sequence ]
   	{\small Exemplary ss containing folding motifs within folA-WT Shine-Dalgarno sequence}
   	\label{fig:local_foldings}
\end{figure*}

\begin{figure*}[tph]
\centering
\includegraphics[width=\textwidth]{RNA_local_population_evolution_summary}
\caption[Population dynamics]{\small Population dynamics of four structrual motifs during co-transcriptional folding.}
\label{fig:populations}
\end{figure*}

\paragraph{$p_{unbound}$ analysis} We calculated $p_{unbound}$ with respect to transcription time and $k_0/k_T$ (Figure \ref{fig:RNA_p_unbound_SD_k_tuning}-\ref{fig:RNA_p_unbound_base[-14]_k_tuning}). Deviation of asymptotic behavior from equilibrium value (calculated by nupack.ppairs) is possiblly due to the limited set of foldons (only used mfe to obtain current results).

\begin{figure}
	\centering
	\includegraphics[width=\linewidth]{p_unbound/RNA_p_unbound_SD_k_tuning}
	\caption{}
	\label{fig:RNA_p_unbound_SD_k_tuning}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{p_unbound/RNA_p_unbound_base[-8]_k_tuning}
\caption{}
\label{fig:RNA_p_unbound_base[-8]_k_tuning}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{p_unbound/RNA_p_unbound_base[-9]_k_tuning}
\caption{}
\label{fig:RNA_p_unbound_base[-9]_k_tuning}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{p_unbound/RNA_p_unbound_base[-10]_k_tuning}
\caption{}
\label{fig:RNA_p_unbound_base[-10]_k_tuning}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{p_unbound/RNA_p_unbound_base[-11]_k_tuning}
\caption{}
\label{fig:RNA_p_unbound_base[-11]_k_tuning}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{p_unbound/RNA_p_unbound_base[-12]_k_tuning}
\caption{}
\label{fig:RNA_p_unbound_base[-12]_k_tuning}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{p_unbound/RNA_p_unbound_base[-13]_k_tuning}
\caption{}
\label{fig:RNA_p_unbound_base[-13]_k_tuning}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{p_unbound/RNA_p_unbound_base[-14]_k_tuning}
\caption{}
\label{fig:RNA_p_unbound_base[-14]_k_tuning}
\end{figure}

%\paragraph{a.} Using a genetic-algorithm based method and NUPACK to predict populated RNA configurations during cotranscriptional folding (in progress);
%\paragraph{b.} Using master equation method to simulate evolution of folding configurations and SD sequence accessibility.

%In order to examine when the one-dimensional coordinate projection could be recognized as effective reaction coordinate,
%we then examine the probability distribution of committors for transition path trajectories $p(q|TP)$, for which a single peak of probability $p(q|TP)$ have been ultilized as a indicator for 'good' reaction coordinates.
% Firstly, We found that for harmonic toy model, the shape of $p(q|TP)$ is very sensitive to the definition of source/sink region. For illustration, $p(q|TP)$ for two different selection
%  of source/sink regions was compared: in the first case, only two free energy minimum was indentified as source or sink\textbf{(S1)}; in the second case, only the barrier top was
%  defined as the transition path, while other two region of the free energy landscape was calssified as source/sink\textbf{(S2)}.

%\cite{Jacobs2018,Chaudhury2010,Vanden-Eijnden2010,Metzner,Krivov}

\small
%\bibliographystyle{plain}
%\bibliography{0727}

\end{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                 %
% GEANT manual in LaTeX form                                      %
%                                                                 %
% Michel Goossens (for translation into LaTeX)                    %
% Version 1.00                                                    %
% Last Mod. Jan 24 1991 1300  MG + IB                             %
%                                                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Origin{L.Urb\'{a}n}
\Revision{J. Chwastowski}
\Submitted{26.10.84}\Revised{16.12.93}
\Version{GEANT 3.16}\Routid{PHYS231}
\Makehead{Simulation of photoelectric Effect}
\section{Subroutines}
\Shubr{GPHOT}
{\tt GPHOT} simulates the photoelectric effect. It uses the following
input and output:
\begin{DLtt}{MMMMMMM}
\item[Input]{via common \Cind{GCTRAK}}
\item[Output]{via common \Cind{GCKING}}
\end{DLtt}
It calls the functions \Rind{GPHSG1}, \Rind{GPHSGP}, \Rind{GAVRL2}
and \Rind{GAVRL3} for the cross-section and the functions \Rind{GHPHAK},
\Rind{GHPHAL1}, \Rind{GHPHAL2}, \Rind{GPHAL3} for the cosine distribution
of the photoelectron. \Rind{GPHOT} is called by the tracking routine
\Rind{GTGAMA}, if, and when, the photon reaches its interaction point.
\Sfunc{GAVRL2}{VALUE = GAVRL2(GAMAL2,BETAL2,X)}
\Rind{GAVRL2} calculates approximation of the cross-section for the
photoelectric effect from $L_{II}$ shell. {\tt GAMAL2},
{\tt BETAL2} are the Lorentz gamma and beta factors of the emitted
photoelectron and $X = m_e/E_\gamma$ where $m_e$ is
the electron mass and $E_\gamma$ is the incident radiation energy.
\Rind{GAVRL2} is called by \Rind{GHPOT}.
\Sfunc{GAVRL3}{VALUE = GAVRL3(GAMAL3,BETAL3,X)}
\Rind{GAVRL3} calculates approximation of the cross-section for the
photoelectric effect from $L_{III}$ shell.
{\tt GAMAL3}, {\tt BETAL3} are the Lorentz gamma and beta factors of the
emitted photoelectron and $X = m_e/E_\gamma$ where $m_e$ is the electron
mass and $E_\gamma$ is the  incident radiation energy.
{\tt GAVRL3} is called by \Rind{GPHOT}.
\Sfunc{GPHAK}{VALUE = GPHAK(BETAK)}
\Sfunc{GPHAL1}{VALUE = GPHAL1(BETAL1)}
{\tt GPHAK} and its entry point {\tt GPHAL1} poll the cosine distribution
(w.r.t. the incident photon direction) of the photoelectron emitted from
$K$ or $L_{I}$ shell, respectively. They are called by \Rind{GPHOT}.
\Sfunc{GPHAL2}{VALUE = GPHAL2(BETAL2)}
\Rind{GPHAL2} polls the cosine distribution (w.r.t. the incident photon
direction) of the photoelectron emitted from $L_{II}$ shell.
\Sfunc{GPHAL3}{VALUE = GPHAL3(BETAL3)}
{\tt GPHAL3} polls the cosine distribution (w.r.t. the incident photon
direction) of the photoelectron emitted from $L_{III}$ shell.
It is called by \Rind{GPHOT}.
\Sfunc{GPHSGP}{VALUE = GPHSGP(EGAM)}
\Rind{GPHSGP} calculates the photoelectric effect total cross-section for
a particular atom of a mixture taking into account weights. It is called by
\Rind{GPHOT} for ${\tt Z} \leq  100$.

\section{Method}

If the energy of the radiation incident on an atom is $E_{\gamma}$, then
the quanta can be absorbed if $E_{\gamma} > E_{shell}$.
The photoelectron is emitted with total energy:
\begin{equation}
E_{photoelectron} = E_{\gamma}-E_{shell}+m_e.
\end{equation}
In the above equation it is assumed that the atom has infinite mass. One should
note that there exists a correction term (see \cite{bib-BETHE} and
references therein) which becomes more and more important with
increasing $E_{\gamma}$ \cite{bib-HALL} \cite{bib-PRATT} \cite{bib-PRATT1}.

\subsection{Probability of Interaction with an Atom}
Probability of the interaction with an atom is calculated taking into
account partial cross-sections of atoms of a mixture
or a compound.
\subsection{Probability of Interaction with a Shell}
To calculate the probability of the interaction with a particular shell we use
the jump ratios defined as:
\begin{equation}
J_{shell} = \frac{\sigma(E_{shell}+\delta E)}{\sigma(E_{shell}-\delta E)}
\label{eq:jumprat}
\end{equation}
where $\delta E \rightarrow 0$.
In addition we assume that the jump ratio is also valid away from the edges.\\
From (\ref{eq:jumprat}) it follows that the probability $p_{shell}$
to interact with a shell is:
\begin{equation}
p_{shell} = 1-\frac{1}{J_{shell}}
\label{eq:probrat}
\end{equation}
We use the following parametrisation of the jump ratios for $K$ and
$L_{I}$ shells\cite{bib-VEIGELE}:
\begin{equation}
J_K = \frac{125}{Z} + 3.5
\end{equation}
\begin{equation}
J_{L_{I}} = 1.2
\label{eq:jumpl1}
\end{equation}
For the $L_{II}$ and $L_{III}$ shells we adopt approximation of the formulae
calculated by Gavrila \cite{bib-GAVRILA-L}:
\begin{eqnarray}
\sigma_{L_{II}} &=& \gamma \beta \frac{m_e}{E_\gamma}
              \left\{
               \gamma^3-5\gamma^2+24\gamma-16
               -(\gamma^2+3\gamma-8)\frac{\log(\gamma(1+\beta))}{\gamma\beta}
              \right\}
\label{eq:sigmal2}
\end{eqnarray}
and
\begin{eqnarray}
\sigma_{L_{III}} &=& \gamma \beta \frac{m_e}{E_\gamma}
             \left\{
                4\gamma^3-6\gamma^2+5\gamma+3
               -(\gamma^2-3\gamma+4)\frac{\log(\gamma(1+\beta))}{\gamma\beta}
             \right\}
\label{eq:sigmal3}
\end{eqnarray}
where\\

\begin{tabular}[t]{l@{\hspace{1cm}}p{.7\textwidth}}
$ \gamma, \beta $    & are the emitted photoelectron  Lorentz gamma and beta
                       factors;\\
$ E_\gamma      $    & is the incident radiation energy;  \\
$ m_e           $    & is the electron mass.  \\
\end{tabular}\\
Below an example of the shell interaction probability calculations for
$E_\gamma > E_K$ is given.\\
If
\begin{eqnarray*}
   \Sigma_{II,III} & = &  \sigma_{L_{II}}+\sigma_{L_{III}} \\
   r_{L_{II}} & = & \frac{\sigma_{L_{II}}}{\Sigma_{II,III}}  \\
   r_{L_{III}} & = & \frac{\sigma_{L_{III}}}{\Sigma_{II,III}}
\end{eqnarray*}
then from (\ref{eq:probrat}) one can find that
\begin{eqnarray*}
       p_K & = & 1-\frac{1}{J_K} \\
       p_{L_1} & = & (1-p_K)\cdot (1 - \frac{1}{J_{L_1}}) \\
       p_{L_{II}} & = & (1-p_K-p_{L_I})\cdot r_{L_{II}} \\
       p_{L_{III}} & = & (1-p_K-p_{L_I})\cdot r_{L_{III}}
\end{eqnarray*}
After simple calculations one obtains the probability distribution function
which is used to select the shell.
\subsection{Angular distributions of photoelectrons}

The angular distributions of photoelectrons should be calculated using the
partial wave analysis for the outgoing electron. Since this method is very time
consuming we use approximations of the angular distributions calculated by
F. von Sauter \cite{bib-SAUTER1} \cite{bib-SAUTER2} (K shell) and Gavrila
\cite{bib-GAVRILA-K} \cite{bib-GAVRILA-L}
(K and L shells). We use the cross-section
which is correct only to zero order in $\alpha Z$. This approximation foresees
zero scattering amplitude in the direction of incident photon while
experimentally the cross-section at $0$ angle is non-vanishing \cite{bib-NAGEL}.
If
\begin{eqnarray*}
           X &=& 1-\beta\cos\Theta
\end{eqnarray*}
then for $K$ and $L_I$ shells we use:
\begin{eqnarray}
           \frac{d\sigma_{K,L_{I}}}{d(\cos\Theta)}
           &\sim& \frac{\sin^2\Theta}{X^4}
                \left\{1+ \frac{1}{2}\gamma(\gamma-1)(\gamma-2)\right\}
\label{eq:angkl}
\end{eqnarray}
 and for $L_{II}$  and $L_{III}$ shells we have:
\begin{eqnarray}
 \frac{d\sigma_{L_{II}}}{d(\cos\Theta)}
           &\sim & \frac{(\gamma^2-1)^{\frac{1}{2}}}{\gamma^5(\gamma-1)^5}
           \left\{ \frac{\gamma(3\gamma+1)}{2 X^4}
      -\frac{\gamma^2(9\gamma^2+30\gamma-7)}{8 X^3} \right.  \nonumber \\
      \ & \ &      +\frac{\gamma^3(\gamma^3+6\gamma^2+11\gamma-2)}{4 X^2}
            -\frac{\gamma^4(\gamma-1)(\gamma+7)}{8 X} \\
         \ & \ &    +\sin^2\Theta
                  \left.    \left(
                         \frac{(\gamma+1)}{X^5}
                        -\frac{\gamma(\gamma+1)}{X^4}
                        -\frac{\gamma^2(3\gamma+1)(\gamma^2-1)}{X^3}
                      \right)
           \right\} \nonumber
\label{eq:angl2}
\end{eqnarray}

\begin{eqnarray}
           \frac{d\sigma_{L_{III}}}{d(\cos\Theta)}
           &\sim & \frac{(\gamma^2-1)^{\frac{1}{2}}}{\gamma^5(\gamma-1)^5}
           \left\{ -\frac{\gamma(3\gamma-1)}{2 X^4}
                   +\frac{\gamma^2(3\gamma^2-1)}{X^3} \right. \nonumber \\
        \ & \ & \frac{\gamma^3(\gamma^3-3\gamma^2+2\gamma+1)}{X^3}
                   -\frac{\gamma^4(\gamma-2)(\gamma-1)}{2 X} \\
        \ & \ & +\sin^2\Theta
                  \left.    \left(
                   \frac{(\gamma+1)}{X^5}
                  -\frac{\gamma(\gamma+1)(3\gamma-1)}{X^4}
                  +\frac{\gamma^2(\gamma^2-1)}{X^3}
                      \right)
           \right\} \nonumber
\label{eq:angl3}
\end{eqnarray}
The azimuthal angle distribution is uniform.

\subsection{Final State}

After the photoelectron emission the atom is left in excited state.
The excitation energy equal to the binding energy $E_i$ of the shell in which the interaction took place. Subsequently the atom emits a fluorescent photon
or Auger or Coster-Kronig electron. The selection of radiative or
non-radiative transition is based on compilation by Krause \cite{bib-KRAUSE}.\\
The Auger or Coster-Kronig transitions are represented by the most probable
line for a given vacancy \cite{bib-CULLEN}. The emitted electron energy $E_e$ is
\begin{equation}
 E_e = E_i-(E_j+E_k)
\label{eq:augere}
\end{equation}
where
$E_i, E_j, E_k$ are the subshell binding energies and $E_j > E_k$.\\
In case of fluorescence we use transition rates of Scofield \cite{bib-SCOFIELD}.
We use only those transitions for which the occurrence probability is not less
than 1\%. The fluorescent photon is emitted with energy $E_\gamma$
\begin{equation}
E_\gamma = E_i-E_j
\label{eq:fluore}
\end{equation}
for transition between the subshells $i$ and $j$.\\
In addition to the above, to fulfill the energy conservation law,
emission of an additional photon is simulated. For non-radiative transitions
its energy is $E_k$ (see formula \ref{eq:augere}). In case of fluorescent
transition this photon has energy $E_j$ (see equation \ref{eq:fluore}).
The angular distribution of the emitted particle is isotropic.


\subsubsection{Guisarme}\label{weapon:guisarme}
Weapon, Guisarme, Two-Handed, Unusual, Melee\\
Size: L\\
Cost: 500 Gold

\textbf{Stab}\\
4AP, ST or AG to hit, \passus{2} Reach\\
1d10 + \sfrac{1}{3}\texttimes ST or AG Piercing Damage

\textbf{Slash}\\
4AP, ST or AG to hit, \passus{2} Reach\\
2d10 + \sfrac{1}{2}\texttimes ST or AG Cutting Damage


\subsection{Helmets}

\begin{longtable}{|C{2cm} L{2cm} L{2cm} L{8cm}|}
\hline
\large{\textbf{Name}} &
\large{\textbf{Cost}} &
\large{\textbf{Slot}} &
\large{\textbf{Resistance}}
\\ \hline
\WeaponRow{Padded Coif}{75 m}{1}{
\textbf{Head:} \hfill \break
\textit{Slashing:} $+15\%$ \hfill \break
\textit{Crushing:} $+15\%$ \hfill \break
\textit{Piercing:} $+15\%$ \hfill \break
\textit{Cold:} $+20\%$ \hfill \break
\textit{Hot:} $-20\%$
}{A \textbf{Padded Coif} is made out of padded textiles that wrap around the wearer's head - it is basically a Gambeson for the Head, although it only protects the top, the back and the sides of the head, not the front.}
\WeaponRow{Chainmail Coif}{100 m}{2}{
\textbf{Head:} \hfill \break
\textit{Slashing:} $+50\% \pm modifiers$ \hfill \break
\textit{Crushing:} $+5\% \pm modifiers$ \hfill \break
\textit{Piercing:} $+5\% \pm modifiers$
}{A \textbf{Chainmail Coif} is made by linking metal rings together, just like a Chainmail Hauberk - as the name suggests, it is Chainmail for the Head. \textbf{A Chainmail Coif cannot be worn on its own, and must be worn over a Padded Coif}.}
\WeaponRow{Nasal Helmet}{100 m}{32}{
\textbf{Head:} \hfill \break
\textit{Slashing:} $+75\% \pm modifiers$ \hfill \break
\textit{Crushing:} $+15\% \pm modifiers$ \hfill \break
\textit{Piercing:} $+10\% \pm modifiers$
}{A \textbf{Nasal Helmet} is a metal helmet protecting the top of the head, and the centre of the front by projecting a bar that covers the nose. While not mandatory, it is highly recommended to be born over a Chainmail Coif.}
\WeaponRow{Kettle Helmet}{100 m}{3}{
\textbf{Head:} \hfill \break
\textit{Slashing:} $+55\% \pm modifiers$ \hfill \break
\textit{Crushing:} $+35\% \pm modifiers$ \hfill \break
\textit{Piercing:} $+5\% \pm modifiers$
}{A \textbf{Kettle Helmet} is a metal helmet made in the shape of a brimmed hat - it protects against blows that come from the top, and is thus typically worn by warriors who expect to be struct from above by a horseman, such as archers and crossbowmen. Just like the Nasal Helmet, it is not mandatory, but highly recommended to wear a Chainmail Coif underneath the Kettle Helmet.}
\WeaponRow{Great Helm}{150 m}{3}{
\textbf{Head:} \hfill \break
\textit{Slashing:} $+100\% \pm modifiers$ \hfill \break
\textit{Crushing:} $+30\% \pm modifiers$ \hfill \break
\textit{Piercing:} $+30\% \pm modifiers$ \hfill \break
\textit{Hot:} $-30\%$
}{The \textbf{Great Helm} is an evolution of the Nasal Helmet, having evolved by gradually adding more and more parts to it, until the end result was a flat-topped cylinder that completely covers the head and only has very small openings for ventilation and vision. While offering a great deal of protection, the obstruction of vision and hearing gives the wearer a \Malus{1} to Dexterity while wearing it, and the limited space for ventilation heavily accelerates the user overheating in hot conditions.}
\WeaponRow{Bascinet \& Visor}{175 m}{3}{
\textbf{Head:} \hfill \break
\textit{Slashing:} $+100\% \pm modifiers$ \hfill \break
\textit{Crushing:} $+30\% \pm modifiers$ \hfill \break
\textit{Piercing:} $+30\% \pm modifiers$ \hfill \break
\textit{Hot:} $-20\%$
}{The \textbf{Bascinet \& Visor} is an evolution of the Great Helm, effectively splitting the helmet into two parts: the Bascinet that covers the top, back and sides of the head, and the Visor, which protects the front of the face, and can be lifted up any time to reveal the identity of the wearer, or to make breathing easier. Bascinets offer the same amount of protection that Great Helms do, but without the Dexterity malus \textit{(and a reduced malus to Heat resistance)}, due to the rounded visors offering greater amount of vision and better ventilation.}
\WeaponRow{Barbute}{150 m}{3}{
\textbf{Head:} \hfill \break
\textit{Slashing:} $+90\% \pm modifiers$ \hfill \break
\textit{Crushing:} $+20\% \pm modifiers$ \hfill \break
\textit{Piercing:} $+10\% \pm modifiers$ \hfill \break
}{The \textbf{Barbute} can be most easily described as a Visorless Bascinet, but modified maximize the protection the wearer receives without a visor, while still maintaining great vision. The lack of visor also ensures much better ventilation than the bascinet.}
\end{longtable}


%%
%% Automatically generated file from DocOnce source
%% (https://github.com/hplgit/doconce/)
%%
%%

%-------------------- begin preamble ----------------------

\documentclass[%
oneside,                 % oneside: electronic viewing, twoside: printing
final,                   % draft: marks overfull hboxes, figures with paths
10pt]{article}

\listfiles               %  print all files needed to compile this document

\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb}
\usepackage[table]{xcolor}
\usepackage{bm,ltablex,microtype}

\usepackage[pdftex]{graphicx}

\usepackage[T1]{fontenc}
%\usepackage[latin1]{inputenc}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}

\usepackage{lmodern}         % Latin Modern fonts derived from Computer Modern

% Hyperlinks in PDF:
\definecolor{linkcolor}{rgb}{0,0,0.4}
\usepackage{hyperref}
\hypersetup{
    breaklinks=true,
    colorlinks=true,
    linkcolor=linkcolor,
    urlcolor=linkcolor,
    citecolor=black,
    filecolor=black,
    %filecolor=blue,
    pdfmenubar=true,
    pdftoolbar=true,
    bookmarksdepth=3   % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC
    }
%\hyperbaseurl{}   % hyperlinks are relative to this root

\setcounter{tocdepth}{2}  % levels in table of contents

% --- fancyhdr package for fancy headers ---
\usepackage{fancyhdr}
\fancyhf{} % sets both header and footer to nothing
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[LE,RO]{\thepage}
% Ensure copyright on titlepage (article style) and chapter pages (book style)
\fancypagestyle{plain}{
  \fancyhf{}
  \fancyfoot[C]{{\footnotesize \copyright\ 1999-2019, "Computational Physics I FYS3150/FYS4150":"http://www.uio.no/studier/emner/matnat/fys/FYS3150/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}}
%  \renewcommand{\footrulewidth}{0mm}
  \renewcommand{\headrulewidth}{0mm}
}
% Ensure copyright on titlepages with \thispagestyle{empty}
\fancypagestyle{empty}{
  \fancyhf{}
  \fancyfoot[C]{{\footnotesize \copyright\ 1999-2019, "Computational Physics I FYS3150/FYS4150":"http://www.uio.no/studier/emner/matnat/fys/FYS3150/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}}
  \renewcommand{\footrulewidth}{0mm}
  \renewcommand{\headrulewidth}{0mm}
}

\pagestyle{fancy}

% prevent orhpans and widows
\clubpenalty = 10000
\widowpenalty = 10000

% --- end of standard preamble for documents ---

% insert custom LaTeX commands...

\raggedbottom
\makeindex
\usepackage[totoc]{idxlayout}   % for index in the toc
\usepackage[nottoc]{tocbibind}  % for references/bibliography in the toc

%-------------------- end preamble ----------------------

\begin{document}

% matching end for #ifdef PREAMBLE

\newcommand{\exercisesection}[1]{\subsection*{#1}}

% ------------------- main content ----------------------

% ----------------- title -------------------------

\thispagestyle{empty}

\begin{center}
{\LARGE\bf
\begin{spacing}{1.25}
Project 2, deadline  September 30
\end{spacing}
}
\end{center}

% ----------------- author(s) -------------------------

\begin{center}
{\bf \href{{http://www.uio.no/studier/emner/matnat/fys/FYS3150/index-eng.html}}{Computational Physics I FYS3150/FYS4150}}
\end{center}

    \begin{center}
% List of all institutions:
\centerline{{\small Department of Physics, University of Oslo, Norway}}
\end{center}

% ----------------- end author(s) -------------------------

% --- begin date ---
\begin{center}
Sep 18, 2019
\end{center}
% --- end date ---

\vspace{1cm}

\subsection*{Eigenvalue problems, from the equations of a buckling beam to Schroedinger's equation for two electrons in a three-dimensional harmonic oscillator well}

\paragraph{Introduction.}
The aim of this project is to develop your own code for solving
eigenvalue problems. The matrix to diagonalize is the same as the one
we encountered in project one, a so-called tridiagonal Toeplitz
matrix. This matrix has analytical eigenpairs (eigenvalues and
eigenvectors) and gives us an excellent testing ground for our
algorithms. In this project we will develop an eigenvalue solver based
on Jacobi's method. The project will also introduce you to units tests
and we will compare our results against other eigenvalue solvers (from
LAPACK and/or numpy).

This project aims also at introducing to you the concept of \href{{http://www.springer.com/us/book/9783319327259}}{scaling
of equations}. This
means often either making various variables dimensionless or
introducing units which are more convenient.

We will start with the two-point boundary value problem of a buckling
beam or a spring fastened at both ends. This is one of the problems
which has analytical solutions. Thereafter, by simply adding a new
variable along the diagonal elements, we can study quantum mechanical
problems. In particular, we will study the harmonic oscillator problem
in three dimensions, with one or two electrons. For the latter case we
can study the role of the repulsive Coulomb interaction and extract
interesting physics results. For selected frequencies, this
interacting two-electron problem exhibits analytical solutions, one of the few cases of an interacting system where wecan find analytical solutions. See
\href{{http://prola.aps.org/abstract/PRA/v48/i5/p3561_1}}{M. Taut, Phys. Rev. A 48, 3561
(1993)} for the derivation of analytical expressions for the eigenpairs..

Electrons confined in small areas in semiconductors, so-called quantum
dots, form a hot research area in modern solid-state physics, with
applications spanning from such diverse fields as quantum
nano-medicine to the contruction of quantum gates.
The article on quantum computing with quantum dots by \href{{http://journals.aps.org/pra/abstract/10.1103/PhysRevA.57.120}}{Loss and DiVincenzo} is an excellent read for those interested in this exciting topic.

\paragraph{The buckling beam problem, a classical wave function problem in one dimension.}
We start with the following differential equation, namely
\[
\gamma \frac{d^2 u(x)}{dx^2} = -F u(x),
\]
where $u(x)$ is the vertical displacement of the beam in the $y$ direction.
The beam has length $L$, $x\in [0,L]$ and $F$ is a force applied at $(L,0)$ in the direction towards the origin.
The parameter $\gamma$ is a constant defined by properties like the rigidity of the beam.
We apply again so-called Dirichlet boundary conditions and set $u(0)=u(L)=0$.

In this specific case two of the  parameters $\gamma$, $F$ and $L$ are known. As an example, assume we know $F$ and $L$. Then the eigenvalue problem we set up below will allow us to find $\gamma$.

We define a dimensional variable
\[
 \rho = \frac{x}{L},
\]
meaning that we have $\rho \in [0,1]$.    By reordering the equation as
\[
 \frac{d^2 u(\rho)}{d\rho^2} = -\frac{FL^2}{\gamma} u(\rho)=-\lambda u(\rho),
\]
with $\lambda= FL^2/\gamma$ we have an equation that when discretized, becomes an eigenvalue problem.
We use the same
expression for the second derivative of a function $u$ as we did in project 1, namely
\begin{equation}
    u''=\frac{u(\rho+h) -2u(\rho) +u(\rho-h)}{h^2} +O(h^2),
    \label{eq:diffoperation}
\end{equation}
where $h$ is our step.
Next we define minimum and maximum values for the variable $\rho$,
$\rho_{\mathrm{min}}=0$  and $\rho_{\mathrm{max}}=1$, respectively.
With a given number of mesh points, $N$, we
define the step length $h$ as, with $\rho_{\mathrm{min}}=\rho_0$  and $\rho_{\mathrm{max}}=\rho_N$,
\begin{equation*}
  h=\frac{\rho_N-\rho_0 }{N}.
\end{equation*}
The value of $\rho$ at a point $i$ is then
\[
    \rho_i= \rho_0 + ih \hspace{1cm} i=1,2,\dots , N.
\]
We can rewrite the differential equation for a value $\rho_i$ as
\[
-\frac{u(\rho_i+h) -2u(\rho_i) +u(\rho_i-h)}{h^2}  = \lambda u(\rho_i),
\]
or in  a more compact way as
\[
-\frac{u_{i+1} -2u_i +u_{i-1} }{h^2}  = \lambda u_i.
\]
Following our approach from project 1, we can rewrite this equation in a more a general form, but now
as an eigenvalue problem, that is
\begin{equation}
    \begin{bmatrix} d& a & 0   & 0    & \dots  &0     & 0 \\
                                a & d & a & 0    & \dots  &0     &0 \\
                                0   & a & d & a  &0       &\dots & 0\\
                                \dots  & \dots & \dots & \dots  &\dots      &\dots & \dots\\
                                0   & \dots & \dots & \dots  &a  &d & a\\
                                0   & \dots & \dots & \dots  &\dots       &a & d\end{bmatrix}
                                 \begin{bmatrix} u_1 \\ u_2 \\ u_3 \\ \dots \\ u_{N-2} \\ u_{N-1}\end{bmatrix} = \lambda \begin{bmatrix} u_1 \\ u_2 \\ u_3 \\ \dots \\ u_{N-2} \\ u_{N-1}\end{bmatrix} .
\label{eq:matrixse}
\end{equation}
As in project 1, we have not included the endpoints $u_0$ and $u_N$.
We have defined $d=2/h^2$ and the non-diagonal ones as $a=-1/h^2$. This eigenvalue problem has analytical eigenpairs, with eigenvalues given as
\[
\lambda_j = d+2a\cos{(\frac{j\pi}{N+1})} \hspace{0.1cm} j=1,2,\dots N.
\]

\paragraph{Project 2 a): Mathematical intermezzo.}
A unitary transformation preserves  the orthogonality of the obtained eigenvectors. To see this consider first a basis of vectors $\mathbf{v}_i$,
\[
\mathbf{v}_i = \begin{bmatrix} v_{i1} \\ \dots \\ \dots \\v_{in} \end{bmatrix}
\]
We assume that the basis is orthogonal, that is
\[
\mathbf{v}_j^T\mathbf{v}_i = \delta_{ij}.
\]
Show that an orthogonal or unitary transformation
\[
\mathbf{w}_i=\mathbf{U}\mathbf{v}_i,
\]
preserves the dot product and orthogonality.

\paragraph{Project 2 b): Setting up a code for tridiagonal Toeplitz matrix.}
Your task now is to write a function which implements Jacobi's rotation algorithm (see Lecture notes chapter 7)  in order to solve Eq. (\ref{eq:matrixse}).
However, the first simple check is to set up the matrix to diagonalize for a given $N$ and use either armadillo's or numpy's functions for diagonalizing a matrix. You can then check that you obtain the analytical eigenvalues.

For Jacobi's method,
we define the quantities $\tan\theta = t= s/c$, with $s=\sin\theta$ and $c=\cos\theta$ and
\begin{equation*}\cot 2\theta=\tau = \frac{a_{ll}-a_{kk}}{2a_{kl}}.
\end{equation*}
We can then define the angle $\theta$ so that the non-diagonal matrix elements of the transformed matrix
$a_{kl}$ become non-zero and
we obtain the quadratic equation (using $\cot 2\theta=1/2(\cot \theta-\tan\theta)$

\begin{equation*}
t^2+2\tau t-1= 0,
\end{equation*}
resulting in

\begin{equation*}
  t = -\tau \pm \sqrt{1+\tau^2},
\end{equation*}
and $c$ and $s$ are easily obtained via

\begin{equation*}
   c = \frac{1}{\sqrt{1+t^2}},
\end{equation*}
and $s=tc$.

How many similarity transformations are needed before you reach a
result where all non-diagonal matrix elements are essentially zero?
Try to estimate the number of transformations and extract a behavior as function
of the dimensionality of the matrix. Compare your results with the analytical ones.

You can check your results against the Armadillo function for solving
eigenvalue problems. The armadillo function \emph{eigsys} can be used to find eigenvalues and eigenvectors.
A Python program which solves this part of the project is available under the \href{{http://compphysics.github.io/ComputationalPhysics/doc/pub/projectwriting/html/projectwriting.html}}{project writing slides}.

Comment your results (here you could for example compute the time needed for
both algorithms for a given dimensionality of the matrix).

\paragraph{Project 2 c): Implementing tests in your code.}
In this project (and later ones as well) we will implement so-called
\textbf{unit} tests. Our unit tests are mainly meant to test mathematical
properties of our algorithm. During the development phase of a program
it is useful to devise tests that your program should pass. One of
these is to make sure that for a given simple test matrix (say a
$5\times 5$ matrix) our algorithm for searching for the largest
non-diagonal element always returns the correct answer. Furthermore,
for a known simple matrix, irrespective of changes made, we should
always get the same and correct eigenvalues. Another test is to make
sure that the orthogonality shown in exercise (a) is preserved. Try to
figure out other tests your code should pass, based either on the
mathematical properties of the algorithms or more program specific
tests. Implement at least two unit tests in this project.

\paragraph{Extending our machinery to quantum mechanics.}
Here we will assume that these electrons move in a three-dimensional harmonic
oscillator potential (they are confined by for example quadrupole fields)
and repel  each other via the static Coulomb interaction.
We assume spherical symmetry.  You don't need to think of quantum mechanics when solving this project, look at it as another diagonalization problem.

We are first interested in the solution of the radial part of Schroedinger's equation for one electron. This equation reads

\begin{equation*}
  -\frac{\hbar^2}{2 m} \left ( \frac{1}{r^2} \frac{d}{dr} r^2
  \frac{d}{dr} - \frac{l (l + 1)}{r^2} \right )R(r)
     + V(r) R(r) = E R(r).
\end{equation*}
In our case $V(r)$ is the harmonic oscillator potential $(1/2)kr^2$ with
$k=m\omega^2$ and $E$ is
the energy of the harmonic oscillator in three dimensions.
The oscillator frequency is $\omega$ and the energies are

\begin{equation*}
E_{nl}=  \hbar \omega \left(2n+l+\frac{3}{2}\right),
\end{equation*}
with $n=0,1,2,\dots$ and $l=0,1,2,\dots$.

Since we have made a transformation to spherical coordinates it means that
$r\in [0,\infty)$.
The quantum number
$l$ is the orbital momentum of the electron.
%
Then we substitute $R(r) = (1/r) u(r)$ and obtain
%

\begin{equation*}
  -\frac{\hbar^2}{2 m} \frac{d^2}{dr^2} u(r)
       + \left ( V(r) + \frac{l (l + 1)}{r^2}\frac{\hbar^2}{2 m}
                                    \right ) u(r)  = E u(r) .
\end{equation*}
%
The boundary conditions are $u(0)=0$ and $u(\infty)=0$.

We introduce a dimensionless variable $\rho = (1/\alpha) r$
where $\alpha$ is a constant with dimension length and get
%

\begin{equation*}
  -\frac{\hbar^2}{2 m \alpha^2} \frac{d^2}{d\rho^2} u(\rho)
       + \left ( V(\rho) + \frac{l (l + 1)}{\rho^2}
         \frac{\hbar^2}{2 m\alpha^2} \right ) u(\rho)  = E u(\rho) .
\end{equation*}
%
We will set in this project $l=0$.
Inserting $V(\rho) = (1/2) k \alpha^2\rho^2$ we end up with

\begin{equation*}
  -\frac{\hbar^2}{2 m \alpha^2} \frac{d^2}{d\rho^2} u(\rho)
       + \frac{k}{2} \alpha^2\rho^2u(\rho)  = E u(\rho) .
\end{equation*}
We multiply thereafter with $2m\alpha^2/\hbar^2$ on both sides and obtain

\begin{equation*}
  -\frac{d^2}{d\rho^2} u(\rho)
       + \frac{mk}{\hbar^2} \alpha^4\rho^2u(\rho)  = \frac{2m\alpha^2}{\hbar^2}E u(\rho) .
\end{equation*}
The constant $\alpha$ can now be fixed
so that

\begin{equation*}
\frac{mk}{\hbar^2} \alpha^4 = 1,
\end{equation*}
or

\begin{equation*}
\alpha = \left(\frac{\hbar^2}{mk}\right)^{1/4}.
\end{equation*}
Defining

\begin{equation*}
\lambda = \frac{2m\alpha^2}{\hbar^2}E,
\end{equation*}
we can rewrite Schroedinger's equation as

\begin{equation*}
  -\frac{d^2}{d\rho^2} u(\rho) + \rho^2u(\rho)  = \lambda u(\rho) .
\end{equation*}
This is the first equation to solve numerically. In three dimensions
the eigenvalues for $l=0$ are
$\lambda_0=3,\lambda_1=7,\lambda_2=11,\dots .$

We define minimum and maximum values for the variable $\rho$,
$\rho_{\mathrm{min}}=0$  and $\rho_{\mathrm{max}}$, respectively.
You need to check your results for the energies against different values
$\rho_{\mathrm{max}}$, since we cannot set
$\rho_{\mathrm{max}}=\infty$.

With a given number of mesh points, $N$, we
define the step length $h$ as, with $\rho_{\mathrm{min}}=\rho_0$  and $\rho_{\mathrm{max}}=\rho_N$,

\begin{equation*}
  h=\frac{\rho_N-\rho_0 }{N}.
\end{equation*}
The value of $\rho$ at a point $i$ is then
\[
    \rho_i= \rho_0 + ih \hspace{1cm} i=1,2,\dots , N.
\]
We can rewrite the Schroedinger equation for a value $\rho_i$ as

\[
-\frac{u(\rho_i+h) -2u(\rho_i) +u(\rho_i-h)}{h^2}+\rho_i^2u(\rho_i)  = \lambda u(\rho_i),
\]
or in  a more compact way

\[
-\frac{u_{i+1} -2u_i +u_{i-1}}{h^2}+\rho_i^2u_i=-\frac{u_{i+1} -2u_i +u_{i-1} }{h^2}+V_iu_i  = \lambda u_i,
\]
where $V_i=\rho_i^2$ is the harmonic oscillator potential.

We define first the diagonal matrix element
\begin{equation*}
   d_i=\frac{2}{h^2}+V_i,
\end{equation*}
and the non-diagonal matrix element
\begin{equation*}
   e_i=-\frac{1}{h^2}.
\end{equation*}
In this case the non-diagonal matrix elements are given by a mere constant.
\emph{All non-diagonal matrix elements are equal}.
With these definitions the Schroedinger equation takes the following form

\begin{equation*}
d_iu_i+e_{i}u_{i-1}+e_{i}u_{i+1}  = \lambda u_i,
\end{equation*}
where $u_i$ is unknown. We can write the
latter equation as a matrix eigenvalue problem
\begin{equation}
    \begin{bmatrix}d_1 & e_1 & 0   & 0    & \dots  &0     & 0 \\
                                e_1 & d_2 & e_2 & 0    & \dots  &0     &0 \\
                                0   & e_2 & d_3 & e_3  &0       &\dots & 0\\
                                \dots  & \dots & \dots & \dots  &\dots      &\dots & \dots\\
                                0   & \dots & \dots & \dots  &\dots  e_{N-3}     &d_{N-2} & e_{N-2}\\
                                0   & \dots & \dots & \dots  &\dots       &e_{N-2} & d_{N-1}
             \end{bmatrix}  \begin{bmatrix} u_{1} \\
                                                              u_{2} \\
                                                              \dots\\ \dots\\ \dots\\
                                                              u_{N-1}
             \end{bmatrix}=\lambda \begin{bmatrix} u_{1} \\
                                                              u_{2} \\
                                                              \dots\\ \dots\\ \dots\\
                                                              u_{N-1}
             \end{bmatrix}.
      \label{eq:sematrix}
\end{equation}

Note here that we have not included the endpoints since we assume that they are knowm (as we did in project 1). The matrix is also symmetric in this case.

\paragraph{Project 2 d): Quantum dots in three dimensions, one electron.}
Add the harmonic oscillator potential to your tridiagonal Toeplitz matrix from 2a-2c and diagonalize the matrix.
Study the results as functions of the number of integration points $N$ and your approximation to $\rho_{\mathrm{max}}$.
The analytical results with our scaling for the one-electron energies are $\lambda=3,7,11,15,\dots$. How many integration points do you need in order to reproduce the analytical results with say four leading digits after the decimal point?

You can reuse the code you wrote for part (b),
but you need to add  the potential $\rho^2$ to the diagonal elements.

\paragraph{Project 2 e): Quantum dots in three dimensions, two electrons.}
Note: if you are not interested in the explicit quantum physics case here, you can replace this part with either 2g or 2h below. The latter ones are optional exercises if you do this.

We will now study two electrons in a harmonic oscillator well which
also interact via a repulsive Coulomb interaction.
Let us start with the single-electron equation written as

\begin{equation*}
  -\frac{\hbar^2}{2 m} \frac{d^2}{dr^2} u(r)
       + \frac{1}{2}k r^2u(r)  = E^{(1)} u(r),
\end{equation*}
where $E^{(1)}$ stands for the energy with one electron only.
For two electrons with no repulsive Coulomb interaction, we have the following
Schroedinger equation

\begin{equation*}
\left(  -\frac{\hbar^2}{2 m} \frac{d^2}{dr_1^2} -\frac{\hbar^2}{2 m} \frac{d^2}{dr_2^2}+ \frac{1}{2}k r_1^2+ \frac{1}{2}k r_2^2\right)u(r_1,r_2)  = E^{(2)} u(r_1,r_2) .
\end{equation*}

Note that we deal with a two-electron wave function $u(r_1,r_2)$ and
two-electron energy $E^{(2)}$.

With no interaction this can be written out as the product of two
single-electron wave functions, that is we have a solution on closed form.

We introduce the relative coordinate $\mathbf{r} = \mathbf{r}_1-\mathbf{r}_2$
and the center-of-mass coordinate $\mathbf{R} = 1/2(\mathbf{r}_1+\mathbf{r}_2)$.
With these new coordinates, the radial Schroedinger equation reads

\begin{equation*}
\left(  -\frac{\hbar^2}{m} \frac{d^2}{dr^2} -\frac{\hbar^2}{4 m} \frac{d^2}{dR^2}+ \frac{1}{4} k r^2+  kR^2\right)u(r,R)  = E^{(2)} u(r,R).
\end{equation*}

The equations for $r$ and $R$ can be separated via the ansatz for the
wave function $u(r,R) = \psi(r)\phi(R)$ and the energy is given by the sum
of the relative energy $E_r$ and the center-of-mass energy $E_R$, that
is

\begin{equation*}
E^{(2)}=E_r+E_R.
\end{equation*}

We add then the repulsive Coulomb interaction between two electrons,
namely a term

\begin{equation*}
V(r_1,r_2) = \frac{\beta e^2}{|\mathbf{r}_1-\mathbf{r}_2|}=\frac{\beta e^2}{r},
\end{equation*}
with $\beta e^2=1.44$ eVnm.

Adding this term, the $r$-dependent Schroedinger equation becomes

\begin{equation*}
\left(  -\frac{\hbar^2}{m} \frac{d^2}{dr^2}+ \frac{1}{4}k r^2+\frac{\beta e^2}{r}\right)\psi(r)  = E_r \psi(r).
\end{equation*}
This equation is similar to the one we had previously in (b) and we introduce
again a dimensionless variable $\rho = r/\alpha$. Repeating the same
steps as above, we arrive at

\begin{equation*}
  -\frac{d^2}{d\rho^2} \psi(\rho)
       + \frac{1}{4}\frac{mk}{\hbar^2} \alpha^4\rho^2\psi(\rho)+\frac{m\alpha \beta e^2}{\rho\hbar^2}\psi(\rho)  =
\frac{m\alpha^2}{\hbar^2}E_r \psi(\rho) .
\end{equation*}
We want to manipulate this equation further to make it as similar to that in (a)
as possible. We define a new 'frequency'

\begin{equation*}
\omega_r^2=\frac{1}{4}\frac{mk}{\hbar^2} \alpha^4,
\end{equation*}
and fix the constant $\alpha$ by requiring

\begin{equation*}
\frac{m\alpha \beta e^2}{\hbar^2}=1
\end{equation*}
or

\begin{equation*}
\alpha = \frac{\hbar^2}{m\beta e^2}.
\end{equation*}
Defining

\begin{equation*}
\lambda = \frac{m\alpha^2}{\hbar^2}E,
\end{equation*}
we can rewrite Schroedinger's equation as

\begin{equation*}
  -\frac{d^2}{d\rho^2} \psi(\rho) + \omega_r^2\rho^2\psi(\rho) +\frac{1}{\rho} = \lambda \psi(\rho).
\end{equation*}
We treat $\omega_r$ as a parameter which reflects the strength of the oscillator potential.

Here we will study the cases $\omega_r = 0.01$, $\omega_r = 0.5$, $\omega_r =1$,
and $\omega_r = 5$
for the ground state only, that is the lowest-lying state.

With no repulsive Coulomb interaction
you should get a result which corresponds to
the relative energy of a non-interacting system.
Make sure your results are
stable as functions of $\rho_{\mathrm{max}}$ and the number of steps.

We are only interested in the ground state with $l=0$. We omit the
center-of-mass energy.

You can reuse the code you wrote for part (b),
but you need to add  the potential $\omega_r^2\rho^2+1/\rho$ to the diagonal elements.

Comment the results for the lowest state (ground state) as function of
varying strengths of $\omega_r$.

For specific oscillator frequencies, the above equation has answers in an analytical form,
see the article by \href{{http://prola.aps.org/abstract/PRA/v48/i5/p3561_1}}{M. Taut, Phys. Rev. A 48, 3561 (1993)}.

\paragraph{Project 2 f): First optional exercise: Quantum physics analysis of  the results.}
This exercise is a continuation of the previous and adds more quantum physics to the analysis.
In this exercise we want to plot the wave function
for two electrons as functions of the relative coordinate $r$ and different
values of $\omega_r$.  With no Coulomb interaction you should have a result which corresponds to the non-interacting case.
Plot either the function itself or the probability distribution (the function squared) with and without the repulsion between the two electrons.
Varying $\omega_r$, the shape of the wave function
will change.

We are only interested in the wave function for the ground state with $l=0$ and
omit again the  center-of-mass motion.

The eigenvectors are normalized.
Plot then the normalized wave functions for different  values of $\omega_r$ and comment the results.

\paragraph{Project 2 g): Second optional challenge: Smarter way of finding the eigenvalues.}
This exercise is also optional and is an algorithmic challenge. Your matrix is already tridiagonal.
Can you devise a more efficient way to find the eigenvalues and eigenvectors instead of the brute force application of Jacobi's method?
Hint: Use the bisection method discussed in for example \href{{http://www.maths.ed.ac.uk/~aar/papers/bamawi.pdf}}{Barth, Martin and Wilkinson, Numerische Mathematik 9, 386 (1967)}.

\paragraph{Project 2 h): Third optional challenge: Implementing Lanczos' algorithm.}
This exercise is optional and is meant more as a challenge for those of you with an interest in other algorithms for solving eigenvalue problems.
Implement the iterative Lanczos' algorithm discussed in the lecture notes and compute the lowest eigenvalues
as done in exercise (c) or (d) above. Compare your results and discuss faults and merits of the iterative method versus
direct methods like Jacobi's method.

\subsection*{Introduction to numerical projects}

Here follows a brief recipe and recommendation on how to write a report for each
project.

\begin{itemize}
  \item Give a short description of the nature of the problem and the eventual  numerical methods you have used.

  \item Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.

  \item Include the source code of your program. Comment your program properly.

  \item If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.

  \item Include your results either in figure form or in a table. Remember to        label your results. All tables and figures should have relevant captions        and labels on the axes.

  \item Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.

  \item Try to give an interpretation of you results in your answers to  the problems.

  \item Critique: if possible include your comments and reflections about the  exercise, whether you felt you learnt something, ideas for improvements and  other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.

  \item Try to establish a practice where you log your work at the  computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember  what a previous test version  of your program did. Here you could also record  the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning.
\end{itemize}

\noindent
\subsection*{Format for electronic delivery of report and programs}

The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file.  As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report:

\begin{itemize}
  \item Use Devilry to hand in your projects, log in  at  \href{{http://devilry.ifi.uio.no}}{\nolinkurl{http://devilry.ifi.uio.no}} with your normal UiO username and password and choose either 'fys3150' or 'fys4150'. There you can load up the files within the deadline.

  \item Upload \textbf{only} the report file!  For the source code file(s) you have developed please provide us with your link to your github domain.  The report file should include all of your discussions and a list of the codes you have developed.  Do not include library files which are available at the course homepage, unless you have made specific changes to them.

  \item In your git repository, please include a folder which contains selected results. These can be in the form of output from your code for a selected set of runs and input parameters.

  \item In this and all later projects, you should include tests (for example unit tests) of your code(s).

  \item Comments  from us on your projects, approval or not, corrections to be made  etc can be found under your Devilry domain and are only visible to you and the teachers of the course.
\end{itemize}

\noindent
Finally,
we encourage you to work two and two together. Optimal working groups consist of
2-3 students. You can then hand in a common report.

% ------------------- end of main content ---------------

\end{document}