mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-13 20:57:06 +01:00
Merge branch 'develop' into feature/gpt
This commit is contained in:
@ -76,7 +76,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
std::cout << GridLogMessage << "Spatial zero-mode norm 2" << std::endl;
|
||||
sliceSum(a, zm, grid.Nd() - 1);
|
||||
for (unsigned int t = 0; t < latt_size.size(); ++t)
|
||||
for (unsigned int t = 0; t < latt_size[Tp]; ++t)
|
||||
{
|
||||
std::cout << GridLogMessage << "t = " << t << " " << std::sqrt(norm2(zm[t])) << std::endl;
|
||||
}
|
||||
|
622
tests/debug/Test_cayley_mres.cc
Normal file
622
tests/debug/Test_cayley_mres.cc
Normal file
@ -0,0 +1,622 @@
|
||||
/*************************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_cayley_cg.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
Author: paboyle <paboyle@ph.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>
|
||||
#include <Grid/qcd/action/fermion/Reconstruct5Dprop.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
|
||||
|
||||
template<class What>
|
||||
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<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
const int Ls=10;
|
||||
std::vector < ComplexD > omegas;
|
||||
std::vector < ComplexD > omegasrev(Ls);
|
||||
|
||||
#if 1
|
||||
omegas.push_back( std::complex<double>(1.45806438985048,-0) );
|
||||
omegas.push_back( std::complex<double>(0.830951166685955,-0) );
|
||||
omegas.push_back( std::complex<double>(0.341985020453729,-0) );
|
||||
omegas.push_back( std::complex<double>(0.126074299502912,-0) );
|
||||
// omegas.push_back( std::complex<double>(0.0686324988446592,0.0550658530827402) );
|
||||
// omegas.push_back( std::complex<double>(0.0686324988446592,-0.0550658530827402) );
|
||||
omegas.push_back( std::complex<double>(0.0686324988446592,0));
|
||||
omegas.push_back( std::complex<double>(0.0686324988446592,0));
|
||||
omegas.push_back( std::complex<double>(0.0990136651962626,-0) );
|
||||
omegas.push_back( std::complex<double>(0.21137902619029,-0) );
|
||||
omegas.push_back( std::complex<double>(0.542352409156791,-0) );
|
||||
omegas.push_back( std::complex<double>(1.18231318389348,-0) );
|
||||
#else
|
||||
omegas.push_back( std::complex<double>(0.8,0.0));
|
||||
omegas.push_back( std::complex<double>(1.1,0.0));
|
||||
omegas.push_back( std::complex<double>(1.2,0.0));
|
||||
omegas.push_back( std::complex<double>(1.3,0.0));
|
||||
omegas.push_back( std::complex<double>(0.5,0.2));
|
||||
omegas.push_back( std::complex<double>(0.5,-0.2));
|
||||
omegas.push_back( std::complex<double>(0.8,0.0));
|
||||
omegas.push_back( std::complex<double>(1.1,0.0));
|
||||
omegas.push_back( std::complex<double>(1.2,0.0));
|
||||
omegas.push_back( std::complex<double>(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<int> seeds4({1,2,3,4});
|
||||
std::vector<int> 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<<GridLogMessage <<"======================"<<std::endl;
|
||||
std::cout<<GridLogMessage <<"DomainWallFermion test"<<std::endl;
|
||||
std::cout<<GridLogMessage <<"======================"<<std::endl;
|
||||
DomainWallFermionR Ddwf(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5);
|
||||
TestConserved<DomainWallFermionR>(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<ComplexD> gamma(Ls,ComplexD(1.0,0.0));
|
||||
|
||||
std::cout<<GridLogMessage <<"======================"<<std::endl;
|
||||
std::cout<<GridLogMessage <<"MobiusFermion test"<<std::endl;
|
||||
std::cout<<GridLogMessage <<"======================"<<std::endl;
|
||||
MobiusFermionR Dmob(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,b,c);
|
||||
TestConserved<MobiusFermionR>(Dmob,Dmob,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5);
|
||||
|
||||
std::cout<<GridLogMessage <<"======================"<<std::endl;
|
||||
std::cout<<GridLogMessage <<"ScaledShamirFermion test"<<std::endl;
|
||||
std::cout<<GridLogMessage <<"======================"<<std::endl;
|
||||
ScaledShamirFermionR Dsham(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,2.0);
|
||||
TestConserved<ScaledShamirFermionR>(Dsham,Dsham,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5);
|
||||
|
||||
std::cout<<GridLogMessage <<"======================"<<std::endl;
|
||||
std::cout<<GridLogMessage <<"ZMobiusFermion test"<<std::endl;
|
||||
std::cout<<GridLogMessage <<"======================"<<std::endl;
|
||||
for(int s=0;s<Ls;s++) omegasrev[s]=conjugate(omegas[Ls-1-s]);
|
||||
// for(int s=0;s<Ls;s++) omegasrev[s]=omegas[Ls-1-s];
|
||||
ZMobiusFermionR ZDmob(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,omegas,b,c);
|
||||
ZMobiusFermionR ZDmobrev(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,omegasrev,b,c);
|
||||
|
||||
TestConserved<ZMobiusFermionR>(ZDmob,ZDmobrev,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5);
|
||||
|
||||
Grid_finalize();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Action>
|
||||
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<LatticeColourMatrix> 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<Action,LatticeFermion> HermOp(Ddwf);
|
||||
MdagMLinearOperator<Action,LatticeFermion> HermOprev(Ddwfrev);
|
||||
ConjugateGradient<LatticeFermion> CG(1.0e-16,100000);
|
||||
for(int s=0;s<Nd;s++){
|
||||
for(int c=0;c<Nc;c++){
|
||||
LatticeFermion src4 (UGrid);
|
||||
PropToFerm<Action>(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<Action>(prop5,result5,s,c);
|
||||
|
||||
LatticeFermion result4(UGrid);
|
||||
Ddwf.ExportPhysicalFermionSolution(result5,result4);
|
||||
FermToProp<Action>(prop4,result4,s,c);
|
||||
|
||||
Ddwfrev.ImportPhysicalFermionSource(src4,src5);
|
||||
Ddwfrev.Mdag(src5,Mdagsrc5);
|
||||
CG(HermOprev,Mdagsrc5,result5);
|
||||
FermToProp<Action>(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<Nd;s++){
|
||||
for(int c=0;c<Nc;c++){
|
||||
|
||||
LatticeFermion src5 (FGrid);
|
||||
PropToFerm<Action>(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<Action>(seqprop,result4,s,c);
|
||||
}
|
||||
}
|
||||
|
||||
Gamma g5(Gamma::Algebra::Gamma5);
|
||||
Gamma gT(Gamma::Algebra::GammaT);
|
||||
|
||||
std::vector<TComplex> sumPA;
|
||||
std::vector<TComplex> sumSV;
|
||||
std::vector<TComplex> sumVV;
|
||||
std::vector<TComplex> sumPP;
|
||||
std::vector<TComplex> 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<Nt;t++){
|
||||
std::cout <<" SV "<<real(TensorRemove(sumSV[t]));
|
||||
std::cout <<" VV "<<real(TensorRemove(sumVV[t]))<<std::endl;
|
||||
}
|
||||
for(int t=0;t<Nt;t++){
|
||||
std::cout <<" PAc "<<real(TensorRemove(sumPA[t]));
|
||||
std::cout <<" PJ5q "<<real(TensorRemove(sumPJ5q[t]));
|
||||
std::cout <<" Ward Identity defect " <<real(TensorRemove(sumPA[t]-sumPA[(t-1+Nt)%Nt] - 2.0*(Ddwf.mass*sumPP[t] + sumPJ5q[t]) ))<<"\n";
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
// 3pt vs 2pt check
|
||||
///////////////////////////////
|
||||
{
|
||||
Gamma::Algebra gA = (curr == Current::Axial) ? Gamma::Algebra::Gamma5 : Gamma::Algebra::Identity;
|
||||
Gamma g(gA);
|
||||
|
||||
LatticePropagator cur(UGrid);
|
||||
LatticePropagator tmp(UGrid);
|
||||
LatticeComplex c(UGrid);
|
||||
SpinColourMatrix qSite;
|
||||
peekSite(qSite, seqprop, coor);
|
||||
|
||||
Complex test_S, test_V, check_S, check_V;
|
||||
|
||||
std::vector<TComplex> 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<<GridLogMessage << std::setprecision(14)<<"Test S = " << abs(test_S) << std::endl;
|
||||
std::cout<<GridLogMessage << "Test V = " << abs(test_V) << std::endl;
|
||||
std::cout<<GridLogMessage << "Check S = " << abs(check_S) << std::endl;
|
||||
std::cout<<GridLogMessage << "Check V = " << abs(check_V) << std::endl;
|
||||
|
||||
// Check difference = 0
|
||||
check_S = check_S - test_S;
|
||||
check_V = check_V - test_V;
|
||||
|
||||
std::cout<<GridLogMessage << "Consistency check for sequential conserved " <<std::endl;
|
||||
std::cout<<GridLogMessage << "Diff S = " << abs(check_S) << std::endl;
|
||||
std::cout<<GridLogMessage << "Diff V = " << abs(check_V) << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
#if 0
|
||||
template<class Action>
|
||||
void TestConserved1(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<LatticeColourMatrix> U(4,UGrid);
|
||||
|
||||
LatticePropagator prop5(FGrid);
|
||||
LatticePropagator prop5rev(FGrid);
|
||||
LatticePropagator prop4(UGrid);
|
||||
LatticePropagator Axial_mu(UGrid);
|
||||
LatticeComplex PA (UGrid);
|
||||
LatticeComplex PAxyz(UGrid);
|
||||
LatticeComplex PJ5q(UGrid);
|
||||
LatticeComplex PP (UGrid);
|
||||
std::vector<LatticePropagator> prop(Ls,UGrid);
|
||||
std::vector<LatticePropagator> proprev(Ls,UGrid);
|
||||
|
||||
SpinColourMatrix kronecker; kronecker=1.0;
|
||||
std::cout << kronecker << std::endl;
|
||||
phys_src=Zero();
|
||||
pokeSite(kronecker,phys_src,Coordinate({0,0,0,0}));
|
||||
|
||||
MdagMLinearOperator<Action,LatticeFermion> HermOp(Ddwf);
|
||||
MdagMLinearOperator<Action,LatticeFermion> HermOprev(Ddwfrev);
|
||||
ConjugateGradient<LatticeFermion> CG(1.0e-12,10000);
|
||||
|
||||
for(int s=0;s<Nd;s++){
|
||||
for(int c=0;c<Nc;c++){
|
||||
LatticeFermion src4 (UGrid);
|
||||
PropToFerm<Action>(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<Action>(prop5,result5,s,c);
|
||||
|
||||
LatticeFermion result4(UGrid);
|
||||
Ddwf.ExportPhysicalFermionSolution(result5,result4);
|
||||
FermToProp<Action>(prop4,result4,s,c);
|
||||
|
||||
Ddwfrev.Mdag(src5,Mdagsrc5);
|
||||
CG(HermOprev,Mdagsrc5,result5);
|
||||
FermToProp<Action>(prop5rev,result5,s,c);
|
||||
}
|
||||
}
|
||||
|
||||
for(int s=0;s<Ls;s++){
|
||||
ExtractSlice(prop[s], prop5, s , 0);
|
||||
ExtractSlice(proprev[s], prop5rev, s , 0);
|
||||
}
|
||||
|
||||
Gamma g5(Gamma::Algebra::Gamma5);
|
||||
LatticeComplex C(UGrid);
|
||||
std::vector<LatticeComplex> PAmu(Nd,UGrid);
|
||||
LatticePropagator p5d(UGrid);
|
||||
LatticePropagator us_p5d(UGrid);
|
||||
LatticePropagator gp5d(UGrid);
|
||||
LatticePropagator gus_p5d(UGrid);
|
||||
|
||||
#define Pp(Q) (0.5*(Q+g5*Q))
|
||||
#define Pm(Q) (0.5*(Q-g5*Q))
|
||||
#define Q_4d(Q) (Pm((Q)[0]) + Pp((Q)[Ls-1]))
|
||||
#define TopRowWithSource(Q) (phys_src + (1.0-mass)*Q_4d(Q))
|
||||
|
||||
std::vector<LatticePropagator> L_Q(Ls,UGrid); L_Q=proprev; // shorthand name
|
||||
std::vector<LatticePropagator> R_Q(Ls,UGrid); R_Q=prop; // shorthand name
|
||||
|
||||
LatticePropagator L_TmLsGq0(UGrid);
|
||||
LatticePropagator L_TmLsTmp(UGrid);
|
||||
LatticePropagator R_TmLsGq0(UGrid);
|
||||
LatticePropagator R_TmLsTmp(UGrid);
|
||||
{
|
||||
LatticePropagator TermA(UGrid);
|
||||
LatticePropagator TermB(UGrid);
|
||||
LatticePropagator TermC(UGrid);
|
||||
LatticePropagator TermD(UGrid);
|
||||
TermA = (Pp(Q_4d(L_Q)));
|
||||
TermB = (Pm(Q_4d(L_Q)));
|
||||
TermC = (Pm(TopRowWithSource(L_Q)));
|
||||
TermD = (Pp(TopRowWithSource(L_Q)));
|
||||
|
||||
L_TmLsGq0 = (TermD - TermA + TermB);
|
||||
L_TmLsTmp = (TermC - TermB + TermA);
|
||||
|
||||
TermA = (Pp(Q_4d(R_Q)));
|
||||
TermB = (Pm(Q_4d(R_Q)));
|
||||
TermC = (Pm(TopRowWithSource(R_Q)));
|
||||
TermD = (Pp(TopRowWithSource(R_Q)));
|
||||
|
||||
R_TmLsGq0 = (TermD - TermA + TermB);
|
||||
R_TmLsTmp = (TermC - TermB + TermA);
|
||||
}
|
||||
|
||||
std::vector<LatticePropagator> R_TmLsGq(Ls,UGrid);
|
||||
std::vector<LatticePropagator> L_TmLsGq(Ls,UGrid);
|
||||
for(int s=0;s<Ls;s++){
|
||||
R_TmLsGq[s] = (Pm((R_Q)[(s)]) + Pp((R_Q)[((s)-1+Ls)%Ls]));
|
||||
L_TmLsGq[s] = (Pm((L_Q)[(s)]) + Pp((L_Q)[((s)-1+Ls)%Ls]));
|
||||
}
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
PAmu[mu]=Zero();
|
||||
Gamma gmu=Gamma(Gmu[mu]);
|
||||
|
||||
for(int s=0;s<Ls;s++){
|
||||
|
||||
int sp = (s+1)%Ls;
|
||||
int sr = Ls-1-s;
|
||||
int srp= (sr+1)%Ls;
|
||||
|
||||
// Mobius parameters
|
||||
auto b=Ddwf.bs[s];
|
||||
auto c=Ddwf.cs[s];
|
||||
assert(Ddwfrev.bs[sr]==Ddwf.bs[s]);
|
||||
assert(Ddwfrev.cs[sr]==Ddwf.cs[s]);
|
||||
|
||||
LatticePropagator tmp(UGrid);
|
||||
|
||||
if (s == 0) {
|
||||
p5d =(b*Pm(L_TmLsGq[Ls-1])+ c*Pp(L_TmLsGq[Ls-1]) + b*Pp(L_TmLsTmp) + c*Pm(L_TmLsTmp ));
|
||||
tmp =(b*Pm(R_TmLsGq0) + c*Pp(R_TmLsGq0 ) + b*Pp(R_TmLsGq[1]) + c*Pm(R_TmLsGq[1]));
|
||||
us_p5d = peekLorentz(Umu,mu)*Cshift(tmp,mu,1);
|
||||
} else if (s == Ls-1) {
|
||||
p5d =(b*Pm(L_TmLsGq0) + c*Pp(L_TmLsGq0 ) + b*Pp(L_TmLsGq[1]) + c*Pm(L_TmLsGq[1]));
|
||||
tmp =(b*Pm(R_TmLsGq[Ls-1])+ c*Pp(R_TmLsGq[Ls-1]) + b*Pp(R_TmLsTmp) + c*Pm(R_TmLsTmp ));
|
||||
us_p5d = peekLorentz(Umu,mu)*Cshift(tmp,mu,1);
|
||||
} else {
|
||||
p5d =(b*Pm(L_TmLsGq[sr]) + c*Pp(L_TmLsGq[sr])+ b*Pp(L_TmLsGq[srp])+ c*Pm(L_TmLsGq[srp]));
|
||||
tmp =(b*Pm(R_TmLsGq[s]) + c*Pp(R_TmLsGq[s]) + b*Pp(R_TmLsGq[sp ])+ c*Pm(R_TmLsGq[sp]));
|
||||
us_p5d = peekLorentz(Umu,mu)*Cshift(tmp,mu,1);
|
||||
}
|
||||
|
||||
gp5d=g5*p5d;
|
||||
gus_p5d=gmu*us_p5d;
|
||||
auto bpc = 0.5/(b+c);
|
||||
C = bpc*localInnerProduct(gp5d,gus_p5d);
|
||||
C-= bpc*localInnerProduct(gp5d,us_p5d);
|
||||
|
||||
if (s == 0) {
|
||||
p5d =(b*Pm(R_TmLsGq0) + c*Pp(R_TmLsGq0 ) + b*Pp(R_TmLsGq[1]) + c*Pm(R_TmLsGq[1]));
|
||||
tmp =(b*Pm(L_TmLsGq[Ls-1])+ c*Pp(L_TmLsGq[Ls-1]) + b*Pp(L_TmLsTmp) + c*Pm(L_TmLsTmp ));
|
||||
us_p5d = peekLorentz(Umu,mu)*Cshift(tmp,mu,1);
|
||||
} else if (s == Ls-1) {
|
||||
p5d =(b*Pm(R_TmLsGq[Ls-1])+ c*Pp(R_TmLsGq[Ls-1]) + b*Pp(R_TmLsTmp) + c*Pm(R_TmLsTmp ));
|
||||
tmp =(b*Pm(L_TmLsGq0) + c*Pp(L_TmLsGq0 ) + b*Pp(L_TmLsGq[1]) + c*Pm(L_TmLsGq[1]));
|
||||
us_p5d = peekLorentz(Umu,mu)*Cshift(tmp,mu,1);
|
||||
} else {
|
||||
p5d =(b*Pm(R_TmLsGq[s]) + c*Pp(R_TmLsGq[s]) + b*Pp(R_TmLsGq[sp ])+ c*Pm(R_TmLsGq[sp]));
|
||||
tmp =(b*Pm(L_TmLsGq[sr]) + c*Pp(L_TmLsGq[sr]) + b*Pp(L_TmLsGq[srp])+ c*Pm(L_TmLsGq[srp]));
|
||||
us_p5d = peekLorentz(Umu,mu)*Cshift(tmp,mu,1);
|
||||
}
|
||||
|
||||
gp5d=gmu*p5d;
|
||||
gus_p5d=g5*us_p5d;
|
||||
|
||||
bpc = 0.5/(b+c);
|
||||
C+= bpc*localInnerProduct(gus_p5d,gp5d);
|
||||
C+= bpc*localInnerProduct(gus_p5d,p5d);
|
||||
|
||||
if (s < Ls/2) PAmu[mu] -= C;
|
||||
else PAmu[mu] += C;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "done "<<std::endl;
|
||||
LatticePropagator psi(UGrid);
|
||||
psi = (prop[Ls/2-1]+g5*prop[Ls/2-1] +prop[Ls/2] -g5*prop[Ls/2] )*0.5;
|
||||
PJ5q=localInnerProduct(psi,psi);
|
||||
std::cout << " J5qref "<<norm2(PJ5q)<<std::endl;
|
||||
|
||||
std::cout << " DmuAmu "<<std::endl;
|
||||
LatticeComplex Defect(UGrid);
|
||||
Defect = Zero();
|
||||
for(int mu=0;mu<Nd;mu++) {
|
||||
Defect = Defect + PAmu[mu]-Cshift(PAmu[mu],mu,-1);
|
||||
}
|
||||
Ddwf.ContractConservedCurrent(prop5rev,prop5,Axial_mu,phys_src,Current::Axial,Tdir);
|
||||
PA = trace(g5*Axial_mu);
|
||||
PP = trace(adj(prop4)*prop4);
|
||||
|
||||
Defect = Defect - 2.0*Ddwf.mass* PP;
|
||||
Defect = Defect - 2.0*PJ5q;
|
||||
|
||||
std::vector<TComplex> sumPAref;
|
||||
std::vector<TComplex> sumPA;
|
||||
std::vector<TComplex> sumPP;
|
||||
std::vector<TComplex> sumPJ5qref;
|
||||
std::vector<TComplex> sumPJ5q;
|
||||
std::vector<TComplex> 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<Nt;t++){
|
||||
std::cout <<t<<" PAc reference "<<real(TensorRemove(sumPAref[t]));
|
||||
std::cout <<" PAc action "<<real(TensorRemove(sumPA[t]));
|
||||
std::cout <<" PJ5q ref "<<real(TensorRemove(sumPJ5qref[t]));
|
||||
std::cout <<" PJ5q action "<<real(TensorRemove(sumPJ5q[t]));
|
||||
std::cout <<"WTI defects "<<real(TensorRemove(sumPAref[t]-sumPAref[(t-1+Nt)%Nt] - 2.0*(Ddwf.mass*sumPP[t] + sumPJ5q[t]) ))<<",";
|
||||
std::cout <<real(TensorRemove(sumPA[t]-sumPA[(t-1+Nt)%Nt] - 2.0*(Ddwf.mass*sumPP[t] + sumPJ5q[t]) ))<<"\n";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Verify solution with independent true residual
|
||||
LatticeGaugeField Umu5d(FGrid);
|
||||
std::vector<LatticeColourMatrix> U(4,FGrid);
|
||||
{
|
||||
auto Umu5d_v = Umu5d.View();
|
||||
auto Umu_v = Umu.View();
|
||||
for(int ss=0;ss<Umu.Grid()->oSites();ss++){
|
||||
for(int s=0;s<Ls;s++){
|
||||
Umu5d_v[Ls*ss+s] = Umu_v[ss];
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
U[mu] = PeekIndex<LorentzIndex>(Umu5d,mu);
|
||||
}
|
||||
LatticeFermion ref(FGrid);
|
||||
LatticeFermion tmp(FGrid);
|
||||
ref = Zero();
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
tmp = U[mu]*Cshift(result5,mu+1,1);
|
||||
ref=ref + tmp - Gamma(Gmu[mu])*tmp;
|
||||
|
||||
tmp =adj(U[mu])*result5;
|
||||
tmp =Cshift(tmp,mu+1,-1);
|
||||
ref=ref + tmp + Gamma(Gmu[mu])*tmp;
|
||||
}
|
||||
ref = -0.5*ref;
|
||||
// Dperp
|
||||
{
|
||||
RealD diag = 5.0 - Ddwf.M5;
|
||||
mass = Ddwf.mass;
|
||||
auto psi=result5.View();
|
||||
auto chi=tmp.View();
|
||||
thread_for(sss,UGrid->oSites(),{
|
||||
uint64_t ss= sss*Ls;
|
||||
typedef vSpinColourVector spinor;
|
||||
spinor tmp1, tmp2;
|
||||
for(int s=0;s<Ls;s++){
|
||||
uint64_t idx_u = ss+((s+1)%Ls);
|
||||
uint64_t idx_l = ss+((s+Ls-1)%Ls);
|
||||
spProj5m(tmp1,psi(idx_u));
|
||||
spProj5p(tmp2,psi(idx_l));
|
||||
double pu = (s==(Ls-1)) ? mass: -1.0;
|
||||
double pl = (s==0) ? mass: -1.0;
|
||||
chi[ss+s]=diag*psi(ss+s)+pu*tmp1+pl*tmp2;
|
||||
}
|
||||
});
|
||||
}
|
||||
ref = ref + tmp;
|
||||
ref = ref - src5;
|
||||
std::cout << "residual "<< norm2(ref)<< std::endl;
|
||||
std::cout << "src "<< norm2(src5)<< std::endl;
|
||||
std::cout << "result "<< norm2(result5)<< std::endl;
|
||||
*/
|
85
tests/solver/Test_wilsonclover_bicgstab_prec.cc
Normal file
85
tests/solver/Test_wilsonclover_bicgstab_prec.cc
Normal file
@ -0,0 +1,85 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_wilson_cg_unprec.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::Algebra Gmu [] = {
|
||||
Gamma::Algebra::GammaX,
|
||||
Gamma::Algebra::GammaY,
|
||||
Gamma::Algebra::GammaZ,
|
||||
Gamma::Algebra::GammaT
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
Coordinate latt_size = GridDefaultLatt();
|
||||
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
Coordinate mpi_layout = GridDefaultMpi();
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBGrid(&Grid);
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
LatticeFermion src(&Grid); random(pRNG,src);
|
||||
RealD nrm = norm2(src);
|
||||
LatticeFermion result(&Grid); result=Zero();
|
||||
LatticeGaugeField Umu(&Grid); SU3::HotConfiguration(pRNG,Umu);
|
||||
|
||||
double volume=1;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
volume=volume*latt_size[mu];
|
||||
}
|
||||
|
||||
RealD mass = -0.1;
|
||||
RealD csw_r = 1.0;
|
||||
RealD csw_t = 1.0;
|
||||
WilsonCloverFermionR Dw(Umu, Grid, RBGrid, mass, csw_r, csw_t);
|
||||
|
||||
LatticeFermion src_o(&RBGrid);
|
||||
LatticeFermion result_o(&RBGrid);
|
||||
pickCheckerboard(Odd, src_o, src);
|
||||
result_o = Zero();
|
||||
|
||||
NonHermitianSchurDiagMooeeOperator<WilsonCloverFermionR,LatticeFermion> HermOp(Dw);
|
||||
BiCGSTAB<LatticeFermion> CG(1.0e-8,10000);
|
||||
CG(HermOp, src_o, result_o);
|
||||
|
||||
Grid_finalize();
|
||||
}
|
81
tests/solver/Test_wilsonclover_bicgstab_schur.cc
Normal file
81
tests/solver/Test_wilsonclover_bicgstab_schur.cc
Normal file
@ -0,0 +1,81 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_wilson_cg_unprec.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::Algebra Gmu [] = {
|
||||
Gamma::Algebra::GammaX,
|
||||
Gamma::Algebra::GammaY,
|
||||
Gamma::Algebra::GammaZ,
|
||||
Gamma::Algebra::GammaT
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
Coordinate latt_size = GridDefaultLatt();
|
||||
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
Coordinate mpi_layout = GridDefaultMpi();
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBGrid(&Grid);
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
LatticeFermion src(&Grid); random(pRNG,src);
|
||||
RealD nrm = norm2(src);
|
||||
LatticeFermion result(&Grid); result=Zero();
|
||||
LatticeGaugeField Umu(&Grid); SU3::HotConfiguration(pRNG,Umu);
|
||||
|
||||
double volume=1;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
volume=volume*latt_size[mu];
|
||||
}
|
||||
|
||||
RealD mass = -0.1;
|
||||
RealD csw_r = 1.0;
|
||||
RealD csw_t = 1.0;
|
||||
WilsonCloverFermionR Dw(Umu, Grid, RBGrid, mass, csw_r, csw_t);
|
||||
|
||||
BiCGSTAB<LatticeFermion> CG(1.0e-8,10000);
|
||||
NonHermitianSchurRedBlackDiagMooeeSolve<LatticeFermion> SchurSolver(CG);
|
||||
|
||||
SchurSolver(Dw, src, result);
|
||||
|
||||
Grid_finalize();
|
||||
}
|
80
tests/solver/Test_wilsonclover_bicgstab_unprec.cc
Normal file
80
tests/solver/Test_wilsonclover_bicgstab_unprec.cc
Normal file
@ -0,0 +1,80 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_wilson_cg_unprec.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::Algebra Gmu [] = {
|
||||
Gamma::Algebra::GammaX,
|
||||
Gamma::Algebra::GammaY,
|
||||
Gamma::Algebra::GammaZ,
|
||||
Gamma::Algebra::GammaT
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
Coordinate latt_size = GridDefaultLatt();
|
||||
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
Coordinate mpi_layout = GridDefaultMpi();
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBGrid(&Grid);
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
LatticeFermion src(&Grid); random(pRNG,src);
|
||||
RealD nrm = norm2(src);
|
||||
LatticeFermion result(&Grid); result=Zero();
|
||||
LatticeGaugeField Umu(&Grid); SU3::HotConfiguration(pRNG,Umu);
|
||||
|
||||
double volume=1;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
volume=volume*latt_size[mu];
|
||||
}
|
||||
|
||||
RealD mass = -0.1;
|
||||
RealD csw_r = 1.0;
|
||||
RealD csw_t = 1.0;
|
||||
WilsonCloverFermionR Dw(Umu, Grid, RBGrid, mass, csw_r, csw_t);
|
||||
|
||||
NonHermitianLinearOperator<WilsonCloverFermionR,LatticeFermion> HermOp(Dw);
|
||||
BiCGSTAB<LatticeFermion> CG(1.0e-8,10000);
|
||||
CG(HermOp,src,result);
|
||||
|
||||
Grid_finalize();
|
||||
}
|
91
tests/solver/Test_wilsonclover_cg_prec.cc
Normal file
91
tests/solver/Test_wilsonclover_cg_prec.cc
Normal file
@ -0,0 +1,91 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_wilson_cg_prec.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::Algebra Gmu [] = {
|
||||
Gamma::Algebra::GammaX,
|
||||
Gamma::Algebra::GammaY,
|
||||
Gamma::Algebra::GammaZ,
|
||||
Gamma::Algebra::GammaT
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
|
||||
Coordinate latt_size = GridDefaultLatt();
|
||||
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
Coordinate mpi_layout = GridDefaultMpi();
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBGrid(&Grid);
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
LatticeFermion src(&Grid); random(pRNG,src);
|
||||
RealD nrm = norm2(src);
|
||||
LatticeFermion result(&Grid); result=Zero();
|
||||
LatticeGaugeField Umu(&Grid); SU3::HotConfiguration(pRNG,Umu);
|
||||
|
||||
std::vector<LatticeColourMatrix> U(4,&Grid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
U[mu] = PeekIndex<LorentzIndex>(Umu,mu);
|
||||
}
|
||||
|
||||
RealD mass = -0.1;
|
||||
RealD csw_r = 1.0;
|
||||
RealD csw_t = 1.0;
|
||||
WilsonCloverFermionR Dw(Umu, Grid, RBGrid, mass, csw_r, csw_t);
|
||||
|
||||
// HermitianOperator<WilsonFermion,LatticeFermion> HermOp(Dw);
|
||||
// ConjugateGradient<LatticeFermion> CG(1.0e-8,10000);
|
||||
// CG(HermOp,src,result);
|
||||
|
||||
LatticeFermion src_o(&RBGrid);
|
||||
LatticeFermion result_o(&RBGrid);
|
||||
pickCheckerboard(Odd,src_o,src);
|
||||
result_o=Zero();
|
||||
|
||||
SchurDiagMooeeOperator<WilsonCloverFermionR,LatticeFermion> HermOpEO(Dw);
|
||||
ConjugateGradient<LatticeFermion> CG(1.0e-8,10000);
|
||||
CG(HermOpEO,src_o,result_o);
|
||||
|
||||
|
||||
Grid_finalize();
|
||||
}
|
77
tests/solver/Test_wilsonclover_cg_schur.cc
Normal file
77
tests/solver/Test_wilsonclover_cg_schur.cc
Normal file
@ -0,0 +1,77 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_wilson_cg_schur.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::Algebra Gmu [] = {
|
||||
Gamma::Algebra::GammaX,
|
||||
Gamma::Algebra::GammaY,
|
||||
Gamma::Algebra::GammaZ,
|
||||
Gamma::Algebra::GammaT
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
|
||||
Coordinate latt_size = GridDefaultLatt();
|
||||
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
Coordinate mpi_layout = GridDefaultMpi();
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBGrid(&Grid);
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
LatticeGaugeField Umu(&Grid); SU3::HotConfiguration(pRNG,Umu);
|
||||
|
||||
LatticeFermion src(&Grid); random(pRNG,src);
|
||||
LatticeFermion result(&Grid); result=Zero();
|
||||
LatticeFermion resid(&Grid);
|
||||
|
||||
RealD mass = -0.1;
|
||||
RealD csw_r = 1.0;
|
||||
RealD csw_t = 1.0;
|
||||
WilsonCloverFermionR Dw(Umu, Grid, RBGrid, mass, csw_r, csw_t);
|
||||
|
||||
ConjugateGradient<LatticeFermion> CG(1.0e-8,10000);
|
||||
SchurRedBlackDiagMooeeSolve<LatticeFermion> SchurSolver(CG);
|
||||
|
||||
SchurSolver(Dw,src,result);
|
||||
|
||||
Grid_finalize();
|
||||
}
|
80
tests/solver/Test_wilsonclover_cg_unprec.cc
Normal file
80
tests/solver/Test_wilsonclover_cg_unprec.cc
Normal file
@ -0,0 +1,80 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_wilson_cg_unprec.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::Algebra Gmu [] = {
|
||||
Gamma::Algebra::GammaX,
|
||||
Gamma::Algebra::GammaY,
|
||||
Gamma::Algebra::GammaZ,
|
||||
Gamma::Algebra::GammaT
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
Coordinate latt_size = GridDefaultLatt();
|
||||
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
Coordinate mpi_layout = GridDefaultMpi();
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBGrid(&Grid);
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
LatticeFermion src(&Grid); random(pRNG,src);
|
||||
RealD nrm = norm2(src);
|
||||
LatticeFermion result(&Grid); result=Zero();
|
||||
LatticeGaugeField Umu(&Grid); SU3::HotConfiguration(pRNG,Umu);
|
||||
|
||||
double volume=1;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
volume=volume*latt_size[mu];
|
||||
}
|
||||
|
||||
RealD mass = -0.1;
|
||||
RealD csw_r = 1.0;
|
||||
RealD csw_t = 1.0;
|
||||
WilsonCloverFermionR Dw(Umu, Grid, RBGrid, mass, csw_r, csw_t);
|
||||
|
||||
MdagMLinearOperator<WilsonFermionR,LatticeFermion> HermOp(Dw);
|
||||
ConjugateGradient<LatticeFermion> CG(1.0e-8,10000);
|
||||
CG(HermOp,src,result);
|
||||
|
||||
Grid_finalize();
|
||||
}
|
126
tests/solver/Test_wilsonclover_mixedbicgstab_prec.cc
Normal file
126
tests/solver/Test_wilsonclover_mixedbicgstab_prec.cc
Normal file
@ -0,0 +1,126 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_dwf_cg_prec.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::Algebra Gmu [] = {
|
||||
Gamma::Algebra::GammaX,
|
||||
Gamma::Algebra::GammaY,
|
||||
Gamma::Algebra::GammaZ,
|
||||
Gamma::Algebra::GammaT
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::cout << GridLogMessage << "::::: NB: to enable a quick bit reproducibility check use the --checksums flag. " << std::endl;
|
||||
|
||||
GridCartesian *FGrid_d = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd, vComplexD::Nsimd()), GridDefaultMpi());
|
||||
GridCartesian *FGrid_f = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd, vComplexF::Nsimd()), GridDefaultMpi());
|
||||
GridRedBlackCartesian *FrbGrid_d = SpaceTimeGrid::makeFourDimRedBlackGrid(FGrid_d);
|
||||
GridRedBlackCartesian *FrbGrid_f = SpaceTimeGrid::makeFourDimRedBlackGrid(FGrid_f);
|
||||
|
||||
std::vector<int> fSeeds({1, 2, 3, 4});
|
||||
GridParallelRNG fPRNG(FGrid_d);
|
||||
fPRNG.SeedFixedIntegers(fSeeds);
|
||||
|
||||
// clang-format off
|
||||
LatticeFermionD src(FGrid_d); gaussian(fPRNG, src);
|
||||
LatticeFermionD result(FGrid_d); result = Zero();
|
||||
LatticeGaugeFieldD Umu_d(FGrid_d); SU3::HotConfiguration(fPRNG, Umu_d);
|
||||
LatticeGaugeFieldF Umu_f(FGrid_f); precisionChange(Umu_f, Umu_d);
|
||||
// clang-format on
|
||||
|
||||
RealD mass = -0.1;
|
||||
RealD csw_r = 1.0;
|
||||
RealD csw_t = 1.0;
|
||||
WilsonCloverFermionD Dw_d(Umu_d, *FGrid_d, *FrbGrid_d, mass, csw_r, csw_t);
|
||||
WilsonCloverFermionF Dw_f(Umu_f, *FGrid_f, *FrbGrid_f, mass, csw_r, csw_t);
|
||||
|
||||
LatticeFermionD src_o(FrbGrid_d);
|
||||
LatticeFermionD result_o(FrbGrid_d);
|
||||
LatticeFermionD result_o_2(FrbGrid_d);
|
||||
pickCheckerboard(Odd, src_o, src);
|
||||
result_o.Checkerboard() = Odd;
|
||||
result_o = Zero();
|
||||
result_o_2.Checkerboard() = Odd;
|
||||
result_o_2 = Zero();
|
||||
|
||||
NonHermitianSchurDiagMooeeOperator<WilsonCloverFermionD, LatticeFermionD> NonHermOpEO_d(Dw_d);
|
||||
NonHermitianSchurDiagMooeeOperator<WilsonCloverFermionF, LatticeFermionF> NonHermOpEO_f(Dw_f);
|
||||
|
||||
std::cout << GridLogMessage << "::::::::::::: Starting mixed CG" << std::endl;
|
||||
MixedPrecisionBiCGSTAB<LatticeFermionD, LatticeFermionF> mCG(1.0e-8, 10000, 50, FrbGrid_f, NonHermOpEO_f, NonHermOpEO_d);
|
||||
mCG(src_o, result_o);
|
||||
|
||||
std::cout << GridLogMessage << "::::::::::::: Starting regular CG" << std::endl;
|
||||
BiCGSTAB<LatticeFermionD> CG(1.0e-8, 10000);
|
||||
CG(NonHermOpEO_d, src_o, result_o_2);
|
||||
|
||||
LatticeFermionD diff_o(FrbGrid_d);
|
||||
RealD diff = axpy_norm(diff_o, -1.0, result_o, result_o_2);
|
||||
|
||||
std::cout << GridLogMessage << "::::::::::::: Diff between mixed and regular CG: " << diff << std::endl;
|
||||
|
||||
#ifdef HAVE_LIME
|
||||
if( GridCmdOptionExists(argv,argv+argc,"--checksums") )
|
||||
{
|
||||
std::string file1("./Propagator1");
|
||||
emptyUserRecord record;
|
||||
uint32_t nersc_csum;
|
||||
uint32_t scidac_csuma;
|
||||
uint32_t scidac_csumb;
|
||||
typedef SpinColourVectorD FermionD;
|
||||
typedef vSpinColourVectorD vFermionD;
|
||||
|
||||
BinarySimpleMunger<FermionD,FermionD> munge;
|
||||
std::string format = getFormatString<vFermionD>();
|
||||
|
||||
BinaryIO::writeLatticeObject<vFermionD,FermionD>(result_o,file1,munge, 0, format,
|
||||
nersc_csum,scidac_csuma,scidac_csumb);
|
||||
|
||||
std::cout << GridLogMessage << " Mixed checksums "<<std::hex << scidac_csuma << " "<<scidac_csumb<<std::endl;
|
||||
|
||||
BinaryIO::writeLatticeObject<vFermionD,FermionD>(result_o_2,file1,munge, 0, format,
|
||||
nersc_csum,scidac_csuma,scidac_csumb);
|
||||
|
||||
std::cout << GridLogMessage << " CG checksums "<<std::hex << scidac_csuma << " "<<scidac_csumb<<std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
Grid_finalize();
|
||||
}
|
126
tests/solver/Test_wilsonclover_mixedcg_prec.cc
Normal file
126
tests/solver/Test_wilsonclover_mixedcg_prec.cc
Normal file
@ -0,0 +1,126 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_dwf_cg_prec.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::Algebra Gmu [] = {
|
||||
Gamma::Algebra::GammaX,
|
||||
Gamma::Algebra::GammaY,
|
||||
Gamma::Algebra::GammaZ,
|
||||
Gamma::Algebra::GammaT
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::cout << GridLogMessage << "::::: NB: to enable a quick bit reproducibility check use the --checksums flag. " << std::endl;
|
||||
|
||||
GridCartesian *FGrid_d = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd, vComplexD::Nsimd()), GridDefaultMpi());
|
||||
GridCartesian *FGrid_f = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd, vComplexF::Nsimd()), GridDefaultMpi());
|
||||
GridRedBlackCartesian *FrbGrid_d = SpaceTimeGrid::makeFourDimRedBlackGrid(FGrid_d);
|
||||
GridRedBlackCartesian *FrbGrid_f = SpaceTimeGrid::makeFourDimRedBlackGrid(FGrid_f);
|
||||
|
||||
std::vector<int> fSeeds({1, 2, 3, 4});
|
||||
GridParallelRNG fPRNG(FGrid_d);
|
||||
fPRNG.SeedFixedIntegers(fSeeds);
|
||||
|
||||
// clang-format off
|
||||
LatticeFermionD src(FGrid_d); gaussian(fPRNG, src);
|
||||
LatticeFermionD result(FGrid_d); result = Zero();
|
||||
LatticeGaugeFieldD Umu_d(FGrid_d); SU3::HotConfiguration(fPRNG, Umu_d);
|
||||
LatticeGaugeFieldF Umu_f(FGrid_f); precisionChange(Umu_f, Umu_d);
|
||||
// clang-format on
|
||||
|
||||
RealD mass = -0.1;
|
||||
RealD csw_r = 1.0;
|
||||
RealD csw_t = 1.0;
|
||||
WilsonCloverFermionD Dw_d(Umu_d, *FGrid_d, *FrbGrid_d, mass, csw_r, csw_t);
|
||||
WilsonCloverFermionF Dw_f(Umu_f, *FGrid_f, *FrbGrid_f, mass, csw_r, csw_t);
|
||||
|
||||
LatticeFermionD src_o(FrbGrid_d);
|
||||
LatticeFermionD result_o(FrbGrid_d);
|
||||
LatticeFermionD result_o_2(FrbGrid_d);
|
||||
pickCheckerboard(Odd, src_o, src);
|
||||
result_o.Checkerboard() = Odd;
|
||||
result_o = Zero();
|
||||
result_o_2.Checkerboard() = Odd;
|
||||
result_o_2 = Zero();
|
||||
|
||||
SchurDiagMooeeOperator<WilsonCloverFermionD, LatticeFermionD> HermOpEO_d(Dw_d);
|
||||
SchurDiagMooeeOperator<WilsonCloverFermionF, LatticeFermionF> HermOpEO_f(Dw_f);
|
||||
|
||||
std::cout << GridLogMessage << "::::::::::::: Starting mixed CG" << std::endl;
|
||||
MixedPrecisionConjugateGradient<LatticeFermionD, LatticeFermionF> mCG(1.0e-8, 10000, 50, FrbGrid_f, HermOpEO_f, HermOpEO_d);
|
||||
mCG(src_o, result_o);
|
||||
|
||||
std::cout << GridLogMessage << "::::::::::::: Starting regular CG" << std::endl;
|
||||
ConjugateGradient<LatticeFermionD> CG(1.0e-8, 10000);
|
||||
CG(HermOpEO_d, src_o, result_o_2);
|
||||
|
||||
LatticeFermionD diff_o(FrbGrid_d);
|
||||
RealD diff = axpy_norm(diff_o, -1.0, result_o, result_o_2);
|
||||
|
||||
std::cout << GridLogMessage << "::::::::::::: Diff between mixed and regular CG: " << diff << std::endl;
|
||||
|
||||
#ifdef HAVE_LIME
|
||||
if( GridCmdOptionExists(argv,argv+argc,"--checksums") )
|
||||
{
|
||||
std::string file1("./Propagator1");
|
||||
emptyUserRecord record;
|
||||
uint32_t nersc_csum;
|
||||
uint32_t scidac_csuma;
|
||||
uint32_t scidac_csumb;
|
||||
typedef SpinColourVectorD FermionD;
|
||||
typedef vSpinColourVectorD vFermionD;
|
||||
|
||||
BinarySimpleMunger<FermionD,FermionD> munge;
|
||||
std::string format = getFormatString<vFermionD>();
|
||||
|
||||
BinaryIO::writeLatticeObject<vFermionD,FermionD>(result_o,file1,munge, 0, format,
|
||||
nersc_csum,scidac_csuma,scidac_csumb);
|
||||
|
||||
std::cout << GridLogMessage << " Mixed checksums "<<std::hex << scidac_csuma << " "<<scidac_csumb<<std::endl;
|
||||
|
||||
BinaryIO::writeLatticeObject<vFermionD,FermionD>(result_o_2,file1,munge, 0, format,
|
||||
nersc_csum,scidac_csuma,scidac_csumb);
|
||||
|
||||
std::cout << GridLogMessage << " CG checksums "<<std::hex << scidac_csuma << " "<<scidac_csumb<<std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
Grid_finalize();
|
||||
}
|
303
tests/solver/Test_zMADWF_prec.cc
Normal file
303
tests/solver/Test_zMADWF_prec.cc
Normal file
@ -0,0 +1,303 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/solver/Test_zMADWF_prec.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Christopher Kelly <ckelly@phys.columbia.edu>
|
||||
|
||||
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 */
|
||||
|
||||
//This test computes the zMobius approximation to the Mobius action and uses it within the MADWF context to accelerate an inversion
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
|
||||
struct TestParams{
|
||||
bool load_config;
|
||||
std::string config_file;
|
||||
|
||||
double mass;
|
||||
|
||||
std::string outer_precon;
|
||||
std::string inner_precon;
|
||||
|
||||
int Ls_outer;
|
||||
double b_plus_c_outer;
|
||||
double resid_outer;
|
||||
|
||||
int Ls_inner;
|
||||
double b_plus_c_inner; //irrelevant for ZMobius
|
||||
double resid_inner;
|
||||
bool zmobius_inner;
|
||||
double lambda_max; //upper bound of H_T eigenvalue range required to generate zMobius approximation
|
||||
|
||||
TestParams(): load_config(true), config_file("ckpoint_lat.1000"), mass(0.01),
|
||||
Ls_outer(24), b_plus_c_outer(2.0), resid_outer(1e-8),
|
||||
Ls_inner(12), b_plus_c_inner(1.0), resid_inner(1e-8), zmobius_inner(true), lambda_max(1.42), outer_precon("Standard"), inner_precon("Standard")
|
||||
{}
|
||||
|
||||
void write(const std::string &file) const{
|
||||
XmlWriter wr(file);
|
||||
#define DOIT(A) wr.writeDefault(#A, A)
|
||||
DOIT(load_config);
|
||||
DOIT(config_file);
|
||||
DOIT(mass);
|
||||
DOIT(outer_precon);
|
||||
DOIT(inner_precon);
|
||||
DOIT(Ls_outer);
|
||||
DOIT(b_plus_c_outer);
|
||||
DOIT(resid_outer);
|
||||
DOIT(Ls_inner);
|
||||
DOIT(b_plus_c_inner);
|
||||
DOIT(resid_inner);
|
||||
DOIT(zmobius_inner);
|
||||
DOIT(lambda_max);
|
||||
#undef DOIT
|
||||
}
|
||||
void read(const std::string &file){
|
||||
XmlReader rd(file);
|
||||
#define DOIT(A) rd.readDefault(#A, A)
|
||||
DOIT(load_config);
|
||||
DOIT(config_file);
|
||||
DOIT(mass);
|
||||
DOIT(outer_precon);
|
||||
DOIT(inner_precon);
|
||||
DOIT(Ls_outer);
|
||||
DOIT(b_plus_c_outer);
|
||||
DOIT(resid_outer);
|
||||
DOIT(Ls_inner);
|
||||
DOIT(b_plus_c_inner);
|
||||
DOIT(resid_inner);
|
||||
DOIT(zmobius_inner);
|
||||
DOIT(lambda_max);
|
||||
#undef DOIT
|
||||
}
|
||||
};
|
||||
|
||||
struct RunParamsPrecStd{
|
||||
typedef SchurRedBlackDiagMooeeSolve<LatticeFermionD> SchurSolverType;
|
||||
|
||||
template<typename Action>
|
||||
using HermOpType = SchurDiagMooeeOperator<Action, LatticeFermionD>;
|
||||
};
|
||||
|
||||
struct RunParamsPrecDiagTwo{
|
||||
typedef SchurRedBlackDiagTwoSolve<LatticeFermionD> SchurSolverType;
|
||||
|
||||
template<typename Action>
|
||||
using HermOpType = SchurDiagTwoOperator<Action, LatticeFermionD>;
|
||||
};
|
||||
|
||||
|
||||
struct CGincreaseTol : public MADWFinnerIterCallbackBase{
|
||||
ConjugateGradient<LatticeFermionD> &cg_inner;
|
||||
RealD outer_resid;
|
||||
|
||||
CGincreaseTol(ConjugateGradient<LatticeFermionD> &cg_inner,
|
||||
RealD outer_resid): cg_inner(cg_inner), outer_resid(outer_resid){}
|
||||
|
||||
void operator()(const RealD current_resid){
|
||||
std::cout << "CGincreaseTol with current residual " << current_resid << " changing inner tolerance " << cg_inner.Tolerance << " -> ";
|
||||
while(cg_inner.Tolerance < current_resid) cg_inner.Tolerance *= 2;
|
||||
//cg_inner.Tolerance = outer_resid/current_resid;
|
||||
std::cout << cg_inner.Tolerance << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename RunParamsOuter, typename RunParamsInner>
|
||||
void run(const TestParams ¶ms){
|
||||
RealD bmc = 1.0; //use Shamir kernel
|
||||
std::vector<ComplexD> gamma_inner;
|
||||
|
||||
std::cout << "Compute parameters" << std::endl;
|
||||
if(params.zmobius_inner){
|
||||
Approx::computeZmobiusGamma(gamma_inner, params.b_plus_c_inner, params.Ls_inner, params.b_plus_c_outer, params.Ls_outer, params.lambda_max);
|
||||
}else{
|
||||
Approx::zolotarev_data *zdata = Approx::higham(1.0,params.Ls_inner);
|
||||
gamma_inner.resize(params.Ls_inner);
|
||||
for(int s=0;s<params.Ls_inner;s++) gamma_inner[s] = zdata->gamma[s];
|
||||
Approx::zolotarev_free(zdata);
|
||||
}
|
||||
std::cout << "gamma:\n";
|
||||
for(int s=0;s<params.Ls_inner;s++) std::cout << s << " " << gamma_inner[s] << std::endl;
|
||||
|
||||
|
||||
GridCartesian* UGrid = SpaceTimeGrid::makeFourDimGrid(
|
||||
GridDefaultLatt(), GridDefaultSimd(Nd, vComplexD::Nsimd()),
|
||||
GridDefaultMpi());
|
||||
GridRedBlackCartesian* UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
|
||||
|
||||
GridCartesian* FGrid_outer = SpaceTimeGrid::makeFiveDimGrid(params.Ls_outer, UGrid);
|
||||
GridCartesian* FGrid_inner = SpaceTimeGrid::makeFiveDimGrid(params.Ls_inner, UGrid);
|
||||
|
||||
GridRedBlackCartesian* FrbGrid_outer = SpaceTimeGrid::makeFiveDimRedBlackGrid(params.Ls_outer, UGrid);
|
||||
GridRedBlackCartesian* FrbGrid_inner = SpaceTimeGrid::makeFiveDimRedBlackGrid(params.Ls_inner, UGrid);
|
||||
|
||||
|
||||
std::vector<int> seeds4({1, 2, 3, 4});
|
||||
std::vector<int> seeds5({5, 6, 7, 8});
|
||||
|
||||
GridParallelRNG RNG5_outer(FGrid_outer);
|
||||
RNG5_outer.SeedFixedIntegers(seeds5);
|
||||
|
||||
GridParallelRNG RNG4(UGrid);
|
||||
RNG4.SeedFixedIntegers(seeds4);
|
||||
|
||||
LatticeFermionD src4(UGrid); random(RNG4,src4);
|
||||
|
||||
LatticeFermionD result_outer(FGrid_outer);
|
||||
result_outer = Zero();
|
||||
LatticeGaugeFieldD Umu(UGrid);
|
||||
|
||||
if(params.load_config){
|
||||
FieldMetaData header;
|
||||
NerscIO::readConfiguration(Umu, header, params.config_file);
|
||||
|
||||
for(int i=0;i<Nd;i++){
|
||||
assert(header.dimension[i] == GridDefaultLatt()[i]);
|
||||
}
|
||||
}else{
|
||||
SU3::HotConfiguration(RNG4, Umu);
|
||||
}
|
||||
|
||||
std::cout << GridLogMessage << "Lattice dimensions: " << GridDefaultLatt()
|
||||
<< " Ls: " << params.Ls_outer << std::endl;
|
||||
|
||||
RealD M5 = 1.8;
|
||||
|
||||
RealD b_outer = (params.b_plus_c_outer + bmc)/2.;
|
||||
RealD c_outer = (params.b_plus_c_outer - bmc)/2.;
|
||||
|
||||
RealD b_inner = (params.b_plus_c_inner + bmc)/2.;
|
||||
RealD c_inner = (params.b_plus_c_inner - bmc)/2.;
|
||||
|
||||
MobiusFermionD D_outer(Umu, *FGrid_outer, *FrbGrid_outer, *UGrid, *UrbGrid, params.mass, M5, b_outer, c_outer);
|
||||
ZMobiusFermionD D_inner(Umu, *FGrid_inner, *FrbGrid_inner, *UGrid, *UrbGrid, params.mass, M5, gamma_inner, b_inner, c_inner);
|
||||
|
||||
LatticeFermionD src_outer(FGrid_outer);
|
||||
D_outer.ImportPhysicalFermionSource(src4,src_outer); //applies D_-
|
||||
|
||||
//Solve using a regular even-odd preconditioned CG for the Hermitian operator
|
||||
//M y = x
|
||||
//Mprec y'_o = x'_o where Mprec = Doo - Doe Dee^-1 Deo and x'_o = -Doe Dee^-1 x_e + x_o
|
||||
//y_o = y'_o
|
||||
|
||||
//(Mprec^dag Mprec) y'_o = Mprec^dag x'_o
|
||||
//y'_o = (Mprec^dag Mprec)^-1 Mprec^dag x'_o
|
||||
|
||||
//We can get Mprec^dag x'_o from x_o from SchurRedBlackDiagMooeeSolve::RedBlackSource
|
||||
ConjugateGradient<LatticeFermionD> CG_outer(params.resid_outer, 10000);
|
||||
typename RunParamsOuter::SchurSolverType SchurSolver_outer(CG_outer);
|
||||
|
||||
LatticeFermionD tmp_e_outer(FrbGrid_outer);
|
||||
LatticeFermionD src_o_outer(FrbGrid_outer);
|
||||
SchurSolver_outer.RedBlackSource(D_outer, src_outer, tmp_e_outer, src_o_outer);
|
||||
|
||||
LatticeFermionD result_o_outer(FrbGrid_outer);
|
||||
result_o_outer = Zero();
|
||||
|
||||
GridStopWatch CGTimer;
|
||||
|
||||
typename RunParamsOuter::HermOpType<MobiusFermionD> HermOpEO_outer(D_outer);
|
||||
|
||||
CGTimer.Start();
|
||||
CG_outer(HermOpEO_outer, src_o_outer, result_o_outer);
|
||||
CGTimer.Stop();
|
||||
|
||||
std::cout << GridLogMessage << "Total outer CG time : " << CGTimer.Elapsed()
|
||||
<< std::endl;
|
||||
|
||||
CGTimer.Reset();
|
||||
|
||||
//Solve for y using MADWF with internal preconditioning
|
||||
|
||||
//typedef PauliVillarsSolverRBprec<LatticeFermionD, typename RunParamsOuter::SchurSolverType> PVtype;
|
||||
//PVtype PV_outer(SchurSolver_outer);
|
||||
|
||||
typedef PauliVillarsSolverFourierAccel<LatticeFermionD, LatticeGaugeFieldD> PVtype;
|
||||
PVtype PV_outer(Umu, CG_outer);
|
||||
|
||||
ConjugateGradient<LatticeFermionD> CG_inner(params.resid_inner, 10000, 0);
|
||||
|
||||
CGincreaseTol update(CG_inner, params.resid_outer);
|
||||
|
||||
typename RunParamsInner::SchurSolverType SchurSolver_inner(CG_inner);
|
||||
|
||||
ZeroGuesser<LatticeFermion> Guess;
|
||||
MADWF<MobiusFermionD, ZMobiusFermionD, PVtype, typename RunParamsInner::SchurSolverType, ZeroGuesser<LatticeFermion> > madwf(D_outer, D_inner, PV_outer, SchurSolver_inner, Guess, params.resid_outer, 100, &update);
|
||||
|
||||
LatticeFermionD result_MADWF(FGrid_outer);
|
||||
result_MADWF = Zero();
|
||||
|
||||
CGTimer.Start();
|
||||
madwf(src4, result_MADWF);
|
||||
CGTimer.Stop();
|
||||
|
||||
LatticeFermionD result_o_MADWF(FrbGrid_outer);
|
||||
pickCheckerboard(Odd, result_o_MADWF, result_MADWF);
|
||||
|
||||
std::cout << GridLogMessage << "Total MADWF time : " << CGTimer.Elapsed()
|
||||
<< std::endl;
|
||||
|
||||
LatticeFermionD diff = result_o_MADWF - result_o_outer;
|
||||
std::cout <<GridLogMessage<< "Odd-parity MADWF result norm " << norm2(result_o_MADWF)
|
||||
<< " Regular result norm " << norm2(result_o_outer)
|
||||
<< " Norm of diff " << norm2(diff)<<std::endl;
|
||||
|
||||
|
||||
//std::cout << GridLogMessage << "######## Dhop calls summary" << std::endl;
|
||||
//D_outer.Report();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
std::cout << "Init" << std::endl;
|
||||
Grid_init(&argc, &argv);
|
||||
|
||||
TestParams params;
|
||||
|
||||
if( GridCmdOptionExists(argv,argv+argc,"--params") ){
|
||||
std::string pfile = GridCmdOptionPayload(argv,argv+argc,"--params");
|
||||
if(pfile == "TEMPLATE"){
|
||||
params.write("params.templ");
|
||||
return 0;
|
||||
}else{
|
||||
params.read(pfile);
|
||||
}
|
||||
}
|
||||
|
||||
if(params.outer_precon == "Standard" && params.inner_precon == "Standard" ){
|
||||
run<RunParamsPrecStd, RunParamsPrecStd>(params);
|
||||
}else if(params.outer_precon == "DiagTwo" && params.inner_precon == "Standard"){
|
||||
run<RunParamsPrecDiagTwo, RunParamsPrecStd>(params);
|
||||
}else if(params.outer_precon == "Standard" && params.inner_precon == "DiagTwo"){
|
||||
run<RunParamsPrecStd, RunParamsPrecDiagTwo>(params);
|
||||
}else if(params.outer_precon == "DiagTwo" && params.inner_precon == "DiagTwo"){
|
||||
run<RunParamsPrecDiagTwo, RunParamsPrecDiagTwo>(params);
|
||||
}else assert(0);
|
||||
|
||||
Grid_finalize();
|
||||
}
|
Reference in New Issue
Block a user