From 634790416087d4d9173469ded57622004c812bf7 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Thu, 18 Jan 2018 13:21:13 +0000 Subject: [PATCH] More user-friendly environment for the shGordon test file --- lib/qcd/action/scalar/shGordonAction.h | 1 + tests/hmc/Test_hmc_shGordonAction.cc | 73 ++++++++++++-------------- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/lib/qcd/action/scalar/shGordonAction.h b/lib/qcd/action/scalar/shGordonAction.h index 12f208ac..961230fe 100644 --- a/lib/qcd/action/scalar/shGordonAction.h +++ b/lib/qcd/action/scalar/shGordonAction.h @@ -64,6 +64,7 @@ class shGordonAction : public QCD::Action { tmp = 2.0*QCD::Nd*phi; for (int mu = 0; mu < QCD::Nd; mu++) tmp -= Cshift(phi, mu, 1) + Cshift(phi, mu, -1); + std::cout << GridLogDebug << "Phi norm : " << norm2(phi) << std::endl; force+= tmp - 0.5*mass_square/g*(exp(g*phi) - exp(-g*phi)); } }; diff --git a/tests/hmc/Test_hmc_shGordonAction.cc b/tests/hmc/Test_hmc_shGordonAction.cc index 45cb6b62..ada82c1f 100644 --- a/tests/hmc/Test_hmc_shGordonAction.cc +++ b/tests/hmc/Test_hmc_shGordonAction.cc @@ -27,10 +27,30 @@ See the full license in the file "LICENSE" in the top level distribution directo /* END LEGAL */ #include +namespace Grid { +class ScalarActionParameters : Serializable { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(ScalarActionParameters, + double, mass_squared, + double, g); + + template + ScalarActionParameters(Reader& Reader){ + read(Reader, "ScalarAction", *this); + } + +}; +} + + + + int main(int argc, char **argv) { using namespace Grid; using namespace Grid::QCD; + typedef Grid::JSONReader Serialiser; + Grid_init(&argc, &argv); int threads = GridThread::GetThreads(); // here make a routine to print all the relevant information on the run @@ -38,11 +58,17 @@ int main(int argc, char **argv) { // Typedefs to simplify notation typedef ScalarGenericHMCRunner HMCWrapper; // Uses the default minimum norm, real scalar fields - //typedef Representations::Field> > ScalarMatrixFields; - //typedef HMCWrapperTemplate, MinimumNorm2, ScalarMatrixFields> HMCWrapper; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: HMCWrapper TheHMC; + TheHMC.ReadCommandLine(argc, argv); + if (TheHMC.ParameterFile.empty()){ + std::cout << "Input file not specified." + << "Use --ParameterFile option in the command line.\nAborting" + << std::endl; + exit(1); + } + Serialiser Reader(TheHMC.ParameterFile); // Grid from the command line constexpr int Ndimensions = 2; GridModule ScalarGrid; @@ -59,41 +85,15 @@ int main(int argc, char **argv) { TheHMC.Resources.AddGrid("scalar", ScalarGrid); std::cout << "Lattice size : " << GridDefaultLatt() << std::endl; - /* - GridModule ScalarGrid; - ScalarGrid.set_full( SpaceTimeGrid::makeFourDimGrid( - GridDefaultLatt(), GridDefaultSimd(Nd, vReal::Nsimd()), - GridDefaultMpi())); - ScalarGrid.set_rb(SpaceTimeGrid::makeFourDimRedBlackGrid(ScalarGrid.get_full())); - TheHMC.Resources.AddGrid("scalar", ScalarGrid); - */ - // Possibile to create the module by hand - // hardcoding parameters or using a Reader - - // Checkpointer definition - CheckpointerParameters CPparams; - CPparams.config_prefix = "ckpoint_scalar_lat"; - CPparams.rng_prefix = "ckpoint_scalar_rng"; - CPparams.saveInterval = 50; - CPparams.format = "IEEE64BIG"; - + CheckpointerParameters CPparams(Reader); TheHMC.Resources.LoadBinaryCheckpointer(CPparams); - RNGModuleParameters RNGpar; - RNGpar.serial_seeds = "1 2 3 4 5"; - RNGpar.parallel_seeds = "6 7 8 9 10"; + RNGModuleParameters RNGpar(Reader); TheHMC.Resources.SetRNGSeeds(RNGpar); - ////////////////////////////////////////////// - - ///////////////////////////////////////////////////////////// - // Collect actions, here use more encapsulation - // need wrappers of the fermionic classes - // that have a complex construction - // standard - - // Real Scalar action - shGordonActionR Saction(0.1,0.1); + // Real Scalar sh-Gordon action + ScalarActionParameters SPar(Reader); + shGordonActionR Saction(SPar.mass_squared, SPar.g); // Collect actions ActionLevel Level1(1); @@ -102,12 +102,7 @@ int main(int argc, char **argv) { TheHMC.TheAction.push_back(Level1); ///////////////////////////////////////////////////////////// - - // HMC parameters are serialisable - TheHMC.Parameters.MD.MDsteps = 100; - TheHMC.Parameters.MD.trajL = 1.0; - - TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file + TheHMC.Parameters.initialize(Reader); TheHMC.Run(); Grid_finalize();