From 7ee66bf4533309bc1be3783fd278a85bfbb1237d Mon Sep 17 00:00:00 2001 From: Michael Marshall <43034299+mmphys@users.noreply.github.com> Date: Sun, 19 Sep 2021 19:45:20 +0100 Subject: [PATCH 1/5] Make sure H5NS has empty definition if HDF5 built without C++ namespace. Add comment in Hdf5IO.cc indicating likely source of error using H5NS, i.e. lack of --enable-cxx in hdf5 configure. --- Grid/serialisation/Hdf5IO.cc | 2 +- Grid/serialisation/Hdf5IO.h | 4 ---- Grid/serialisation/Hdf5Type.h | 4 +++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Grid/serialisation/Hdf5IO.cc b/Grid/serialisation/Hdf5IO.cc index d3c7061e..db78df8e 100644 --- a/Grid/serialisation/Hdf5IO.cc +++ b/Grid/serialisation/Hdf5IO.cc @@ -33,7 +33,7 @@ using namespace Grid; #ifndef H5_NO_NAMESPACE -using namespace H5NS; +using namespace H5NS; // Compile error here? Try adding --enable-cxx to hdf5 configure #endif // Writer implementation /////////////////////////////////////////////////////// diff --git a/Grid/serialisation/Hdf5IO.h b/Grid/serialisation/Hdf5IO.h index 46cb07e1..ae5e740b 100644 --- a/Grid/serialisation/Hdf5IO.h +++ b/Grid/serialisation/Hdf5IO.h @@ -40,10 +40,6 @@ #include #include "Hdf5Type.h" -#ifndef H5_NO_NAMESPACE -#define H5NS H5 -#endif - // default thresold above which datasets are used instead of attributes #ifndef HDF5_DEF_DATASET_THRES #define HDF5_DEF_DATASET_THRES 6u diff --git a/Grid/serialisation/Hdf5Type.h b/Grid/serialisation/Hdf5Type.h index 64dda349..d8a0dd22 100644 --- a/Grid/serialisation/Hdf5Type.h +++ b/Grid/serialisation/Hdf5Type.h @@ -5,7 +5,9 @@ #include #include -#ifndef H5_NO_NAMESPACE +#ifdef H5_NO_NAMESPACE +#define H5NS +#else #define H5NS H5 #endif From 67e08aa952539c92cd03b9449924bad5c96e7f36 Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Thu, 23 Sep 2021 23:39:55 +0200 Subject: [PATCH 2/5] New file not run yet --- examples/Example_wall_wall_spectrum.cc | 404 +++++++++++++++++++++++++ 1 file changed, 404 insertions(+) create mode 100644 examples/Example_wall_wall_spectrum.cc diff --git a/examples/Example_wall_wall_spectrum.cc b/examples/Example_wall_wall_spectrum.cc new file mode 100644 index 00000000..0d70f351 --- /dev/null +++ b/examples/Example_wall_wall_spectrum.cc @@ -0,0 +1,404 @@ +/* + * Warning: This code illustrative only: not well tested, and not meant for production use + * without regression / tests being applied + */ + +#include + +using namespace std; +using namespace Grid; +typedef SpinColourMatrix Propagator; +typedef SpinColourVector Fermion; + +template class CovariantLaplacianCshift : public SparseMatrixBase +{ +public: + INHERIT_GIMPL_TYPES(Gimpl); + + GridBase *grid; + GaugeField U; + + CovariantLaplacianCshift(GaugeField &_U) : + grid(_U.Grid()), + U(_U) { }; + + virtual GridBase *Grid(void) { return grid; }; + + virtual void M (const Field &in, Field &out) + { + out=Zero(); + for(int mu=0;mu(U, mu); // NB: Inefficent + out = out - Gimpl::CovShiftForward(Umu,mu,in); + out = out - Gimpl::CovShiftBackward(Umu,mu,in); + out = out + 2.0*in; + } + }; + virtual void Mdag (const Field &in, Field &out) { M(in,out);}; // Laplacian is hermitian + virtual void Mdiag (const Field &in, Field &out) {assert(0);}; // Unimplemented need only for multigrid + virtual void Mdir (const Field &in, Field &out,int dir, int disp){assert(0);}; // Unimplemented need only for multigrid + virtual void MdirAll (const Field &in, std::vector &out) {assert(0);}; // Unimplemented need only for multigrid +}; + +void MakePhase(Coordinate mom,LatticeComplex &phase) +{ + GridBase *grid = phase.Grid(); + auto latt_size = grid->GlobalDimensions(); + ComplexD ci(0.0,1.0); + phase=Zero(); + + LatticeComplex coor(phase.Grid()); + for(int mu=0;mu::avgPlaquette(U); + + std::cout << " Initial plaquette "<::SteepestDescentGaugeFix(Ufix,xform,alpha,10000,1.0e-12, 1.0e-12,true,orthog); + + plaq=WilsonLoops::avgPlaquette(Ufix); + + std::cout << " Final plaquette "< +void GaussianSmear(LatticeGaugeField &U,Field &unsmeared,Field &smeared) +{ + typedef CovariantLaplacianCshift Laplacian_t; + Laplacian_t Laplacian(U); + + Integer Iterations = 40; + Real width = 2.0; + Real coeff = (width*width) / Real(4*Iterations); + + Field tmp(U.Grid()); + smeared=unsmeared; + // chi = (1-p^2/2N)^N kronecker + for(int n = 0; n < Iterations; ++n) { + Laplacian.M(smeared,tmp); + smeared = smeared - coeff*tmp; + std::cout << " smear iter " << n<<" " < +void Solve(Action &D,LatticePropagator &source,LatticePropagator &propagator) +{ + GridBase *UGrid = D.GaugeGrid(); + GridBase *FGrid = D.FermionGrid(); + + LatticeFermion src4 (UGrid); + LatticeFermion src5 (FGrid); + LatticeFermion result5(FGrid); + LatticeFermion result4(UGrid); + + ConjugateGradient CG(1.0e-8,100000); + SchurRedBlackDiagMooeeSolve schur(CG); + ZeroGuesser ZG; // Could be a DeflatedGuesser if have eigenvectors + for(int s=0;s(src4,source,s,c); + + D.ImportPhysicalFermionSource(src4,src5); + + result5=Zero(); + schur(D,src5,result5,ZG); + std::cout<(propagator,result4,s,c); + } + } +} + +class MesonFile: Serializable { +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(MesonFile, std::vector >, data); +}; + +void MesonTrace(std::string file,LatticePropagator &q1,LatticePropagator &q2,LatticeComplex &phase) +{ + const int nchannel=4; + Gamma::Algebra Gammas[nchannel][2] = { + {Gamma::Algebra::Gamma5 ,Gamma::Algebra::Gamma5}, + {Gamma::Algebra::GammaTGamma5,Gamma::Algebra::GammaTGamma5}, + {Gamma::Algebra::GammaTGamma5,Gamma::Algebra::Gamma5}, + {Gamma::Algebra::Gamma5 ,Gamma::Algebra::GammaTGamma5} + }; + + Gamma G5(Gamma::Algebra::Gamma5); + + LatticeComplex meson_CF(q1.Grid()); + MesonFile MF; + + for(int ch=0;ch meson_T; + sliceSum(meson_CF,meson_T, Tdir); + + int nt=meson_T.size(); + + std::vector corr(nt); + for(int t=0;t &q1,std::vector &q2) +{ + const int nchannel=4; + Gamma::Algebra Gammas[nchannel][2] = { + {Gamma::Algebra::Gamma5 ,Gamma::Algebra::Gamma5}, + {Gamma::Algebra::GammaTGamma5,Gamma::Algebra::GammaTGamma5}, + {Gamma::Algebra::GammaTGamma5,Gamma::Algebra::Gamma5}, + {Gamma::Algebra::Gamma5 ,Gamma::Algebra::GammaTGamma5} + }; + + Gamma G5(Gamma::Algebra::Gamma5); + int nt=q1.size(); + std::vector meson_CF(nt); + MesonFile MF; + + for(int ch=0;ch corr(nt); + for(int t=0;t seeds4({1,2,3,4}); + GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4); + + LatticeGaugeField Umu(UGrid); + LatticeGaugeField Ufixed(UGrid); + std::string config; + if( argc > 1 && argv[1][0] != '-' ) + { + std::cout<::ColdConfiguration(Umu); + // SU::HotConfiguration(RNG4,Umu); + config="HotConfig"; + } + GaugeFix(Umu,Ufixed); + Umu=Ufixed; + + + std::vector masses({ 0.004,0.02477,0.447} ); // u/d, s, c ?? + std::vector M5s ({ 1.8,1.8,1.0} ); + std::vector bs ({ 1.0,1.0,1.5} ); // DDM + std::vector cs ({ 0.0,0.0,0.5} ); // DDM + std::vector Ls_s ({ 16,16,12} ); + std::vector FGrids; + std::vector FrbGrids; + + int nmass = masses.size(); + + std::vector FermActs; + + std::cout< PointProps(nmass,UGrid); + std::vector GaussProps(nmass,UGrid); + std::vector Z2Props (nmass,UGrid); + std::vector GFProps (nmass,UGrid); + + for(int m=0;m > wsnk_z2Props(nmass); + std::vector > wsnk_gfProps(nmass); + for(int m=0;m Date: Tue, 28 Sep 2021 12:44:26 +0100 Subject: [PATCH 3/5] LinearFunction loops over vectors by default, can be overloaded --- Grid/algorithms/LinearOperator.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Grid/algorithms/LinearOperator.h b/Grid/algorithms/LinearOperator.h index 1add212c..815226d2 100644 --- a/Grid/algorithms/LinearOperator.h +++ b/Grid/algorithms/LinearOperator.h @@ -530,6 +530,16 @@ public: template class LinearFunction { public: virtual void operator() (const Field &in, Field &out) = 0; + + virtual void operator() (const std::vector &in, std::vector &out) + { + assert(in.size() == out.size()); + + for (unsigned int i = 0; i < in.size(); ++i) + { + (*this)(in[i], out[i]); + } + } }; template class IdentityLinearFunction : public LinearFunction { From 9523ad3d7345f443c272e6c148f7c54311b64e68 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Tue, 28 Sep 2021 12:45:47 +0100 Subject: [PATCH 4/5] vector version of Schur solver use vector guesser --- Grid/algorithms/iterative/SchurRedBlack.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Grid/algorithms/iterative/SchurRedBlack.h b/Grid/algorithms/iterative/SchurRedBlack.h index 15ef95c7..d97e4993 100644 --- a/Grid/algorithms/iterative/SchurRedBlack.h +++ b/Grid/algorithms/iterative/SchurRedBlack.h @@ -185,16 +185,19 @@ namespace Grid { //////////////////////////////////////////////// if ( subGuess ) guess_save.resize(nblock,grid); - for(int b=0;b Date: Thu, 30 Sep 2021 19:25:12 +0100 Subject: [PATCH 5/5] deflated guesser can optionally be used with less vectors than provided --- Grid/algorithms/iterative/Deflation.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Grid/algorithms/iterative/Deflation.h b/Grid/algorithms/iterative/Deflation.h index 626b60e3..43fe3e35 100644 --- a/Grid/algorithms/iterative/Deflation.h +++ b/Grid/algorithms/iterative/Deflation.h @@ -54,15 +54,23 @@ class DeflatedGuesser: public LinearFunction { private: const std::vector &evec; const std::vector &eval; + const unsigned int N; public: - DeflatedGuesser(const std::vector & _evec,const std::vector & _eval) : evec(_evec), eval(_eval) {}; + DeflatedGuesser(const std::vector & _evec,const std::vector & _eval) + : DeflatedGuesser(_evec, _eval, _evec.size()) + {} + + DeflatedGuesser(const std::vector & _evec, const std::vector & _eval, const unsigned int _N) + : evec(_evec), eval(_eval), N(_N) + { + assert(evec.size()==eval.size()); + assert(N <= evec.size()); + } virtual void operator()(const Field &src,Field &guess) { guess = Zero(); - assert(evec.size()==eval.size()); - auto N = evec.size(); for (int i=0;i