4 #include <gsl/gsl_rng.h>
8 #include "latlib/neigh.h"
10 class sim : public o815::sim {
26 void updatePhi (const int& x);
27 void updatePhi_angle_relax (const int& x, const complex<double>& V);
28 void updatePhi_angle_rand (const int& x, const complex<double>& V);
29 void updatePhi_r (const int& x, const complex<double>& V);
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::updatePhi_r (const int& x, const complex<double>& V)
49 const double r = exp( - M * norm(conf[x].phi)
51 + 2 * real( conf[x].phi * conj(V) ) );
53 conf[x].phi = sqrt(std::log( 1./(1-r) )) / sqrt(M)
54 * polar( 1.0, arg(conf[x].phi) )
58 void sim::updatePhi_angle_relax (const int& x, const complex<double>& V)
60 const double V2diff = pow(real(V), 2) - pow(imag(V), 2);
61 const double Vprod = real(V)*imag(V);
62 conf[x].phi = complex<double> ( + real(conf[x].phi) * V2diff + 2 * imag(conf[x].phi) * Vprod,
63 - imag(conf[x].phi) * V2diff + 2 * real(conf[x].phi) * Vprod ) / norm(V);
66 void sim::updatePhi_angle_rand (const int& x, const complex<double>& V)
68 conf[x].phi = polar( abs(conf[x].phi), gsl_rng_uniform(rangsl) * 2*M_PI );
71 void sim::updatePhi (const int& x)
75 for (int nu=0; nu<4; nu++)
76 V += conf[ (*nb)[x*4+nu] ].phi;
80 if ( gsl_rng_uniform(rangsl) < 0.5 )
81 updatePhi_angle_relax(x,V);
83 updatePhi_angle_rand(x,V);
86 void sim::_makeSweep() {
87 for (int ichecker=0; ichecker<2; ichecker++)
88 for (int it=0; it<O815->comargs.lsize[0]; it++)
89 for (int iy=(it+ichecker)%2; iy<O815->comargs.lsize[1]; iy+=2)
90 updatePhi( it*O815->comargs.lsize[1] + iy );
93 void sim::_newParas() {
94 m = (*O815->paraQ)["mass"];
95 M = pow( (*O815->paraQ)["mass"], 2 ) + 4;
96 *log << "SIM: Resetting fields." << endl << flush;
98 for (int ix=0; ix<LSIZE2; ix++)