|
2 Dimensional Ising Model
Simulate the change in energy and magnetization in a ferro magnet
|
The Ising model in 2 dimensions. More...
#include <IsingModel.hpp>
Public Member Functions | |
| IsingModel (int L, double T) | |
| Constructor for the Ising model. | |
| IsingModel (int L, double T, int val) | |
| Constructor for the Ising model. | |
| data_t | Metropolis () |
| The Metropolis algorithm. | |
Private Member Functions | |
| void | initialize_engine () |
| Initialize the RNG. | |
| void | initialize_lattice () |
| Initialize the lattice with a random distribution of 1s and -1s. | |
| void | initialize_lattice (int val) |
| Initialize the lattice with a specific value. | |
| void | initialize_neighbors () |
| initialize the neighbors matrix. | |
| void | initialize_energy_diff () |
| Initialize the energy_diff array with the correct values. | |
| void | initialize_magnetization () |
| Initialize the magnetization of the system. | |
| void | initialize_energy () |
| Initialize the energy of the system. | |
| IsingModel () | |
| Constructor used for testing. | |
Private Attributes | |
| arma::Mat< int > | lattice |
| \( L \times L \) matrix where element \( x \in {-1, 1}\). | |
| arma::Mat< int > | neighbors |
| \( L \times 2 \) matrix with the neighbors of each element \( x_i \). | |
| double | energy_diff [17] |
| An array containing all possible energy differences. | |
| double | T |
| The temperature of the model. | |
| int | L |
| Size of the lattice. | |
| int64_t | E |
| The current energy state. unit: \( J \). | |
| int64_t | M |
| The current magnetic strength. unit: Unitless. | |
| std::mt19937 | engine |
| The RNG that is used for the Metropolis algorithm. | |
Friends | |
| class | IsingModelTest |
| Give access to private members to the test class IsingModelTest. | |
The Ising model in 2 dimensions.
None of the methods are parallelized, as there is very little benefit in doing so.
Definition at line 36 of file IsingModel.hpp.
|
private |
Constructor used for testing.
Definition at line 14 of file IsingModel.cpp.
| IsingModel::IsingModel | ( | int | L, |
| double | T | ||
| ) |
Constructor for the Ising model.
| L | The size of the lattice. |
| T | The temperature for the system. |
Definition at line 19 of file IsingModel.cpp.
| IsingModel::IsingModel | ( | int | L, |
| double | T, | ||
| int | val | ||
| ) |
Constructor for the Ising model.
| L | The size of the lattice. |
| T | The temperature for the system. |
| val | The value to set for all spins. |
Definition at line 31 of file IsingModel.cpp.
|
private |
Initialize the energy of the system.
Definition at line 96 of file IsingModel.cpp.
|
private |
Initialize the energy_diff array with the correct values.
Definition at line 81 of file IsingModel.cpp.
|
private |
Initialize the RNG.
Definition at line 43 of file IsingModel.cpp.
|
private |
Initialize the lattice with a random distribution of 1s and -1s.
Definition at line 49 of file IsingModel.cpp.
|
private |
Initialize the lattice with a specific value.
Definition at line 59 of file IsingModel.cpp.
|
private |
Initialize the magnetization of the system.
Definition at line 88 of file IsingModel.cpp.
|
private |
initialize the neighbors matrix.
Definition at line 70 of file IsingModel.cpp.
| data_t IsingModel::Metropolis | ( | ) |
The Metropolis algorithm.
Definition at line 110 of file IsingModel.cpp.
|
friend |
Give access to private members to the test class IsingModelTest.
Definition at line 40 of file IsingModel.hpp.
|
private |
The current energy state. unit: \( J \).
Definition at line 70 of file IsingModel.hpp.
|
private |
An array containing all possible energy differences.
Definition at line 58 of file IsingModel.hpp.
|
private |
The RNG that is used for the Metropolis algorithm.
Definition at line 78 of file IsingModel.hpp.
|
private |
Size of the lattice.
Definition at line 66 of file IsingModel.hpp.
|
private |
\( L \times L \) matrix where element \( x \in {-1, 1}\).
Definition at line 44 of file IsingModel.hpp.
|
private |
The current magnetic strength. unit: Unitless.
Definition at line 74 of file IsingModel.hpp.
|
private |
\( L \times 2 \) matrix with the neighbors of each element \( x_i \).
The reason why it's \( L \times 2 \) instead of \( L \times 2 \), is that we can see that we can use the same column for the left and upper neighbor, and we can use the same column for the right and lower neighbor.
Definition at line 54 of file IsingModel.hpp.
|
private |
The temperature of the model.
Definition at line 62 of file IsingModel.hpp.