mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-19 00:07:05 +01:00
All tests compile.
This commit is contained in:
@ -27,76 +27,126 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
/* END LEGAL */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
|
||||
class HmcRunner : public ConjugateNerscHmcRunner {
|
||||
public:
|
||||
|
||||
void BuildTheAction (int argc, char **argv)
|
||||
|
||||
{
|
||||
typedef GparityWilsonImplR ImplPolicy;
|
||||
typedef GparityDomainWallFermionR FermionAction;
|
||||
|
||||
typedef typename FermionAction::FermionField FermionField;
|
||||
|
||||
const int Ls = 8;
|
||||
|
||||
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
|
||||
FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||
FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||
|
||||
// temporarily need a gauge field
|
||||
LatticeGaugeField U(UGrid);
|
||||
|
||||
// Gauge action
|
||||
ConjugateWilsonGaugeActionR Waction(5.6);
|
||||
|
||||
// Fermion action
|
||||
const int nu = 3;
|
||||
std::vector<int> twists(Nd,0);
|
||||
twists[nu] = 1;
|
||||
FermionAction::ImplParams params;
|
||||
params.twists = twists;
|
||||
Real mass=0.04;
|
||||
Real pv =1.0;
|
||||
RealD M5=1.5;
|
||||
FermionAction DenOp(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,params);
|
||||
FermionAction NumOp(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,pv,M5,params);
|
||||
|
||||
ConjugateGradient<FermionField> CG(1.0e-8,10000);
|
||||
TwoFlavourEvenOddRatioPseudoFermionAction<ImplPolicy> Nf2(NumOp, DenOp,CG,CG);
|
||||
|
||||
//Collect actions
|
||||
ActionLevel<LatticeGaugeField> Level1;
|
||||
Level1.push_back(&Nf2);
|
||||
Level1.push_back(&Waction);
|
||||
TheAction.push_back(Level1);
|
||||
|
||||
Run(argc,argv);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
int main(int argc, char **argv) {
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
Grid_init(&argc, &argv);
|
||||
int threads = GridThread::GetThreads();
|
||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
// here make a routine to print all the relevant information on the run
|
||||
std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl;
|
||||
|
||||
HmcRunner TheHMC;
|
||||
// Typedefs to simplify notation
|
||||
typedef ConjugateHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
|
||||
|
||||
typedef GparityWilsonImplR FermionImplPolicy;
|
||||
typedef GparityDomainWallFermionR FermionAction;
|
||||
typedef typename FermionAction::FermionField FermionField;
|
||||
|
||||
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
HMCWrapper TheHMC;
|
||||
|
||||
// Grid from the command line
|
||||
TheHMC.Resources.AddFourDimGrid("gauge");
|
||||
// Possibile to create the module by hand
|
||||
// hardcoding parameters or using a Reader
|
||||
|
||||
|
||||
// Checkpointer definition
|
||||
CheckpointerParameters CPparams;
|
||||
CPparams.config_prefix = "ckpoint_EODWF_lat";
|
||||
CPparams.rng_prefix = "ckpoint_EODWF_rng";
|
||||
CPparams.saveInterval = 5;
|
||||
CPparams.format = "IEEE64BIG";
|
||||
|
||||
TheHMC.BuildTheAction(argc,argv);
|
||||
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
|
||||
|
||||
RNGModuleParameters RNGpar;
|
||||
RNGpar.SerialSeed = {1,2,3,4,5};
|
||||
RNGpar.ParallelSeed = {6,7,8,9,10};
|
||||
TheHMC.Resources.SetRNGSeeds(RNGpar);
|
||||
|
||||
// Construct observables
|
||||
// here there is too much indirection
|
||||
PlaquetteObsParameters PlPar;
|
||||
PlPar.output_prefix = "Plaquette";
|
||||
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
|
||||
TheHMC.Resources.AddObservable(&PlaqModule);
|
||||
//////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Collect actions, here use more encapsulation
|
||||
// need wrappers of the fermionic classes
|
||||
// that have a complex construction
|
||||
// standard
|
||||
RealD beta = 5.6 ;
|
||||
ConjugateWilsonGaugeActionR Waction(beta);
|
||||
|
||||
const int Ls = 8;
|
||||
auto GridPtr = TheHMC.Resources.GetCartesian();
|
||||
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
|
||||
auto FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,GridPtr);
|
||||
auto FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,GridPtr);
|
||||
|
||||
|
||||
// temporarily need a gauge field
|
||||
LatticeGaugeField U(GridPtr);
|
||||
|
||||
const int nu = 3;
|
||||
std::vector<int> twists(Nd,0);
|
||||
twists[nu] = 1;
|
||||
FermionAction::ImplParams params;
|
||||
params.twists = twists;
|
||||
Real mass=0.04;
|
||||
Real pv =1.0;
|
||||
RealD M5=1.5;
|
||||
|
||||
FermionAction DenOp(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,mass,M5, params);
|
||||
FermionAction NumOp(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,pv, M5, params);
|
||||
|
||||
double StoppingCondition = 1.0e-8;
|
||||
double MaxCGIterations = 10000;
|
||||
ConjugateGradient<FermionField> CG(StoppingCondition,MaxCGIterations);
|
||||
TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy> Nf2(NumOp, DenOp,CG,CG);
|
||||
|
||||
// Set smearing (true/false), default: false
|
||||
Nf2.is_smeared = false;
|
||||
|
||||
// Collect actions
|
||||
ActionLevel<HMCWrapper::Field> Level1(1);
|
||||
Level1.push_back(&Nf2);
|
||||
|
||||
ActionLevel<HMCWrapper::Field> Level2(4);
|
||||
Level2.push_back(&Waction);
|
||||
|
||||
TheHMC.TheAction.push_back(Level1);
|
||||
TheHMC.TheAction.push_back(Level2);
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
// HMC parameters are serialisable
|
||||
TheHMC.Parameters.MD.MDsteps = 20;
|
||||
TheHMC.Parameters.MD.trajL = 1.0;
|
||||
|
||||
TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
|
||||
|
||||
// Reset performance counters
|
||||
NumOp.ZeroCounters();
|
||||
DenOp.ZeroCounters();
|
||||
TheHMC.Run(); // no smearing
|
||||
// TheHMC.Run(SmearingPolicy); // for smearing
|
||||
|
||||
std::cout << GridLogMessage << "Numerator report, Pauli-Villars term : " << std::endl;
|
||||
NumOp.Report();
|
||||
std::cout << GridLogMessage << "Denominator report, Dw(m) term (includes CG) : " << std::endl;
|
||||
DenOp.Report();
|
||||
|
||||
Grid_finalize();
|
||||
|
||||
|
||||
|
||||
|
||||
} // main
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user