Implementations of different problems

This commit is contained in:
2023-11-08 17:31:14 +01:00
parent 5ac838a266
commit 090510175b
13 changed files with 704 additions and 98 deletions

View File

@@ -12,7 +12,10 @@
#ifndef __ISING_MODEL__
#define __ISING_MODEL__
#include "constants.hpp"
#include "data_type.hpp"
#include "typedefs.hpp"
#include "utils.hpp"
#include <armadillo>
#include <random>
@@ -27,7 +30,6 @@
#define DOWN 1
#define RIGHT 1
/** @brief The Ising model in 2 dimensions.
*
* @details None of the methods are parallelized, as there is very little
@@ -36,15 +38,15 @@
class IsingModel {
private:
friend class IsingModelTest;
/** @brief \f$ L \cross L \f$ matrix where element $ x \in {-1, 1}$.
/** @brief \f$ L \times L \f$ matrix where element \f$ x \in {-1, 1}\f$.
* */
arma::Mat<int> lattice;
/** @brief \f$ L \cross 2 \f$ matrix with the neighbors of each element
/** @brief \f$ L \times 2 \f$ matrix with the neighbors of each element
* \f$ x_i \f$.
*
* @details The reason why it's \f$ L \cross 2 \f$ instead of
* \f$ L \cross 2 \f$, is that we can see that we can use the same column
* @details The reason why it's \f$ L \times 2 \f$ instead of
* \f$ L \times 2 \f$, 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.
* */
@@ -64,19 +66,11 @@ private:
/** @brief The current energy state. unit: \f$ J \f$.
* */
int E;
double E;
/** @brief The current magnetic strength. unit: Unitless.
* */
int M;
/** @brief Energy per spin. unit: \f$ J \f$.
* */
double eps;
/** @brief Magnetization per spin. unit: Unitless.
* */
double m;
double M;
/** @brief Initialize the lattice with a random distribution of 1s and
* -1s.
@@ -121,19 +115,19 @@ public:
/** @brief The Metropolis algorithm.
* */
void Metropolis(std::mt19937 engine);
data_t Metropolis(std::mt19937 &engine);
/** @brief Get the current energy.
*
* @return int
* @return double
* */
int get_E();
double get_E();
/** @brief Get the current magnetization.
*
* @return int
* @return double
* */
int get_M();
double get_M();
};
#endif