//-------------------------------------------------------------------- /*! @file HMC.h * @brief Classes for Hybrid Monte Carlo update * * @author Guido Cossu * Time-stamp: <2015-07-30 16:58:26 neo> */ //-------------------------------------------------------------------- #ifndef HMC_INCLUDED #define HMC_INCLUDED #include namespace Grid{ namespace QCD{ struct HMCparameters{ Integer StartTrajectory; Integer Trajectories; /* @brief Number of sweeps in this run */ bool MetropolisTest; Integer NoMetropolisUntil; HMCparameters(){ ////////////////////////////// Default values MetropolisTest = true; NoMetropolisUntil = 10; StartTrajectory = 0; Trajectories = 200; ///////////////////////////////// } }; template class HmcObservable { public: virtual void TrajectoryComplete (int traj, GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG & pRNG )=0; }; // template template class HybridMonteCarlo { private: const HMCparameters Params; GridSerialRNG &sRNG; // Fixme: need a RNG management strategy. GridParallelRNG &pRNG; // Fixme: need a RNG management strategy. GaugeField & Ucur; IntegratorType &TheIntegrator; std::vector *> Observables; ///////////////////////////////////////////////////////// // Metropolis step ///////////////////////////////////////////////////////// bool metropolis_test(const RealD DeltaH){ RealD rn_test; RealD prob = std::exp(-DeltaH); random(sRNG,rn_test); std::cout<1.0) || (rn_test <= prob)){ // accepted std::cout< *obs) { Observables.push_back(obs); } void evolve(void){ Real DeltaH; GaugeField Ucopy(Ucur._grid); // Actual updates (evolve a copy Ucopy then copy back eventually) for(int traj=Params.StartTrajectory; traj < Params.Trajectories+Params.StartTrajectory; ++traj){ std::cout< Params.NoMetropolisUntil) { accept = metropolis_test(DeltaH); } if ( accept ) { Ucur = Ucopy; } plaq = WilsonLoops::avgPlaquette(Ucur); std::cout << " Now gauge field has plaq = "<< plaq <TrajectoryComplete (traj+1,Ucur,sRNG,pRNG); } } } }; }// QCD }// Grid #endif