Author: Xihe Han
This program can graph the spin-flipping process of a micro state and calculate the related macroscopic quantities (energy, specific heat, entropy, magnetization, magnetic susceptibility) with plotting capabilities following the metropolis algorithm for the 2-dimensional Ising model problem.
This project requires:
- Functional
C++
compiler that supportC++11
standard. Gnu Make
for using the make file.- Eigen, a BLAS library for
C++
. OpenMP
for parallel computing.gnuplot
for plotting.
# pacman -S eigen
# apt-get install libeigen3-dev
$ brew install eigen
Note: Eigen
is a header file only library.
- Clone the following GitHub repository and
cd
into the source files' location.
$ git clone https://github.com/nobrainmonkey/6810_final && cd 6810_final/src
- Use
Gnu Make
with the makefilemake_main
to build the project.
$ make -f make_main
The project should now be built in the directory 6810_final/bin
.
If you have not downloaded Eigen
from your package manager, it would not be placed in the system default include
directory.
To fix this, either install eigen
from your package manager, or do the following:
- Locate the directory of
eigen
source file - Use the best editor- vim to open
/6810_final/src/make_main
- Edit line 6 , put the absolute directory of the
eigen
source file after=
- Change line 9 to
-I (EIGEN_PATH) FLAGS= -Wall -O3 -fopenmp -std=c++11
- Make the project again.
To run the program, run the following command:
$ ./calculate.x
A CLI interface should prompt you to enter simulation values. Here are some explanation of each option. The user will input the value they want to modify with their corresponding numbered label into the terminal emulator.
This mode returns your a .dat
file containing every macroscopic quantities' calculation.
thread
determines how many physical threads does the program utilize.sample
determines the number of Metropolis algorithm to perform. The final data will be an average over all samples. For good-quality graph, makesample
to be 1000.iterations
determines the number of spin flips for our system to perform in order to reach thermal equilibrium. This value will be suggested automatically to be the size of the micro state * 1000.J
is the spin interaction parameter of the Ising model Hamiltonian.h
is the field interaction parameter of the Ising model Hamiltonian.row
determines the number of rows of our spin system.col
determines the number of columns of our spin system. This does not need to equal torow
.Tmin
determines the minimum temperature in which we start our evaluation. I would highly recommend not to decrease this value as for extremely low temperature, our micro state will tend to a local minimum more often.Tmax
determines the maximum temperature where we end our evaluation.dT
determines the temperature steps starting fromTmin
toTmax
.
After you are satisfied with the values, enter 0
to run the calculation. The data will be stored under /6810_final/data
. A sample data is provided for a 20 x 20 system. under /6810_final/good_data
.
After we each run, a window of gnuplot
should automatically pop up with every graph of the calculated values with their corresponding labels.
Sample plot:
System size = 10 x 10, sample size = 1000, Tmin = 0.5, Tmax= 6, dT=0.1
This mode gives you a terminal based visualization of how a spin system evolve using the metropolis algorithm.
-
Currently, this mode only work on Unix-like system. If you run a NT system, please refer to
/6810_final/src/microstate.cpp
and look for thegraph_evolve
method. I have provided instructions of how to make it work on NT systems. -
To draw the spins correctly, make sure your terminal emulator have
UTF-8
encode support. -
Because different terminal emulators handle
clear
differently, your result may vary depending on your terminal emulator. Note that there could potentially be flashing image for some terminal emulators. If you experience this, setfps
to be around 10 might help.- Known working terminal emulators:
Konsole
Alacritty
(flashing on high frame rate)Kitty
- Known none-working terminal emulators:
gnome-terminal
- Known working terminal emulators:
-
The
row
andcol
variables are inherited from the calculation mode. -
graphing Temperature
determines the temperature where we bring our system to thermal equilibrium. -
graphing time
is the time in second where we graph the evolution of our spin system. -
graphing iteration per frame
determines the number of iteration passed each frame. -
graphing fps
determines how many frames we output on our terminal per second -
start graphing!
enters the graphing mode.
If for some reasons you cannot run this mode, here is what it looks like in real time for a 20 x 20 system:
For performance and error analysis, please refer to /6810_final/docs
.