#include #include #include #include using namespace std; /* Program for 3-state Potts model modified from Ising model program available * in course webpage (ising_sim.c). Uses heat bath update and measures * energy and magnetization. * *Changed 29.11.2007: Fixed energy measurement. * * */ extern "C" { #include "mersenne.h" }; /* Lattice size, adjust */ #define NX 64 #define NY 64 /* How many iterations for each measurements */ #define N_MEASURE 10 /* spin storage */ static int s[NX][NY]; static double beta; /* Neighbour index arrays, to be filled at the beginning */ static int xup[NX],yup[NY],xdn[NX],ydn[NY]; void update(void); void measure(int iter, FILE *f); int main(int argc, char* argv[]) { int i,x,y,n_loops; long seed; char fname[200]; FILE *f; /* Read in the input */ printf(" Beta (value 0: beta_c = log(1+sqrt(3))) : "); scanf("%lg",&beta); if (beta == 0.0) beta = log(1+sqrt(3.0)); /* critical beta for 2D 3-state Potts model*/ printf(" Number of update sweeps : "); scanf("%d",&n_loops); printf(" Name of measurement file : "); scanf("%s",fname); f = fopen(fname,"w"); /* open output file */ printf(" Random number seed : "); scanf("%ld",&seed); seed_mersenne( seed ); /* "Warm up" the rng generator */ for (i=0; i<543210; i++) mersenne(); printf(" ++++++++++++++++++++++++++++++++++++++++++\n"); printf(" Ising model, %d x %d lattice, beta %g\n",NX,NY,beta); printf(" Heat bath update, %d updates/measurement, %d updates\n", N_MEASURE, n_loops); printf(" Output file %s\n",fname); printf(" Random seed %ld\n", seed ); /* fill up the index array */ for (i=0; i