Loading...
Searching...
No Matches
IsingModel.hpp
Go to the documentation of this file.
#ifndef __ISING_MODEL__
#define __ISING_MODEL__
#include "constants.hpp"
#include "data_type.hpp"
#include "typedefs.hpp"
#include "utils.hpp"
#include <armadillo>
#include <random>
#include <unordered_map>
#define INDEX(I, N) (I + N) % N
// Indeces for the neighbor matrix.
#define UP 0
#define LEFT 0
#define DOWN 1
#define RIGHT 1
class IsingModel {
private:
friend class IsingModelTest;
arma::Mat<int> lattice;
arma::Mat<int> neighbors;
std::unordered_map<int, double> energy_diff;
double T;
int L;
int E;
int M;
void initialize_lattice();
void initialize_neighbors();
void initialize_energy_diff();
void initialize_magnetization();
void initialize_energy();
IsingModel();
public:
IsingModel(int L, double T);
IsingModel(int L, double T, int val);
data_t Metropolis();
int get_E();
int get_M();
};
#endif
IsingModelTest
Test class for the Ising model.
Definition: test_suite.cpp:30
IsingModel
The Ising model in 2 dimensions.
Definition: IsingModel.hpp:37
IsingModel::M
int M
The current magnetic strength. unit: Unitless.
Definition: IsingModel.hpp:72
IsingModel::energy_diff
std::unordered_map< int, double > energy_diff
A hash map containing all possible energy changes.
Definition: IsingModel.hpp:56
IsingModel::T
double T
The temperature of the model.
Definition: IsingModel.hpp:60
IsingModel::L
int L
Size of the lattice.
Definition: IsingModel.hpp:64
IsingModel::lattice
arma::Mat< int > lattice
matrix where element .
Definition: IsingModel.hpp:42
IsingModel::initialize_lattice
void initialize_lattice()
Initialize the lattice with a random distribution of 1s and -1s.
Definition: IsingModel.cpp:44
IsingModel::Metropolis
data_t Metropolis()
The Metropolis algorithm.
Definition: IsingModel.cpp:96
IsingModel::initialize_energy
void initialize_energy()
Initialize the energy.
Definition: IsingModel.cpp:82
IsingModel::initialize_neighbors
void initialize_neighbors()
initialize the neighbors matrix.
Definition: IsingModel.cpp:56
IsingModel::initialize_magnetization
void initialize_magnetization()
Initialize the magnetization.
Definition: IsingModel.cpp:74
IsingModel::neighbors
arma::Mat< int > neighbors
matrix with the neighbors of each element .
Definition: IsingModel.hpp:52
IsingModel::get_M
int get_M()
Get the current magnetization.
Definition: IsingModel.cpp:140
IsingModel::get_E
int get_E()
Get the current energy.
Definition: IsingModel.cpp:135
IsingModel::IsingModel
IsingModel()
Constructor used for testing.
Definition: IsingModel.cpp:17
IsingModel::E
int E
The current energy state. unit: .
Definition: IsingModel.hpp:68
IsingModel::initialize_energy_diff
void initialize_energy_diff()
Initialize the hashmap with the correct values.
Definition: IsingModel.cpp:67
data_t
Definition: data_type.hpp:18
constants.hpp
Library of constants.
data_type.hpp
Header for the data_t type.
typedefs.hpp
Useful typedefs for cleaner code.
utils.hpp
Function prototypes and macros that are useful.