Update code

This commit is contained in:
2023-11-21 11:24:34 +01:00
parent 816e38e9e4
commit f07fb8829b
12 changed files with 522 additions and 343 deletions

View File

@@ -21,7 +21,6 @@
#include <random>
#include <unordered_map>
// Faster modulo
#define INDEX(I, N) (I + N) % N
// Indeces for the neighbor matrix.
@@ -50,7 +49,7 @@ private:
* for the left and upper neighbor, and we can use the same column for the
* right and lower neighbor.
* */
arma::Mat<uint> neighbors;
arma::Mat<int> neighbors;
/** @brief A hash map containing all possible energy changes.
* */
@@ -62,15 +61,15 @@ private:
/** @brief Size of the lattice.
* */
uint L;
int L;
/** @brief The current energy state. unit: \f$ J \f$.
* */
double E;
int E;
/** @brief The current magnetic strength. unit: Unitless.
* */
double M;
int M;
/** @brief Initialize the lattice with a random distribution of 1s and
* -1s.
@@ -103,7 +102,7 @@ public:
* @param L The size of the lattice.
* @param T The temperature for the system.
* */
IsingModel(uint L, double T);
IsingModel(int L, double T);
/** @brief Constructor for the Ising model.
*
@@ -111,23 +110,23 @@ public:
* @param T The temperature for the system.
* @param val The value to set for all spins.
* */
IsingModel(uint L, double T, int val);
IsingModel(int L, double T, int val);
/** @brief The Metropolis algorithm.
* */
data_t Metropolis(std::mt19937 &engine);
data_t Metropolis();
/** @brief Get the current energy.
*
* @return double
* */
double get_E();
int get_E();
/** @brief Get the current magnetization.
*
* @return double
* */
double get_M();
int get_M();
};
#endif