|
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. | |
| int | get_E () |
| Get the current energy. | |
| int | get_M () |
| Get the current magnetization. | |
Private Member Functions | |
| void | initialize_lattice () |
| Initialize the lattice with a random distribution of 1s and -1s. | |
| void | initialize_neighbors () |
| initialize the neighbors matrix. | |
| void | initialize_energy_diff () |
| Initialize the hashmap with the correct values. | |
| void | initialize_magnetization () |
| Initialize the magnetization. | |
| void | initialize_energy () |
| Initialize the energy. | |
| 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 \). | |
| std::unordered_map< int, double > | energy_diff |
| A hash map containing all possible energy changes. | |
| double | T |
| The temperature of the model. | |
| int | L |
| Size of the lattice. | |
| int | E |
| The current energy state. unit: \( J \). | |
| int | M |
| The current magnetic strength. unit: Unitless. | |
Friends | |
| 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 37 of file IsingModel.hpp.
|
private |
Constructor used for testing.
Definition at line 17 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 21 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 32 of file IsingModel.cpp.
| int IsingModel::get_E | ( | ) |
| int IsingModel::get_M | ( | ) |
|
private |
Initialize the energy.
Definition at line 82 of file IsingModel.cpp.
|
private |
Initialize the hashmap with the correct values.
Definition at line 67 of file IsingModel.cpp.
|
private |
Initialize the lattice with a random distribution of 1s and -1s.
Definition at line 44 of file IsingModel.cpp.
|
private |
Initialize the magnetization.
Definition at line 74 of file IsingModel.cpp.
|
private |
initialize the neighbors matrix.
Definition at line 56 of file IsingModel.cpp.
| data_t IsingModel::Metropolis | ( | ) |
The Metropolis algorithm.
Definition at line 96 of file IsingModel.cpp.
|
friend |
Definition at line 39 of file IsingModel.hpp.
|
private |
The current energy state. unit: \( J \).
Definition at line 68 of file IsingModel.hpp.
|
private |
A hash map containing all possible energy changes.
Definition at line 56 of file IsingModel.hpp.
|
private |
Size of the lattice.
Definition at line 64 of file IsingModel.hpp.
|
private |
\( L \times L \) matrix where element \( x \in {-1, 1}\).
Definition at line 42 of file IsingModel.hpp.
|
private |
The current magnetic strength. unit: Unitless.
Definition at line 72 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 52 of file IsingModel.hpp.
|
private |
The temperature of the model.
Definition at line 60 of file IsingModel.hpp.