/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./tests/Test_cayley_cg.cc Copyright (C) 2015 Author: Peter Boyle Author: paboyle 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 #include using namespace std; using namespace Grid; template void TestConserved(What & Ddwf, What & Ddwfrev, LatticeGaugeField &Umu, GridCartesian * FGrid, GridRedBlackCartesian * FrbGrid, GridCartesian * UGrid, GridRedBlackCartesian * UrbGrid, RealD mass, RealD M5, GridParallelRNG *RNG4, GridParallelRNG *RNG5); Gamma::Algebra Gmu [] = { Gamma::Algebra::GammaX, Gamma::Algebra::GammaY, Gamma::Algebra::GammaZ, Gamma::Algebra::GammaT, Gamma::Algebra::Gamma5 }; int main (int argc, char ** argv) { Grid_init(&argc,&argv); int threads = GridThread::GetThreads(); std::cout< omegas; std::vector < ComplexD > omegasrev(Ls); #if 1 omegas.push_back( std::complex(1.45806438985048,-0) ); omegas.push_back( std::complex(0.830951166685955,-0) ); omegas.push_back( std::complex(0.341985020453729,-0) ); omegas.push_back( std::complex(0.126074299502912,-0) ); // omegas.push_back( std::complex(0.0686324988446592,0.0550658530827402) ); // omegas.push_back( std::complex(0.0686324988446592,-0.0550658530827402) ); omegas.push_back( std::complex(0.0686324988446592,0)); omegas.push_back( std::complex(0.0686324988446592,0)); omegas.push_back( std::complex(0.0990136651962626,-0) ); omegas.push_back( std::complex(0.21137902619029,-0) ); omegas.push_back( std::complex(0.542352409156791,-0) ); omegas.push_back( std::complex(1.18231318389348,-0) ); #else omegas.push_back( std::complex(0.8,0.0)); omegas.push_back( std::complex(1.1,0.0)); omegas.push_back( std::complex(1.2,0.0)); omegas.push_back( std::complex(1.3,0.0)); omegas.push_back( std::complex(0.5,0.2)); omegas.push_back( std::complex(0.5,-0.2)); omegas.push_back( std::complex(0.8,0.0)); omegas.push_back( std::complex(1.1,0.0)); omegas.push_back( std::complex(1.2,0.0)); omegas.push_back( std::complex(1.3,0.0)); #endif GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()), GridDefaultMpi()); GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid); GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid); GridCartesian * UGridF = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplexF::Nsimd()), GridDefaultMpi()); GridRedBlackCartesian * UrbGridF = SpaceTimeGrid::makeFourDimRedBlackGrid(UGridF); GridCartesian * FGridF = SpaceTimeGrid::makeFiveDimGrid(Ls,UGridF); GridRedBlackCartesian * FrbGridF = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGridF); std::vector seeds4({1,2,3,4}); std::vector seeds5({5,6,7,8}); GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5); GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4); LatticeGaugeField Umu(UGrid); SU3::ColdConfiguration(Umu); // SU3::HotConfiguration(RNG4,Umu); RealD mass=0.3; RealD M5 =1.0; std::cout<(Ddwf,Ddwf,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); RealD b=1.5;// Scale factor b+c=2, b-c=1 RealD c=0.5; // std::vector gamma(Ls,ComplexD(1.0,0.0)); std::cout<(Dmob,Dmob,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); std::cout<(Dsham,Dsham,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); std::cout<(ZDmob,ZDmobrev,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); Grid_finalize(); } template void TestConserved(Action & Ddwf, Action & Ddwfrev, LatticeGaugeField &Umu, GridCartesian * FGrid, GridRedBlackCartesian * FrbGrid, GridCartesian * UGrid, GridRedBlackCartesian * UrbGrid, RealD mass, RealD M5, GridParallelRNG *RNG4, GridParallelRNG *RNG5) { int Ls=Ddwf.Ls; LatticePropagator phys_src(UGrid); std::vector U(4,UGrid); LatticePropagator seqsrc(FGrid); LatticePropagator prop5(FGrid); LatticePropagator prop5rev(FGrid); LatticePropagator prop4(UGrid); LatticePropagator Axial_mu(UGrid); LatticePropagator Vector_mu(UGrid); LatticeComplex PA (UGrid); LatticeComplex SV (UGrid); LatticeComplex VV (UGrid); LatticeComplex PJ5q(UGrid); LatticeComplex PP (UGrid); LatticePropagator seqprop(UGrid); SpinColourMatrix kronecker; kronecker=1.0; Coordinate coor({0,0,0,0}); phys_src=Zero(); pokeSite(kronecker,phys_src,coor); MdagMLinearOperator HermOp(Ddwf); MdagMLinearOperator HermOprev(Ddwfrev); ConjugateGradient CG(1.0e-16,100000); for(int s=0;s(src4,phys_src,s,c); LatticeFermion src5 (FGrid); Ddwf.ImportPhysicalFermionSource(src4,src5); LatticeFermion result5(FGrid); result5=Zero(); // CGNE LatticeFermion Mdagsrc5 (FGrid); Ddwf.Mdag(src5,Mdagsrc5); CG(HermOp,Mdagsrc5,result5); FermToProp(prop5,result5,s,c); LatticeFermion result4(UGrid); Ddwf.ExportPhysicalFermionSolution(result5,result4); FermToProp(prop4,result4,s,c); Ddwfrev.ImportPhysicalFermionSource(src4,src5); Ddwfrev.Mdag(src5,Mdagsrc5); CG(HermOprev,Mdagsrc5,result5); FermToProp(prop5rev,result5,s,c); } } #if 1 auto curr = Current::Axial; const int mu_J=Nd-1; #else auto curr = Current::Vector; const int mu_J=0; #endif const int t_J=0; LatticeComplex ph (UGrid); ph=1.0; Ddwf.SeqConservedCurrent(prop5, seqsrc, phys_src, curr, mu_J, t_J, t_J,// whole lattice ph); for(int s=0;s(src5,seqsrc,s,c); LatticeFermion result5(FGrid); result5=Zero(); // CGNE LatticeFermion Mdagsrc5 (FGrid); Ddwf.Mdag(src5,Mdagsrc5); CG(HermOp,Mdagsrc5,result5); LatticeFermion result4(UGrid); Ddwf.ExportPhysicalFermionSolution(result5,result4); FermToProp(seqprop,result4,s,c); } } Gamma g5(Gamma::Algebra::Gamma5); Gamma gT(Gamma::Algebra::GammaT); std::vector sumPA; std::vector sumSV; std::vector sumVV; std::vector sumPP; std::vector sumPJ5q; Ddwf.ContractConservedCurrent(prop5rev,prop5,Axial_mu,phys_src,Current::Axial,Tdir); Ddwf.ContractConservedCurrent(prop5rev,prop5,Vector_mu,phys_src,Current::Vector,Tdir); Ddwf.ContractJ5q(prop5,PJ5q); PA = trace(g5*Axial_mu); SV = trace(Vector_mu); VV = trace(gT*Vector_mu); PP = trace(adj(prop4)*prop4); // Spatial sum sliceSum(PA,sumPA,Tdir); sliceSum(SV,sumSV,Tdir); sliceSum(VV,sumVV,Tdir); sliceSum(PP,sumPP,Tdir); sliceSum(PJ5q,sumPJ5q,Tdir); int Nt=sumPA.size(); for(int t=0;t check_buf; test_S = trace(qSite*g); test_V = trace(qSite*g*Gamma::gmu[mu_J]); Ddwf.ContractConservedCurrent(prop5rev,prop5,cur,phys_src,curr,mu_J); c = trace(cur*g); sliceSum(c, check_buf, Tp); check_S = TensorRemove(check_buf[t_J]); auto gmu=Gamma::gmu[mu_J]; c = trace(cur*g*gmu); sliceSum(c, check_buf, Tp); check_V = TensorRemove(check_buf[t_J]); std::cout< sumPAref; std::vector sumPA; std::vector sumPP; std::vector sumPJ5qref; std::vector sumPJ5q; std::vector sumDefect; // Spatial sum sliceSum(PAmu[Tdir],sumPAref,Tdir); sliceSum(PA,sumPA,Tdir); sliceSum(PJ5q,sumPJ5q,Tdir); sliceSum(PP,sumPP,Tdir); sliceSum(Defect,sumDefect,Tdir); Ddwf.ContractJ5q(prop5,PJ5q); sliceSum(PJ5q,sumPJ5qref,Tdir); int Nt=sumPA.size(); for(int t=0;t U(4,FGrid); { autoView( Umu5d_v , Umu5d, CpuWrite); autoView( Umu_v , Umu , CpuRead); for(int ss=0;ssoSites();ss++){ for(int s=0;s(Umu5d,mu); } LatticeFermion ref(FGrid); LatticeFermion tmp(FGrid); ref = Zero(); for(int mu=0;muoSites(),{ uint64_t ss= sss*Ls; typedef vSpinColourVector spinor; spinor tmp1, tmp2; for(int s=0;s