-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lattice.hh
67 lines (52 loc) · 2.02 KB
/
Lattice.hh
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
// -----------------------------------------------------------------
// Lattice for phi^4 simulations using mu action
#ifndef _LATTICE_HH
#define _LATTICE_HH
#include "HashTable.hh" // Hash table for searching cluster
#include <vector> // Lattice is vector of vectors
#include <gsl/gsl_rng.h> // Random number generators
#include <gsl/gsl_sf_exp.h> // Exponential functions
// A simple struct to hold a site's neighbors
struct siteNeighbors {
unsigned int prevX;
unsigned int nextX;
unsigned int prevY;
unsigned int nextY;
};
// -----------------------------------------------------------------
// -----------------------------------------------------------------
// Class definition
class Lattice {
public:
// Member data
std::vector<double> lattice; // Continuous values
unsigned int length; // Lattice length (square)
unsigned int latticeSize; // Number of sites in lattice
double muSquared; // Bare mass-squared
double lambda; // Bare coupling
// Neighboring lattice sites
std::vector<siteNeighbors*> neighbors;
HashTable *cluster;
gsl_rng *generator;
// Constructors, destructor
Lattice(double m, double l, unsigned int length);
Lattice();
~Lattice();
// Set up periodic boundary conditions
void getNeighbors(unsigned int site, siteNeighbors* toInit);
// Calculation methods
double calcTotalEnergy();
double calcAveragePhi();
void calcCorrelations(double spatialCorr[], double momCorr[],
double phibar);
// Metropolis and Wolff algorithms
void metropolis(unsigned int site);
bool clusterCheck(unsigned int site, unsigned int toAdd);
// Inelegant but faster
void growClusterPos(unsigned int site);
void growClusterNeg(unsigned int site);
void flipCluster();
unsigned int wolff(unsigned int site); // Returns cluster size
};
#endif
// -----------------------------------------------------------------