Finished first review, and added a few comments.

This commit is contained in:
Janita Willumsen 2023-12-04 19:31:43 +01:00
commit df699e0ea0
7 changed files with 156 additions and 136 deletions

View file

@ -3,8 +3,8 @@
\begin{document}
\section{Methods}\label{sec:methods}
\subsection{The Ising model}\label{subsec:ising_model}
The Ising model consist of a lattice of spins, which can be though of as atoms
in a grid. In two dimensions, the length of the lattice is given by $L$, and the
The Ising model consists of a lattice of spins, which can be thought of as atoms
in a grid. In two dimensions, the length of a lattice is given by $L$, and the
number of spins within a lattice is given by $N = L^{2}$. When we consider the
entire lattice, the system spin configuration is represented as a matrix $L \times L$
\begin{align*}
@ -23,15 +23,15 @@ The spins interact with its nearest neighbors, and in a two-dimensional lattice
each spin has up to four nearest neighbors. In our experiments we will use periodic
boundary conditions, resulting in all spins having exactly four nearest neighbors.
To find the analytical expressions necessary for validating our model implementation,
we will assume a $2 \times 2$ lattice.
we assume a $2 \times 2$ lattice.
The hamiltonian of the Ising model is given by
\begin{equation}
E(\mathbf{s}) = -J \sum_{\langle k l \rangle}^{N} s_{k} s_{l} - B \sum_{k}^{N} s_{k}\ ,
\label{eq:energy_hamiltonian}
\end{equation}
where $\langle k l \rangle$ denote a spin pair. $J$ is the coupling constant, and
$B$ is the external magnetic field. For simplicity, we will consider the Ising model
where $\langle k l \rangle$ denotes a spin pair. $J$ is the coupling constant, and
$B$ is the external magnetic field. For simplicity, we consider the Ising model
where $B = 0$, and find the total system energy given by
\begin{equation}
E(\mathbf{s}) = -J \sum_{\langle k l \rangle}^{N} s_{k} s_{l} \ .
@ -89,13 +89,13 @@ in Appendix \ref{sec:energy_special}.
0 & -8J & -4 & 1 \\
\hline
\end{tabular}
\caption{Values of total energy, total magnetization, and degeneracy for the
\caption{Values of the total energy, total magnetization, and degeneracy for the
possible states of a system for a $2 \times 2$ lattice, with periodic boundary
conditions.}
\label{tab:lattice_config}
\end{table}
We calculate the analytical values for a $2 \times 2$ lattice, found in Table \ref{tab:lattice_config}.
However, we scale the total energy and total magnetization by number of spins,
However, we scale the total energy and total magnetization by the number of spins,
to compare these quantities for lattices where $L > 2$. Energy per spin is given by
\begin{equation}
\epsilon (\mathbf{s}) = \frac{E(\mathbf{s})}{N} \ ,
@ -165,10 +165,10 @@ We also need to determine the heat capacity
\label{eq:heat_capacity}
\end{equation}
and the magnetic susceptibility
\begin{align*}
\begin{equation}
\chi = \frac{1}{k_{\text{B} T}} (\mathbb{E}(M^{2}) - [\mathbb{E}(M)]^{2}) \ .
\label{eq:susceptibility}
\end{align*}
\end{equation}
In Appendix \ref{sec:heat_susceptibility} we derive expressions for the heat
capacity and the susceptibility, and find the heat capacity
\begin{align*}
@ -205,29 +205,29 @@ Boltzmann constant we derive the remaining units, which can be found in Table
We consider the Ising model in two dimensions, with no external external magnetic
field. At temperatures below the critical temperature $T_{c}$, the Ising model will
magnetize spontaneously. When increasing the temperature of the external field,
the Ising model transition from an ordered to an unordered phase. The spins become
more correlated, and we can measure the discontinous behavior as an increase in
the Ising model transitions from an ordered to an unordered phase. The spins become
more correlated, and we can measure the discontinuous behavior as an increase in
correlation length $\xi (T)$ \cite[p. 432]{hj:2015:comp_phys}. At $T_{c}$, the
correlation length is proportional with the lattice size, resulting in the critical
correlation length is proportional to the lattice size, resulting in the critical
temperature scaling relation
\begin{equation}
T_{c}(L) - T_{c}(L = \infty) = aL^{-1} \ ,
\label{eq:critical_infinite}
\end{equation}
where $a$ is a constant. For the Ising model in two dimensions, with an lattice of
where $a$ is a constant. For the Ising model in two dimensions, with a lattice of
infinite size, the analytical solution of the critical temperature is
\begin{equation}
T_{c}(L = \infty) = \frac{2}{\ln (1 + \sqrt{2})} J/k_{B} \approx 2.269 J/k_{B}
\label{eq:critical_solution}
\end{equation}
This result was found analytically by Lars Onsager in 1944. We can estimate the
critical temperature of an infinite lattice, using finite lattices critical temperature
and linear regression.
This result was found analytically by Lars Onsager in 1944 \cite{onsager:1944}. We can estimate the
critical temperature of an infinite lattice, using the critical temperature of
finite lattices of different sizes and linear regression.
\subsection{The Markov chain Monte Carlo method}\label{subsec:mcmc_method}
Markov chains consist of a sequence of samples, where the probability of the next
sample depend on the probability of the current sample. Whereas the Monte Carlo
sample depends on the probability of the current sample. Whereas the Monte Carlo
method introduces randomness to the sampling, which allows us to approximate
statistical quantities \cite{tds:2021:mcmc} without using the pdf directly. We
generate samples of spin configuration, to approximate $\langle \epsilon \rangle$,
@ -236,10 +236,10 @@ $\langle |m| \rangle$, $C_{V}$, and $\chi$, using the Markov chain Monte Carlo
The Ising model is initialized in a random state, and the Markov chain is evolved
until the model reaches an equilibrium state. However, generating new random states
require ergodicity and detailed balance. A Markov chain is ergoditic when all system
states can be reached at every current state, whereas detaild balance implies no
net flux of probability. To satisfy these criterias we use the Metropolis-Hastings
algorithm, found in Figure \ref{algo:metropolis}, to generate samples of microstates.
requires ergodicity and detailed balance. A Markov chain is ergoditic when all system
states can be reached at every current state, whereas detailed balance implies no
net flux of probability. To satisfy these criteria we use the Metropolis-Hastings
algorithm, found in Algorithm \ref{algo:metropolis}, to generate samples of microstates.
One Monte Carlo cycle consist of changing the initial configuration of the lattice,
by randomly flipping a spin. When a spin is flipped, the change in energy is evaluated as
@ -258,41 +258,38 @@ $\Delta E = \{-16J, -8J, 0, 8J, 16J\}$, we derive these values in Appendix \ref{
We can avoid computing the Boltzmann factor, by using a look up table (LUT).
We use $\Delta E$ as an index to access the resulting value of the exponential function,
in an array.
\begin{figure}[H]
\begin{algorithm}[H]
\caption{Metropolis-Hastings Algorithm}
\label{algo:metropolis}
\begin{algorithmic}
\Procedure{Metropolis}{$lattice, energy, magnetization$}
\For{ Each spin in the lattice }
\State $ri \leftarrow \text{random index of the lattice}$
\State $rj \leftarrow \text{random index of the lattice}$
\State $dE \leftarrow 2 \cdot lattice_{ri,rj} \cdot (lattice_{ri,rj-1} + lattice_{ri,rj+1}
+ lattice_{ri-1,rj} + lattice_{ri+1,rj} )$
\begin{algorithm}[H]
\caption{Metropolis-Hastings Algorithm}
\label{algo:metropolis}
\begin{algorithmic}
\Procedure{Metropolis}{$lattice, energy, magnetization$}
\For{ Each spin in the lattice }
\State $ri \leftarrow \text{random index of the lattice}$
\State $rj \leftarrow \text{random index of the lattice}$
\State $dE \leftarrow 2 \cdot lattice_{ri,rj} \cdot (lattice_{ri,rj-1} + lattice_{ri,rj+1}
+ lattice_{ri-1,rj} + lattice_{ri+1,rj} )$
\State $rn \leftarrow \text{random number} \in [0,1)$
\If{$rn \leq e^{- \frac{dE}{T}}$}
\State $lattice_{ri,rj} = -1 \cdot lattice_{ri,rj}$
\State $magnetization = magnetization + 2 \cdot lattice_{ri,rj}$
\State $energy = energy + dE$
\EndIf
\EndFor
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{figure}
The Markov process reach an equilibrium after a certain number of Monte Carlo cycles,
where the system state reflects the state of a real system. After this burn-in time,
given by number of Monte Carlo cycles, we can start sampling microstates.
The probability distribution of the samples will tend toward the actual probability
distribution of the system.
\State $rn \leftarrow \text{random number} \in [0,1)$
\If{$rn \leq e^{- \frac{dE}{T}}$}
\State $lattice_{ri,rj} = -1 \cdot lattice_{ri,rj}$
\State $magnetization = magnetization + 2 \cdot lattice_{ri,rj}$
\State $energy = energy + dE$
\EndIf
\EndFor
\EndProcedure
\end{algorithmic}
\end{algorithm}
The Markov process reaches an equilibrium after a certain number of Monte Carlo cycles,
called burn-in time. After the burn-in time, the system state reflects the state of a real system.
and we can start sampling microstates. The probability distribution of the samples
will tend toward the actual probability distribution of the system.
\subsection{Implementation and testing}\label{subsec:implementation_test}
We implemented a test suite, and compared the numerical estimates to the analytical
results from Section \ref{subsec:statistical_mechanics}. In addition, we set a tolerance to
verify convergence, and a maximum number of Monte Carlo cycles to avoid longer
runtimes during implementation.
runtimes during execution.
We used a pattern to access all neighboring spins, where all indices of the neighboring
spins are put in an $L \times 2$ matrix. The indices are accessed using pre-defined
@ -315,11 +312,11 @@ Monte Carlo cycles when analyzing phase transitions.
\subsection{Tools}\label{subsec:tools}
The Ising model and MCMC methods are implemented in C++, and parallelized using
both \verb|OpenMPI| \cite{gabriel:2004:open_mpi} and \verb|OpenMP| \cite{openmp:2018}.
We used the Python library \verb|matplotlib| \cite{hunter:2007:matplotlib} to produce
We use the Python library \verb|matplotlib| \cite{hunter:2007:matplotlib} to produce
all the plots, \verb|seaborn| \cite{waskom:2021:seaborn} to set the theme in the
figures. We also used a linear regression method from the Python library \verb|SciPy|.
To optimize our implementation, we used a profiler tool \verb|Scalasca| \cite{scalasca}
and \verb|Score-P| \cite{scorep}.
figures. We also use a linear regression method and the normal distribution method
from the Python library \verb|SciPy|. To optimize our implementation, we used a
profiling tool \verb|Score-P| \cite{scorep}.
\end{document}