2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
28
29
30
31
32
33
34
37 std::cout << __FILE__ << " " << __LINE__ << ": " << msg << std::endl
43
44
45#define __METHOD_NAME__ details::methodName(__PRETTY_FUNCTION__)
49
50
51
52
53
54
55
56
57
58inline std::string
methodName(
const std::string &pretty_function)
60 size_t colons = pretty_function.find(
"::");
61 size_t begin = pretty_function.substr(0, colons).rfind(
" ") + 1;
62 size_t end = pretty_function.rfind(
"(") - begin;
64 return pretty_function.substr(begin, end) +
"()";
72
73
74
75
76
77
78
79
80
84
85
86
87
88
89
90
91
92
93
98
99
100
101
102
103
104
105
106
107bool mkpath(std::string path,
int mode = 0777);
110
111
112
113
114
115std::string
dirname(
const std::string &path);
118
119
120
121
122
123
124
125
126
127
128
129
130std::string
concatpath(
const std::string &left,
const std::string &right);
#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.
std::string methodName(const std::string &pretty_function)
Takes in the PRETTY_FUNCTION string and removes the return type.
bool mkpath(std::string path, int mode=0777)
Make path given.
std::string scientific_format(double d, int width=20, int prec=10)
Turns a double into a string written in scientific format.
std::string scientific_format(const std::vector< double > &v, int width=20, int prec=10)
Turns a vector of doubles into a string written in scientific format.
std::string concatpath(const std::string &left, const std::string &right)
Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.
std::string dirname(const std::string &path)
Get the directory name of the path.