This commit is contained in:
Cory Balaton 2023-10-31 20:12:30 +01:00
commit d19ca073a0
No known key found for this signature in database
GPG key ID: 3E5FCEBFD80F432B
2 changed files with 58 additions and 7 deletions

View file

@ -27,10 +27,11 @@
#define DOWN 1
#define RIGHT 1
/** @brief The Ising model in 2 dimensions.
*
* @details Here we set \f$ J = 1 \f$, and the Boltzmann constant
* \f$ k_B = 1 \f$.
* @details None of the methods are parallelized, as there is very little
* benefit in doing so.
* */
class IsingModel {
private:
@ -39,16 +40,26 @@ private:
* */
arma::Mat<int> lattice;
/** @brief \f$ L \cross 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
* for the left and upper neighbor, and we can use the same column for the
* right and lower neighbor.
* */
arma::Mat<uint> neighbors;
/** @brief A hash map containing all possible energy changes.
* */
std::unordered_map<int, double> energy_diff;
/** @brief Temperature
/** @brief The temperature of the model.
* */
double T;
/** @brief Size of the lattice.
* */
uint L;
/** @brief The current energy state. unit: \f$ J \f$.
@ -72,32 +83,57 @@ private:
* */
void initialize_lattice();
/** @brief initialize the neighbors matrix.
* */
void initialize_neighbors();
/** @brief Initialize the hashmap with the correct values.
* */
void initialize_energy_diff();
/** @brief Initialize the model.
/** @brief Initialize the magnetization.
* */
void initialize_magnetization();
/** @brief Initialize the energy.
* */
void initialize_energy();
/** @brief Constructor used for testing.
* */
IsingModel();
public:
/** @brief Constructor for the Ising model.
*
* @param L The size of the lattice.
* @param T The temperature for the system.
* */
IsingModel(uint L, double T);
/** @brief Constructor for the Ising model.
*
* @param L The size of the lattice.
* @param T The temperature for the system.
* @param val The value to set for all spins.
* */
IsingModel(uint L, double T, int val);
/** @brief The Metropolis algorithm.
* */
void Metropolis(std::mt19937 engine);
/** @brief Get the current energy.
*
* @return int
* */
int get_E();
/** @brief Get the current magnetization.
*
* @return int
* */
int get_M();
};
#endif