mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-14 13:57:07 +01:00
Merge branch 'develop' into feature/json-fix
This commit is contained in:
@ -36,6 +36,7 @@ using namespace Grid::QCD;
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
#ifdef HAVE_LIME
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::cout <<GridLogMessage<< " main "<<std::endl;
|
||||
@ -96,4 +97,5 @@ int main (int argc, char ** argv)
|
||||
std::cout <<GridLogMessage<< "norm2 Gauge Diff = "<<norm2(Umu_diff)<<std::endl;
|
||||
|
||||
Grid_finalize();
|
||||
#endif
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ using namespace Grid::QCD;
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
#ifdef HAVE_LIME
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
|
||||
@ -112,4 +113,5 @@ int main (int argc, char ** argv)
|
||||
std::cout<<GridLogMessage << "calculated link trace " <<l*LinkTraceScale<<std::endl;
|
||||
|
||||
Grid_finalize();
|
||||
#endif
|
||||
}
|
||||
|
@ -183,8 +183,6 @@ void IntTester(const functor &func)
|
||||
{
|
||||
typedef Integer scal;
|
||||
typedef vInteger vec;
|
||||
GridSerialRNG sRNG;
|
||||
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||
|
||||
int Nsimd = vec::Nsimd();
|
||||
|
||||
@ -287,6 +285,50 @@ void ReductionTester(const functor &func)
|
||||
}
|
||||
|
||||
|
||||
template<class reduced,class scal, class vec,class functor >
|
||||
void IntReductionTester(const functor &func)
|
||||
{
|
||||
int Nsimd = vec::Nsimd();
|
||||
|
||||
std::vector<scal> input1(Nsimd);
|
||||
std::vector<scal> input2(Nsimd);
|
||||
reduced result(0);
|
||||
reduced reference(0);
|
||||
reduced tmp;
|
||||
|
||||
std::vector<vec,alignedAllocator<vec> > buf(3);
|
||||
vec & v_input1 = buf[0];
|
||||
vec & v_input2 = buf[1];
|
||||
|
||||
for(int i=0;i<Nsimd;i++){
|
||||
input1[i] = (i + 1) * 30;
|
||||
input2[i] = (i + 1) * 20;
|
||||
}
|
||||
|
||||
merge<vec,scal>(v_input1,input1);
|
||||
merge<vec,scal>(v_input2,input2);
|
||||
|
||||
func.template vfunc<reduced,vec>(result,v_input1,v_input2);
|
||||
|
||||
for(int i=0;i<Nsimd;i++) {
|
||||
func.template sfunc<reduced,scal>(tmp,input1[i],input2[i]);
|
||||
reference+=tmp;
|
||||
}
|
||||
|
||||
std::cout<<GridLogMessage << " " << func.name()<<std::endl;
|
||||
|
||||
int ok=0;
|
||||
if ( reference-result != 0 ){
|
||||
std::cout<<GridLogMessage<< "*****" << std::endl;
|
||||
std::cout<<GridLogMessage<< reference-result << " " <<reference<< " " << result<<std::endl;
|
||||
ok++;
|
||||
}
|
||||
if ( ok==0 ) {
|
||||
std::cout<<GridLogMessage << " OK!" <<std::endl;
|
||||
}
|
||||
assert(ok==0);
|
||||
}
|
||||
|
||||
|
||||
class funcPermute {
|
||||
public:
|
||||
@ -691,6 +733,7 @@ int main (int argc, char ** argv)
|
||||
IntTester(funcPlus());
|
||||
IntTester(funcMinus());
|
||||
IntTester(funcTimes());
|
||||
IntReductionTester<Integer, Integer, vInteger>(funcReduce());
|
||||
|
||||
std::cout<<GridLogMessage << "==================================="<< std::endl;
|
||||
std::cout<<GridLogMessage << "Testing precisionChange "<< std::endl;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_stencil.cc
|
||||
|
||||
@ -33,9 +33,8 @@ using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
int main(int argc, char ** argv) {
|
||||
Grid_init(&argc, &argv);
|
||||
|
||||
// typedef LatticeColourMatrix Field;
|
||||
typedef LatticeComplex Field;
|
||||
@ -47,7 +46,7 @@ int main (int argc, char ** argv)
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
double volume = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3];
|
||||
|
||||
|
||||
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian rbFine(latt_size,simd_layout,mpi_layout);
|
||||
GridParallelRNG fRNG(&Fine);
|
||||
@ -55,14 +54,14 @@ int main (int argc, char ** argv)
|
||||
// fRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9});
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
fRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
|
||||
Field Foo(&Fine);
|
||||
Field Bar(&Fine);
|
||||
Field Check(&Fine);
|
||||
Field Diff(&Fine);
|
||||
LatticeComplex lex(&Fine);
|
||||
|
||||
lex = zero;
|
||||
lex = zero;
|
||||
random(fRNG,Foo);
|
||||
gaussian(fRNG,Bar);
|
||||
|
||||
@ -98,7 +97,7 @@ int main (int argc, char ** argv)
|
||||
Fine.oCoorFromOindex(ocoor,o);
|
||||
ocoor[dir]=(ocoor[dir]+disp)%Fine._rdimensions[dir];
|
||||
}
|
||||
|
||||
|
||||
SimpleCompressor<vobj> compress;
|
||||
myStencil.HaloExchange(Foo,compress);
|
||||
|
||||
@ -147,7 +146,7 @@ int main (int argc, char ** argv)
|
||||
<<") " <<check<<" vs "<<bar<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}}}}
|
||||
|
||||
if (nrm > 1.0e-4) {
|
||||
@ -187,16 +186,15 @@ int main (int argc, char ** argv)
|
||||
Fine.oCoorFromOindex(ocoor,o);
|
||||
ocoor[dir]=(ocoor[dir]+disp)%Fine._rdimensions[dir];
|
||||
}
|
||||
|
||||
|
||||
SimpleCompressor<vobj> compress;
|
||||
|
||||
|
||||
Bar = Cshift(Foo,dir,disp);
|
||||
|
||||
if ( disp & 0x1 ) {
|
||||
ECheck.checkerboard = Even;
|
||||
OCheck.checkerboard = Odd;
|
||||
} else {
|
||||
} else {
|
||||
ECheck.checkerboard = Odd;
|
||||
OCheck.checkerboard = Even;
|
||||
}
|
||||
@ -213,7 +211,7 @@ int main (int argc, char ** argv)
|
||||
permute(OCheck._odata[i],EFoo._odata[SE->_offset],permute_type);
|
||||
else if (SE->_is_local)
|
||||
OCheck._odata[i] = EFoo._odata[SE->_offset];
|
||||
else
|
||||
else
|
||||
OCheck._odata[i] = EStencil.CommBuf()[SE->_offset];
|
||||
}
|
||||
OStencil.HaloExchange(OFoo,compress);
|
||||
@ -222,18 +220,18 @@ int main (int argc, char ** argv)
|
||||
StencilEntry *SE;
|
||||
SE = OStencil.GetEntry(permute_type,0,i);
|
||||
// std::cout << "ODD source "<< i<<" -> " <<SE->_offset << " "<< SE->_is_local<<std::endl;
|
||||
|
||||
|
||||
if ( SE->_is_local && SE->_permute )
|
||||
permute(ECheck._odata[i],OFoo._odata[SE->_offset],permute_type);
|
||||
else if (SE->_is_local)
|
||||
ECheck._odata[i] = OFoo._odata[SE->_offset];
|
||||
else
|
||||
else
|
||||
ECheck._odata[i] = OStencil.CommBuf()[SE->_offset];
|
||||
}
|
||||
|
||||
|
||||
setCheckerboard(Check,ECheck);
|
||||
setCheckerboard(Check,OCheck);
|
||||
|
||||
|
||||
Real nrmC = norm2(Check);
|
||||
Real nrmB = norm2(Bar);
|
||||
Diff = Check-Bar;
|
||||
@ -256,10 +254,10 @@ int main (int argc, char ** argv)
|
||||
diff =norm2(ddiff);
|
||||
if ( diff > 0){
|
||||
std::cout <<"Coor (" << coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3] <<") "
|
||||
<<"shift "<<disp<<" dir "<< dir
|
||||
<<"shift "<<disp<<" dir "<< dir
|
||||
<< " stencil impl " <<check<<" vs cshift impl "<<bar<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
}}}}
|
||||
|
||||
if (nrm > 1.0e-4) exit(-1);
|
||||
|
@ -73,7 +73,7 @@ int main (int argc, char ** argv)
|
||||
|
||||
std::vector<LatticeColourMatrix> U(4,&Fine);
|
||||
|
||||
NerscField header;
|
||||
FieldMetaData header;
|
||||
|
||||
std::string file("./ckpoint_lat.4000");
|
||||
NerscIO::readConfiguration(Umu,header,file);
|
||||
|
@ -90,7 +90,7 @@ int main (int argc, char ** argv)
|
||||
|
||||
std::vector<LatticeColourMatrix> U(4,&Fine);
|
||||
|
||||
NerscField header;
|
||||
FieldMetaData header;
|
||||
|
||||
std::string file("./ckpoint_lat.4000");
|
||||
NerscIO::readConfiguration(Umu,header,file);
|
||||
|
@ -28,212 +28,6 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
/* END LEGAL */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
template <class Gimpl>
|
||||
class FourierAcceleratedGaugeFixer : public Gimpl {
|
||||
public:
|
||||
INHERIT_GIMPL_TYPES(Gimpl);
|
||||
|
||||
typedef typename Gimpl::GaugeLinkField GaugeMat;
|
||||
typedef typename Gimpl::GaugeField GaugeLorentz;
|
||||
|
||||
static void GaugeLinkToLieAlgebraField(const std::vector<GaugeMat> &U,std::vector<GaugeMat> &A) {
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
// ImplComplex cmi(0.0,-1.0);
|
||||
Complex cmi(0.0,-1.0);
|
||||
A[mu] = Ta(U[mu]) * cmi;
|
||||
}
|
||||
}
|
||||
static void DmuAmu(const std::vector<GaugeMat> &A,GaugeMat &dmuAmu) {
|
||||
dmuAmu=zero;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
dmuAmu = dmuAmu + A[mu] - Cshift(A[mu],mu,-1);
|
||||
}
|
||||
}
|
||||
static void SteepestDescentGaugeFix(GaugeLorentz &Umu,Real & alpha,int maxiter,Real Omega_tol, Real Phi_tol) {
|
||||
GridBase *grid = Umu._grid;
|
||||
|
||||
Real org_plaq =WilsonLoops<Gimpl>::avgPlaquette(Umu);
|
||||
Real org_link_trace=WilsonLoops<Gimpl>::linkTrace(Umu);
|
||||
Real old_trace = org_link_trace;
|
||||
Real trG;
|
||||
|
||||
std::vector<GaugeMat> U(Nd,grid);
|
||||
GaugeMat dmuAmu(grid);
|
||||
|
||||
for(int i=0;i<maxiter;i++){
|
||||
for(int mu=0;mu<Nd;mu++) U[mu]= PeekIndex<LorentzIndex>(Umu,mu);
|
||||
//trG = SteepestDescentStep(U,alpha,dmuAmu);
|
||||
trG = FourierAccelSteepestDescentStep(U,alpha,dmuAmu);
|
||||
for(int mu=0;mu<Nd;mu++) PokeIndex<LorentzIndex>(Umu,U[mu],mu);
|
||||
// Monitor progress and convergence test
|
||||
// infrequently to minimise cost overhead
|
||||
if ( i %20 == 0 ) {
|
||||
Real plaq =WilsonLoops<Gimpl>::avgPlaquette(Umu);
|
||||
Real link_trace=WilsonLoops<Gimpl>::linkTrace(Umu);
|
||||
|
||||
std::cout << GridLogMessage << " Iteration "<<i<< " plaq= "<<plaq<< " dmuAmu " << norm2(dmuAmu)<< std::endl;
|
||||
|
||||
Real Phi = 1.0 - old_trace / link_trace ;
|
||||
Real Omega= 1.0 - trG;
|
||||
|
||||
|
||||
std::cout << GridLogMessage << " Iteration "<<i<< " Phi= "<<Phi<< " Omega= " << Omega<< " trG " << trG <<std::endl;
|
||||
if ( (Omega < Omega_tol) && ( ::fabs(Phi) < Phi_tol) ) {
|
||||
std::cout << GridLogMessage << "Converged ! "<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
old_trace = link_trace;
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
static Real SteepestDescentStep(std::vector<GaugeMat> &U,Real & alpha, GaugeMat & dmuAmu) {
|
||||
GridBase *grid = U[0]._grid;
|
||||
|
||||
std::vector<GaugeMat> A(Nd,grid);
|
||||
GaugeMat g(grid);
|
||||
|
||||
GaugeLinkToLieAlgebraField(U,A);
|
||||
ExpiAlphaDmuAmu(A,g,alpha,dmuAmu);
|
||||
|
||||
|
||||
Real vol = grid->gSites();
|
||||
Real trG = TensorRemove(sum(trace(g))).real()/vol/Nc;
|
||||
|
||||
SU<Nc>::GaugeTransform(U,g);
|
||||
|
||||
return trG;
|
||||
}
|
||||
|
||||
static Real FourierAccelSteepestDescentStep(std::vector<GaugeMat> &U,Real & alpha, GaugeMat & dmuAmu) {
|
||||
|
||||
GridBase *grid = U[0]._grid;
|
||||
|
||||
Real vol = grid->gSites();
|
||||
|
||||
FFT theFFT((GridCartesian *)grid);
|
||||
|
||||
LatticeComplex Fp(grid);
|
||||
LatticeComplex psq(grid); psq=zero;
|
||||
LatticeComplex pmu(grid);
|
||||
LatticeComplex one(grid); one = Complex(1.0,0.0);
|
||||
|
||||
GaugeMat g(grid);
|
||||
GaugeMat dmuAmu_p(grid);
|
||||
std::vector<GaugeMat> A(Nd,grid);
|
||||
|
||||
GaugeLinkToLieAlgebraField(U,A);
|
||||
|
||||
DmuAmu(A,dmuAmu);
|
||||
|
||||
theFFT.FFT_all_dim(dmuAmu_p,dmuAmu,FFT::forward);
|
||||
|
||||
//////////////////////////////////
|
||||
// Work out Fp = psq_max/ psq...
|
||||
//////////////////////////////////
|
||||
std::vector<int> latt_size = grid->GlobalDimensions();
|
||||
std::vector<int> coor(grid->_ndimension,0);
|
||||
for(int mu=0;mu<Nd;mu++) {
|
||||
|
||||
Real TwoPiL = M_PI * 2.0/ latt_size[mu];
|
||||
LatticeCoordinate(pmu,mu);
|
||||
pmu = TwoPiL * pmu ;
|
||||
psq = psq + 4.0*sin(pmu*0.5)*sin(pmu*0.5);
|
||||
}
|
||||
|
||||
Complex psqMax(16.0);
|
||||
Fp = psqMax*one/psq;
|
||||
|
||||
/*
|
||||
static int once;
|
||||
if ( once == 0 ) {
|
||||
std::cout << " Fp " << Fp <<std::endl;
|
||||
once ++;
|
||||
}*/
|
||||
|
||||
pokeSite(TComplex(1.0),Fp,coor);
|
||||
|
||||
dmuAmu_p = dmuAmu_p * Fp;
|
||||
|
||||
theFFT.FFT_all_dim(dmuAmu,dmuAmu_p,FFT::backward);
|
||||
|
||||
GaugeMat ciadmam(grid);
|
||||
Complex cialpha(0.0,-alpha);
|
||||
ciadmam = dmuAmu*cialpha;
|
||||
SU<Nc>::taExp(ciadmam,g);
|
||||
|
||||
Real trG = TensorRemove(sum(trace(g))).real()/vol/Nc;
|
||||
|
||||
SU<Nc>::GaugeTransform(U,g);
|
||||
|
||||
return trG;
|
||||
}
|
||||
|
||||
static void ExpiAlphaDmuAmu(const std::vector<GaugeMat> &A,GaugeMat &g,Real & alpha, GaugeMat &dmuAmu) {
|
||||
GridBase *grid = g._grid;
|
||||
Complex cialpha(0.0,-alpha);
|
||||
GaugeMat ciadmam(grid);
|
||||
DmuAmu(A,dmuAmu);
|
||||
ciadmam = dmuAmu*cialpha;
|
||||
SU<Nc>::taExp(ciadmam,g);
|
||||
}
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////
|
||||
// NB The FT for fields living on links has an extra phase in it
|
||||
// Could add these to the FFT class as a later task since this code
|
||||
// might be reused elsewhere ????
|
||||
////////////////////////////////////////////////////////////////
|
||||
static void InverseFourierTransformAmu(FFT &theFFT,const std::vector<GaugeMat> &Ap,std::vector<GaugeMat> &Ax) {
|
||||
GridBase * grid = theFFT.Grid();
|
||||
std::vector<int> latt_size = grid->GlobalDimensions();
|
||||
|
||||
ComplexField pmu(grid);
|
||||
ComplexField pha(grid);
|
||||
GaugeMat Apha(grid);
|
||||
|
||||
Complex ci(0.0,1.0);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
Real TwoPiL = M_PI * 2.0/ latt_size[mu];
|
||||
LatticeCoordinate(pmu,mu);
|
||||
pmu = TwoPiL * pmu ;
|
||||
pha = exp(pmu * (0.5 *ci)); // e(ipmu/2) since Amu(x+mu/2)
|
||||
|
||||
Apha = Ap[mu] * pha;
|
||||
|
||||
theFFT.FFT_all_dim(Apha,Ax[mu],FFT::backward);
|
||||
}
|
||||
}
|
||||
static void FourierTransformAmu(FFT & theFFT,const std::vector<GaugeMat> &Ax,std::vector<GaugeMat> &Ap) {
|
||||
GridBase * grid = theFFT.Grid();
|
||||
std::vector<int> latt_size = grid->GlobalDimensions();
|
||||
|
||||
ComplexField pmu(grid);
|
||||
ComplexField pha(grid);
|
||||
Complex ci(0.0,1.0);
|
||||
|
||||
// Sign convention for FFTW calls:
|
||||
// A(x)= Sum_p e^ipx A(p) / V
|
||||
// A(p)= Sum_p e^-ipx A(x)
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
Real TwoPiL = M_PI * 2.0/ latt_size[mu];
|
||||
LatticeCoordinate(pmu,mu);
|
||||
pmu = TwoPiL * pmu ;
|
||||
pha = exp(-pmu * (0.5 *ci)); // e(+ipmu/2) since Amu(x+mu/2)
|
||||
|
||||
theFFT.FFT_all_dim(Ax[mu],Ap[mu],FFT::backward);
|
||||
Ap[mu] = Ap[mu] * pha;
|
||||
}
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
@ -264,22 +58,24 @@ int main (int argc, char ** argv)
|
||||
std::cout<< "*****************************************************************" <<std::endl;
|
||||
|
||||
LatticeGaugeField Umu(&GRID);
|
||||
LatticeGaugeField Urnd(&GRID);
|
||||
LatticeGaugeField Uorg(&GRID);
|
||||
LatticeColourMatrix g(&GRID); // Gauge xform
|
||||
|
||||
|
||||
SU3::ColdConfiguration(pRNG,Umu); // Unit gauge
|
||||
Uorg=Umu;
|
||||
Urnd=Umu;
|
||||
|
||||
SU3::RandomGaugeTransform(pRNG,Urnd,g); // Unit gauge
|
||||
|
||||
SU3::RandomGaugeTransform(pRNG,Umu,g); // Unit gauge
|
||||
Real plaq=WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu);
|
||||
std::cout << " Initial plaquette "<<plaq << std::endl;
|
||||
|
||||
|
||||
|
||||
Real alpha=0.1;
|
||||
FourierAcceleratedGaugeFixer<PeriodicGimplR>::SteepestDescentGaugeFix(Umu,alpha,10000,1.0e-10, 1.0e-10);
|
||||
|
||||
Umu = Urnd;
|
||||
FourierAcceleratedGaugeFixer<PeriodicGimplR>::SteepestDescentGaugeFix(Umu,alpha,10000,1.0e-12, 1.0e-12,false);
|
||||
|
||||
plaq=WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu);
|
||||
std::cout << " Final plaquette "<<plaq << std::endl;
|
||||
@ -288,14 +84,28 @@ int main (int argc, char ** argv)
|
||||
std::cout << " Norm Difference "<< norm2(Uorg) << std::endl;
|
||||
|
||||
|
||||
// std::cout<< "*****************************************************************" <<std::endl;
|
||||
// std::cout<< "* Testing Fourier accelerated fixing *" <<std::endl;
|
||||
// std::cout<< "*****************************************************************" <<std::endl;
|
||||
std::cout<< "*****************************************************************" <<std::endl;
|
||||
std::cout<< "* Testing Fourier accelerated fixing *" <<std::endl;
|
||||
std::cout<< "*****************************************************************" <<std::endl;
|
||||
Umu=Urnd;
|
||||
FourierAcceleratedGaugeFixer<PeriodicGimplR>::SteepestDescentGaugeFix(Umu,alpha,10000,1.0e-12, 1.0e-12,true);
|
||||
|
||||
// std::cout<< "*****************************************************************" <<std::endl;
|
||||
// std::cout<< "* Testing non-unit configuration *" <<std::endl;
|
||||
// std::cout<< "*****************************************************************" <<std::endl;
|
||||
plaq=WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu);
|
||||
std::cout << " Final plaquette "<<plaq << std::endl;
|
||||
|
||||
std::cout<< "*****************************************************************" <<std::endl;
|
||||
std::cout<< "* Testing non-unit configuration *" <<std::endl;
|
||||
std::cout<< "*****************************************************************" <<std::endl;
|
||||
|
||||
SU3::HotConfiguration(pRNG,Umu); // Unit gauge
|
||||
|
||||
plaq=WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu);
|
||||
std::cout << " Initial plaquette "<<plaq << std::endl;
|
||||
|
||||
FourierAcceleratedGaugeFixer<PeriodicGimplR>::SteepestDescentGaugeFix(Umu,alpha,10000,1.0e-12, 1.0e-12,true);
|
||||
|
||||
plaq=WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu);
|
||||
std::cout << " Final plaquette "<<plaq << std::endl;
|
||||
|
||||
|
||||
Grid_finalize();
|
||||
|
@ -336,7 +336,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
std::cout << GridLogMessage << "norm cMmat : " << norm2(cMat)
|
||||
<< std::endl;
|
||||
cMat = expMat(cMat, ComplexD(1.0, 0.0));
|
||||
cMat = expMat(cMat,1.0);// ComplexD(1.0, 0.0));
|
||||
std::cout << GridLogMessage << "norm expMat: " << norm2(cMat)
|
||||
<< std::endl;
|
||||
peekSite(cm, cMat, mysite);
|
||||
|
@ -67,7 +67,7 @@ int main (int argc, char ** argv)
|
||||
LatticeFermion err(FGrid);
|
||||
LatticeGaugeField Umu(UGrid);
|
||||
|
||||
NerscField header;
|
||||
FieldMetaData header;
|
||||
std::string file("./ckpoint_lat.400");
|
||||
NerscIO::readConfiguration(Umu,header,file);
|
||||
|
||||
|
@ -133,8 +133,8 @@ int main (int argc, char ** argv)
|
||||
int Nconv;
|
||||
RealD eresid = 1.0e-6;
|
||||
|
||||
ImplicitlyRestartedLanczos<LatticeComplex> IRL(HermOp,X,Nk,Nm,eresid,Nit);
|
||||
ImplicitlyRestartedLanczos<LatticeComplex> ChebyIRL(HermOp,Cheby,Nk,Nm,eresid,Nit);
|
||||
ImplicitlyRestartedLanczos<LatticeComplex> IRL(HermOp,X,Nk,Nk,Nm,eresid,Nit);
|
||||
ImplicitlyRestartedLanczos<LatticeComplex> ChebyIRL(HermOp,Cheby,Nk,Nk,Nm,eresid,Nit);
|
||||
|
||||
LatticeComplex src(grid); gaussian(RNG,src);
|
||||
{
|
||||
|
@ -1,368 +0,0 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: tests/hadrons/Test_hadrons.hpp
|
||||
|
||||
Copyright (C) 2017
|
||||
|
||||
Author: Andrew Lawson <andrew.lawson1991@gmail.com>
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#include <Grid/Hadrons/Application.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
|
||||
/*******************************************************************************
|
||||
* Macros to reduce code duplication.
|
||||
******************************************************************************/
|
||||
// Useful definitions
|
||||
#define ZERO_MOM "0. 0. 0. 0."
|
||||
#define INIT_INDEX(s, n) (std::string(s) + "_" + std::to_string(n))
|
||||
#define ADD_INDEX(s, n) (s + "_" + std::to_string(n))
|
||||
#define LABEL_3PT(s, t1, t2) ADD_INDEX(INIT_INDEX(s, t1), t2)
|
||||
#define LABEL_4PT(s, t1, t2, t3) ADD_INDEX(ADD_INDEX(INIT_INDEX(s, t1), t2), t3)
|
||||
#define LABEL_4PT_NOISE(s, t1, t2, t3, nn) ADD_INDEX(ADD_INDEX(ADD_INDEX(INIT_INDEX(s, t1), t2), t3), nn)
|
||||
|
||||
// Wall source/sink macros
|
||||
#define NAME_3MOM_WALL_SOURCE(t, mom) ("wall_" + std::to_string(t) + "_" + mom)
|
||||
#define NAME_WALL_SOURCE(t) NAME_3MOM_WALL_SOURCE(t, ZERO_MOM)
|
||||
#define NAME_POINT_SOURCE(pos) ("point_" + pos)
|
||||
|
||||
#define MAKE_3MOM_WALL_PROP(tW, mom, propName, solver)\
|
||||
{\
|
||||
std::string srcName = NAME_3MOM_WALL_SOURCE(tW, mom);\
|
||||
makeWallSource(application, srcName, tW, mom);\
|
||||
makePropagator(application, propName, srcName, solver);\
|
||||
}
|
||||
|
||||
#define MAKE_WALL_PROP(tW, propName, solver)\
|
||||
MAKE_3MOM_WALL_PROP(tW, ZERO_MOM, propName, solver)
|
||||
|
||||
// Sequential source macros
|
||||
#define MAKE_SEQUENTIAL_PROP(tS, qSrc, mom, propName, solver)\
|
||||
{\
|
||||
std::string srcName = ADD_INDEX(qSrc + "_seq", tS);\
|
||||
makeSequentialSource(application, srcName, qSrc, tS, mom);\
|
||||
makePropagator(application, propName, srcName, solver);\
|
||||
}
|
||||
|
||||
// Point source macros
|
||||
#define MAKE_POINT_PROP(pos, propName, solver)\
|
||||
{\
|
||||
std::string srcName = NAME_POINT_SOURCE(pos);\
|
||||
makePointSource(application, srcName, pos);\
|
||||
makePropagator(application, propName, srcName, solver);\
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Functions for propagator construction.
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Name: makePointSource
|
||||
* Purpose: Construct point source and add to application module.
|
||||
* Parameters: application - main application that stores modules.
|
||||
* srcName - name of source module to create.
|
||||
* pos - Position of point source.
|
||||
* Returns: None.
|
||||
******************************************************************************/
|
||||
inline void makePointSource(Application &application, std::string srcName,
|
||||
std::string pos)
|
||||
{
|
||||
// If the source already exists, don't make the module again.
|
||||
if (!(Environment::getInstance().hasModule(srcName)))
|
||||
{
|
||||
MSource::Point::Par pointPar;
|
||||
pointPar.position = pos;
|
||||
application.createModule<MSource::Point>(srcName, pointPar);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Name: makeSequentialSource
|
||||
* Purpose: Construct sequential source and add to application module.
|
||||
* Parameters: application - main application that stores modules.
|
||||
* srcName - name of source module to create.
|
||||
* qSrc - Input quark for sequential inversion.
|
||||
* tS - sequential source timeslice.
|
||||
* mom - momentum insertion (default is zero).
|
||||
* Returns: None.
|
||||
******************************************************************************/
|
||||
inline void makeSequentialSource(Application &application, std::string srcName,
|
||||
std::string qSrc, unsigned int tS,
|
||||
std::string mom = ZERO_MOM)
|
||||
{
|
||||
// If the source already exists, don't make the module again.
|
||||
if (!(Environment::getInstance().hasModule(srcName)))
|
||||
{
|
||||
MSource::SeqGamma::Par seqPar;
|
||||
seqPar.q = qSrc;
|
||||
seqPar.tA = tS;
|
||||
seqPar.tB = tS;
|
||||
seqPar.mom = mom;
|
||||
seqPar.gamma = Gamma::Algebra::GammaT;
|
||||
application.createModule<MSource::SeqGamma>(srcName, seqPar);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Name: makeWallSource
|
||||
* Purpose: Construct wall source and add to application module.
|
||||
* Parameters: application - main application that stores modules.
|
||||
* srcName - name of source module to create.
|
||||
* tW - wall source timeslice.
|
||||
* mom - momentum insertion (default is zero).
|
||||
* Returns: None.
|
||||
******************************************************************************/
|
||||
inline void makeWallSource(Application &application, std::string srcName,
|
||||
unsigned int tW, std::string mom = ZERO_MOM)
|
||||
{
|
||||
// If the source already exists, don't make the module again.
|
||||
if (!(Environment::getInstance().hasModule(srcName)))
|
||||
{
|
||||
MSource::Wall::Par wallPar;
|
||||
wallPar.tW = tW;
|
||||
wallPar.mom = mom;
|
||||
application.createModule<MSource::Wall>(srcName, wallPar);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Name: makeWallSink
|
||||
* Purpose: Wall sink smearing of a propagator.
|
||||
* Parameters: application - main application that stores modules.
|
||||
* propName - name of input propagator.
|
||||
* wallName - name of smeared propagator.
|
||||
* mom - momentum insertion (default is zero).
|
||||
* Returns: None.
|
||||
******************************************************************************/
|
||||
inline void makeWallSink(Application &application, std::string propName,
|
||||
std::string wallName, std::string mom = ZERO_MOM)
|
||||
{
|
||||
// If the propagator has already been smeared, don't smear it again.
|
||||
// Temporarily removed, strategy for sink smearing likely to change.
|
||||
/*if (!(Environment::getInstance().hasModule(wallName)))
|
||||
{
|
||||
MSink::Wall::Par wallPar;
|
||||
wallPar.q = propName;
|
||||
wallPar.mom = mom;
|
||||
application.createModule<MSink::Wall>(wallName, wallPar);
|
||||
}*/
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Name: makePropagator
|
||||
* Purpose: Construct source and propagator then add to application module.
|
||||
* Parameters: application - main application that stores modules.
|
||||
* propName - name of propagator module to create.
|
||||
* srcName - name of source module to use.
|
||||
* solver - solver to use (default is CG).
|
||||
* Returns: None.
|
||||
******************************************************************************/
|
||||
inline void makePropagator(Application &application, std::string &propName,
|
||||
std::string &srcName, std::string &solver)
|
||||
{
|
||||
// If the propagator already exists, don't make the module again.
|
||||
if (!(Environment::getInstance().hasModule(propName)))
|
||||
{
|
||||
Quark::Par quarkPar;
|
||||
quarkPar.source = srcName;
|
||||
quarkPar.solver = solver;
|
||||
application.createModule<Quark>(propName, quarkPar);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Name: makeLoop
|
||||
* Purpose: Use noise source and inversion result to make loop propagator, then
|
||||
* add to application module.
|
||||
* Parameters: application - main application that stores modules.
|
||||
* propName - name of propagator module to create.
|
||||
* srcName - name of noise source module to use.
|
||||
* resName - name of inversion result on given noise source.
|
||||
* Returns: None.
|
||||
******************************************************************************/
|
||||
inline void makeLoop(Application &application, std::string &propName,
|
||||
std::string &srcName, std::string &resName)
|
||||
{
|
||||
// If the loop propagator already exists, don't make the module again.
|
||||
if (!(Environment::getInstance().hasModule(propName)))
|
||||
{
|
||||
MLoop::NoiseLoop::Par loopPar;
|
||||
loopPar.q = resName;
|
||||
loopPar.eta = srcName;
|
||||
application.createModule<MLoop::NoiseLoop>(propName, loopPar);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Contraction module creation.
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Name: mesonContraction
|
||||
* Purpose: Create meson contraction module and add to application module.
|
||||
* Parameters: application - main application that stores modules.
|
||||
* npt - specify n-point correlator (for labelling).
|
||||
* q1 - quark propagator 1.
|
||||
* q2 - quark propagator 2.
|
||||
* label - unique label to construct module name.
|
||||
* mom - momentum to project (default is zero)
|
||||
* gammas - gamma insertions at source and sink.
|
||||
* Returns: None.
|
||||
******************************************************************************/
|
||||
inline void mesonContraction(Application &application, unsigned int npt,
|
||||
std::string &q1, std::string &q2,
|
||||
std::string &label,
|
||||
std::string mom = ZERO_MOM,
|
||||
std::string gammas = "<Gamma5 Gamma5>")
|
||||
{
|
||||
std::string modName = std::to_string(npt) + "pt_" + label;
|
||||
if (!(Environment::getInstance().hasModule(modName)))
|
||||
{
|
||||
MContraction::Meson::Par mesPar;
|
||||
mesPar.output = std::to_string(npt) + "pt/" + label;
|
||||
mesPar.q1 = q1;
|
||||
mesPar.q2 = q2;
|
||||
mesPar.mom = mom;
|
||||
mesPar.gammas = gammas;
|
||||
application.createModule<MContraction::Meson>(modName, mesPar);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Name: gamma3ptContraction
|
||||
* Purpose: Create gamma3pt contraction module and add to application module.
|
||||
* Parameters: application - main application that stores modules.
|
||||
* npt - specify n-point correlator (for labelling).
|
||||
* q1 - quark propagator 1.
|
||||
* q2 - quark propagator 2.
|
||||
* q3 - quark propagator 3.
|
||||
* label - unique label to construct module name.
|
||||
* gamma - gamma insertions between q2 and q3.
|
||||
* Returns: None.
|
||||
******************************************************************************/
|
||||
inline void gamma3ptContraction(Application &application, unsigned int npt,
|
||||
std::string &q1, std::string &q2,
|
||||
std::string &q3, std::string &label,
|
||||
Gamma::Algebra gamma = Gamma::Algebra::Identity)
|
||||
{
|
||||
std::string modName = std::to_string(npt) + "pt_" + label;
|
||||
if (!(Environment::getInstance().hasModule(modName)))
|
||||
{
|
||||
MContraction::Gamma3pt::Par gamma3ptPar;
|
||||
gamma3ptPar.output = std::to_string(npt) + "pt/" + label;
|
||||
gamma3ptPar.q1 = q1;
|
||||
gamma3ptPar.q2 = q2;
|
||||
gamma3ptPar.q3 = q3;
|
||||
gamma3ptPar.gamma = gamma;
|
||||
application.createModule<MContraction::Gamma3pt>(modName, gamma3ptPar);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Name: weakContraction[Eye,NonEye]
|
||||
* Purpose: Create Weak Hamiltonian contraction module for Eye/NonEye topology
|
||||
* and add to application module.
|
||||
* Parameters: application - main application that stores modules.
|
||||
* npt - specify n-point correlator (for labelling).
|
||||
* q1 - quark propagator 1.
|
||||
* q2 - quark propagator 2.
|
||||
* q3 - quark propagator 3.
|
||||
* q4 - quark propagator 4.
|
||||
* label - unique label to construct module name.
|
||||
* Returns: None.
|
||||
******************************************************************************/
|
||||
#define HW_CONTRACTION(top) \
|
||||
inline void weakContraction##top(Application &application, unsigned int npt,\
|
||||
std::string &q1, std::string &q2, \
|
||||
std::string &q3, std::string &q4, \
|
||||
std::string &label)\
|
||||
{\
|
||||
std::string modName = std::to_string(npt) + "pt_" + label;\
|
||||
if (!(Environment::getInstance().hasModule(modName)))\
|
||||
{\
|
||||
MContraction::WeakHamiltonian##top::Par weakPar;\
|
||||
weakPar.output = std::to_string(npt) + "pt/" + label;\
|
||||
weakPar.q1 = q1;\
|
||||
weakPar.q2 = q2;\
|
||||
weakPar.q3 = q3;\
|
||||
weakPar.q4 = q4;\
|
||||
application.createModule<MContraction::WeakHamiltonian##top>(modName, weakPar);\
|
||||
}\
|
||||
}
|
||||
HW_CONTRACTION(Eye) // weakContractionEye
|
||||
HW_CONTRACTION(NonEye) // weakContractionNonEye
|
||||
|
||||
/*******************************************************************************
|
||||
* Name: disc0Contraction
|
||||
* Purpose: Create contraction module for 4pt Weak Hamiltonian + current
|
||||
* disconnected topology for neutral mesons and add to application
|
||||
* module.
|
||||
* Parameters: application - main application that stores modules.
|
||||
* q1 - quark propagator 1.
|
||||
* q2 - quark propagator 2.
|
||||
* q3 - quark propagator 3.
|
||||
* q4 - quark propagator 4.
|
||||
* label - unique label to construct module name.
|
||||
* Returns: None.
|
||||
******************************************************************************/
|
||||
inline void disc0Contraction(Application &application,
|
||||
std::string &q1, std::string &q2,
|
||||
std::string &q3, std::string &q4,
|
||||
std::string &label)
|
||||
{
|
||||
std::string modName = "4pt_" + label;
|
||||
if (!(Environment::getInstance().hasModule(modName)))
|
||||
{
|
||||
MContraction::WeakNeutral4ptDisc::Par disc0Par;
|
||||
disc0Par.output = "4pt/" + label;
|
||||
disc0Par.q1 = q1;
|
||||
disc0Par.q2 = q2;
|
||||
disc0Par.q3 = q3;
|
||||
disc0Par.q4 = q4;
|
||||
application.createModule<MContraction::WeakNeutral4ptDisc>(modName, disc0Par);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Name: discLoopContraction
|
||||
* Purpose: Create contraction module for disconnected loop and add to
|
||||
* application module.
|
||||
* Parameters: application - main application that stores modules.
|
||||
* q_loop - loop quark propagator.
|
||||
* modName - unique module name.
|
||||
* gamma - gamma matrix to use in contraction.
|
||||
* Returns: None.
|
||||
******************************************************************************/
|
||||
inline void discLoopContraction(Application &application,
|
||||
std::string &q_loop, std::string &modName,
|
||||
Gamma::Algebra gamma = Gamma::Algebra::Identity)
|
||||
{
|
||||
if (!(Environment::getInstance().hasModule(modName)))
|
||||
{
|
||||
MContraction::DiscLoop::Par discPar;
|
||||
discPar.output = "disc/" + modName;
|
||||
discPar.q_loop = q_loop;
|
||||
discPar.gamma = gamma;
|
||||
application.createModule<MContraction::DiscLoop>(modName, discPar);
|
||||
}
|
||||
}
|
@ -65,6 +65,10 @@ int main(int argc, char *argv[])
|
||||
// set fermion boundary conditions to be periodic space, antiperiodic time.
|
||||
std::string boundary = "1 1 1 -1";
|
||||
|
||||
// sink
|
||||
MSink::Point::Par sinkPar;
|
||||
sinkPar.mom = "0 0 0";
|
||||
application.createModule<MSink::ScalarPoint>("sink", sinkPar);
|
||||
for (unsigned int i = 0; i < flavour.size(); ++i)
|
||||
{
|
||||
// actions
|
||||
@ -115,15 +119,15 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// propagators
|
||||
Quark::Par quarkPar;
|
||||
MFermion::GaugeProp::Par quarkPar;
|
||||
quarkPar.solver = "CG_" + flavour[i];
|
||||
quarkPar.source = srcName;
|
||||
application.createModule<Quark>(qName[i], quarkPar);
|
||||
application.createModule<MFermion::GaugeProp>(qName[i], quarkPar);
|
||||
for (unsigned int mu = 0; mu < Nd; ++mu)
|
||||
{
|
||||
quarkPar.source = seqName[i][mu];
|
||||
seqName[i][mu] = "Q_" + flavour[i] + "-" + seqName[i][mu];
|
||||
application.createModule<Quark>(seqName[i][mu], quarkPar);
|
||||
application.createModule<MFermion::GaugeProp>(seqName[i][mu], quarkPar);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +140,7 @@ int main(int argc, char *argv[])
|
||||
mesPar.q1 = qName[i];
|
||||
mesPar.q2 = qName[j];
|
||||
mesPar.gammas = "all";
|
||||
mesPar.mom = "0. 0. 0. 0.";
|
||||
mesPar.sink = "sink";
|
||||
application.createModule<MContraction::Meson>("meson_Z2_"
|
||||
+ std::to_string(t)
|
||||
+ "_"
|
||||
@ -155,7 +159,7 @@ int main(int argc, char *argv[])
|
||||
mesPar.q1 = qName[i];
|
||||
mesPar.q2 = seqName[j][mu];
|
||||
mesPar.gammas = "all";
|
||||
mesPar.mom = "0. 0. 0. 0.";
|
||||
mesPar.sink = "sink";
|
||||
application.createModule<MContraction::Meson>("3pt_Z2_"
|
||||
+ std::to_string(t)
|
||||
+ "_"
|
||||
|
@ -1,342 +0,0 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: tests/hadrons/Test_hadrons_rarekaon.cc
|
||||
|
||||
Copyright (C) 2017
|
||||
|
||||
Author: Andrew Lawson <andrew.lawson1991@gmail.com>
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "Test_hadrons.hpp"
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
|
||||
enum quarks
|
||||
{
|
||||
light = 0,
|
||||
strange = 1,
|
||||
charm = 2
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// parse command line //////////////////////////////////////////////////////
|
||||
std::string configStem;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
std::cerr << "usage: " << argv[0] << " <configuration filestem> [Grid options]";
|
||||
std::cerr << std::endl;
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
configStem = argv[1];
|
||||
|
||||
// initialization //////////////////////////////////////////////////////////
|
||||
Grid_init(&argc, &argv);
|
||||
HadronsLogError.Active(GridLogError.isActive());
|
||||
HadronsLogWarning.Active(GridLogWarning.isActive());
|
||||
HadronsLogMessage.Active(GridLogMessage.isActive());
|
||||
HadronsLogIterative.Active(GridLogIterative.isActive());
|
||||
HadronsLogDebug.Active(GridLogDebug.isActive());
|
||||
LOG(Message) << "Grid initialized" << std::endl;
|
||||
|
||||
// run setup ///////////////////////////////////////////////////////////////
|
||||
Application application;
|
||||
std::vector<double> mass = {.01, .04, .2};
|
||||
std::vector<std::string> flavour = {"l", "s", "c"};
|
||||
std::vector<std::string> solvers = {"CG_l", "CG_s", "CG_c"};
|
||||
std::string kmom = "0. 0. 0. 0.";
|
||||
std::string pmom = "1. 0. 0. 0.";
|
||||
std::string qmom = "-1. 0. 0. 0.";
|
||||
std::string mqmom = "1. 0. 0. 0.";
|
||||
std::vector<unsigned int> tKs = {0};
|
||||
unsigned int dt_pi = 16;
|
||||
std::vector<unsigned int> tJs = {8};
|
||||
unsigned int n_noise = 1;
|
||||
unsigned int nt = 32;
|
||||
bool do_disconnected(false);
|
||||
|
||||
// Global parameters.
|
||||
Application::GlobalPar globalPar;
|
||||
globalPar.trajCounter.start = 1500;
|
||||
globalPar.trajCounter.end = 1520;
|
||||
globalPar.trajCounter.step = 20;
|
||||
globalPar.seed = "1 2 3 4";
|
||||
globalPar.genetic.maxGen = 1000;
|
||||
globalPar.genetic.maxCstGen = 200;
|
||||
globalPar.genetic.popSize = 20;
|
||||
globalPar.genetic.mutationRate = .1;
|
||||
application.setPar(globalPar);
|
||||
|
||||
// gauge field
|
||||
if (configStem == "None")
|
||||
{
|
||||
application.createModule<MGauge::Unit>("gauge");
|
||||
}
|
||||
else
|
||||
{
|
||||
MGauge::Load::Par gaugePar;
|
||||
gaugePar.file = configStem;
|
||||
application.createModule<MGauge::Load>("gauge", gaugePar);
|
||||
}
|
||||
|
||||
// set fermion boundary conditions to be periodic space, antiperiodic time.
|
||||
std::string boundary = "1 1 1 -1";
|
||||
|
||||
for (unsigned int i = 0; i < flavour.size(); ++i)
|
||||
{
|
||||
// actions
|
||||
MAction::DWF::Par actionPar;
|
||||
actionPar.gauge = "gauge";
|
||||
actionPar.Ls = 16;
|
||||
actionPar.M5 = 1.8;
|
||||
actionPar.mass = mass[i];
|
||||
actionPar.boundary = boundary;
|
||||
application.createModule<MAction::DWF>("DWF_" + flavour[i], actionPar);
|
||||
|
||||
// solvers
|
||||
// RBPrecCG -> CG
|
||||
MSolver::RBPrecCG::Par solverPar;
|
||||
solverPar.action = "DWF_" + flavour[i];
|
||||
solverPar.residual = 1.0e-8;
|
||||
application.createModule<MSolver::RBPrecCG>(solvers[i],
|
||||
solverPar);
|
||||
}
|
||||
|
||||
// Create noise propagators for loops.
|
||||
std::vector<std::string> noiseSrcs;
|
||||
std::vector<std::vector<std::string>> noiseRes;
|
||||
std::vector<std::vector<std::string>> noiseProps;
|
||||
if (n_noise > 0)
|
||||
{
|
||||
MSource::Z2::Par noisePar;
|
||||
noisePar.tA = 0;
|
||||
noisePar.tB = nt - 1;
|
||||
std::string loop_stem = "loop_";
|
||||
|
||||
noiseRes.resize(flavour.size());
|
||||
noiseProps.resize(flavour.size());
|
||||
for (unsigned int nn = 0; nn < n_noise; ++nn)
|
||||
{
|
||||
std::string eta = INIT_INDEX("noise", nn);
|
||||
application.createModule<MSource::Z2>(eta, noisePar);
|
||||
noiseSrcs.push_back(eta);
|
||||
|
||||
for (unsigned int f = 0; f < flavour.size(); ++f)
|
||||
{
|
||||
std::string loop_prop = INIT_INDEX(loop_stem + flavour[f], nn);
|
||||
std::string loop_res = loop_prop + "_res";
|
||||
makePropagator(application, loop_res, eta, solvers[f]);
|
||||
makeLoop(application, loop_prop, eta, loop_res);
|
||||
noiseRes[f].push_back(loop_res);
|
||||
noiseProps[f].push_back(loop_prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Translate rare kaon decay across specified timeslices.
|
||||
for (unsigned int i = 0; i < tKs.size(); ++i)
|
||||
{
|
||||
// Zero-momentum wall source propagators for kaon and pion.
|
||||
unsigned int tK = tKs[i];
|
||||
unsigned int tpi = (tK + dt_pi) % nt;
|
||||
std::string q_Kl_0 = INIT_INDEX("Q_l_0", tK);
|
||||
std::string q_pil_0 = INIT_INDEX("Q_l_0", tpi);
|
||||
MAKE_WALL_PROP(tK, q_Kl_0, solvers[light]);
|
||||
MAKE_WALL_PROP(tpi, q_pil_0, solvers[light]);
|
||||
|
||||
// Wall sources for kaon and pion with momentum insertion. If either
|
||||
// p or k are zero, or p = k, re-use the existing name to avoid
|
||||
// duplicating a propagator.
|
||||
std::string q_Ks_k = INIT_INDEX("Q_Ks_k", tK);
|
||||
std::string q_Ks_p = INIT_INDEX((kmom == pmom) ? "Q_Ks_k" : "Q_Ks_p", tK);
|
||||
std::string q_pil_k = INIT_INDEX((kmom == ZERO_MOM) ? "Q_l_0" : "Q_l_k", tpi);
|
||||
std::string q_pil_p = INIT_INDEX((pmom == kmom) ? q_pil_k : ((pmom == ZERO_MOM) ? "Q_l_0" : "Q_l_p"), tpi);
|
||||
MAKE_3MOM_WALL_PROP(tK, kmom, q_Ks_k, solvers[strange]);
|
||||
MAKE_3MOM_WALL_PROP(tK, pmom, q_Ks_p, solvers[strange]);
|
||||
MAKE_3MOM_WALL_PROP(tpi, kmom, q_pil_k, solvers[light]);
|
||||
MAKE_3MOM_WALL_PROP(tpi, pmom, q_pil_p, solvers[light]);
|
||||
|
||||
/***********************************************************************
|
||||
* CONTRACTIONS: pi and K 2pt contractions with mom = p, k.
|
||||
**********************************************************************/
|
||||
// Wall-Point
|
||||
std::string PW_K_k = INIT_INDEX("PW_K_k", tK);
|
||||
std::string PW_K_p = INIT_INDEX("PW_K_p", tK);
|
||||
std::string PW_pi_k = INIT_INDEX("PW_pi_k", tpi);
|
||||
std::string PW_pi_p = INIT_INDEX("PW_pi_p", tpi);
|
||||
mesonContraction(application, 2, q_Kl_0, q_Ks_k, PW_K_k, kmom);
|
||||
mesonContraction(application, 2, q_Kl_0, q_Ks_p, PW_K_p, pmom);
|
||||
mesonContraction(application, 2, q_pil_k, q_pil_0, PW_pi_k, kmom);
|
||||
mesonContraction(application, 2, q_pil_p, q_pil_0, PW_pi_p, pmom);
|
||||
// Wall-Wall, to be done - requires modification of meson module.
|
||||
|
||||
/***********************************************************************
|
||||
* CONTRACTIONS: 3pt Weak Hamiltonian, C & W (non-Eye type) classes.
|
||||
**********************************************************************/
|
||||
std::string HW_CW_k = LABEL_3PT("HW_CW_k", tK, tpi);
|
||||
std::string HW_CW_p = LABEL_3PT("HW_CW_p", tK, tpi);
|
||||
weakContractionNonEye(application, 3, q_Kl_0, q_Ks_k, q_pil_k, q_pil_0, HW_CW_k);
|
||||
weakContractionNonEye(application, 3, q_Kl_0, q_Ks_p, q_pil_p, q_pil_0, HW_CW_p);
|
||||
|
||||
/***********************************************************************
|
||||
* CONTRACTIONS: 3pt sd insertion.
|
||||
**********************************************************************/
|
||||
// Note: eventually will use wall sink smeared q_Kl_0 instead.
|
||||
std::string sd_k = LABEL_3PT("sd_k", tK, tpi);
|
||||
std::string sd_p = LABEL_3PT("sd_p", tK, tpi);
|
||||
gamma3ptContraction(application, 3, q_Kl_0, q_Ks_k, q_pil_k, sd_k);
|
||||
gamma3ptContraction(application, 3, q_Kl_0, q_Ks_p, q_pil_p, sd_p);
|
||||
|
||||
for (unsigned int nn = 0; nn < n_noise; ++nn)
|
||||
{
|
||||
/*******************************************************************
|
||||
* CONTRACTIONS: 3pt Weak Hamiltonian, S and E (Eye type) classes.
|
||||
******************************************************************/
|
||||
// Note: eventually will use wall sink smeared q_Kl_0 instead.
|
||||
for (unsigned int f = 0; f < flavour.size(); ++f)
|
||||
{
|
||||
if ((f != strange) || do_disconnected)
|
||||
{
|
||||
std::string HW_SE_k = LABEL_3PT("HW_SE_k_" + flavour[f], tK, tpi);
|
||||
std::string HW_SE_p = LABEL_3PT("HW_SE_p_" + flavour[f], tK, tpi);
|
||||
std::string loop_q = noiseProps[f][nn];
|
||||
weakContractionEye(application, 3, q_Kl_0, q_Ks_k, q_pil_k, loop_q, HW_CW_k);
|
||||
weakContractionEye(application, 3, q_Kl_0, q_Ks_p, q_pil_p, loop_q, HW_CW_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Perform separate contractions for each t_J position.
|
||||
for (unsigned int j = 0; j < tJs.size(); ++j)
|
||||
{
|
||||
// Sequential sources for current insertions. Local for now,
|
||||
// gamma_0 only.
|
||||
unsigned int tJ = (tJs[j] + tK) % nt;
|
||||
MSource::SeqGamma::Par seqPar;
|
||||
std::string q_KlCl_q = LABEL_3PT("Q_KlCl_q", tK, tJ);
|
||||
std::string q_KsCs_mq = LABEL_3PT("Q_KsCs_mq", tK, tJ);
|
||||
std::string q_pilCl_q = LABEL_3PT("Q_pilCl_q", tpi, tJ);
|
||||
std::string q_pilCl_mq = LABEL_3PT("Q_pilCl_mq", tpi, tJ);
|
||||
MAKE_SEQUENTIAL_PROP(tJ, q_Kl_0, qmom, q_KlCl_q, solvers[light]);
|
||||
MAKE_SEQUENTIAL_PROP(tJ, q_Ks_k, mqmom, q_KsCs_mq, solvers[strange]);
|
||||
MAKE_SEQUENTIAL_PROP(tJ, q_pil_p, qmom, q_pilCl_q, solvers[light]);
|
||||
MAKE_SEQUENTIAL_PROP(tJ, q_pil_0, mqmom, q_pilCl_mq, solvers[light]);
|
||||
|
||||
/*******************************************************************
|
||||
* CONTRACTIONS: pi and K 3pt contractions with current insertion.
|
||||
******************************************************************/
|
||||
// Wall-Point
|
||||
std::string C_PW_Kl = LABEL_3PT("C_PW_Kl", tK, tJ);
|
||||
std::string C_PW_Ksb = LABEL_3PT("C_PW_Ksb", tK, tJ);
|
||||
std::string C_PW_pilb = LABEL_3PT("C_PW_pilb", tK, tJ);
|
||||
std::string C_PW_pil = LABEL_3PT("C_PW_pil", tK, tJ);
|
||||
mesonContraction(application, 3, q_KlCl_q, q_Ks_k, C_PW_Kl, pmom);
|
||||
mesonContraction(application, 3, q_Kl_0, q_KsCs_mq, C_PW_Ksb, pmom);
|
||||
mesonContraction(application, 3, q_pil_0, q_pilCl_q, C_PW_pilb, kmom);
|
||||
mesonContraction(application, 3, q_pilCl_mq, q_pil_p, C_PW_pil, kmom);
|
||||
// Wall-Wall, to be done.
|
||||
|
||||
/*******************************************************************
|
||||
* CONTRACTIONS: 4pt contractions, C & W classes.
|
||||
******************************************************************/
|
||||
std::string CW_Kl = LABEL_4PT("CW_Kl", tK, tJ, tpi);
|
||||
std::string CW_Ksb = LABEL_4PT("CW_Ksb", tK, tJ, tpi);
|
||||
std::string CW_pilb = LABEL_4PT("CW_pilb", tK, tJ, tpi);
|
||||
std::string CW_pil = LABEL_4PT("CW_pil", tK, tJ, tpi);
|
||||
weakContractionNonEye(application, 4, q_KlCl_q, q_Ks_k, q_pil_p, q_pil_0, CW_Kl);
|
||||
weakContractionNonEye(application, 4, q_Kl_0, q_KsCs_mq, q_pil_p, q_pil_0, CW_Ksb);
|
||||
weakContractionNonEye(application, 4, q_Kl_0, q_Ks_k, q_pilCl_q, q_pil_0, CW_pilb);
|
||||
weakContractionNonEye(application, 4, q_Kl_0, q_Ks_k, q_pil_p, q_pilCl_mq, CW_pil);
|
||||
|
||||
/*******************************************************************
|
||||
* CONTRACTIONS: 4pt contractions, sd insertions.
|
||||
******************************************************************/
|
||||
// Note: eventually will use wall sink smeared q_Kl_0/q_KlCl_q instead.
|
||||
std::string sd_Kl = LABEL_4PT("sd_Kl", tK, tJ, tpi);
|
||||
std::string sd_Ksb = LABEL_4PT("sd_Ksb", tK, tJ, tpi);
|
||||
std::string sd_pilb = LABEL_4PT("sd_pilb", tK, tJ, tpi);
|
||||
gamma3ptContraction(application, 4, q_KlCl_q, q_Ks_k, q_pil_p, sd_Kl);
|
||||
gamma3ptContraction(application, 4, q_Kl_0, q_KsCs_mq, q_pil_p, sd_Ksb);
|
||||
gamma3ptContraction(application, 4, q_Kl_0, q_Ks_k, q_pilCl_q, sd_pilb);
|
||||
|
||||
// Sequential sources for each noise propagator.
|
||||
for (unsigned int nn = 0; nn < n_noise; ++nn)
|
||||
{
|
||||
std::string loop_stem = "loop_";
|
||||
|
||||
// Contraction required for each quark flavour - alternatively
|
||||
// drop the strange loop if not performing disconnected
|
||||
// contractions or neglecting H_W operators Q_3 -> Q_10.
|
||||
for (unsigned int f = 0; f < flavour.size(); ++f)
|
||||
{
|
||||
if ((f != strange) || do_disconnected)
|
||||
{
|
||||
std::string eta = noiseSrcs[nn];
|
||||
std::string loop_q = noiseProps[f][nn];
|
||||
std::string loop_qCq = LABEL_3PT(loop_stem + flavour[f], tJ, nn);
|
||||
std::string loop_qCq_res = loop_qCq + "_res";
|
||||
MAKE_SEQUENTIAL_PROP(tJ, noiseRes[f][nn], qmom,
|
||||
loop_qCq_res, solvers[f]);
|
||||
makeLoop(application, loop_qCq, eta, loop_qCq_res);
|
||||
|
||||
/*******************************************************
|
||||
* CONTRACTIONS: 4pt contractions, S & E classes.
|
||||
******************************************************/
|
||||
// Note: eventually will use wall sink smeared q_Kl_0/q_KlCl_q instead.
|
||||
std::string SE_Kl = LABEL_4PT_NOISE("SE_Kl", tK, tJ, tpi, nn);
|
||||
std::string SE_Ksb = LABEL_4PT_NOISE("SE_Ksb", tK, tJ, tpi, nn);
|
||||
std::string SE_pilb = LABEL_4PT_NOISE("SE_pilb", tK, tJ, tpi, nn);
|
||||
std::string SE_loop = LABEL_4PT_NOISE("SE_loop", tK, tJ, tpi, nn);
|
||||
weakContractionEye(application, 4, q_KlCl_q, q_Ks_k, q_pil_p, loop_q, SE_Kl);
|
||||
weakContractionEye(application, 4, q_Kl_0, q_KsCs_mq, q_pil_p, loop_q, SE_Ksb);
|
||||
weakContractionEye(application, 4, q_Kl_0, q_Ks_k, q_pilCl_q, loop_q, SE_pilb);
|
||||
weakContractionEye(application, 4, q_Kl_0, q_Ks_k, q_pil_p, loop_qCq, SE_loop);
|
||||
|
||||
/*******************************************************
|
||||
* CONTRACTIONS: 4pt contractions, pi0 disconnected
|
||||
* loop.
|
||||
******************************************************/
|
||||
std::string disc0 = LABEL_4PT_NOISE("disc0", tK, tJ, tpi, nn);
|
||||
disc0Contraction(application, q_Kl_0, q_Ks_k, q_pilCl_q, loop_q, disc0);
|
||||
|
||||
/*******************************************************
|
||||
* CONTRACTIONS: Disconnected loop.
|
||||
******************************************************/
|
||||
std::string discLoop = "disc_" + loop_qCq;
|
||||
discLoopContraction(application, loop_qCq, discLoop);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// execution
|
||||
std::string par_file_name = "rarekaon_000_100_tK0_tpi16_tJ8_noloop_mc0.2.xml";
|
||||
application.saveParameterFile(par_file_name);
|
||||
application.run();
|
||||
|
||||
// epilogue
|
||||
LOG(Message) << "Grid is finalizing now" << std::endl;
|
||||
Grid_finalize();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -63,6 +63,10 @@ int main(int argc, char *argv[])
|
||||
MSource::Point::Par ptPar;
|
||||
ptPar.position = "0 0 0 0";
|
||||
application.createModule<MSource::Point>("pt", ptPar);
|
||||
// sink
|
||||
MSink::Point::Par sinkPar;
|
||||
sinkPar.mom = "0 0 0";
|
||||
application.createModule<MSink::ScalarPoint>("sink", sinkPar);
|
||||
|
||||
// set fermion boundary conditions to be periodic space, antiperiodic time.
|
||||
std::string boundary = "1 1 1 -1";
|
||||
@ -86,31 +90,31 @@ int main(int argc, char *argv[])
|
||||
solverPar);
|
||||
|
||||
// propagators
|
||||
Quark::Par quarkPar;
|
||||
MFermion::GaugeProp::Par quarkPar;
|
||||
quarkPar.solver = "CG_" + flavour[i];
|
||||
quarkPar.source = "pt";
|
||||
application.createModule<Quark>("Qpt_" + flavour[i], quarkPar);
|
||||
application.createModule<MFermion::GaugeProp>("Qpt_" + flavour[i], quarkPar);
|
||||
quarkPar.source = "z2";
|
||||
application.createModule<Quark>("QZ2_" + flavour[i], quarkPar);
|
||||
application.createModule<MFermion::GaugeProp>("QZ2_" + flavour[i], quarkPar);
|
||||
}
|
||||
for (unsigned int i = 0; i < flavour.size(); ++i)
|
||||
for (unsigned int j = i; j < flavour.size(); ++j)
|
||||
{
|
||||
MContraction::Meson::Par mesPar;
|
||||
|
||||
mesPar.output = "mesons/pt_" + flavour[i] + flavour[j];
|
||||
mesPar.q1 = "Qpt_" + flavour[i];
|
||||
mesPar.q2 = "Qpt_" + flavour[j];
|
||||
mesPar.gammas = "all";
|
||||
mesPar.mom = "0. 0. 0. 0.";
|
||||
mesPar.output = "mesons/pt_" + flavour[i] + flavour[j];
|
||||
mesPar.q1 = "Qpt_" + flavour[i];
|
||||
mesPar.q2 = "Qpt_" + flavour[j];
|
||||
mesPar.gammas = "all";
|
||||
mesPar.sink = "sink";
|
||||
application.createModule<MContraction::Meson>("meson_pt_"
|
||||
+ flavour[i] + flavour[j],
|
||||
mesPar);
|
||||
mesPar.output = "mesons/Z2_" + flavour[i] + flavour[j];
|
||||
mesPar.q1 = "QZ2_" + flavour[i];
|
||||
mesPar.q2 = "QZ2_" + flavour[j];
|
||||
mesPar.gammas = "all";
|
||||
mesPar.mom = "0. 0. 0. 0.";
|
||||
mesPar.output = "mesons/Z2_" + flavour[i] + flavour[j];
|
||||
mesPar.q1 = "QZ2_" + flavour[i];
|
||||
mesPar.q2 = "QZ2_" + flavour[j];
|
||||
mesPar.gammas = "all";
|
||||
mesPar.sink = "sink";
|
||||
application.createModule<MContraction::Meson>("meson_Z2_"
|
||||
+ flavour[i] + flavour[j],
|
||||
mesPar);
|
||||
|
193
tests/hmc/Test_hmc_ScalarActionNxN.cc
Normal file
193
tests/hmc/Test_hmc_ScalarActionNxN.cc
Normal file
@ -0,0 +1,193 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_hmc_WilsonFermionGauge.cc
|
||||
|
||||
Copyright (C) 2016
|
||||
|
||||
Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
||||
|
||||
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 <Grid/Grid.h>
|
||||
namespace Grid {
|
||||
class ScalarActionParameters : Serializable {
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(ScalarActionParameters,
|
||||
double, mass_squared,
|
||||
double, lambda);
|
||||
|
||||
template <class ReaderClass >
|
||||
ScalarActionParameters(Reader<ReaderClass>& Reader){
|
||||
read(Reader, "ScalarAction", *this);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
template <class Impl>
|
||||
class MagMeas : public HmcObservable<typename Impl::Field> {
|
||||
public:
|
||||
typedef typename Impl::Field Field;
|
||||
typedef typename Impl::Simd::scalar_type Trace;
|
||||
|
||||
void TrajectoryComplete(int traj,
|
||||
Field &U,
|
||||
GridSerialRNG &sRNG,
|
||||
GridParallelRNG &pRNG) {
|
||||
|
||||
int def_prec = std::cout.precision();
|
||||
|
||||
std::cout << std::setprecision(std::numeric_limits<Real>::digits10 + 1);
|
||||
std::cout << GridLogMessage
|
||||
<< "m= " << TensorRemove(trace(sum(U))) << std::endl;
|
||||
std::cout << GridLogMessage
|
||||
<< "m^2= " << TensorRemove(trace(sum(U)*sum(U))) << std::endl;
|
||||
std::cout << GridLogMessage
|
||||
<< "phi^2= " << TensorRemove(sum(trace(U*U))) << std::endl;
|
||||
std::cout.precision(def_prec);
|
||||
|
||||
}
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
template <class Impl>
|
||||
class MagMod: public ObservableModule<MagMeas<Impl>, NoParameters>{
|
||||
typedef ObservableModule<MagMeas<Impl>, NoParameters> ObsBase;
|
||||
using ObsBase::ObsBase; // for constructors
|
||||
|
||||
// acquire resource
|
||||
virtual void initialize(){
|
||||
this->ObservablePtr.reset(new MagMeas<Impl>());
|
||||
}
|
||||
public:
|
||||
MagMod(): ObsBase(NoParameters()){}
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
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
|
||||
std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl;
|
||||
|
||||
// Typedefs to simplify notation
|
||||
constexpr int Ncolours = 2;
|
||||
constexpr int Ndimensions = 3;
|
||||
typedef ScalarNxNAdjGenericHMCRunner<Ncolours> HMCWrapper; // Uses the default minimum norm, real scalar fields
|
||||
typedef ScalarAdjActionR<Ncolours, Ndimensions> ScalarAction;
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
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
|
||||
GridModule ScalarGrid;
|
||||
if (GridDefaultLatt().size() != Ndimensions){
|
||||
std::cout << "Incorrect dimension of the grid\n. Expected dim="<< Ndimensions << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
if (GridDefaultMpi().size() != Ndimensions){
|
||||
std::cout << "Incorrect dimension of the mpi grid\n. Expected dim="<< Ndimensions << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
ScalarGrid.set_full(new GridCartesian(GridDefaultLatt(),GridDefaultSimd(Ndimensions, vComplex::Nsimd()),GridDefaultMpi()));
|
||||
ScalarGrid.set_rb(new GridRedBlackCartesian(ScalarGrid.get_full()));
|
||||
TheHMC.Resources.AddGrid("scalar", ScalarGrid);
|
||||
std::cout << "Lattice size : " << GridDefaultLatt() << std::endl;
|
||||
|
||||
// Checkpointer definition
|
||||
CheckpointerParameters CPparams(Reader);
|
||||
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
|
||||
|
||||
RNGModuleParameters RNGpar(Reader);
|
||||
TheHMC.Resources.SetRNGSeeds(RNGpar);
|
||||
|
||||
// Construct observables
|
||||
typedef MagMod<HMCWrapper::ImplPolicy> MagObs;
|
||||
TheHMC.Resources.AddObservable<MagObs>();
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Collect actions, here use more encapsulation
|
||||
|
||||
// Scalar action in adjoint representation
|
||||
ScalarActionParameters SPar(Reader);
|
||||
ScalarAction Saction(SPar.mass_squared, SPar.lambda);
|
||||
|
||||
// Collect actions
|
||||
ActionLevel<ScalarAction::Field, ScalarNxNMatrixFields<Ncolours>> Level1(1);
|
||||
Level1.push_back(&Saction);
|
||||
TheHMC.TheAction.push_back(Level1);
|
||||
/////////////////////////////////////////////////////////////
|
||||
TheHMC.Parameters.initialize(Reader);
|
||||
|
||||
TheHMC.Run();
|
||||
|
||||
Grid_finalize();
|
||||
} // main
|
||||
|
||||
/* Examples for input files
|
||||
|
||||
JSON
|
||||
|
||||
{
|
||||
"Checkpointer": {
|
||||
"config_prefix": "ckpoint_scalar_lat",
|
||||
"rng_prefix": "ckpoint_scalar_rng",
|
||||
"saveInterval": 1,
|
||||
"format": "IEEE64BIG"
|
||||
},
|
||||
"RandomNumberGenerator": {
|
||||
"serial_seeds": "1 2 3 4 6",
|
||||
"parallel_seeds": "6 7 8 9 11"
|
||||
},
|
||||
"ScalarAction":{
|
||||
"mass_squared": 0.5,
|
||||
"lambda": 0.1
|
||||
},
|
||||
"HMC":{
|
||||
"StartTrajectory": 0,
|
||||
"Trajectories": 100,
|
||||
"MetropolisTest": true,
|
||||
"NoMetropolisUntil": 10,
|
||||
"StartingType": "HotStart",
|
||||
"MD":{
|
||||
"name": "MinimumNorm2",
|
||||
"MDsteps": 15,
|
||||
"trajL": 2.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XML example not provided yet
|
||||
|
||||
*/
|
@ -516,7 +516,7 @@ int main (int argc, char ** argv)
|
||||
LatticeColourMatrix U(UGrid);
|
||||
LatticeColourMatrix zz(UGrid);
|
||||
|
||||
NerscField header;
|
||||
FieldMetaData header;
|
||||
std::string file("./ckpoint_lat.4000");
|
||||
NerscIO::readConfiguration(Umu,header,file);
|
||||
|
||||
|
@ -54,7 +54,7 @@ int main (int argc, char ** argv)
|
||||
GridParallelRNG RNG5rb(FrbGrid); RNG5.SeedFixedIntegers(seeds5);
|
||||
|
||||
LatticeGaugeField Umu(UGrid);
|
||||
SU3::TepidConfiguration(RNG4, Umu);
|
||||
SU3::HotConfiguration(RNG4, Umu);
|
||||
|
||||
std::vector<LatticeColourMatrix> U(4,UGrid);
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
@ -92,16 +92,15 @@ int main (int argc, char ** argv)
|
||||
|
||||
|
||||
std::vector<RealD> eval(Nm);
|
||||
FermionField src(FrbGrid); gaussian(RNG5rb,src);
|
||||
FermionField src(FrbGrid);
|
||||
gaussian(RNG5rb,src);
|
||||
std::vector<FermionField> evec(Nm,FrbGrid);
|
||||
for(int i=0;i<1;i++){
|
||||
std::cout << i<<" / "<< Nm<< " grid pointer "<<evec[i]._grid<<std::endl;
|
||||
std::cout << GridLogMessage <<i<<" / "<< Nm<< " grid pointer "<<evec[i]._grid<<std::endl;
|
||||
};
|
||||
|
||||
int Nconv;
|
||||
IRL.calc(eval,evec,
|
||||
src,
|
||||
Nconv);
|
||||
IRL.calc(eval,evec,src,Nconv);
|
||||
|
||||
|
||||
Grid_finalize();
|
||||
|
@ -51,7 +51,7 @@ int main (int argc, char ** argv)
|
||||
typedef typename ImprovedStaggeredFermion5DR::ComplexField ComplexField;
|
||||
typename ImprovedStaggeredFermion5DR::ImplParams params;
|
||||
|
||||
const int Ls=4;
|
||||
const int Ls=8;
|
||||
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
@ -74,17 +74,19 @@ int main (int argc, char ** argv)
|
||||
|
||||
LatticeGaugeField Umu(UGrid); SU3::HotConfiguration(pRNG,Umu);
|
||||
|
||||
RealD mass=0.01;
|
||||
RealD mass=0.003;
|
||||
ImprovedStaggeredFermion5DR Ds(Umu,Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass);
|
||||
MdagMLinearOperator<ImprovedStaggeredFermion5DR,FermionField> HermOp(Ds);
|
||||
|
||||
ConjugateGradient<FermionField> CG(1.0e-8,10000);
|
||||
BlockConjugateGradient<FermionField> BCG(1.0e-8,10000);
|
||||
MultiRHSConjugateGradient<FermionField> mCG(1.0e-8,10000);
|
||||
int blockDim = 0;
|
||||
BlockConjugateGradient<FermionField> BCGrQ(BlockCGrQ,blockDim,1.0e-8,10000);
|
||||
BlockConjugateGradient<FermionField> BCG (BlockCG,blockDim,1.0e-8,10000);
|
||||
BlockConjugateGradient<FermionField> mCG (CGmultiRHS,blockDim,1.0e-8,10000);
|
||||
|
||||
std::cout << GridLogMessage << "************************************************************************ "<<std::endl;
|
||||
std::cout << GridLogMessage << "****************************************************************** "<<std::endl;
|
||||
std::cout << GridLogMessage << " Calling 4d CG "<<std::endl;
|
||||
std::cout << GridLogMessage << "************************************************************************ "<<std::endl;
|
||||
std::cout << GridLogMessage << "****************************************************************** "<<std::endl;
|
||||
ImprovedStaggeredFermionR Ds4d(Umu,Umu,*UGrid,*UrbGrid,mass);
|
||||
MdagMLinearOperator<ImprovedStaggeredFermionR,FermionField> HermOp4d(Ds4d);
|
||||
FermionField src4d(UGrid); random(pRNG,src4d);
|
||||
@ -111,7 +113,7 @@ int main (int argc, char ** argv)
|
||||
std::cout << GridLogMessage << " Calling Block CG for "<<Ls <<" right hand sides" <<std::endl;
|
||||
std::cout << GridLogMessage << "************************************************************************ "<<std::endl;
|
||||
result=zero;
|
||||
BCG(HermOp,src,result);
|
||||
BCGrQ(HermOp,src,result);
|
||||
std::cout << GridLogMessage << "************************************************************************ "<<std::endl;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user