diff --git a/Grid/qcd/hmc/HMC.h b/Grid/qcd/hmc/HMC.h index c56ae6ad8c..2f765c48bf 100644 --- a/Grid/qcd/hmc/HMC.h +++ b/Grid/qcd/hmc/HMC.h @@ -93,7 +93,20 @@ struct HMCparameters: Serializable { }; template -class HybridMonteCarlo { +class HybridMonteCarlo +/*! @brief The HMC class, + * which performs the metropolis + * accept/reject step and molecular dynamics + * integration step. + * + * As introduced in Duane, Kennedy, Pendleton & Roweth, + * Phys. Letters B, 2, 1987 + * https://doi.org/10.1016/0370-2693(87)91197-X + * + * See Rothe, Third Edition, Section 16.7 + * 'The Hybrid Monte Carlo Algorithm' + */ +{ private: const HMCparameters Params; @@ -289,7 +302,7 @@ class HybridMonteCarlo { std::cout << GridLogDebug << "Observables # " << obs << std::endl; std::cout << GridLogDebug << "Observables total " << Observables.size() << std::endl; std::cout << GridLogDebug << "Observables pointer " << Observables[obs] << std::endl; - Observables[obs]->TrajectoryComplete(traj + 1, TheIntegrator.Smearer, sRNG, pRNG); + Observables[obs]->TrajectoryComplete(traj + 1, TheIntegrator.Smearer, sRNG, pRNG, accept); } std::cout << GridLogHMC << ":::::::::::::::::::::::::::::::::::::::::::" << std::endl; } diff --git a/Grid/qcd/observables/hmc_observable.h b/Grid/qcd/observables/hmc_observable.h index 277ded28d1..31a992da30 100644 --- a/Grid/qcd/observables/hmc_observable.h +++ b/Grid/qcd/observables/hmc_observable.h @@ -32,7 +32,20 @@ directory NAMESPACE_BEGIN(Grid); template -class HmcObservable { +class HmcObservable +/*! @brief HMC Observable class, + * HMC observables inherit the method + * TrajectoryComplete from here, which + * is used to run the computation of + * on-the-fly observables. + * + * Expects: + * an integer traj : trajectory number + * a reference to ConfigurationBase : the gauge field configuration + * a reference to a serial RNG + * a reference to a parallel RNG + */ +{ public: virtual void TrajectoryComplete(int traj, ConfigurationBase &SmartConfig, @@ -45,6 +58,25 @@ class HmcObservable { Field &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG) = 0; + + // allow backward compatibility with current observables that do not have + // acceptance argument + virtual void TrajectoryComplete(int traj, + ConfigurationBase &SmartConfig, + GridSerialRNG &sRNG, + GridParallelRNG &pRNG, + bool accept) + { + TrajectoryComplete(traj,SmartConfig.get_U(false),sRNG,pRNG,accept); // Unsmeared observable + }; + virtual void TrajectoryComplete(int traj, + Field &U, + GridSerialRNG &sRNG, + GridParallelRNG &pRNG, + bool accept) + { + TrajectoryComplete(traj, U, sRNG, pRNG); + }; }; NAMESPACE_END(Grid);