2
3
4
5
6
7
8
9
10
11
12#ifndef __ISING_MODEL__
13#define __ISING_MODEL__
21#include <unordered_map>
23#define INDEX(I, N) (I + N) % N
32
33
34
35
39
43
47
48
49
50
51
52
53
57
61
65
69
73
77
81
85
86
90
94
98
102
106
110
115
116
117
118
122
123
124
125
126
130
#define UP
Used for the neighbor matrix in the class.
#define INDEX(I, N)
I modulo N.
#define DOWN
Used for the neighbor matrix in the class.
#define LEFT
Used for the neighbor matrix in the class.
#define RIGHT
Used for the neighbor matrix in the class.
Test class for the Ising model.
The Ising model in 2 dimensions.
std::mt19937 engine
The RNG that is used for the Metropolis algorithm.
int64_t E
The current energy state. unit: .
double T
The temperature of the model.
int L
Size of the lattice.
arma::Mat< int > lattice
matrix where element .
void initialize_lattice()
Initialize the lattice with a random distribution of 1s and -1s.
IsingModel(int L, double T, int val)
Constructor for the Ising model.
IsingModel(int L, double T)
Constructor for the Ising model.
data_t Metropolis()
The Metropolis algorithm.
void initialize_energy()
Initialize the energy of the system.
void initialize_neighbors()
initialize the neighbors matrix.
double energy_diff[17]
An array containing all possible energy differences.
void initialize_magnetization()
Initialize the magnetization of the system.
arma::Mat< int > neighbors
matrix with the neighbors of each element .
void initialize_engine()
Initialize the RNG.
void initialize_lattice(int val)
Initialize the lattice with a specific value.
IsingModel()
Constructor used for testing.
int64_t M
The current magnetic strength. unit: Unitless.
void initialize_energy_diff()
Initialize the energy_diff array with the correct values.
Type to use with the IsingModel class and montecarlo module.
data_t(double E, double E2, double M, double M2, double M_abs)
Constructor with parameters.