This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
potts.h
76 lines (60 loc) · 1.74 KB
/
potts.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef POTTS_H
#define POTTS_H
#include <random>
enum UPDATE_ALG { METROPOLIS, WANGLANDAU };
class POTTS_MODEL{
public:
POTTS_MODEL(); // Constructor
~POTTS_MODEL(); // Destructor
bool wanglandau, coldstart;
bool interface = false; // Type of Simulation to run
unsigned int size; // Grid Length
unsigned int n_q; // Number of Possible q states
unsigned int interfacepoint;
unsigned int k;
// Metropolis Algorithm Parameters
double beta;
bool randomspin;
unsigned int n_samples;
// Wang Landau Algorithm Parameters
double a0, target_e, target_width;
unsigned int n_entropic_samples;
unsigned int n_asamples;
// Angles
double *angles;
// Initialisation functions for grid
void metropolis();
void wang_landau();
private:
unsigned int **grid;
unsigned int volume;
unsigned int n_therm = 100000;
unsigned int acceptance = 0;
// Energy and Magnetisation Calculation Functions
double energycalc();
double magnetisationcalc();
double energychange(unsigned int, unsigned int);
// Update Algorithms
void metropolis_update();
void smooth_metropolis_update(unsigned int, unsigned int);
int outsideenergyband();
void wanglandau_update();
void smooth_wanglandau_update(unsigned int, unsigned int);
void drivetotarget(unsigned int, unsigned int);
// Measurement for Update
void metropolis_measurement(unsigned int);
void wanglandau_measurement(unsigned int);
std::mt19937_64 generator;
// Measurement arrays
double *energy;
double *magnetisation;
double *estar;
double *aguess;
double cur_a;
// Analysis
double metropolis_average(double *);
double metropolis_error(double *, double);
double wanglandau_average(double *);
double wanglandau_error(double *, double);
};
#endif