diff --git a/latex/ising_model.tex b/latex/ising_model.tex index be6820d..82b7fbc 100644 --- a/latex/ising_model.tex +++ b/latex/ising_model.tex @@ -10,6 +10,9 @@ % Allows special characters (including æøå) \usepackage[utf8]{inputenc} \usepackage{fontawesome} +\usepackage{multirow} +\usepackage[table]{xcolor} +% \rowcolors{2}{gray!15}{white} % \usepackage{tabularx} % \usepackage[english]{babel} @@ -23,12 +26,12 @@ \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{subfigure} % imports a lot of cool and useful figure commands +\usepackage{subcaption} % \usepackage{float} %\usepackage[section]{placeins} \usepackage{algorithm} \usepackage[noend]{algpseudocode} -\usepackage{subfigure} \usepackage{tikz} % \usetikzlibrary{quantikz} % defines the color of hyperref objects @@ -73,6 +76,8 @@ % Conclusion \subfile{sections/conclusion} +\clearpage +\newpage % Appendix \subfile{sections/appendices} diff --git a/latex/references.bib b/latex/references.bib index 2513567..391436b 100644 --- a/latex/references.bib +++ b/latex/references.bib @@ -67,3 +67,20 @@ } # Miscellaneous things +@misc{obermeyer:2020:ising, + author = {Johannes Obermeyer}, + title = {The Ising Model in One and Two Dimensions}, + year = {2020}, + url = {https://www.thphys.uni-heidelberg.de/~wolschin/statsem20_3s.pdf}, + urldate = {2023-11-13}, + pages = {16}, + note = {Seminar on Statistical Physics at the University of Heidelberg, summary} +} + +@book{springer:2012:modernstat, + author = {Jay L. Devore and Kenneth N. Berk}, + title = {Modern Mathematical Statistics with Application}, + publisher = {Cham: Springer International Publishing AG}, + year = {2021}, + edition = {3} +} \ No newline at end of file diff --git a/latex/sections/appendices.tex b/latex/sections/appendices.tex index 3525403..4719731 100644 --- a/latex/sections/appendices.tex +++ b/latex/sections/appendices.tex @@ -3,6 +3,24 @@ \begin{document} \appendix \section{Ising model system states}\label{sec:system_states} +Units +\begin{table}[H] + \centering + \begin{tabular}[c]{cc} % @{\extracolsep{\fill}} + \hline + Value & Unit \\ + \hline + $[ E ]$ & $J$ \\ + $[ T ]$ & $J / k_{\text{B}}$ \\ + $[ M ]$ & $\dots$ \\ + $[ C_{\text{V}} ]$ & $k_{\text{B}}$ \\ + $[ \chi ]$ & $1 / J$ \\ + \hline + \end{tabular} + \caption{Units, given by the coupling constant $J$ and the Boltzmann constant $k_{\text{B}}$.} + \label{tab:units} +\end{table} + To avoid counting duplicates, we used \begin{figure}\label{fig:tikz_counting} \centering @@ -30,14 +48,196 @@ To avoid counting duplicates, we used \caption{Rules for multiplying spin pairs.} \end{figure} +\begin{figure}\label{fig:tikz_neighbor} + \centering + \begin{subfigure}{0.4\linewidth} + \begin{tikzpicture} + \draw (0, 0) grid (2, 2); + \node (s1) at (0.5, 1.5) {$\uparrow$}; + \node (s2) at (1.5, 1.5) {$\uparrow$}; + \node (s3) at (0.5, 0.5) {$\downarrow$}; + \node (s4) at (1.5, 0.5) {$\downarrow$}; + \end{tikzpicture} + \caption{} + \label{fig:sub_tikz_neighbor_a} + \end{subfigure} + \ + \begin{subfigure}{0.4\linewidth} + \begin{tikzpicture} + \draw (0, 0) grid (2, 2); + \node (s1) at (0.5, 1.5) {$\uparrow$}; + \node (s2) at (1.5, 1.5) {$\downarrow$}; + \node (s3) at (0.5, 0.5) {$\downarrow$}; + \node (s4) at (1.5, 0.5) {$\uparrow$}; + \end{tikzpicture} + \caption{} + \label{fig:sub_tikz_neighbor_b} + \end{subfigure} + \caption{Possible spin configurations for two spins up.} +\end{figure} + \section{Analytical expressions}\label{sec:analytical_expressions} -The Boltzmann distribution is normalized using a partition function $Z$ given by +The Boltzmann distribution is normalized using a partition function $Z$, given by +\begin{equation}\label{eq:partition} + Z = \sum_{\text{all possible } \mathbf{s}}^{N} +\end{equation} +We use the values estimated for the $2 \times 2$ case, found in \ref{tab:lattice_config}, +and find \begin{align*} - Z &= \sum_{\text{all possible } s_{i}}^{N} e^{-\beta E(\mathbf{s})} \\ - &= \dots \\ - &= 4 \cosh (8 \beta J) + 12 \\ + Z &= 1 \cdot e^{-\beta (-8J)} + 4 \cdot e^{-\beta (0)} + 4 \cdot e^{-\beta (0)} + 2 \cdot e^{-\beta (8J)} \\ + & \quad + 4 \cdot e^{-\beta (0)} 1 \cdot e^{-\beta (-8J)} \\ + &= 2e^{8 \beta J} + 2e^{-8 \beta J} + 12. +\end{align*} +We rewrite the expression using $\cosh(8 \beta J) = 1/2 \big( e^{8 \beta J} + e^{-8 \beta J})$, and get +\begin{align*} + z &= 4 \cosh (8 \beta J) + 12 +\end{align*} +The Boltzmann distribution is given by +\begin{equation}\label{eq:boltzmann} + p(\mathbf{s} \ | \ T) = \frac{1}{Z} e^{-\beta E(\mathbf{s})}, +\end{equation} +for a given temperature $T$. With our expression for the partition function, we +get the probability distribution +\begin{align*} + p(\mathbf{s} \ | \ T) &= \frac{1}{4 \cosh (8 \beta J) + 12} e^{-\beta E(\mathbf{s})} \end{align*} +For discrete random variables $X$, with a known probability distribution, the +expected value of $x$ is given by +\begin{align*} + \mathbb{E}(x) &= \sum_{x \in D} x \cdot p(x) & \text{\cite[p. 127]{springer:2012:modernstat}}. +\end{align*} +For a function of a stochastic random variable, the expected value of $x$ is +\begin{align*} + \mathbb{E}(h(X)) &= \sum_{x \in D} h(x) \cdot p(x) +\end{align*} +And in the case of a linear function we have +\begin{align*} + \mathbb{E}(aX + b) &= a \cdot \mathbb{E}(X) + b & \text{\cite[p. 131]{springer:2012:modernstat}} +\end{align*} +In our case the discrete random variable is the spin configuration, and we want +to find the expected value of the function $E(\mathbf{s})$. In addition, we use +$\langle E \rangle$ as notation for expexted value of a given variable, since $\mathbf{s}$ is the stochastic +random variable. +The expression for total energy and total magnetization is given in eq. \eqref{eq:energy} and \eqref{eq:magnetization}. +The expected values for these is given by +\begin{equation*} + \langle E(\mathbf{s}) \rangle = \sum_{i=1}^{N} E(s_{i}) p(s_{i} \ | \ T) +\end{equation*} + +\begin{equation*} + \langle |M(\mathbf{s})| \rangle = \sum_{i=1}^{N} |M(s_{i})| p(s_{i} \ | \ T) +\end{equation*} + +Since we want to compare expected values for different lattice sizes, we have to +find the expected values per spin. We normalize the total expressions for total +energy \eqref{eq:energy} and magnetizaation \eqref{eq:magnetization} by the +number of spins to get +\begin{equation}\label{eq:spin_energy} + \epsilon(\mathbf{s}) = \frac{E(\mathbf{s})}{N} +\end{equation} + +\begin{equation}\label{eq:spin_magnetization} + m(\mathbf{s}) = \frac{M(\mathbf{s})}{N} +\end{equation} + +Both energy per spin and magnetization per spin are functions of $\mathbf{s}$, +we will use the short hand notation $\langle \epsilon \rangle$ and $\langle |m| \rangle$. +In addition, the number of spins are given as a constant for each lattice. We can +rewrite and use this when we find the expectation values per spin, for energy per spin +\begin{align*} + \langle \epsilon \rangle &= \sum_{i=1}^{N} \epsilon(s_{i}) p(s_{i} \ | \ T) \\ + &= \sum_{i=1}^{N} \frac{E(\mathbf{s})}{N} p(s_{i} \ | \ T) \\ + &= \frac{1}{N} \sum_{i=1}^{N} E(\mathbf{s}) p(s_{i} \ | \ T) +\end{align*} +The same applies for magnetization per spin +\begin{align*} + \langle |m| \rangle = \frac{1}{N} \sum_{i=1}^{N} |M(s_{i})| p(s_{i} \ | \ T) +\end{align*} +Continuing with the expectation values for a $2 \times 2$ lattice, excluding the terms which give zero we get +\begin{align*} + \langle E \rangle &= (-8J) \cdot \frac{1}{Z} e^{8 \beta J} + 2 \cdot (8J) \cdot \frac{1}{Z} e^{-8 \beta J} + (-8J) \cdot \frac{1}{Z} e^{8 \beta J} \\ + &= \frac{16J}{Z} \big(e^{-8 \beta J} - e^{8 \beta J}) \\ + &= -\frac{32J \sinh(8 \beta J)}{4(\cosh(8 \beta J) + 3)} \\ + &= -\frac{8J \sinh(8 \beta J)}{\cosh(8 \beta J) + 3}, +\end{align*} +and +\begin{align*} + \langle |M| \rangle &= 4 \cdot \frac{1}{Z} \cdot e^{8 \beta J} + 4 \cdot 2 \cdot \frac{1}{Z} \cdot e^{0} \\ + & \quad + 4 \cdot | -2| \cdot \frac{1}{Z} \cdot e^{0} + | -4| \cdot e^{8 \beta J} \\ + &= \frac{8 e^{8 \beta J} + 16}{Z} \\ + &= \frac{4 (2e^{8 \beta J} + 4)}{4(\cosh(8 \beta J) + 3)} \\ + &= \frac{2(e^{8 \beta J} + 2)}{\cosh(8 \beta J) + 3} +\end{align*} +The squared function +\begin{align*} + \langle E^{2} \rangle &= (-8J)^{2} \cdot \frac{1}{Z} e^{8 \beta J} + 2 \cdot (8J)^{2} \cdot \frac{1}{Z} e^{-8 \beta J} + (-8J)^{2} \cdot \frac{1}{Z} e^{8 \beta J} \\ + &= \frac{128J^{2}}{Z} \big(e^{8 \beta J} + e^{-8 \beta J} \big) \\ + &= \frac{128J^{2} \cosh(8 \beta J)}{4(\cosh(8 \beta J) + 3)} \\ + &= \frac{64J^{2} \cosh(8 \beta J)}{\cosh(8 \beta J) + 3}, +\end{align*} +and +\begin{align*} + \langle M^{2} \rangle &= 4^{2} \cdot \frac{1}{Z} \cdot e^{8 \beta J} + 4 \cdot 2^{2} \cdot \frac{1}{Z} \cdot e^{0} \\ + & \quad + 4 \cdot (-2)^{2} \cdot \frac{1}{Z} \cdot e^{0} + (-4)^{2}\cdot e^{8 \beta J} \\ + &= \frac{32e^{8 \beta J} + 32}{Z} \\ + &= \frac{4 (8e^{8 \beta J} + 8)}{4(\cosh(8 \beta J) + 3)} \\ + &= \frac{8e^{8 \beta J} + 8}{\cosh(8 \beta J) + 3} +\end{align*} +The squared expectation value is given by +\begin{align*} + \langle E \rangle^{2} &= \bigg(-\frac{8J \sinh(8 \beta J)}{\cosh(8 \beta J) + 3} \bigg)^{2} \\ + &= \frac{64J^{2} \sinh^{2}(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}}, +\end{align*} +and +\begin{align*} + \langle |M| \rangle^{2} &= \Big( \frac{2(e^{8 \beta J} + 2)}{\cosh(8 \beta J) + 3} \Big)^{2} \\ + &= \frac{4(e^{8 \beta J} + 2)^{2}}{(\cosh(8 \beta J) + 3)^{2}} +\end{align*} +Calculating the heat capacity and susceptibility, we need the variance of both total +energy and total magnetizaation. We obtain this using the definition +\begin{align*} + \mathbb{V}(X) &= \sum_{x \in D} [(x - \mathbb{E}(x))^2 \cdot p(x)] & \text{\cite[p. 132]{springer:2012:modernstat}}. \\ + &= \mathbb{E}(X^{2}) - [\mathbb{E}(X)]^{2} +\end{align*} +The variance of total energy is given by +\begin{align*} + \mathbb{V}(E) &= \mathbb{E}(E^{2}) - [\mathbb{E}(E)]^{2} \\ + &= \frac{64J^{2} \cosh(8 \beta J)}{\cosh(8 \beta J) + 3} - \frac{64J^{2} \sinh^{2}(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}} \\ + &= 64J^{2} \bigg( \frac{\cosh(8 \beta J)}{\cosh(8 \beta J) + 3} - \frac{\sinh^{2}(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}} \bigg) \\ + &= 64J^{2} \bigg( \frac{(\cosh(8 \beta J)) \cdot (\cosh(8 \beta J) + 3)}{(\cosh(8 \beta J) + 3)^{2}} \\ + & \quad - \frac{\sinh^{2}(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}} \bigg) \\ + &= 64J^{2} \bigg( \frac{\cosh^{2}(8 \beta J) + 3\cosh(8 \beta J) - \sinh^{2}(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}} \bigg) \\ + &= 64J^{2} \bigg( \frac{3\cosh(8 \beta J) + 1}{(\cosh(8 \beta J) + 3)^{2}} \bigg) +\end{align*} +\begin{align*} + \mathbb{V}(M) &= \mathbb{E}(M^{2}) - [\mathbb{E}(|M|)]^{2} \\ + &= \frac{8e^{8 \beta J} + 8}{\cosh(8 \beta J) + 3} - \frac{4(e^{8 \beta J} + 2)^{2}}{(\cosh(8 \beta J) + 3)^{2}} \\ + &= \frac{(8(e^{8 \beta J} + 1)) \cdot (\cosh(8 \beta J) + 3) - 4(e^{8 \beta J} + 2)^{2}}{(\cosh(8 \beta J) + 3)^{2}} \\ + &= \frac{4(e^{8 \beta J} + 1) \cdot (e^{8 \beta J} + e^{-8 \beta J}) + 24(e^{8 \beta J} + 1) - 4(e^{8 \beta J} + 1)^{2}}{(\cosh(8 \beta J) + 3)^{2}} \\ + &= \frac{4e^{2(8 \beta J)} + 4e^{8 \beta J} 4e^{0} + 4e^{-8 \beta J} 24e^{8 \beta J} + 24 - 4e^{2(8 \beta J)} - 16e^{8 \beta J} - 16}{(\cosh(8 \beta J) + 3)^{2}} \\ + &= \frac{4(3e^{8 \beta J} + e^{-8 \beta J} + 3)}{(\cosh(8 \beta J) + 3)^{2}} +\end{align*} + +\begin{align*} + C_{\text{V}} &= \frac{1}{N} \frac{1}{k_{\text{B} T^{2}}} (\mathbb{E}(E^{2}) - [\mathbb{E}(E)]^{2}) \\ + &= \frac{1}{N k_{\text{B} T^{2}}} \mathbb{V}(E) \\ + &= \frac{64J^{2} }{N k_{\text{B}} T^{2}} \bigg( \frac{3\cosh(8 \beta J) + 1}{(\cosh(8 \beta J) + 3)^{2}} \bigg) +\end{align*} + +\begin{align*} + \chi &= \frac{1}{N} \frac{1}{k_{\text{B} T}} (\mathbb{E}(M^{2}) - [\mathbb{E}(M)]^{2}) \\ + &= \frac{1}{N k_{\text{B} T}} \mathbb{V}(M) \\ + &= \frac{4}{N k_{\text{B} T}} \bigg( \frac{3e^{8 \beta J} + e^{-8 \beta J} + 3}{(\cosh(8 \beta J) + 3)^{2}} \bigg) +\end{align*} +\begin{align*} + \langle \epsilon^{2} \rangle &= \frac{1}{N^{2}} \sum_{i=1}^{N} E(\mathbf{s})^{2} p(s_{i} \ | \ T) \\ + &= +\end{align*} +The same applies for magnetization per spin +\begin{align*} + \langle |m| \rangle = \frac{1}{N} \sum_{i=1}^{N} |M(s_{i})| p(s_{i} \ | \ T) +\end{align*} \end{document} \ No newline at end of file diff --git a/latex/sections/methods.tex b/latex/sections/methods.tex index 9376258..690cefe 100644 --- a/latex/sections/methods.tex +++ b/latex/sections/methods.tex @@ -1,13 +1,75 @@ -\documentclass[../ising_model.tex]{subfiles} +\documentclass[../ising_model.tex]{subfiles} -\begin{document} +\begin{document} \section{Methods}\label{sec:methods} \subsection{The Ising model}\label{sec:ising_model} % Add definitions +The Ising model correspond to a lattice with a number of spin sites, where +each spin has the possible state up $\uparrow$ or down $\downarrow$. We will study the +two-dimensional Ising model for ferromagnets, however, the model is not resticted +to this dimentionality~\cite[p. 3]{obermeyer:2020:ising}. We will assume a square lattice, where the length $L$ of +the lattice give the number of spin sites $N = L^{2}$. When we +consider the entire 2D lattice we can study the system spin configuration, or the +microstate, given by $\mathbf{s} = (s_{1}, s_{2}, \dots, s_{N})$. The value of +each spin $s_{i}$, where $i \in [1, N]$, is given by the direction of the spin +$\uparrow = +1$ and $\downarrow = -1$. + +We find the total energy of the system using +\begin{equation}\label{eq:energy} + E(\mathbf{s}) = -J \sum_{\langle k l \rangle}^{N} s_{k} s_{l} +\end{equation} +where $\langle k l \rangle$ denotes the neighboring spins. + +The total magnetization of the system is given by +\begin{equation}\label{eq:magnetization} + M(\mathbf{s}) = \sum_{i}^{N} s_{i}, +\end{equation} +with degeneracy denoting how many states have the same values. We will consider +a 2D lattice with $L = 2$, with periodic boundary conditions, following the +counting pattern shown in figure~\ref{fig:tikz_counting}. The resulting values for +the $2 \times 2$ lattice can be found in table \ref{tab:lattice_config}. + +\begin{table}[H] + \centering + \begin{tabular}{cccc} % @{\extracolsep{\fill}} + \hline + Spins up & $E(\mathbf{s})$ & $M(\mathbf{s})$ & Degeneracy \\ + \hline + 4 & -8J & 4 & 1 \\ + 3 & 0 & 2 & 4 \\ + \multirow{2}*{2} & 0 & 0 & 4 \\ + & 8J & 0 & 2 \\ + 1 & 0 & -2 & 4 \\ + 0 & -8J & -4 & 1 \\ + \hline + \end{tabular} + \caption{Values} + \label{tab:lattice_config} +\end{table} + +Probability stuff, for a system with a given temperature $T$. We use the Boltzmann +distribution in the analytical expression, to compare with our results. This is +a probability distribution from the family of exponential +\begin{equation}\label{eq:boltzmann_distribution} + p(\mathbf{s} \ | \ T) = \frac{1}{Z} \exp^{-\beta E(\mathbf{s})}, +\end{equation} +where $Z$ is the partition function $\beta$ is the related to the inverse of the +temperature as +\begin{equation}\label{eq:beta} + \beta = \frac{1}{k_{\text{B}} T}. +\end{equation} +We derive an analytical expression for $Z$ in appendix \ref{sec:analytical_expressions} We will assume a $2 \times 2$ lattice to study the possible system states, and to find analytical expressions necessary in the Markov Chain Monte Carlo method. These results are used to test our code during implementation. + +We study the 2D lattice and find the total energy and the total magnetization of +of the system, in addition to the degeneracy. In addition, we want to work with +unitless spins. To obtain this, we introduce the base unit for energy $J$, and +with the Boltzmann constant we derive other units necessary. The resulting units +can be found in table \ref{tab:units}. + % Problem 1 \begin{equation}\label{eq:partition_function} @@ -31,42 +93,42 @@ These results are used to test our code during implementation. \end{equation} % \begin{equation}\label{eq:energy_total_first} - \langle E \rangle = \frac{-8 J \sinh(8 \beta J)}{\cosh(8 \beta J) + 3} + \langle E \rangle = -\frac{8J \sinh(8 \beta J)}{\cosh(8 \beta J) + 3} \end{equation} % \begin{equation}\label{eq:energy_total_first_squared} - \langle E \rangle^{2} = \frac{64 J^{2} \sinh(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}} + \langle E \rangle^{2} = \frac{64J^{2} \sinh^{2}(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}} \end{equation} % \begin{equation}\label{eq:energy_total_second} - \langle E^{2} \rangle = \frac{64 J^{2} \cosh(8 \beta J)}{\cosh(8 \beta J) + 3} + \langle E^{2} \rangle = \frac{64J^{2} \cosh(8 \beta J)}{\cosh(8 \beta J) + 3} \end{equation} % \begin{equation}\label{eq:magnetization_total_first} - \langle |M| \rangle = \frac{2 e^{8 \beta J}}{\cosh(8 \beta J) + 3} + \langle |M| \rangle = \frac{2(e^{8 \beta J} + 2)}{\cosh(8 \beta J) + 3} \end{equation} % \begin{equation}\label{eq:magnetization_total_first_squared} - \langle |M| \rangle^{2} = \frac{4e^{16 \beta J} + 16e^{8 \beta J} + 16}{(\cosh(8 \beta J) + 3)^{2}} + \langle |M| \rangle^{2} = \frac{4(e^{8 \beta J} + 2)^{2}}{(\cosh(8 \beta J) + 3)^{2}} \end{equation} % \begin{equation}\label{eq:magnetization_total_second} - \langle M^{2} \rangle = \frac{8e^{8 \beta J} + 8}{\cosh(8 \beta J) + 3} + \langle M^{2} \rangle = frac{8(e^{8 \beta J} + 1)}{\cosh(8 \beta J) + 3} \end{equation} % \begin{equation}\label{eq:specific_heat_capacity} - C_{V} = \frac{64 J^{2}}{N k_{\text{B}} T^{2}} \Big( \frac{3 \cosh(8 \beta J) + \cosh^{2}(8 \beta J) - \sinh^{2}(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}} \Big) + C_{V} = \frac{64J^{2} }{N k_{\text{B}} T^{2}} \frac{(3\cosh(8 \beta J) + 1)}{(\cosh(8 \beta J) + 3)^{2}} \end{equation} % \begin{equation}\label{eq:sesceptibility} - \chi = \frac{1}{N k_{\text{B}} T} \Big( \frac{12e^{8 \beta J} + 4 e^{-8 \beta J} + 12}{(\cosh(8 \beta J) + 3)^{2}} \Big) + \chi = \frac{4}{N k_{\text{B} T}} \frac{(3e^{8 \beta J} + e^{-8 \beta J} + 3)}{(\cosh(8 \beta J) + 3)^{2}} \end{equation} The derivation of analytical expressions can be found in appendix \ref{sec:analytical_expressions}. \subsection{Markov Chain Monte Carlo methods}\label{sec:mcmc_methods} -\subsection{Implementation}\label{sec:implementation} +\subsection{Algorithm and implementation}\label{sec:algo_implementation} \subsection{Tools}\label{sec:tools}