4 #include <gsl/gsl_rng.h>
8 #include "latlib/neigh.h"
10 #define EPSILONPHI 0.5
12 class sim : public o815::sim {
29 int updatePhi (const int& x);
33 double SofPhi(const int& x, const complex<double>& phix);
34 double rhoPhi(const int& x, const complex<double>& phixCandidate);
39 sim::sim(o815 *_O815) : o815::sim( _O815,
41 (_O815->comargs.lsize[0]*_O815->comargs.lsize[1]) ) {
42 conf = (siteconf*)confMem;
44 rangsl = gsl_rng_alloc(gsl_rng_ranlxs0);
45 gsl_rng_set(rangsl, time(NULL));
47 LSIZE2 = _O815->comargs.lsize[0] * _O815->comargs.lsize[1];
49 nb = new neigh(2, _O815->comargs.lsize[0], _O815->comargs.lsize[1]);
52 void sim::_makeSweep() {
53 for (int ix = 0; ix < LSIZE2; ix++)
57 void sim::_newParas() {
58 M = pow( (*O815->paraQ)["mass"], 2 ) + 4;
59 *log << "SIM: Resetting fields." << endl << flush;
60 memset(conf, 0, sizeof(siteconf)*LSIZE2);
63 int sim::updatePhi(const int& x) {
64 complex<double> phixCandidate = conf[x].phi +
65 complex<double> ( 2*EPSILONPHI*( 0.5 - gsl_rng_uniform(rangsl) ),
66 2*EPSILONPHI*( 0.5 - gsl_rng_uniform(rangsl) ) );
68 if ( gsl_rng_uniform(rangsl) < rhoPhi(x, phixCandidate) ) {
69 conf[x].phi = phixCandidate;
76 double sim::rhoPhi(const int& x, const complex<double>& phixCandidate) {
77 return exp( SofPhi(x, conf[x].phi) - SofPhi(x, phixCandidate) );
80 double sim::SofPhi(const int& x, const complex<double>& phix) {
81 double sofphi = M * norm(phix);
83 for (int nu=0; nu<4; nu++)
84 sofphi -= 2 * real( conj(phix) * conf[ (*nb)[x*4+nu] ].phi );