X-Git-Url: http://git.treefish.org/~alex/phys/heatbath.git/blobdiff_plain/7a2a209a8e67d342eb4faa2fa203a94fb68d5e6c..4b4dcf9a4b5a913c1574a9cc1aa479f1aa35a003:/sim-nor.hpp diff --git a/sim-nor.hpp b/sim-nor.hpp index aa305ff..b67f8a7 100644 --- a/sim-nor.hpp +++ b/sim-nor.hpp @@ -7,6 +7,8 @@ #include "latlib/neigh.h" +#define EPSILONPHI 0.5 + class sim : public o815::sim { public: struct siteconf { @@ -15,16 +17,17 @@ public: sim(o815 *_O815); siteconf* conf; unsigned int LSIZE2; + double M; + double m; + neigh *nb; private: void _makeSweep(); void _newParas(); - gsl_rng* rangsl; - - neigh *nb; - - void updatePhi (const int& x); + int updatePhi (const int& x); + double SofPhi(const int& x, const complex& phix); + double rhoPhi(const int& x, const complex& phixCandidate); }; @@ -42,17 +45,46 @@ sim::sim(o815 *_O815) : o815::sim( _O815, nb = new neigh(2, _O815->comargs.lsize[0], _O815->comargs.lsize[1]); } -void sim::updatePhi (const int& x) -{ - const double r = gsl_rng_uniform(rangsl); - const double theta = gsl_rng_uniform(rangsl) * 2*M_PI; -} - void sim::_makeSweep() { + for (int ichecker=0; ichecker<2; ichecker++) + for (int it=0; itcomargs.lsize[0]; it++) + for (int iy=(it+ichecker)%2; iycomargs.lsize[1]; iy+=2) + updatePhi( it*O815->comargs.lsize[1] + iy ); } void sim::_newParas() { - /* reset variables */ + m = (*O815->paraQ)["mass"]; + M = pow( (*O815->paraQ)["mass"], 2 ) + 4; + *log << "SIM: Resetting fields." << endl << flush; + + for (int ix=0; ix phixCandidate = conf[x].phi + + complex ( 2*EPSILONPHI*( 0.5 - gsl_rng_uniform(rangsl) ), + 2*EPSILONPHI*( 0.5 - gsl_rng_uniform(rangsl) ) ); + + if ( gsl_rng_uniform(rangsl) < rhoPhi(x, phixCandidate) ) { + conf[x].phi = phixCandidate; + return 1; + } + + return 0; +} + +double sim::rhoPhi(const int& x, const complex& phixCandidate) { + return exp( SofPhi(x, conf[x].phi) - SofPhi(x, phixCandidate) ); +} + +double sim::SofPhi(const int& x, const complex& phix) { + double sofphi = M * norm(phix); + + for (int nu=0; nu<4; nu++) + sofphi -= 2 * real( conj(phix) * conf[ (*nb)[x*4+nu] ].phi ); + + return sofphi; } #endif