%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Sky-MoCa -- A Specific Application}\label{chap:2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{The Code}\label{sec:code}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
We implemented \newterm{Sky-MoCa}, a simulated annealing algorithm based on
Markov chain Monte Carlo integration with Metropolis transition probabilities
for a three-dimensional spin lattice in Julia~\cite{julia}. Julia is a
relatively young language which is advertised on the official
\href{http://julialang.org/}{Julia homepage} as a \emph{high-level,
high-performance dynamic programming language for technical computing}. It is a
perfect fit for rapid prototyping of numerical simulations, where we care most
about developer time, but speed still matters. Its syntax will be familiar to
users of technical computing environments such as Matlab, Octave or also Python.
Another nice feature of Julia is that it can be used in Jupyter notebooks which
work precisely like IPython notebooks.

This allows for nice presentation and even faster prototyping and testing. Of
course one can always export a regular Julia \textsf{.jl} file that can
subsequently be run on a remote machine. The code is available at GitHub under
\href{https://github.com/nikikilbertus/Sky-MoCa}{\textsf{https://github.com/nikikilbertus/Sky-MoCa}}.
It has been written with readability in mind, which sometimes comes at the cost
of performance, and is fully documented such that we will not go into
implementation details in this report. Each simulation run produces a single
HDF5 file containing detailed information down to the full configuration after
every lattice sweep if desired. While there are specific post-processing and
analysis sections in the Julia notebook, the repository also contains a
Mathematica notebook with several visualization capabilities~\cite{mathematica}.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Results}\label{sec:results}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
In this section we perform the analysis described theoretically in
\secref{sec:analysis} for the spin lattice model introduced in
\secref{sec:model}. We show that determining~$\Ntherm$ and~$\Nsweep$ is a
delicate task and that the Metropolis algorithm, while theoretically quite
universal, might become infeasible in practice not only for pathological
systems. One has to take great care in ensuring equilibrium and uncorrelated
configurations, otherwise the simple error estimate~$\sigma/\sqrt{N}$ might
significantly underpredict the true error.

Recall that the first order of business is to determine the thermalization time.
Let us start with a relatively small system of~$N_x = N_y = N_z = 10$, \ie{} a
total of~$10^3$ vertices. In this first stage we want to determine the
thermalization and autocorrelation times for three different temperatures~$T \in
\{1.5, 0.7, 0.1\}$ at a fixed magnetic field~$B=0.3$. Recall that~$J=1$
and~$K=\tan(2 \pi / 10)$, thus all parameters are fixed. We initialize the
system with a hot start and then perform~$N=10^4$ lattice sweeps. Those run on
a MacBook Pro with a 2.2 GHz Intel Core i7 and 16 GB of 1600 MHz DDR3 memory in
less than a minute.

\subsection{Reasonable analysis at high temperature}

We expect the system to thermalize fastest at high temperatures. In
\figref{fig:hot}, we simply plot the energy and all three components of the
magnetization as a function of Monte Carlo time. We do not show the whole region
up to~$10^4$ steps, because apparently the system has thermalized after just a
few hundred sweeps. As expected the energy drops rapidly and levels out at a
constant value. The magnetization in~$\hz$ direction grows rapidly and levels
out at a positive value, thereby following the external magnetic field, which
also points in the~$\hz$ direction. The~$\hx$ and~$\hy$ components stay roughly
at zero. The fluctuations are pretty large, which is expected at high
temperatures. We decided in this case that~$\Ntherm = 500$ is a reasonably long
thermalization time. In the second row of~\figref{fig:hot} we show the
autocorrelation functions for all four observables. Note that the maximal time
shift we are showing here is~$t = 500$, thus much smaller than the number of
configurations we have used for the autocorrelation, namely~$N - \Ntherm = 10^4
- 500 = 9500$.

For all observables the autocorrelations drop quickly and then transition into
noisy behavior already at relatively small~$t$. Apparently already around~$t
\approx 50$, the autocorrelation functions are completely unreliable. In the
last two rows of~\figref{fig:hot}, we plot each of the four autocorrelation
functions separately with an exponential fit. In the least square one parameter
fits to~$\exp(-t/\tau)$ we have only used the values of the autocorrelation
functions shown in the plots, \ie{}~$t \le 80$. At the same time we compute the
integrated autocorrelation time~$\tauint$ according to~\eqref{tauinttrunc}
with~$m$ such that we sum over all values shown in the plot. The fit parameter
for~$\tau$ as well as~$\tauint$ are shown in the plots.

We immediately realize that they do not agree perfectly, but are reasonably
close, given the statistical fluctuations in the autocorrelation functions.
Whenever the autocorrelation lies above the exponential fit for a significant
portion of the range as for the energy~$H$, the integrated autocorrelation is
typically larger than the fit value. However, when it mostly runs below the fit
as for~$M_z$ it is not necessarily smaller. Indeed we have
altered~\eqref{tauinttrunc} slightly to add up absolute values of the
autocorrelation functions. Otherwise we could compensate large correlation by
anticorrelation and thereby reach a smaller autocorrelation time. This is highly
risky of course, since negative correlation is correlation too and cannot cancel
positive correlation.

In the end we take the maximum over all autocorrelation times and settle with a
value of~$T=17$. Had we just looked at the energy, we could have reasoned~$\tau
\approx 8$, less than half. We realize that with~$9500$ configurations we used
less than~$600 \tau$ sweeps to estimate~$\tau$ from the autocorrelation
functions which is already at the edge of best practice. We should have
chosen~$N \gtrsim 2\cdot 10^4$ for better statistics. At this temperature
fluctuations are large and the exact choice of~$\Ntherm$ is still a
matter of taste. Since the thermalization is only necessary once in the
beginning, it is not a big computational setback to choose conservatively. The
large temperature is also reflected in the acceptance rate. It qualitatively
shows a similar behavior like the energy, dropping quickly and then flattening
out at around~$40$\%. Thereby we are confident that the system is indeed
evolving, sampling many different configurations. Eventually, for this situation
we would recommend to skip~$\Nsweep = 6 \cdot \tau \approx 100$ sweeps between
two consecutive configurations of the Markov chain.

\subsection{Faulty analysis at lower temperatures}

To also give an example of faulty analysis, we repeat the same procedure
for~$T=0.7$ and~$T=0.1$. All other parameters, in particular~$N=10^4$, have not
been changed. In \figref{fig:warm} and \figref{fig:cold} we show the best
results achievable by varying the interval on which to fit autocorrelations.
First of all, the amplitude of the fluctuations in the observables clearly
decrease with decreasing temperature. To some extent this makes it easier to
determine~$\Ntherm$. However, with the theoretical preparation from the
previous chapter the issues become quite obvious. While we can still observe
thermalization reasonably well and deduced~$\Ntherm=1500$ and~$\Ntherm=5000$
for~$T=0.7$ and~$T=0.1$ respectively, the autocorrelation functions become
statistically unreliable even above~$0.2$. Thus the autocorrelation times
inferred from the exponential fit and the integrated autocorrelation time differ
by a factor of up to~$1.5$. The fits are a disaster and due to the large
fluctuations in the autocorrelation functions we cannot expect the integrated
autocorrelation time to give reliable results.

The cure of course lies in improving the statistics. For~$N=10^4$ and the chosen
thermalization times there are only~$8500$ and~$5000$ measurements left to
compute the autocorrelation functions. Because~$\tau$ seems to be on the order
of a few hundreds, we have only used roughly~$10 \tau$ sweeps to
determine~$\tau$. We need at least one or two orders of magnitude more Monte
Carlo steps for a reliable estimate of the autocorrelation time. The acceptance
rate drops to approximately~$15$\% and only~$2$\% for~$T=0.7$ and~$T=0.1$
respectively, which is a strong indicator for slow evolution and results in long
autocorrelation times. Varying the temperature clearly shows that every point in
parameter space requires its own analysis. Both the thermalization
time~$\Ntherm=500$ and decorrelation length~$\Nsweep=100$ from the first example
at~$T=1.5$ are far too small for lower temperatures.

For~$T=0.7$ and~$B=0.3$ we are also close to a phase transition and thus might
experience critical slowing. Redoing the analysis for a slightly different
value of~$B$ might completely change the outcome and actually yield reasonable
results. Of course, when inspecting a new system, there is no way of knowing
where critical slowing might occur. Simulated annealing can be a valuable tool
in the sense that we can start at a well understood, high temperature point in
phase space and gradually change the magnetic field and/or the temperature. Note
that technically the decorrelation length also has to be adjusted throughout the
different stages of simulated annealing. Monitoring the acceptance rate can help
to detect critical slowing.

Finally, let us correct the faulty analysis by increasing~$N$ to~$2\cdot 10^5$
for~$T=0.6$ and~$B=0.2$, see \figref{fig:warmlong}. The autocorrelation
functions are much smoother for larger values of~$t$ and the fits seem to be
reliable and agree better with the integrated autocorrelation time. We can now
more confidently deduce~$\tau \approx 182$ and thus~$\Nsweep \approx 1000$. This
shows that the previous analysis would have underestimated the autocorrelation
length of~$M_z$ and also shows that with such a large decorrelation length a
statistically proper simulation already becomes computationally challenging.
These~$2\cdot 10^5$ sweeps already took about half an hour on a laptop computer.
For~$N=1000$ configurations the runtime for this tiny system on a regular
personal computer already goes into the hours. In practice one might settle with
less sweeps in between configurations regardless. A thorough understanding of
the autocorrelation at least tells us how this spoils the naive error estimates.

We delay the actual results of full simulation runs for the second report, where
we go into more details about the physics of the system. We specifically
investigate the transitions into and out of the skyrmion phase.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% T=1.5 B=0.3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}
  \centering
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      xlabel={Monte Carlo time},
      scaled y ticks={base 10:-3},
      legend pos={north east},
      legend entries={energy},
    ]
      \addplot[
        mark=none,
      ] table[x expr=\coordindex, y index=0] {plots/T1.5_B0.3/therm_energy.csv};
    \end{axis}
  \end{tikzpicture}%
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      xlabel={Monte Carlo time},
      cycle list name=rdbu,
      legend style={at={(0.98,0.5)},anchor=east},
      legend entries={$M_x$, $M_y$, $M_z$},
    ]
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T1.5_B0.3/therm_mx.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T1.5_B0.3/therm_my.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T1.5_B0.3/therm_mz.csv};
    \end{axis}
  \end{tikzpicture}%
  \\[0.5cm]
  \begin{tikzpicture}
    \begin{axis}[
      width={\singleplotwidth cm},
      height={\singleplotheight cm},
      xlabel={time shift $t$},
      ylabel={autocorrelation},
      cycle list name=rdbu,
      legend pos={north east},
      legend cell align={left},
      legend entries={$R_{M_x}$, $R_{M_y}$, $R_{M_z}$, $R_{H}$},
    ]
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T1.5_B0.3/auto_mx.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T1.5_B0.3/auto_my.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T1.5_B0.3/auto_mz.csv};
      \addplot+[mark=none, black]
        table[x expr=\coordindex, y index=0] {plots/T1.5_B0.3/auto_energy.csv};
    \end{axis}
  \end{tikzpicture}%
  \\[0.5cm]
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{H},\;\tauint \approx 7.4$} , {fit: $\exp(-t/6.5)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T1.5_B0.3/autofit_energy.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T1.5_B0.3/autofit_energy.csv};
    \end{axis}
  \end{tikzpicture}%
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{M_z},\;\tauint \approx 14.4$} , {fit: $\exp(-t/13.5)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T1.5_B0.3/autofit_mz.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T1.5_B0.3/autofit_mz.csv};
    \end{axis}
  \end{tikzpicture}%
  \\[0.5cm]
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{M_x},\;\tauint \approx 14.7$} , {fit: $\exp(-t/14.7)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T1.5_B0.3/autofit_mx.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T1.5_B0.3/autofit_mx.csv};
    \end{axis}
  \end{tikzpicture}%
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{M_y},\;\tauint \approx 16.7$} , {fit: $\exp(-t/16.8)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T1.5_B0.3/autofit_my.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T1.5_B0.3/autofit_my.csv};
    \end{axis}
  \end{tikzpicture}%
  \caption{We show the thermalization and autocorrelation behavior for a system
  with~$10^3$ lattice sites, periodic boundary conditions and a uniformly random
  start configuration at~$T=1.5$ and~$B=0.3$. In this case we chose~$\Ntherm =
  500$. The acceptance rate settles around~$40$\%. A detailed interpretation of
  the plots is discussed in the text.}
\label{fig:hot}
\end{figure}

% INFO: energy autocorrelation time: fit τ = 6.458405365541238, integrated τ = 7.397862228345494
% INFO: Mx autocorrelation time: fit τ = 14.724579318546557, integrated τ = 14.673065094508395
% INFO: My autocorrelation time: fit τ = 16.763387458492737, integrated τ = 16.658299614290883
% INFO: Mz autocorrelation time: fit τ = 13.508949401610863, integrated τ = 14.386716847818926

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% T=0.7 B=0.3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}
  \centering
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      xlabel={Monte Carlo time},
      scaled y ticks={base 10:-3},
      legend pos={north east},
      legend entries={energy},
    ]
      \addplot[
        mark=none,
      ] table[x expr=\coordindex, y index=0] {plots/T0.7_B0.3/therm_energy.csv};
    \end{axis}
  \end{tikzpicture}%
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      xlabel={Monte Carlo time},
      cycle list name=rdbu,
      legend style={at={(0.98,0.5)},anchor=east},
      legend entries={$M_x$, $M_y$, $M_z$},
    ]
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.7_B0.3/therm_mx.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.7_B0.3/therm_my.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.7_B0.3/therm_mz.csv};
    \end{axis}
  \end{tikzpicture}%
  \\[0.5cm]
  \begin{tikzpicture}
    \begin{axis}[
      width={\singleplotwidth cm},
      height={\singleplotheight cm},
      xlabel={time shift $t$},
      ylabel={autocorrelation},
      xtick={0,400,800,1200,1600},
      cycle list name=rdbu,
      legend pos={north east},
      legend cell align={left},
      legend entries={$R_{M_x}$, $R_{M_y}$, $R_{M_z}$, $R_{H}$},
    ]
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.7_B0.3/auto_mx.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.7_B0.3/auto_my.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.7_B0.3/auto_mz.csv};
      \addplot+[mark=none, black]
        table[x expr=\coordindex, y index=0] {plots/T0.7_B0.3/auto_energy.csv};
    \end{axis}
  \end{tikzpicture}%
  \\[0.5cm]
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{H},\;\tauint \approx 16.5$} , {fit: $\exp(-t/14.3)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T0.7_B0.3/autofit_energy.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T0.7_B0.3/autofit_energy.csv};
    \end{axis}
  \end{tikzpicture}%
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{M_z},\;\tauint \approx 116.2$} , {fit: $\exp(-t/94.6)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T0.7_B0.3/autofit_mz.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T0.7_B0.3/autofit_mz.csv};
    \end{axis}
  \end{tikzpicture}%
  \\[0.5cm]
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{M_x},\;\tauint \approx 115.0$} , {fit: $\exp(-t/103.7)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T0.7_B0.3/autofit_mx.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T0.7_B0.3/autofit_mx.csv};
    \end{axis}
  \end{tikzpicture}%
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{M_y},\;\tauint \approx 146.7$} , {fit: $\exp(-t/150.2)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T0.7_B0.3/autofit_my.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T0.7_B0.3/autofit_my.csv};
    \end{axis}
  \end{tikzpicture}%
  \caption{We show the thermalization and autocorrelation behavior for a system
  with~$10^3$ lattice sites, periodic boundary conditions and a uniformly random
  start configuration at~$T=0.7$ and~$B=0.3$. In this case we chose~$\Ntherm =
  1500$. The acceptance rate settles around~$15$\%. A detailed interpretation of
  the plots is discussed in the text.}
\label{fig:warm}
\end{figure}

% INFO: energy autocorrelation time: fit τ = 14.302802759817167, integrated τ = 16.4810871797162
% INFO: Mx autocorrelation time: fit τ = 103.7086885846073, integrated τ = 115.04788752286501
% INFO: My autocorrelation time: fit τ = 150.15338442825083, integrated τ = 146.72520176024534
% INFO: Mz autocorrelation time: fit τ = 94.5792317279391, integrated τ = 116.18768054047747

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% T=0.1 B=0.3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}
  \centering
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      xlabel={Monte Carlo time},
      scaled y ticks={base 10:-3},
      legend pos={north east},
      legend entries={energy},
    ]
      \addplot[
        mark=none,
      ] table[x expr=\coordindex, y index=0] {plots/T0.1_B0.3/therm_energy.csv};
    \end{axis}
  \end{tikzpicture}%
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      xlabel={Monte Carlo time},
      xtick={0, 2000, 4000, 6000},
      cycle list name=rdbu,
      legend style={at={(0.98,0.5)},anchor=east},
      legend entries={$M_x$, $M_y$, $M_z$},
    ]
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.1_B0.3/therm_mx.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.1_B0.3/therm_my.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.1_B0.3/therm_mz.csv};
    \end{axis}
  \end{tikzpicture}%
  \\[0.5cm]
  \begin{tikzpicture}
    \begin{axis}[
      width={\singleplotwidth cm},
      height={\singleplotheight cm},
      xlabel={time shift $t$},
      xtick={0, 1000, 2000, 3000},
      ylabel={autocorrelation},
      cycle list name=rdbu,
      legend pos={north east},
      legend cell align={left},
      legend entries={$R_{M_x}$, $R_{M_y}$, $R_{M_z}$, $R_{H}$},
    ]
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.1_B0.3/auto_mx.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.1_B0.3/auto_my.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.1_B0.3/auto_mz.csv};
      \addplot+[mark=none, black]
        table[x expr=\coordindex, y index=0] {plots/T0.1_B0.3/auto_energy.csv};
    \end{axis}
  \end{tikzpicture}%
  \\[0.5cm]
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{H},\;\tauint \approx 199.9$} , {fit: $\exp(-t/161.4)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T0.1_B0.3/autofit_energy.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T0.1_B0.3/autofit_energy.csv};
    \end{axis}
  \end{tikzpicture}%
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{M_z},\;\tauint \approx 245.2$} , {fit: $\exp(-t/160.2)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T0.1_B0.3/autofit_mz.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T0.1_B0.3/autofit_mz.csv};
    \end{axis}
  \end{tikzpicture}%
  \\[0.5cm]
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{M_x},\;\tauint \approx 420.8$} , {fit: $\exp(-t/392.5)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T0.1_B0.3/autofit_mx.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T0.1_B0.3/autofit_mx.csv};
    \end{axis}
  \end{tikzpicture}%
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{M_y},\;\tauint \approx 411.3$} , {fit: $\exp(-t/419.8)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T0.1_B0.3/autofit_my.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T0.1_B0.3/autofit_my.csv};
    \end{axis}
  \end{tikzpicture}%
  \caption{We show the thermalization and autocorrelation behavior for a system
  with~$10^3$ lattice sites, periodic boundary conditions and a uniformly random
  start configuration at~$T=0.1$ and~$B=0.3$. In this case we chose~$\Ntherm =
  5000$. The acceptance rate settles around~$2$\%. A detailed interpretation of
  the plots is discussed in the text.}
\label{fig:cold}
\end{figure}

% INFO: energy autocorrelation time: fit τ = 161.41304402901636, integrated τ = 199.87537380804702
% INFO: Mx autocorrelation time: fit τ = 392.46011826024284, integrated τ = 420.79108524886163
% INFO: My autocorrelation time: fit τ = 419.82093950666643, integrated τ = 411.2568200497989
% INFO: Mz autocorrelation time: fit τ = 160.22639277888916, integrated τ = 245.19970750692352

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% T=0.6 B=0.2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}
  \centering
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      xlabel={Monte Carlo time},
      scaled y ticks={base 10:-3},
      legend pos={north east},
      legend entries={energy},
    ]
      \addplot[
        mark=none,
      ] table[x expr=\coordindex, y index=0] {plots/T0.6_B0.2/therm_energy.csv};
    \end{axis}
  \end{tikzpicture}%
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      xlabel={Monte Carlo time},
      cycle list name=rdbu,
      legend style={at={(0.98,0.5)},anchor=east},
      legend entries={$M_x$, $M_y$, $M_z$},
    ]
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.6_B0.2/therm_mx.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.6_B0.2/therm_my.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.6_B0.2/therm_mz.csv};
    \end{axis}
  \end{tikzpicture}%
  \\[0.5cm]
  \begin{tikzpicture}
    \begin{axis}[
      width={\singleplotwidth cm},
      height={\singleplotheight cm},
      xlabel={time shift $t$},
      ylabel={autocorrelation},
      xtick={0,400,800,1200,1600},
      cycle list name=rdbu,
      legend pos={north east},
      legend cell align={left},
      legend entries={$R_{M_x}$, $R_{M_y}$, $R_{M_z}$, $R_{H}$},
    ]
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.6_B0.2/auto_mx.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.6_B0.2/auto_my.csv};
      \addplot+[mark=none, cycle list name=rdbu]
        table[x expr=\coordindex, y index=0] {plots/T0.6_B0.2/auto_mz.csv};
      \addplot+[mark=none, black]
        table[x expr=\coordindex, y index=0] {plots/T0.6_B0.2/auto_energy.csv};
    \end{axis}
  \end{tikzpicture}%
  \\[0.5cm]
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{H},\;\tauint \approx 16.0$} , {fit: $\exp(-t/14.8)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T0.6_B0.2/autofit_energy.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T0.6_B0.2/autofit_energy.csv};
    \end{axis}
  \end{tikzpicture}%
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{M_z},\;\tauint \approx 181.9$} , {fit: $\exp(-t/177.3)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T0.6_B0.2/autofit_mz.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T0.6_B0.2/autofit_mz.csv};
    \end{axis}
  \end{tikzpicture}%
  \\[0.5cm]
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{M_x},\;\tauint \approx 102.0$} , {fit: $\exp(-t/103.2)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T0.6_B0.2/autofit_mx.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T0.6_B0.2/autofit_mx.csv};
    \end{axis}
  \end{tikzpicture}%
  \begin{tikzpicture}
    \begin{axis}[
      width={\sharedplotwidth cm},
      height={\sharedplotheight cm},
      legend pos={north east},
      legend cell align={left},
      legend entries={{$R_{M_y},\;\tauint \approx 100.2$} , {fit: $\exp(-t/100.3)$}},
    ]
      \addplot[mark=none, Crimson]
        table[x expr=\coordindex, y index=0] {plots/T0.6_B0.2/autofit_my.csv};
      \addplot[mark=none, dashed, black]
        table[x expr=\coordindex, y index=1] {plots/T0.6_B0.2/autofit_my.csv};
    \end{axis}
  \end{tikzpicture}%
  \caption{We show the thermalization and autocorrelation behavior for a system
  with~$10^3$ lattice sites, periodic boundary conditions and a uniformly random
  start configuration at~$T=0.6$ and~$B=0.2$. In this case we chose~$\Ntherm =
  5000$. The acceptance rate settles around~$12$\%. A detailed interpretation of
  the plots is discussed in the text.}
\label{fig:warmlong}
\end{figure}

% INFO: energy autocorrelation time: fit τ = 14.793299102883838, integrated τ = 15.967395044037167
% INFO: Mx autocorrelation time: fit τ = 103.15277100727441, integrated τ = 102.04232545115562
% INFO: My autocorrelation time: fit τ = 100.26395989646923, integrated τ = 100.16079252634108
% INFO: Mz autocorrelation time: fit τ = 177.33593054824476, integrated τ = 181.89913958032605

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Conclusion}\label{sec:conclusion}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
Monte Carlo methods provide powerful tools for situations where specialized
rapidly convergent numerical methods fail or become infeasible. However, their
general applicability and relative simplicity often hide the complexity of how
to properly apply them and facilitate premature conclusions. Especially the
preliminary analysis of equilibration and autocorrelation times is a tedious,
but mandatory task.

We motivated and introduced Monte Carlo methods with a special focus on a
combination of simulated annealing and the Metropolis algorithm. In addition to
pointing out common pitfalls in theory, we illustrated proper and improper
analysis by the example of a three-dimensional spin lattice. While this report
focuses purely on the algorithmic aspects, in an accompanying paper we also
discuss physical results of simulations run with Sky-MoCa.


%%==================================
%% Section 0.00: Overview of the ILW
%%==================================

\documentclass[../dissertation.tex]{subfiles}

\begin{document}
% \setcounter{section}{-1}
\section{The Intermediate Long Wave Equation}\label{sec0:ILW}

The Intermediate Long Wave (ILW) equation
\begin{align}
	u_t + \frac{1}{\delta} u_x + 2 u u_x + Tu_{xx} = 0,
\end{align}
models the behavior of long internal gravitational waves in stratified fluid
of depth \label{sym:delta}
$0< \delta < \infty$, \label{sym:delta}
where $T$ denotes the singular integral operator given by
\[
	(Tf)(x)
		:= \frac{1}{2 \delta}
			\pv \int_{\mathbb R} \coth\left( \frac{\pi}{2\delta}(y - x) \right) f(y) \, \mathrm{d}y,
\]
\label{sym0:def}and $\pv$\label{sym0:pv} denotes the Cauchy principal value, \label{sym:pv}
$\pv \int \, \mathrm{d}x = \lim_{\varepsilon\searrow0} \int_{|x|> \varepsilon}\,dx$.
In the
limit $\delta \to 0$, the ILW reduces to the Korteweg de Vries (KdV) equation, and under
the limit $\delta \to \infty$, Santini, Ablowitz and Fokas showed formally in their
1984 paper \cite{Santini1984} that the ILW equation reduces to the Benjamin-Ono
(BO) equation. As such, the
ILW can be thought of as an intermediary between the two equations. While the KdV
equation is very well understood, understanding the BO equation is still an area
of active research.\footnote{For more on the BO equation, please see Allen Wu's papers
\cite{Wu2016} and \cite{Wu2017}.} Given the ILW's role as an
intermediary between the two equations, a mathematically rigorous understanding
of the ILW is of great interest to many mathematicians.

As discussed in the 2019 survey paper \cite{Saut2019} by Jean-Claude Saut,
the formal derivation of the ILW as a model for physical phenomenon was
given by R. I. Joseph in \cite{Joseph_1977}. Joseph based his derivation on
the Whithan non-local equation derived by Gerald Whitham in his 1967 paper
\cite{WhithamGB1967Ndow}. The modern form of the ILW was introduced by
T. Kubota, D.R.S. Ko, and L.D. Dobbs in their 1978 paper \cite{Kubota1978}.
Some atmospheric and oceanic applications of the
ILW can be found in the 1978 paper by D.R. Christie \textit{et al.}
\cite{Christie1978}, the 1980 S.A. Maslow and L.G. Redekopp paper
\cite{maslowe_redekopp_1980}, the 1981 C. Gary Koop and Gerald Butler paper
\cite{koop_butler_1981}, and the 1984 N.N. Romanova paper
\cite{Romanova1984}.

\end{document}