4 #include <gsl/gsl_rng.h>
8 #include "latlib/neigh.h"
10 #define EPSILONPHI 0.5
12 class sim : public o815::sim {
26 int updatePhi (const int& x);
28 double SofPhi(const int& x, const complex<double>& phix);
29 double rhoPhi(const int& x, const complex<double>& phixCandidate);
34 sim::sim(o815 *_O815) : o815::sim( _O815,
36 (_O815->comargs.lsize[0]*_O815->comargs.lsize[1]) ) {
37 conf = (siteconf*)confMem;
39 rangsl = gsl_rng_alloc(gsl_rng_ranlxs0);
40 gsl_rng_set(rangsl, time(NULL));
42 LSIZE2 = _O815->comargs.lsize[0] * _O815->comargs.lsize[1];
44 nb = new neigh(2, _O815->comargs.lsize[0], _O815->comargs.lsize[1]);
47 void sim::_makeSweep() {
48 for (int ix = 0; ix < LSIZE2; ix++)
52 void sim::_newParas() {
53 M = pow( (*O815->paraQ)["mass"], 2 ) + 4;
54 *log << "SIM: Resetting fields." << endl << flush;
55 memset(conf, 0, sizeof(siteconf)*LSIZE2);
58 int sim::updatePhi(const int& x) {
59 complex<double> phixCandidate = conf[x].phi +
60 complex<double> ( 2*EPSILONPHI*( 0.5 - gsl_rng_uniform(rangsl) ),
61 2*EPSILONPHI*( 0.5 - gsl_rng_uniform(rangsl) ) );
63 if ( gsl_rng_uniform(rangsl) < rhoPhi(x, phixCandidate) ) {
64 conf[x].phi = phixCandidate;
71 double sim::rhoPhi(const int& x, const complex<double>& phixCandidate) {
72 return exp( SofPhi(x, conf[x].phi) - SofPhi(x, phixCandidate) );
75 double sim::SofPhi(const int& x, const complex<double>& phix) {
76 double sofphi = M * norm(phix);
78 for (int nu=0; nu<4; nu++)
79 sofphi -= 2 * real( conj(phix) * conf[ (*nb)[x*4+nu] ].phi );