\documentstyle[a4wide,12pt]{article}

\begin{document}
\section*{Introduction to numerical projects}


Here follows a brief recipe and recommendation on how to write a report for each
project.
\begin{itemize}
\item Give a short description of the nature of the problem and the eventual 
numerical methods you have used.
\item Describe the algorithm you have used and/or developed. Here you may find it convenient
to use pseudocoding. In many cases you can describe the algorithm
in the program itself.

\item Include the source code of your program. Comment your program properly.
\item If possible, try to find analytic solutions, or known limits
in order to test your program when developing the code.
\item Include your results either in figure form or in a table. Remember to
       label your results. All tables and figures should have relevant captions
       and labels on the axes.
\item Try to evaluate the reliabilty and numerical stability/precision
of your results. If possible, include a qualitative and/or quantitative
discussion of the numerical stability, eventual loss of precision etc. 

\item Try to give an interpretation of you results in your answers to 
the problems.
\item Critique: if possible include your comments and reflections about the 
exercise, whether you felt you learnt something, ideas for improvements and 
other thoughts you've made when solving the exercise.
We wish to keep this course at the interactive level and your comments can help
us improve it.
\item Try to establish a practice where you log your work at the 
computerlab. You may find such a logbook very handy at later stages
in your work, especially when you don't properly remember 
what a previous test version 
of your program did. Here you could also record 
the time spent on solving the exercise, various algorithms you may have tested
or other topics which you feel worthy of mentioning.
\end{itemize}



\section*{Format for electronic delivery of report and programs}
%
The preferred format for the report is a PDF file. You can also
use DOC or postscript formats. 
As programming language we prefer that you choose between C/C++, Fortran or Python.
The following prescription should be followed when preparing the report:
\begin{itemize}
\item Use Fronter to hand in your projects, log in  at 
blyant.uio.no and choose 'fellesrom fys3150'.
Thereafter you will see an icon to the left with 'hand in' or 'innlevering'.
Click on that icon and go to the given project. 
There you can load up the files within the deadline.
\item Upload {\bf only} the report file and the source code file(s) you have developed.
The report file should include all of your discussions and a list of the codes you have developed. 
Do not include library files which are available at the course homepage, unless you have
made specific changes to them.
\item Comments  from us on your projects, approval or not, corrections to be made 
etc can be found under
your Fronter domain and are only visible to you and the teachers of the course.

\end{itemize}
Finally, 
we do prefer that you work two and two together. Optimal working groups consist of 
2-3 students. You can then hand in a common report. 



\section*{Project 5, Ising model in two dimensions, deadline 24  November  12am (midnight)}
For this project you can build upon program programs/chapter10/ising\_2dim.cpp (or the f90 version).

The project deals with the Ising model in two dimensions, without an external magnetic 
field. In its simplest form
the energy is expressed as
\begin{equation}
  E=-J\sum_{<kl>}^{N}s_ks_l
\end{equation}
with  $s_k=\pm 1$, $N$ is the total number of spins and
$J$ is a coupling constant expressing the strength of the interaction
between neighboring spins.
The symbol $<kl>$ indicates that we sum over nearest
neighbors only. We will assume that we have a ferromagnetic ordering, viz $J> 0$.
We will use periodic boundary conditions and the Metropolis algorithm only. 
\begin{enumerate}

\item[a)] Assume we have only two spins in each dimension, that is $L=2$.
Find the analytic expression for the partition function and the corresponding
expectations values for
for $E$, $|{\cal M}|$, the specific heat $C_V$ and the susceptibility $\chi$ 
as functions of  $T$ using periodic boundary conditions.



\item[b)] 
Write now a code for the Ising model which computes the mean energy 
$E$, mean magnetization 
$|{\cal M}|$, the specific heat $C_V$ and the susceptibility $\chi$ 
as functions of  $T$ using periodic boundary conditions for 
$L=2$ in the $x$ and $y$ directions. 
Compare your results with the expressions from a)
for  a  temperature $T=1.0$ (in units of $kT/J$). 

How many Monte Carlo cycles do you need in order to achieve a good agreeement?


\item[c)]
 
We choose now a square lattice with $L=20$ spins in the $x$ and $y$ directions. 

In [b) we did not study carefully how many Monte Carlo cycles were needed in order to reach the most likely state. Here
we want to perform a study of the time (here it corresponds to the number 
of Monte Carlo cycles) one needs before one reaches an equilibrium situation 
and can start computing various expectations values. Our 
first attempt is a rough and plain graphical
one, where we plot various expectations values as functions of the number of Monte Carlo cycles.

Choose first a temperature of $T=1.0$ (in units of $kT/J$) and study the 
mean energy and magnetisation (absolute value) as functions of the number of Monte Carlo cycles.
Use both an ordered (all spins pointing in one direction) and a random
spin orientation as starting configuration. 
How many Monte Carlo cycles do you need before you reach an equilibrium situation?
Repeat this analysis for $T=2.4$. 

Make also a plot of the total number of accepted configurations 
as function of the total number of Monte Carlo cycles. How does the number of
accepted configurations behave as function of temperature $T$?


\item[d)] Compute thereafter the probability 
$P(E)$ for the previous system with $L=20$ and the same temperatures.
You compute this probability by simply counting the number of times a 
given energy appears in your computation. Start the computation after 
the steady state situation has been reached.
Compare your results with the computed variance in energy 
$\sigma^2_E$ and discuss the behavior you observe. 
\end{enumerate}

Near $T_C$ we can characterize the behavior of many physical quantities
by a power law behavior.
As an example the mean magnetization is given by
\begin{equation}
  \langle {\cal M}(T) \rangle \sim \left(T-T_C\right)^{\beta},
\end{equation}
where $\beta=1/8$ is a so-called critical exponent. A similar relation
applies to the heat capacity 
\begin{equation}
  C_V(T) \sim \left|T_C-T\right|^{\alpha},
\end{equation}
and the susceptibility
\begin{equation}
  \chi(T) \sim \left|T_C-T\right|^{\gamma},
\end{equation}
with $\alpha = 0$ and $\gamma = 7/4$.
Another important quantity is the correlation length, which is expected
to be of the order of the lattice spacing for $T>> T_C$. Because the spins
become more and more correlated as $T$ approaches $T_C$, the correlation
length increases as we get closer to the critical temperature. The divergent
behavior of $\xi$ near $T_C$ 
is
\begin{equation}
  \xi(T) \sim \left|T_C-T\right|^{-\nu}.
  \label{eq:xi}
\end{equation}
A second-order phase transition is characterized by a
correlation length which spans the whole system.
Since we are always limited to a finite lattice, $\xi$ will
be proportional with the size of the lattice. 
Through so-called finite size scaling relations
it is possible to relate the behavior at finite lattices with the 
results for an infinitely large lattice.
The critical temperature scales then as
\begin{equation}
 T_C(L)-T_C(L=\infty) \sim aL^{-1/\nu},
 \label{eq:tc}
\end{equation}
with  $a$ a constant and  $\nu$ defined in Eq.~(\ref{eq:xi}).
We set $T=T_C$ and obtain a mean magnetisation
\begin{equation}
  \langle {\cal M}(T) \rangle \sim \left(T-T_C\right)^{\beta}
  \rightarrow L^{-\beta/\nu},
  \label{eq:scale1}
\end{equation}
a heat capacity
\begin{equation}
  C_V(T) \sim \left|T_C-T\right|^{-\gamma} \rightarrow L^{\alpha/\nu},
  \label{eq:scale2}
\end{equation}
and susceptibility
\begin{equation}
  \chi(T) \sim \left|T_C-T\right|^{-\alpha} \rightarrow L^{\gamma/\nu}.
  \label{eq:scale3}
\end{equation}

\begin{enumerate}
\item [e)]  We wish to study the behavior of the Ising model in two dimensions close to the 
critical temperature as a function of the lattice size $L\times L$.
Calculate the expectation values 
for $\langle E\rangle$ and $|\langle {\cal M}\rangle|$,
the specific heat $C_V$ and the susceptibility $\chi$
as functions  of $T$ for $L=20$, $L=40$, $L=60$ and $L=80$ for $T\in [2.0,2.4]$
with a step in temperature $\Delta T=0.05$. 
Plot  $\langle E\rangle$, $\langle {\cal M}\rangle$, $C_V$ and $\chi$ 
as functions of $T$. Can you see an indication of a phase transition?

The code you use here should be streamlined for high performance since 
the calculations may take quite some time. If you have time, you should parallelize the code and run the calculations on the supercomputing cluster titan.uio.no.
\item[f)]  Use Eq.~(\ref{eq:tc}) and the exact result
$\nu=1$ in order to estimate $T_C$ in the thermodynamic limit $L\rightarrow \infty$
using your simulations with $L=20$, $L=40$, $L=60$ and $L=80$
\item[g)]  Now we will use the exact result 
$kT_C/J=2/ln(1+\sqrt{2})\approx 2.269$ and $\nu=1$.
Determine the numerical values of
$C_V$, $\chi$ and ${\cal M}$ at the exact value $T=T_C$
for  $L=20$, $L=40$, $L=60$ and $L=80$.
Plot $log_{10}$ ${\cal M}$
and $\chi$ as function of $log_{10}$  $L$
and use the scaling relations of 
Eqs.~(\ref{eq:scale1}) and (\ref{eq:scale3}) in order to determine the constants
$\beta$ and $\gamma$. 
Are your log-log plots close to straight lines?
The exact values are $\beta=1/8$ and $\gamma=7/4$.
Make also a  log-log plot of 
$C_V$ as function of  $L$.  Do you get a straight line here as well?  
Comment your results.
\end{enumerate}

The rest of the project is  {\bf Optional (frivillig)}.
\begin{enumerate}

\item[h)] 
The analysis in point [c) 
is rather rough and obviously user dependent, in the sense that it is
very much up to the user to define when an equilibrium situation has been reached.
To improve upon this, compute the so-called time autocorrelation function defined here as
\[
\phi(t)  = \frac{1}{t_{\mathrm{max}}-t}\sum_{t'=0}^{t_{\mathrm{max}}-t}{\cal M}(t'){\cal M}(t'+t)
-\frac{1}{t_{\mathrm{max}}-t}\sum_{t'=0}^{t_{\mathrm{max}}-t}{\cal M}(t')\times
\frac{1}{t_{\mathrm{max}}-t}\sum_{t'=0}^{t_{\mathrm{max}}-t}{\cal M}(t'+t)
\]
for the mean magnetisation ${\cal M}(t)$ (absolute value) and plot it for the 
exact critical temperature as function of the number of Monte Carlo steps per site and 
using your simulations with $L=20$, $L=40$, $L=60$ and $L=80$.
The time $t$ corresponds to a given number of Monte Carlo cycles.
Can you extract an equilibration measure?  How does the correlation time behave
as function of lattice size?

\item[i)]  The last result shows that the Metropolis algorithm is inefficient close to the
critical temperature. Repeat the previous analysis 
using the Wolff algorithm instead of the Metropolis algorithm.
Discuss your results.



\end{enumerate}

\section*{Background literature}
If you wish to read more about the Ising model and statistical physics here are two suggestions.
\begin{enumerate}
\item M.~Plischke and B.~Bergersen, Equilibrium Statistical Physics,
Prentice-Hall, see chapters 5 and 6.
\item M.~E.~J.~Newman and T.~Barkema, Monte Carlo methods in statistical physics, Oxford, see chapters 3 and 4.

\end{enumerate}
\end{document}






