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



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

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

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

\usepackage{amssymb}  % mathematical symbols (physics imports amsmath)
\usepackage{amsmath}
\usepackage{graphicx}         % include graphics such as plots
\usepackage{xcolor}           % set colors
\usepackage{hyperref}         % automagic cross-referencing
\usepackage{listings}         % display code
\usepackage{subfigure}        % imports a lot of cool and useful figure commands
\usepackage{float}
%\usepackage[section]{placeins}
\usepackage{algorithm}
\usepackage{booktabs}
\usepackage[noend]{algpseudocode}
\usepackage{subfigure}
\usepackage{tikz}
\usepackage[noabbrev,nameinlink]{cleveref}
\usepackage[separate-uncertainty=true]{siunitx}
% Define amu = Dalton
\DeclareSIUnit\amu{u}

\usepackage{todonotes}
\usetikzlibrary{quantikz}
% defines the color of hyperref objects
% Blending two colors:  blue!80!black  =  80% blue and 20% black
\hypersetup{ % this is just my personal choice, feel free to change things
    colorlinks,
    linkcolor={red!50!black},
    citecolor={blue!50!black},
    urlcolor={blue!80!black}}


% ===========================================

\newcommand{\expect}[1]{\left\langle#1\right\rangle}

\begin{document}

\title{Efficient Monte-Carlo Sampling of Ising Models}  % self-explanatory
\author{Lars Bogner} % self-explanatory
\date{\today}                             % self-explanatory
\affiliation{{\url{https://github.uio.no/larsbog/FYS4150}}}                            % ignore this, but keep it.

%This is how we create an abstract section.
\begin{abstract}
    This work presents a numerical study of the two-dimensional Ising model using a custom implementation of Markov Chain Monte Carlo sampling with single-spin Metropolis updates. The model is simulated on square lattices with periodic boundary conditions, and the statistical properties of the system, i.e., energy, magnetization, heat capacity, and susceptibility, are extracted across a range of temperatures. Multiple independent Markov chains are executed in parallel to accelerate parameter sweeps, enabling efficient exploration of temperature-dependent behavior. Validation against analytical results for the $L=2$ lattice demonstrates excellent agreement for energy and magnetization, confirming the correctness of the implementation. Detailed equilibration studies highlight the role of ergodicity and illustrate the contrasting dynamical behavior below and above the critical temperature. The simulations reproduce the characteristic signatures of the continuous phase transition at $T_C$, including the emergence of large correlated domains and the divergence of response functions. The methods and performance characteristics of the implementation provide a robust foundation for further investigations of critical phenomena in lattice spin systems.
\end{abstract}
\maketitle
\tableofcontents


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

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

% ===========================================
\section{Conclusion}\label{sec:conclusion}

\input{chapters/conclusion.tex}
% ===========================================
\appendix
\section{Analytical expectation values for the 2x2 lattice} \label{app:analytical}

\begin{table}
    \caption{Possible configurations of a 2x2 lattice with periodic boundary conditions. Assuming $|s_i| = 1$ and properties of each configuration.}
    \label{tab:2x2_configurations}
    \begin{tabular}{cccc}
        \toprule
        $\sum_i \delta_{s_i,1}$ & Degeneracy & Energy $E$ & Magnetization $M$ \\
        \midrule
        0 & 1 & -8J & -4 \\
        1 & 4 & 0 & -2 \\
        2 & 4 & 0 & 0 \\
        2 & 2 & 8J & 0 \\
        3 & 4 & 0 & 2 \\
        4 & 1 & -8J & 4 \\
        \bottomrule
    \end{tabular}
\end{table}

In \cref{tab:2x2_configurations}, a comprehensive list of all possible configurations of a $2\times 2$ lattice with periodic boundary conditions is provided, along with their respective degeneracies, energies, and magnetizations. It is possible to compute the partition function, $Z$, by utilizing the aforementioned information
\begin{equation}
    Z = 2 e^{8J\beta} + 2 e^{-8J\beta} + 12,
\end{equation}
where $\beta = 1/(k_B T)$. From the partition function, we can derive the expectation values for the energy per spin state as
\begin{equation}
    \begin{aligned}
        \expect{\epsilon} &= -\frac{J}{ZN} \sum_{i} E_i \cdot \text{deg}_i \cdot e^{-\beta E_i}\\
        &= \frac{6}{Z} \left(e^{-8\beta} - e^{8 \beta}\right),
    \end{aligned}
\end{equation}
with $N=4$.  In general an expectation value of the ensemble of a general quantity $A$ can be expressed as
\begin{equation}
    \expect{A} = \frac{1}{ZN} \sum_i A_i \cdot \text{deg}_i \cdot e^{-\beta E_i}.
\end{equation}
The following quantities are furthermore obtained analytically:
\begin{align}
    \expect{\epsilon^2} &= \frac{72}{Z} \left(e^{-8\beta} + e^{8 \beta}\right)\\
    \expect{|m|} &= \frac{2}{Z} \left(2+e^{8\beta}\right)\\
    \expect{m^2} &= \frac{8}{Z} \left(1 + e^{8\beta}\right).
\end{align}
Using those expressions it is also straightforward to obtain $\expect{\frac{C_V}{N}}$ and $\expect{\frac{\chi}{N}}$.

For the numerical evaluation at $k_BT = J = 1$ of all expectation values, \texttt{Python} is used. The expectation values shown in \cref{tab:analytical_expectation_values} are obtained from the numerical analysis.

\begin{table}
    \centering
    \caption{Numerical expectation values for the intensive thermodynamic properties of the 2x2 lattice.}
    \label{tab:analytical_expectation_values}
    \begin{tabular}{cc}
        \toprule
        Quantity & Numerical Expectation Value \\
        \midrule
         $\expect{\epsilon}$ & \num{-1.996}  \\
         $\expect{|m|}$ & \num{0.999} \\
         $\expect{\frac{C_V}{N}}$ & \num{11.984} \\
         $\expect{\frac{\chi}{N}}$ & \num{2.996} \\ \bottomrule
    \end{tabular}
\end{table}

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


\end{document}