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 { 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 #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 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