1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-14 17:55:38 +00:00

More user-friendly environment for the shGordon test file

This commit is contained in:
Guido Cossu 2018-01-18 13:21:13 +00:00
parent 736dcd06c2
commit 6347904160
2 changed files with 35 additions and 39 deletions

View File

@ -64,6 +64,7 @@ class shGordonAction : public QCD::Action<typename Impl::Field> {
tmp = 2.0*QCD::Nd*phi; tmp = 2.0*QCD::Nd*phi;
for (int mu = 0; mu < QCD::Nd; mu++) tmp -= Cshift(phi, mu, 1) + Cshift(phi, mu, -1); 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)); force+= tmp - 0.5*mass_square/g*(exp(g*phi) - exp(-g*phi));
} }
}; };

View File

@ -27,10 +27,30 @@ See the full license in the file "LICENSE" in the top level distribution directo
/* END LEGAL */ /* END LEGAL */
#include <Grid/Grid.h> #include <Grid/Grid.h>
namespace Grid {
class ScalarActionParameters : Serializable {
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(ScalarActionParameters,
double, mass_squared,
double, g);
template <class ReaderClass >
ScalarActionParameters(Reader<ReaderClass>& Reader){
read(Reader, "ScalarAction", *this);
}
};
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
using namespace Grid; using namespace Grid;
using namespace Grid::QCD; using namespace Grid::QCD;
typedef Grid::JSONReader Serialiser;
Grid_init(&argc, &argv); Grid_init(&argc, &argv);
int threads = GridThread::GetThreads(); int threads = GridThread::GetThreads();
// here make a routine to print all the relevant information on the run // 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 // Typedefs to simplify notation
typedef ScalarGenericHMCRunner HMCWrapper; // Uses the default minimum norm, real scalar fields typedef ScalarGenericHMCRunner HMCWrapper; // Uses the default minimum norm, real scalar fields
//typedef Representations<EmptyRep<typename ScalarMatrixImplTypes<vComplex, 3>::Field> > ScalarMatrixFields;
//typedef HMCWrapperTemplate<ScalarMatrixImplTypes<vComplex, 3>, MinimumNorm2, ScalarMatrixFields> HMCWrapper;
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
HMCWrapper TheHMC; 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 // Grid from the command line
constexpr int Ndimensions = 2; constexpr int Ndimensions = 2;
GridModule ScalarGrid; GridModule ScalarGrid;
@ -59,41 +85,15 @@ int main(int argc, char **argv) {
TheHMC.Resources.AddGrid("scalar", ScalarGrid); TheHMC.Resources.AddGrid("scalar", ScalarGrid);
std::cout << "Lattice size : " << GridDefaultLatt() << std::endl; std::cout << "Lattice size : " << GridDefaultLatt() << std::endl;
/* CheckpointerParameters CPparams(Reader);
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";
TheHMC.Resources.LoadBinaryCheckpointer(CPparams); TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
RNGModuleParameters RNGpar; RNGModuleParameters RNGpar(Reader);
RNGpar.serial_seeds = "1 2 3 4 5";
RNGpar.parallel_seeds = "6 7 8 9 10";
TheHMC.Resources.SetRNGSeeds(RNGpar); TheHMC.Resources.SetRNGSeeds(RNGpar);
////////////////////////////////////////////// // Real Scalar sh-Gordon action
ScalarActionParameters SPar(Reader);
///////////////////////////////////////////////////////////// shGordonActionR Saction(SPar.mass_squared, SPar.g);
// 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);
// Collect actions // Collect actions
ActionLevel<shGordonActionR::Field, ScalarFields> Level1(1); ActionLevel<shGordonActionR::Field, ScalarFields> Level1(1);
@ -102,12 +102,7 @@ int main(int argc, char **argv) {
TheHMC.TheAction.push_back(Level1); TheHMC.TheAction.push_back(Level1);
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
TheHMC.Parameters.initialize(Reader);
// 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.Run(); TheHMC.Run();
Grid_finalize(); Grid_finalize();