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

\begin{document}
\section{Results}\label{sec:results}
\subsection{Burn-in time}\label{subsec:burnin_time}
We started with a lattice size $L = 20$ and considered the temperatures $T_{1} = 1.0 J/k_{B}$,
and $T_{2} = 2.4 J/k_{B}$, where $T_{2}$ is close to the analytical critical 
temperature given by Equation \eqref{eq:critical_solution}. 

To determine the burn-in time, we used the numerical estimates of energy 
per spin for $T_{1}$ in Figure \ref{fig:burn_in_energy_1_0}, and $T_{2}$ in Figure 
\ref{fig:burn_in_energy_2_4}. We also considered the estimates of magnetization 
per spin for $T_{1}$ in Figure \ref{fig:burn_in_magnetization_1_0}, and for $T_{2}$ 
in Figure \ref{fig:burn_in_energy_2_4}. 
% Not sure about the relevance of the paragraph below
We used random numbers to set the initial state and the index of spin to flip, and 
observed different graphs ... However, when we set the seed of the random number 
engine, we could reproduce the results at every run. It is possible to determine 
the burn-in time analytically, using the correlation time given by $\tau \approx L^{d + z}$. 
Where $d$ is the dimensionality of the system and $z = 2.1665 \pm 0.0012$ 
\footnote{This value was determined by Nightingale and Blöte for the Metropolis algorithm.}. 
However, when we increased number of Monte Carlo cycles the sampled generated during 
the burn-in time did not affect the mean value (...). % Should add result showing this

The lattice was initialized in an ordered and an unordered state, for both temperatures. We observed 
no change in expectation value of energy or magnetization for $T_{1}$, when we 
initialized the lattice in an ordered state. As for the unordered initialized 
lattice, we first observed a change in expectation values, and a stabilization around 
$5000$ Monte Carlo cycles. The expected energy per spin is $\langle \epsilon \rangle = -2$ 
and the expected magnetization per spin is $\langle |m| \rangle = 1.0$. % add something about what is expected for $T_{1}$ ?
For $T_{2}$ we observed a change in expectation values for both the ordered and the 
unordered lattice. 
% \begin{align*}
%     p(s|T=1.0) &= \frac{1}{e^{-\beta \sum E(s)}} e^{-\beta E(s)} \\
%     &= \frac{1}{e^{-(1/k_{B}) \sum E(s)}} e^{-(1/k_{B}) E(s)} \ .
% \end{align*}
For $T_{2}$ we observe an increase in expected energy per spin $\langle \epsilon \rangle \approx -1.23$,
and a decrease in expected magnetization per spin $\langle |m| \rangle \approx 0.46$. 
% Burn-in figures
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/burn_in_time_magnetization_1_0.pdf}
    \caption{Magnetization per spin $\langle |m| \rangle$ as a function of time $t$ given by Monte Carlo cycles, for $T = 1.0 J / k_{B}$}
    \label{fig:burn_in_magnetization_1_0}
\end{figure}
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/burn_in_time_energy_1_0.pdf}
    \caption{Energy per spin $\langle \epsilon \rangle$ as a function of time $t$ given by Monte Carlo cycles, for $T = 1.0 J / k_{B}$}
    \label{fig:burn_in_energy_1_0}
\end{figure}
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/burn_in_time_magnetization_2_4.pdf}
    \caption{Magnetization per spin $\langle |m| \rangle$ as a function of time $t$ given by Monte Carlo cycles, for $T = 2.4 J / k_{B}$}
    \label{fig:burn_in_magnetization_2_4}
\end{figure}
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/burn_in_time_energy_2_4.pdf}
    \caption{Energy per spin $\langle \epsilon \rangle$ as a function of time $t$ given by Monte Carlo cycles, for $T = 2.4 J / k_{B}$}
    \label{fig:burn_in_energy_2_4}
\end{figure}


\subsection{Probability distribution}\label{subsec:probability_distribution}
% Histogram figures
We used the estimated burn-in time of $5000$ Monte Carlo cycles as starting time, and generated 
samples. To visualize the distribution of energy per spin $\epsilon$, we used histograms 
with a bin size $0.02$. In Figure \ref{fig:histogram_1_0} we show the distribution 
for $T_{1}$. Where the resulting expectation 
value of energy per spin is $\langle \epsilon \rangle = -1.9969$, with a low variance 
of Var$(\epsilon) = 0.0001$. %
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/pd_estimate_1_0.pdf}
    \caption{Histogram $T = 1.0 J / k_{B}$}
    \label{fig:histogram_1_0}
\end{figure} %
In Figure \ref{fig:histogram_2_4}, for $T_{2}$, the samples of energy per spin is 
centered around the expectation value $\langle \epsilon \rangle = -1.2370$. %
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/pd_estimate_2_4.pdf}
    \caption{Histogram $T = 2.4 J / k_{B}$}
    \label{fig:histogram_2_4}
\end{figure} % 
However, we observed a higher variance of Var$(\epsilon) = 0.0203$. When the temperature 
increased, the system moved from an ordered to an onordered state. The change in 
system state, or phase transition, indicates the temperature is close to a critical 
point. 


\subsection{Phase transition}\label{subsec:phase_transition}
% Phase transition figures
We continued investigating the behavior of the system around the critical temperature.
First, we generated $10$ million samples of spin configurations for lattices of 
size $L \in \{20, 40, 60, 80, 100\}$, and temperatures $T \in [2.1, 2.4]$. We divided the 
temperature range into $40$ steps, with an equal step size of $0.0075$. The samples 
were generated in parallel, where we allocated $4$ sequential temperatures to $10$ 
MPI processes. Each process was set to spawn $10$ thread, resulting in a total of 
$100$ threads working in parallel. We include results for $1$ million MC cycles 
in Appendix \ref{sec:additional_results}

$\boldsymbol{Rewrite}$ We ran a profiler to make sure the program was fully optimized which found that the 
workload was balanced, the threads was not left idle to long/not a lot of downtime.

In Figure \ref{fig:phase_energy_10M}, for the larger lattices we observe a sharper 
increase in $\langle \epsilon \rangle$ in the temperature range $T \in [2.25, 2.35]$. %]
\begin{figure}
    \centering
    \includegraphics[width=\linewidth]{../images/phase_transition/fox/wide/10M/energy.pdf}
    \caption{$\langle \epsilon \rangle$ for $T \in [2.1, 2.4]$, $10^7$ MC cycles.}
    \label{fig:phase_energy_10M}
\end{figure} % 
We observe a deacrese in $\langle |m| \rangle$ for the same temperature range in 
Figure \ref{fig:phase_magnetization_10M}, suggesting the system moves from an ordered 
magnetized state to a state of no net magnetization. The system energy increase, 
however, there is a loss of magnetization close to the critical temperature.
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/phase_transition/fox/wide/10M/magnetization.pdf}
    \caption{$\langle |m| \rangle$ for $T \in [2.1, 2.4]$, $10^7$ MC cycles.}
    \label{fig:phase_magnetization_10M}
\end{figure} %
In Figure \ref{fig:phase_heat_10M}, we observe an increase in heat capacity in the 
temperature range $T \in [2.25, 2.35]$. In addition, we observed a sharper peak 
value of heat capacity the lattice size increase. 
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/phase_transition/fox/wide/10M/heat_capacity.pdf}
    \caption{$C_{V}$ for $T \in [2.1, 2.4]$, $10^7$ MC cycles.}
    \label{fig:phase_heat_10M}
\end{figure} % 
The magnetic susceptibility in Figure \ref{fig:phase_susceptibility_10M}, show 
the sharp peak in the same temperature range as that of the heat capacity. Since 
shape of the curve for both heat capacity and the magnetic susceptibility become 
sharper when we increase lattice size, we are moving closer to the critical temperature.
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/phase_transition/fox/wide/10M/susceptibility.pdf}
    \caption{$\chi$ for $T \in [2.1, 2.4]$, $10^7$ MC cycles.}
    \label{fig:phase_susceptibility_10M}
\end{figure} %
% Add something about the correlation length?


\subsection{Critical temperature}\label{subsec:critical_temperature}
Based on the heat capacity (Figure \ref{fig:phase_heat_10M}) and susceptibility 
(Figure \ref{fig:phase_susceptibility_10M}), we estimated the critical temperatures 
of lattices of size $L \in \{20, 40, 60, 80, 100\}$ found in Table \ref{tab:critical_temperatures}.
% Tc wide 10M = 2.37, 2.325, 2.3025, 2.295, 2.2875
\begin{table}[H]
    \centering
    \begin{tabular}{cc} % @{\extracolsep{\fill}}
        \hline
        $L$ & $T_{c}(L)$ \\
        \hline 
        $20$ & $2.37 J / k_{B}$ \\
        $40$ & $2.325 J / k_{B}$ \\
        $60$ & $2.3025 J / k_{B}$ \\
        $80$ & $2.295 J / k_{B}$ \\
        $100$ & $2.2875 J / k_{B}$ \\
        \hline
    \end{tabular}
    \caption{Estimated critical temperatures for lattices $L \times L$, where $L$ denote the lattice size.}
    \label{tab:critical_temperatures}
\end{table}
We used the critical temperatures of finite lattices and the scaling relation in 
Equation \eqref{eq:critical_infinite}, Section \ref{subsec:phase_critical}, to estimate 
the critical temperature of a lattice of infinite size. In Figure \ref{fig:linreg_10M}, 
we plot the critical temperatures $T_{c}(L)$ of the inverse lattice size $1/L$. When 
the lattice size increase toward infinity, $1/L$ approaches zero. %
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/phase_transition/fox/wide/1M/linreg.pdf}
    \caption{Linear regression, where $\beta_{0}$ is the intercept approximating $T_{c}(L = \infty)$, and $\beta_{1}$ is the slope.}
    \label{fig:linreg_10M}
\end{figure}
We used linear regression to find the intercept $\beta_{0}$, which gives us an estimated value 
of the critical temperature for a lattice of infinite size. The estimated critical temperature 
is $T_{c \text{num}} \approx 2.2693 J/k_{B}$. We also compared the 
estimate with the analytical solution, the relative error of our estimate is
\begin{equation*}
    \text{Relative error} =  \frac{T_{c \text{ numerical}} - T_{c \text{ analytical}}}{T_{c \text{ analytical}}} \approx 5.05405 \cdot 10^{-5} J/k_{B}
\end{equation*}

\end{document}
