2 Dimensional Ising Model
Simulate the change in energy and magnetization in a ferro magnet
Loading...
Searching...
No Matches
IsingModel.hpp
Go to the documentation of this file.
1
12#ifndef __ISING_MODEL__
13#define __ISING_MODEL__
14
15#include "data_type.hpp"
16#include "utils.hpp"
17
18#include <armadillo>
19#include <cstdint>
20#include <random>
21#include <unordered_map>
22
23#define INDEX(I, N) (I + N) % N
24
25// Indeces for the neighbor matrix.
26#define UP 0
27#define LEFT 0
28#define DOWN 1
29#define RIGHT 1
30
37private:
40 friend class IsingModelTest;
41
44 arma::Mat<int> lattice;
45
54 arma::Mat<int> neighbors;
55
58 double energy_diff[17];
59
62 double T;
63
66 int L;
67
70 int64_t E;
71
74 int64_t M;
75
78 std::mt19937 engine;
79
82 void initialize_engine();
83
87 void initialize_lattice();
88
91 void initialize_lattice(int val);
92
96
100
104
107 void initialize_energy();
108
111 IsingModel();
112
113public:
119 IsingModel(int L, double T);
120
127 IsingModel(int L, double T, int val);
128
132};
133
134#endif
Test class for the Ising model.
Definition: test_suite.cpp:36
The Ising model in 2 dimensions.
Definition: IsingModel.hpp:36
std::mt19937 engine
The RNG that is used for the Metropolis algorithm.
Definition: IsingModel.hpp:78
int64_t E
The current energy state. unit: .
Definition: IsingModel.hpp:70
double T
The temperature of the model.
Definition: IsingModel.hpp:62
int L
Size of the lattice.
Definition: IsingModel.hpp:66
arma::Mat< int > lattice
matrix where element .
Definition: IsingModel.hpp:44
void initialize_lattice()
Initialize the lattice with a random distribution of 1s and -1s.
Definition: IsingModel.cpp:49
data_t Metropolis()
The Metropolis algorithm.
Definition: IsingModel.cpp:110
void initialize_energy()
Initialize the energy of the system.
Definition: IsingModel.cpp:96
void initialize_neighbors()
initialize the neighbors matrix.
Definition: IsingModel.cpp:70
double energy_diff[17]
An array containing all possible energy differences.
Definition: IsingModel.hpp:58
void initialize_magnetization()
Initialize the magnetization of the system.
Definition: IsingModel.cpp:88
arma::Mat< int > neighbors
matrix with the neighbors of each element .
Definition: IsingModel.hpp:54
void initialize_engine()
Initialize the RNG.
Definition: IsingModel.cpp:43
IsingModel()
Constructor used for testing.
Definition: IsingModel.cpp:14
int64_t M
The current magnetic strength. unit: Unitless.
Definition: IsingModel.hpp:74
void initialize_energy_diff()
Initialize the energy_diff array with the correct values.
Definition: IsingModel.cpp:81
Type to use with the IsingModel class and montecarlo module.
Definition: data_type.hpp:19
Header for the data_t type.
Function prototypes and macros that are useful.