heatbath-1mr
heatbath-r
heatbath-1mr+
+heatbath-1mr-
+heatbath-r-
add_executable(heatbath-1mr+ heatbath.cpp)
set_target_properties(heatbath-1mr+ PROPERTIES COMPILE_DEFINITIONS "ALGORITHM_1MRPLUS")
target_link_libraries(heatbath-1mr+ o815 gsl gslcblas lat_neigh)
+
+add_executable(heatbath-1mr- heatbath.cpp)
+set_target_properties(heatbath-1mr- PROPERTIES COMPILE_DEFINITIONS "ALGORITHM_1MRMINUS")
+target_link_libraries(heatbath-1mr- o815 gsl gslcblas lat_neigh)
+
+add_executable(heatbath-r- heatbath.cpp)
+set_target_properties(heatbath-r- PROPERTIES COMPILE_DEFINITIONS "ALGORITHM_RMINUS")
+target_link_libraries(heatbath-r- o815 gsl gslcblas lat_neigh)
#elif ALGORITHM_1MRPLUS
#define ALGORITHM "1mr+"
#include "sim-1mr+.hpp"
+#elif ALGORITHM_1MRMINUS
+#define ALGORITHM "1mr-"
+#include "sim-1mr-.hpp"
+#elif ALGORITHM_RMINUS
+#define ALGORITHM "r-"
+#include "sim-r-.hpp"
#else
#error NO UPDATE-ALGORITHM DEFINED!
#endif
public:
struct obsmem {
- double phip2[2];
+ double phip2[4];
};
obs_phip2_hist(o815 *_O815);
};
obs_phip2_hist::obs_phip2_hist(o815 *_O815) : o815::obs("phip2",
- _O815->paraQ->getParaNames() + "nthstep:iruv:phip2absdiffequi", _O815,
+ _O815->paraQ->getParaNames() + "nthstep:imode:kt:kx:phip2absdiffequi", _O815,
sizeof(obsmem),
"_hist") {
OM = (obsmem*)obsMem;
}
void obs_phip2_hist::_meas(bool loadedobs, const int& nthmeas) {
- if (!loadedobs) {
- for (int kpiruv=0; kpiruv<2; kpiruv++) {
- double ppt = 2.*M_PI/O815->comargs.lsize[0] * ( 0 + kpiruv * O815->comargs.lsize[0]/2 ) ;
- double ppx = 2.*M_PI/O815->comargs.lsize[1] * ( 0 + kpiruv * O815->comargs.lsize[1]/2 );
+ for (int kpimode=0; kpimode<4; kpimode++) {
+ const double ppt = 2.*M_PI/O815->comargs.lsize[0] * ( 0 + int( kpimode/4. * O815->comargs.lsize[0] ) ) ;
+ const double ppx = 2.*M_PI/O815->comargs.lsize[1] * ( 0 + int( kpimode/4. * O815->comargs.lsize[1] ) );
- OM->phip2[ kpiruv ] = 0;
+ if (!loadedobs) {
+ OM->phip2[ kpimode ] = 0;
for (int ixt = 0; ixt < O815->comargs.lsize[0]; ixt++)
for (int ixx = 0; ixx < O815->comargs.lsize[1]; ixx++)
for (int ixpt = 0; ixpt < O815->comargs.lsize[0]; ixpt++)
for (int ixpx = 0; ixpx < O815->comargs.lsize[1]; ixpx++)
- OM->phip2[ kpiruv ] += real( conj( Sim->conf[ ixt*O815->comargs.lsize[1] + ixx ].phi )
- * Sim->conf[ ixpt*O815->comargs.lsize[1] + ixpx ].phi
- * exp ( _i_*(double)ppx*(double)(ixx-ixpx) + _i_*(double)ppt*(double)(ixt-ixpt) ) );
+ OM->phip2[ kpimode ] += real( conj( Sim->conf[ ixt*O815->comargs.lsize[1] + ixx ].phi )
+ * Sim->conf[ ixpt*O815->comargs.lsize[1] + ixpx ].phi
+ * exp ( _i_*(double)ppx*(double)(ixx-ixpx) + _i_*(double)ppt*(double)(ixt-ixpt) ) );
- OM->phip2[ kpiruv ] /= Sim->LSIZE2;
+ OM->phip2[ kpimode ] /= Sim->LSIZE2;
}
- }
-
- for (int kpiruv=0; kpiruv<2; kpiruv++) {
- double ppt = 2.*M_PI/O815->comargs.lsize[0] * ( 0 + kpiruv * O815->comargs.lsize[0]/2 ) ;
- double ppx = 2.*M_PI/O815->comargs.lsize[1] * ( 0 + kpiruv * O815->comargs.lsize[1]/2 );
-
+
*out << O815->paraQ->getParaVals();
*out << "\t" << ( Sim->nequi + (nthmeas+1)*Sim->nskip );
- *out << "\t" << kpiruv;
- *out << "\t" << abs( OM->phip2[ kpiruv ] - 1./(ppt*ppt + ppx*ppx + Sim->m*Sim->m) ) << endl;
+ *out << "\t" << kpimode;
+ *out << "\t" << 0 + int( kpimode/4. * O815->comargs.lsize[0] );
+ *out << "\t" << 0 + int( kpimode/4. * O815->comargs.lsize[1] );
+ *out << "\t" << abs( OM->phip2[ kpimode ] - 1./(ppt*ppt + ppx*ppx + Sim->m*Sim->m) ) << endl;
}
};
--- /dev/null
+#ifndef SIM_HPP
+#define SIM_HPP
+
+#include <gsl/gsl_rng.h>
+#include <complex>
+#include <math.h>
+
+#include "latlib/neigh.h"
+
+class sim : public o815::sim {
+public:
+ struct siteconf {
+ complex<double> phi;
+ };
+ sim(o815 *_O815);
+ siteconf* conf;
+ unsigned int LSIZE2;
+ double M;
+ double m;
+ neigh *nb;
+
+private:
+ void _makeSweep();
+ void _newParas();
+ gsl_rng* rangsl;
+ void updatePhi (const int& x);
+};
+
+
+
+sim::sim(o815 *_O815) : o815::sim( _O815,
+ sizeof(siteconf)*
+ (_O815->comargs.lsize[0]*_O815->comargs.lsize[1]) ) {
+ conf = (siteconf*)confMem;
+
+ rangsl = gsl_rng_alloc(gsl_rng_ranlxs0);
+ gsl_rng_set(rangsl, time(NULL));
+
+ LSIZE2 = _O815->comargs.lsize[0] * _O815->comargs.lsize[1];
+
+ nb = new neigh(2, _O815->comargs.lsize[0], _O815->comargs.lsize[1]);
+}
+
+void sim::updatePhi (const int& x)
+{
+ const double theta = gsl_rng_uniform(rangsl) * 2*M_PI;
+ complex<double> V=0;
+
+ for (int nu=0; nu<4; nu++)
+ V += conf[ (*nb)[x*4+nu] ].phi;
+
+ const double r = exp( - M * norm(conf[x].phi)
+ - 1./M * norm(V)
+ + 2 * real( conf[x].phi * conj(V) ) );
+
+ double oldarg = arg(conf[x].phi);
+
+ conf[x].phi = sqrt(std::log( 1./(1-r) )) / sqrt(M)
+ * polar(1.0, oldarg)
+ + V / M;
+}
+
+void sim::_makeSweep() {
+ for (int ichecker=0; ichecker<2; ichecker++)
+ for (int it=0; it<O815->comargs.lsize[0]; it++)
+ for (int iy=(it+ichecker)%2; iy<O815->comargs.lsize[1]; iy+=2)
+ updatePhi( it*O815->comargs.lsize[1] + iy );
+}
+
+void sim::_newParas() {
+ m = (*O815->paraQ)["mass"];
+ M = pow( (*O815->paraQ)["mass"], 2 ) + 4;
+ *log << "SIM: Resetting fields." << endl << flush;
+
+ for (int ix=0; ix<LSIZE2; ix++)
+ conf[ix].phi = 1;
+}
+
+#endif
--- /dev/null
+#ifndef SIM_HPP
+#define SIM_HPP
+
+#include <gsl/gsl_rng.h>
+#include <complex>
+#include <math.h>
+
+#include "latlib/neigh.h"
+
+class sim : public o815::sim {
+public:
+ struct siteconf {
+ complex<double> phi;
+ };
+ sim(o815 *_O815);
+ siteconf* conf;
+ unsigned int LSIZE2;
+ double M;
+ double m;
+ neigh *nb;
+
+private:
+ void _makeSweep();
+ void _newParas();
+ gsl_rng* rangsl;
+ void updatePhi (const int& x);
+};
+
+
+
+sim::sim(o815 *_O815) : o815::sim( _O815,
+ sizeof(siteconf)*
+ (_O815->comargs.lsize[0]*_O815->comargs.lsize[1]) ) {
+ conf = (siteconf*)confMem;
+
+ rangsl = gsl_rng_alloc(gsl_rng_ranlxs0);
+ gsl_rng_set(rangsl, time(NULL));
+
+ LSIZE2 = _O815->comargs.lsize[0] * _O815->comargs.lsize[1];
+
+ 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;
+ complex<double> V=0;
+
+ for (int nu=0; nu<4; nu++)
+ V += conf[ (*nb)[x*4+nu] ].phi;
+
+ double oldarg = arg(conf[x].phi);
+
+ conf[x].phi = sqrt(std::log( 1./(1-r) )) / sqrt(M)
+ * polar(1.0, oldarg)
+ + V / M;
+}
+
+void sim::_makeSweep() {
+ for (int ichecker=0; ichecker<2; ichecker++)
+ for (int it=0; it<O815->comargs.lsize[0]; it++)
+ for (int iy=(it+ichecker)%2; iy<O815->comargs.lsize[1]; iy+=2)
+ updatePhi( it*O815->comargs.lsize[1] + iy );
+}
+
+void sim::_newParas() {
+ m = (*O815->paraQ)["mass"];
+ M = pow( (*O815->paraQ)["mass"], 2 ) + 4;
+ *log << "SIM: Resetting fields." << endl << flush;
+
+ for (int ix=0; ix<LSIZE2; ix++)
+ conf[ix].phi = 1;
+}
+
+#endif