4 #include <gsl/gsl_rng.h>
8 #include "latlib/neigh.h"
10 class sim : public o815::sim {
26 void updatePhi (const int& x);
27 static double magnYOfR (const double& r);
30 double sim::magnYOfR (const double& r)
32 return sqrt( -std::log(1-r) );
35 sim::sim(o815 *_O815) : o815::sim( _O815,
37 (_O815->comargs.lsize[0]*_O815->comargs.lsize[1]) ) {
38 conf = (siteconf*)confMem;
40 rangsl = gsl_rng_alloc(gsl_rng_ranlxs0);
41 gsl_rng_set(rangsl, time(NULL));
43 LSIZE2 = _O815->comargs.lsize[0] * _O815->comargs.lsize[1];
45 nb = new neigh(2, _O815->comargs.lsize[0], _O815->comargs.lsize[1]);
48 void sim::updatePhi (const int& x)
53 for (int nu=0; nu<4; nu++)
54 V += conf[ (*nb)[x*4+nu] ].phi;
56 #if defined(ALGORITHM_AHBMHB) || defined(ALGORITHM_AHBMOR)
57 Y = polar( abs(Y), gsl_rng_uniform(rangsl) * 2*M_PI );
58 #elif defined(ALGORITHM_AORMHB) || defined(ALGORITHM_AORMOR)
59 const double V2diff = pow(real(V), 2) - pow(imag(V), 2);
60 const double Vprod = real(V)*imag(V);
61 Y = complex<double> ( + real(Y) * V2diff + 2 * imag(Y) * Vprod,
62 - imag(Y) * V2diff + 2 * real(Y) * Vprod ) / norm(V);
65 #if defined(ALGORITHM_AHBMHB) || defined(ALGORITHM_AORMHB)
66 Y = polar( magnYOfR( gsl_rng_uniform(rangsl) ), arg(Y) );
67 #elif defined(ALGORITHM_AHBMOR) || defined(ALGORITHM_AORMOR)
68 Y = polar( magnYOfR( 1 - exp(-norm(Y)) ), arg(Y) ); //!!!!
72 void sim::_makeSweep() {
73 for (int ichecker=0; ichecker<2; ichecker++)
74 for (int it=0; it<O815->comargs.lsize[0]; it++)
75 for (int iy=(it+ichecker)%2; iy<O815->comargs.lsize[1]; iy+=2)
76 updatePhi( it*O815->comargs.lsize[1] + iy );
79 void sim::_newParas() {
80 m = (*O815->paraQ)["mass"];
81 M = pow( (*O815->paraQ)["mass"], 2 ) + 4;
82 *log << "SIM: Resetting fields." << endl << flush;
84 for (int ix=0; ix<LSIZE2; ix++)