From b640230b1e01ec749e7f3e86b5662dfed8c96032 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Fri, 17 Mar 2017 11:40:17 +0900 Subject: [PATCH] Moving hmc observables in a different directory --- lib/qcd/QCD.h | 1 + lib/qcd/hmc/HMC.cc | 36 ------------ lib/qcd/hmc/HMC.h | 6 +- lib/qcd/observables/hmc_observable.h | 48 +++++++++++++++ lib/qcd/observables/plaquette.h | 88 ++++++++++++++++++++++++++++ 5 files changed, 141 insertions(+), 38 deletions(-) delete mode 100644 lib/qcd/hmc/HMC.cc create mode 100644 lib/qcd/observables/hmc_observable.h create mode 100644 lib/qcd/observables/plaquette.h diff --git a/lib/qcd/QCD.h b/lib/qcd/QCD.h index 9fb0d900..8602fcb7 100644 --- a/lib/qcd/QCD.h +++ b/lib/qcd/QCD.h @@ -513,6 +513,7 @@ namespace QCD { #include #include +#include #include diff --git a/lib/qcd/hmc/HMC.cc b/lib/qcd/hmc/HMC.cc deleted file mode 100644 index 6386f5bf..00000000 --- a/lib/qcd/hmc/HMC.cc +++ /dev/null @@ -1,36 +0,0 @@ - /************************************************************************************* - - Grid physics library, www.github.com/paboyle/Grid - - Source file: ./lib/qcd/hmc/HMC.cc - - Copyright (C) 2015 - -Author: Peter Boyle -Author: neo -Author: paboyle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - See the full license in the file "LICENSE" in the top level distribution directory - *************************************************************************************/ - /* END LEGAL */ -#include - -namespace Grid{ - namespace QCD{ - - } -} diff --git a/lib/qcd/hmc/HMC.h b/lib/qcd/hmc/HMC.h index 61a56c7c..a000a412 100644 --- a/lib/qcd/hmc/HMC.h +++ b/lib/qcd/hmc/HMC.h @@ -42,6 +42,8 @@ directory #include #include + + namespace Grid { namespace QCD { @@ -87,7 +89,7 @@ struct HMCparameters: Serializable { }; - +/* // Move this to a different file template class HmcObservable { @@ -144,7 +146,7 @@ class PlaquetteLogger : public HmcObservable { } }; ////////////////////////////////////////////////////////////// - +*/ template class HybridMonteCarlo { diff --git a/lib/qcd/observables/hmc_observable.h b/lib/qcd/observables/hmc_observable.h new file mode 100644 index 00000000..446b3dd1 --- /dev/null +++ b/lib/qcd/observables/hmc_observable.h @@ -0,0 +1,48 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: ./lib/qcd/observables/hmc_observable.h + +Copyright (C) 2017 + +Author: Guido Cossu + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +See the full license in the file "LICENSE" in the top level distribution +directory +*************************************************************************************/ +/* END LEGAL */ + +#ifndef HMC_OBSERVABLE_H +#define HMC_OBSERVABLE_H + +namespace Grid{ + +template +class HmcObservable { + public: + virtual void TrajectoryComplete(int traj, + Field &U, + GridSerialRNG &sRNG, + GridParallelRNG &pRNG) = 0; +}; + +} // namespace Grid + +#include "plaquette.h" + +#endif // HMC_OBSERVABLE_H diff --git a/lib/qcd/observables/plaquette.h b/lib/qcd/observables/plaquette.h new file mode 100644 index 00000000..c5e3f57d --- /dev/null +++ b/lib/qcd/observables/plaquette.h @@ -0,0 +1,88 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: ./lib/qcd/modules/Registration.h + +Copyright (C) 2017 + +Author: Guido Cossu + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +See the full license in the file "LICENSE" in the top level distribution +directory +*************************************************************************************/ +/* END LEGAL */ + +#ifndef HMC_PLAQUETTE_H +#define HMC_PLAQUETTE_H + +namespace Grid{ + namespace QCD{ + + // this is only defined for a gauge theory +template +class PlaquetteLogger : public HmcObservable { + private: + std::string Stem; + + public: + // here forces the Impl to be of gauge fields + // if not the compiler will complain + INHERIT_GIMPL_TYPES(Impl); + typedef typename Impl::Field Field; // necessary for HmcObservable compatibility + PlaquetteLogger(std::string cf) { Stem = cf; }; + + void TrajectoryComplete(int traj, + Field &U, + GridSerialRNG &sRNG, + GridParallelRNG &pRNG) { + std::string file; + { + std::ostringstream os; + os << Stem << "." << traj; + file = os.str(); + } + std::ofstream of(file); + + RealD peri_plaq = WilsonLoops::avgPlaquette(U); + RealD peri_rect = WilsonLoops::avgRectangle(U); + + RealD impl_plaq = WilsonLoops::avgPlaquette(U); + RealD impl_rect = WilsonLoops::avgRectangle(U); + + // Fixme reorganise this output + of << traj << " " << impl_plaq << " " << impl_rect << " " << peri_plaq + << " " << peri_rect << std::endl; + std::cout << GridLogMessage << "traj" + << " " + << "plaq " + << " " + << " rect " + << " " + << "peri_plaq" + << " " + << "peri_rect" << std::endl; + std::cout << GridLogMessage << traj << " " << impl_plaq << " " << impl_rect + << " " << peri_plaq << " " << peri_rect << std::endl; + } +}; +////////////////////////////////////////////////////////////// + +} // namespace QCD +} // namespace Grid + +#endif //HMC_PLAQUETTE_H