Loading...
Searching...
No Matches
IsingModel Class Reference

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

## Detailed Description

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.

## Constructor & Destructor Documentation

## IsingModel() [1/3]

IsingModel::IsingModel | ( |  | ) |

private

Constructor used for testing.

Definition at line 17 of file IsingModel.cpp.

## IsingModel() [2/3]

IsingModel::IsingModel | ( | int | L,
|  | double | T
| ) |  |

Constructor for the Ising model.

Parameters

  L | The size of the lattice.
  T | The temperature for the system.

Definition at line 21 of file IsingModel.cpp.

## IsingModel() [3/3]

IsingModel::IsingModel | ( | int | L,
|  | double | T,
|  | int | val
| ) |  |

Constructor for the Ising model.

Parameters

  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.

## Member Function Documentation

## get_E()

int IsingModel::get_E | ( |  | ) |

Get the current energy.

Returns
  double

Definition at line 135 of file IsingModel.cpp.

## get_M()

int IsingModel::get_M | ( |  | ) |

Get the current magnetization.

Returns
  double

Definition at line 140 of file IsingModel.cpp.

## initialize_energy()

void IsingModel::initialize_energy | ( |  | ) |

private

Initialize the energy.

Definition at line 82 of file IsingModel.cpp.

## initialize_energy_diff()

void IsingModel::initialize_energy_diff | ( |  | ) |

private

Initialize the hashmap with the correct values.

Definition at line 67 of file IsingModel.cpp.

## initialize_lattice()

void IsingModel::initialize_lattice | ( |  | ) |

private

Initialize the lattice with a random distribution of 1s and -1s.

Definition at line 44 of file IsingModel.cpp.

## initialize_magnetization()

void IsingModel::initialize_magnetization | ( |  | ) |

private

Initialize the magnetization.

Definition at line 74 of file IsingModel.cpp.

## initialize_neighbors()

void IsingModel::initialize_neighbors | ( |  | ) |

private

initialize the neighbors matrix.

Definition at line 56 of file IsingModel.cpp.

## Metropolis()

data_t IsingModel::Metropolis | ( |  | ) |

The Metropolis algorithm.

Definition at line 96 of file IsingModel.cpp.

## Friends And Related Function Documentation

## IsingModelTest

friend class IsingModelTest

friend

Definition at line 39 of file IsingModel.hpp.

## Member Data Documentation

## E

int IsingModel::E

private

The current energy state. unit: \( J \).

Definition at line 68 of file IsingModel.hpp.

## energy_diff

std::unordered_map<int, double> IsingModel::energy_diff

private

A hash map containing all possible energy changes.

Definition at line 56 of file IsingModel.hpp.

## L

int IsingModel::L

private

Size of the lattice.

Definition at line 64 of file IsingModel.hpp.

## lattice

arma::Mat<int> IsingModel::lattice

private

\( L \times L \) matrix where element \( x \in {-1, 1}\).

Definition at line 42 of file IsingModel.hpp.

## M

int IsingModel::M

private

The current magnetic strength. unit: Unitless.

Definition at line 72 of file IsingModel.hpp.

## neighbors

arma::Mat<int> IsingModel::neighbors

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.

## T

double IsingModel::T

private

The temperature of the model.

Definition at line 60 of file IsingModel.hpp.

The documentation for this class was generated from the following files:

- include/IsingModel.hpp
- src/IsingModel.cpp