mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-12 20:27:06 +01:00
Merge branch 'master' of https://github.com/paboyle/Grid
This commit is contained in:
113
lib/qcd/LinalgUtils.h
Normal file
113
lib/qcd/LinalgUtils.h
Normal file
@ -0,0 +1,113 @@
|
||||
#ifndef GRID_QCD_LINALG_UTILS_H
|
||||
#define GRID_QCD_LINALG_UTILS_H
|
||||
|
||||
namespace Grid{
|
||||
namespace QCD{
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//This file brings additional linear combination assist that is helpful
|
||||
//to QCD such as chiral projectors and spin matrices applied to one of the inputs.
|
||||
//These routines support five-D chiral fermions and contain s-subslice indexing
|
||||
//on the 5d (rb4d) checkerboarded lattices
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
template<class vobj>
|
||||
void axpby_ssp(Lattice<vobj> &z, RealD a,const Lattice<vobj> &x,RealD b,const Lattice<vobj> &y,int s,int sp)
|
||||
{
|
||||
z.checkerboard = x.checkerboard;
|
||||
conformable(x,y);
|
||||
conformable(x,z);
|
||||
GridBase *grid=x._grid;
|
||||
int Ls = grid->_rdimensions[0];
|
||||
PARALLEL_FOR_LOOP
|
||||
for(int ss=0;ss<grid->oSites();ss+=Ls){ // adds Ls
|
||||
vobj tmp = a*x._odata[ss+s]+b*y._odata[ss+sp];
|
||||
vstream(z._odata[ss+s],tmp);
|
||||
}
|
||||
}
|
||||
|
||||
template<class vobj>
|
||||
void ag5xpby_ssp(Lattice<vobj> &z,RealD a,const Lattice<vobj> &x,RealD b,const Lattice<vobj> &y,int s,int sp)
|
||||
{
|
||||
z.checkerboard = x.checkerboard;
|
||||
conformable(x,y);
|
||||
conformable(x,z);
|
||||
GridBase *grid=x._grid;
|
||||
int Ls = grid->_rdimensions[0];
|
||||
PARALLEL_FOR_LOOP
|
||||
for(int ss=0;ss<grid->oSites();ss+=Ls){ // adds Ls
|
||||
vobj tmp;
|
||||
multGamma5(tmp(),a*x._odata[ss+s]());
|
||||
tmp = tmp + b*y._odata[ss+sp];
|
||||
vstream(z._odata[ss+s],tmp);
|
||||
}
|
||||
}
|
||||
|
||||
template<class vobj>
|
||||
void axpbg5y_ssp(Lattice<vobj> &z,RealD a,const Lattice<vobj> &x,RealD b,const Lattice<vobj> &y,int s,int sp)
|
||||
{
|
||||
z.checkerboard = x.checkerboard;
|
||||
conformable(x,y);
|
||||
conformable(x,z);
|
||||
GridBase *grid=x._grid;
|
||||
int Ls = grid->_rdimensions[0];
|
||||
PARALLEL_FOR_LOOP
|
||||
for(int ss=0;ss<grid->oSites();ss+=Ls){ // adds Ls
|
||||
vobj tmp;
|
||||
multGamma5(tmp(),b*y._odata[ss+sp]());
|
||||
tmp = tmp + a*x._odata[ss+s];
|
||||
vstream(z._odata[ss+s],tmp);
|
||||
}
|
||||
}
|
||||
|
||||
template<class vobj>
|
||||
void ag5xpbg5y_ssp(Lattice<vobj> &z,RealD a,const Lattice<vobj> &x,RealD b,const Lattice<vobj> &y,int s,int sp)
|
||||
{
|
||||
z.checkerboard = x.checkerboard;
|
||||
conformable(x,y);
|
||||
conformable(x,z);
|
||||
GridBase *grid=x._grid;
|
||||
int Ls = grid->_rdimensions[0];
|
||||
PARALLEL_FOR_LOOP
|
||||
for(int ss=0;ss<grid->oSites();ss+=Ls){ // adds Ls
|
||||
vobj tmp1;
|
||||
vobj tmp2;
|
||||
tmp1 = a*x._odata[ss+s]+b*y._odata[ss+sp];
|
||||
multGamma5(tmp2(),tmp1());
|
||||
vstream(z._odata[ss+s],tmp2);
|
||||
}
|
||||
}
|
||||
|
||||
template<class vobj>
|
||||
void axpby_ssp_pminus(Lattice<vobj> &z,RealD a,const Lattice<vobj> &x,RealD b,const Lattice<vobj> &y,int s,int sp)
|
||||
{
|
||||
z.checkerboard = x.checkerboard;
|
||||
conformable(x,y);
|
||||
conformable(x,z);
|
||||
GridBase *grid=x._grid;
|
||||
int Ls = grid->_rdimensions[0];
|
||||
PARALLEL_FOR_LOOP
|
||||
for(int ss=0;ss<grid->oSites();ss+=Ls){ // adds Ls
|
||||
vobj tmp;
|
||||
spProj5m(tmp,y._odata[ss+sp]);
|
||||
tmp = a*x._odata[ss+s]+b*tmp;
|
||||
vstream(z._odata[ss+s],tmp);
|
||||
}
|
||||
}
|
||||
|
||||
template<class vobj>
|
||||
void axpby_ssp_pplus(Lattice<vobj> &z,RealD a,const Lattice<vobj> &x,RealD b,const Lattice<vobj> &y,int s,int sp)
|
||||
{
|
||||
z.checkerboard = x.checkerboard;
|
||||
conformable(x,y);
|
||||
conformable(x,z);
|
||||
GridBase *grid=x._grid;
|
||||
int Ls = grid->_rdimensions[0];
|
||||
PARALLEL_FOR_LOOP
|
||||
for(int ss=0;ss<grid->oSites();ss+=Ls){ // adds Ls
|
||||
vobj tmp;
|
||||
spProj5p(tmp,y._odata[ss+sp]);
|
||||
tmp = a*x._odata[ss+s]+b*tmp;
|
||||
vstream(z._odata[ss+s],tmp);
|
||||
}
|
||||
}
|
||||
}}
|
||||
#endif
|
@ -307,8 +307,10 @@ namespace QCD {
|
||||
} //namespace QCD
|
||||
} // Grid
|
||||
|
||||
#include <qcd/SpaceTimeGrid.h>
|
||||
#include <qcd/Dirac.h>
|
||||
#include <qcd/TwoSpinor.h>
|
||||
#include <qcd/LinalgUtils.h>
|
||||
#include <qcd/action/Actions.h>
|
||||
|
||||
#endif
|
||||
|
52
lib/qcd/SpaceTimeGrid.cc
Normal file
52
lib/qcd/SpaceTimeGrid.cc
Normal file
@ -0,0 +1,52 @@
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Public interface
|
||||
/////////////////////////////////////////////////////////////////
|
||||
GridCartesian *SpaceTimeGrid::makeFourDimGrid(const std::vector<int> & latt,const std::vector<int> &simd,const std::vector<int> &mpi)
|
||||
{
|
||||
return new GridCartesian(latt,simd,mpi);
|
||||
}
|
||||
GridRedBlackCartesian *SpaceTimeGrid::makeFourDimRedBlackGrid(const GridCartesian *FourDimGrid)
|
||||
{
|
||||
return new GridRedBlackCartesian(FourDimGrid);
|
||||
}
|
||||
|
||||
GridCartesian *SpaceTimeGrid::makeFiveDimGrid(int Ls,const GridCartesian *FourDimGrid)
|
||||
{
|
||||
int N4=FourDimGrid->_ndimension;
|
||||
|
||||
std::vector<int> latt5(1,Ls);
|
||||
std::vector<int> simd5(1,1);
|
||||
std::vector<int> mpi5(1,1);
|
||||
|
||||
for(int d=0;d<N4;d++){
|
||||
latt5.push_back(FourDimGrid->_fdimensions[d]);
|
||||
simd5.push_back(FourDimGrid->_simd_layout[d]);
|
||||
mpi5.push_back(FourDimGrid->_processors[d]);
|
||||
}
|
||||
return new GridCartesian(latt5,simd5,mpi5);
|
||||
}
|
||||
|
||||
GridRedBlackCartesian *SpaceTimeGrid::makeFiveDimRedBlackGrid(int Ls,const GridCartesian *FourDimGrid)
|
||||
{
|
||||
int N4=FourDimGrid->_ndimension;
|
||||
int cbd=1;
|
||||
std::vector<int> latt5(1,Ls);
|
||||
std::vector<int> simd5(1,1);
|
||||
std::vector<int> mpi5(1,1);
|
||||
std::vector<int> cb5(1,0);
|
||||
|
||||
for(int d=0;d<N4;d++){
|
||||
latt5.push_back(FourDimGrid->_fdimensions[d]);
|
||||
simd5.push_back(FourDimGrid->_simd_layout[d]);
|
||||
mpi5.push_back(FourDimGrid->_processors[d]);
|
||||
cb5.push_back( 1);
|
||||
}
|
||||
return new GridRedBlackCartesian(latt5,simd5,mpi5,cb5,cbd);
|
||||
}
|
||||
|
||||
}}
|
18
lib/qcd/SpaceTimeGrid.h
Normal file
18
lib/qcd/SpaceTimeGrid.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef GRID_QCD_SPACE_TIME_GRID_H
|
||||
#define GRID_QCD_SPACE_TIME_GRID_H
|
||||
namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
class SpaceTimeGrid {
|
||||
public:
|
||||
|
||||
static GridCartesian *makeFourDimGrid(const std::vector<int> & latt,const std::vector<int> &simd,const std::vector<int> &mpi);
|
||||
static GridRedBlackCartesian *makeFourDimRedBlackGrid (const GridCartesian *FourDimGrid);
|
||||
static GridCartesian *makeFiveDimGrid (int Ls,const GridCartesian *FourDimGrid);
|
||||
static GridRedBlackCartesian *makeFiveDimRedBlackGrid(int Ls,const GridCartesian *FourDimGrid);
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
@ -1,10 +1,100 @@
|
||||
#ifndef GRID_QCD_ACTIONS_H
|
||||
#define GRID_QCD_ACTIONS_H
|
||||
|
||||
#include <qcd/action/fermion/FermionAction.h>
|
||||
#include <qcd/action/fermion/WilsonCompressor.h>
|
||||
#include <qcd/action/fermion/WilsonKernels.h>
|
||||
|
||||
// Some reorganisation likely required as both Chroma and IroIro
|
||||
// are separating the concept of the operator from that of action.
|
||||
//
|
||||
// The FermAction contains methods to create
|
||||
//
|
||||
// * Linear operators (Hermitian and non-hermitian) .. my LinearOperator
|
||||
// * System solvers (Hermitian and non-hermitian) .. my OperatorFunction
|
||||
// * MultiShift System solvers (Hermitian and non-hermitian) .. my OperatorFunction
|
||||
|
||||
|
||||
////////////////////////////////////////////
|
||||
// Abstract base interface
|
||||
////////////////////////////////////////////
|
||||
#include <qcd/action/fermion/FermionOperator.h>
|
||||
|
||||
////////////////////////////////////////////
|
||||
// Utility functions
|
||||
////////////////////////////////////////////
|
||||
#include <qcd/action/fermion/WilsonCompressor.h> //used by all wilson type fermions
|
||||
#include <qcd/action/fermion/WilsonKernels.h> //used by all wilson type fermions
|
||||
|
||||
////////////////////////////////////////////
|
||||
// 4D formulations
|
||||
////////////////////////////////////////////
|
||||
#include <qcd/action/fermion/WilsonFermion.h>
|
||||
#include <qcd/action/fermion/FiveDimWilsonFermion.h>
|
||||
//#include <qcd/action/fermion/CloverFermion.h>
|
||||
|
||||
////////////////////////////////////////////
|
||||
// 5D formulations...
|
||||
////////////////////////////////////////////
|
||||
|
||||
#include <qcd/action/fermion/WilsonFermion5D.h> // used by all 5d overlap types
|
||||
|
||||
//////////
|
||||
// Cayley
|
||||
//////////
|
||||
#include <qcd/action/fermion/CayleyFermion5D.h>
|
||||
|
||||
#include <qcd/action/fermion/DomainWallFermion.h>
|
||||
#include <qcd/action/fermion/DomainWallFermion.h>
|
||||
|
||||
#include <qcd/action/fermion/MobiusFermion.h>
|
||||
#include <qcd/action/fermion/ScaledShamirFermion.h>
|
||||
#include <qcd/action/fermion/OverlapWilsonCayleyTanhFermion.h>
|
||||
|
||||
#include <qcd/action/fermion/MobiusZolotarevFermion.h>
|
||||
#include <qcd/action/fermion/ShamirZolotarevFermion.h>
|
||||
#include <qcd/action/fermion/OverlapWilsonCayleyZolotarevFermion.h>
|
||||
|
||||
//////////////////////
|
||||
// Continued fraction
|
||||
//////////////////////
|
||||
#include <qcd/action/fermion/ContinuedFractionFermion5D.h>
|
||||
#include <qcd/action/fermion/OverlapWilsonContfracTanhFermion.h>
|
||||
#include <qcd/action/fermion/OverlapWilsonContfracZolotarevFermion.h>
|
||||
|
||||
//////////////////////
|
||||
// Partial fraction
|
||||
//////////////////////
|
||||
#include <qcd/action/fermion/PartialFractionFermion5D.h>
|
||||
#include <qcd/action/fermion/OverlapWilsonPartialFractionTanhFermion.h>
|
||||
#include <qcd/action/fermion/OverlapWilsonPartialFractionZolotarevFermion.h>
|
||||
|
||||
|
||||
// Chroma interface defining FermionAction
|
||||
/*
|
||||
template<typename T, typename P, typename Q> class FermAct4D : public FermionAction<T,P,Q>
|
||||
virtual LinearOperator<T>* linOp(Handle< FermState<T,P,Q> > state) const = 0;
|
||||
virtual LinearOperator<T>* lMdagM(Handle< FermState<T,P,Q> > state) const = 0;
|
||||
virtual LinOpSystemSolver<T>* invLinOp(Handle< FermState<T,P,Q> > state,
|
||||
virtual MdagMSystemSolver<T>* invMdagM(Handle< FermState<T,P,Q> > state,
|
||||
virtual LinOpMultiSystemSolver<T>* mInvLinOp(Handle< FermState<T,P,Q> > state,
|
||||
virtual MdagMMultiSystemSolver<T>* mInvMdagM(Handle< FermState<T,P,Q> > state,
|
||||
virtual MdagMMultiSystemSolverAccumulate<T>* mInvMdagMAcc(Handle< FermState<T,P,Q> > state,
|
||||
virtual SystemSolver<T>* qprop(Handle< FermState<T,P,Q> > state,
|
||||
class DiffFermAct4D : public FermAct4D<T,P,Q>
|
||||
virtual DiffLinearOperator<T,Q,P>* linOp(Handle< FermState<T,P,Q> > state) const = 0;
|
||||
virtual DiffLinearOperator<T,Q,P>* lMdagM(Handle< FermState<T,P,Q> > state) const = 0;
|
||||
*/
|
||||
|
||||
|
||||
// Chroma interface defining GaugeAction
|
||||
/*
|
||||
template<typename P, typename Q> class GaugeAction
|
||||
virtual const CreateGaugeState<P,Q>& getCreateState() const = 0;
|
||||
virtual GaugeState<P,Q>* createState(const Q& q) const
|
||||
virtual const GaugeBC<P,Q>& getGaugeBC() const
|
||||
virtual const Set& getSet(void) const = 0;
|
||||
virtual void deriv(P& result, const Handle< GaugeState<P,Q> >& state) const
|
||||
virtual Double S(const Handle< GaugeState<P,Q> >& state) const = 0;
|
||||
|
||||
class LinearGaugeAction : public GaugeAction< multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >
|
||||
typedef multi1d<LatticeColorMatrix> P;
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
0
lib/qcd/action/fermion/.dirstamp
Normal file
0
lib/qcd/action/fermion/.dirstamp
Normal file
346
lib/qcd/action/fermion/CayleyFermion5D.cc
Normal file
346
lib/qcd/action/fermion/CayleyFermion5D.cc
Normal file
@ -0,0 +1,346 @@
|
||||
#include <Grid.h>
|
||||
namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
CayleyFermion5D::CayleyFermion5D(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5) :
|
||||
WilsonFermion5D(_Umu,
|
||||
FiveDimGrid,
|
||||
FiveDimRedBlackGrid,
|
||||
FourDimGrid,
|
||||
FourDimRedBlackGrid,_M5),
|
||||
mass(_mass)
|
||||
{
|
||||
}
|
||||
|
||||
// override multiply
|
||||
RealD CayleyFermion5D::M (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
LatticeFermion Din(psi._grid);
|
||||
|
||||
// Assemble Din
|
||||
for(int s=0;s<Ls;s++){
|
||||
if ( s==0 ) {
|
||||
// Din = bs psi[s] + cs[s] psi[s+1}
|
||||
axpby_ssp_pminus(Din,bs[s],psi,cs[s],psi,s,s+1);
|
||||
// Din+= -mass*cs[s] psi[s+1}
|
||||
axpby_ssp_pplus (Din,1.0,Din,-mass*cs[s],psi,s,Ls-1);
|
||||
} else if ( s==(Ls-1)) {
|
||||
axpby_ssp_pminus(Din,bs[s],psi,-mass*cs[s],psi,s,0);
|
||||
axpby_ssp_pplus (Din,1.0,Din,cs[s],psi,s,s-1);
|
||||
} else {
|
||||
axpby_ssp_pminus(Din,bs[s],psi,cs[s],psi,s,s+1);
|
||||
axpby_ssp_pplus(Din,1.0,Din,cs[s],psi,s,s-1);
|
||||
}
|
||||
}
|
||||
|
||||
DW(Din,chi,DaggerNo);
|
||||
// ((b D_W + D_w hop terms +1) on s-diag
|
||||
axpby(chi,1.0,1.0,chi,psi);
|
||||
|
||||
for(int s=0;s<Ls;s++){
|
||||
if ( s==0 ){
|
||||
axpby_ssp_pminus(chi,1.0,chi,-1.0,psi,s,s+1);
|
||||
axpby_ssp_pplus (chi,1.0,chi,mass,psi,s,Ls-1);
|
||||
} else if ( s==(Ls-1)) {
|
||||
axpby_ssp_pminus(chi,1.0,chi,mass,psi,s,0);
|
||||
axpby_ssp_pplus (chi,1.0,chi,-1.0,psi,s,s-1);
|
||||
} else {
|
||||
axpby_ssp_pminus(chi,1.0,chi,-1.0,psi,s,s+1);
|
||||
axpby_ssp_pplus (chi,1.0,chi,-1.0,psi,s,s-1);
|
||||
}
|
||||
}
|
||||
return norm2(chi);
|
||||
}
|
||||
|
||||
RealD CayleyFermion5D::Mdag (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
// Under adjoint
|
||||
//D1+ D1- P- -> D1+^dag P+ D2-^dag
|
||||
//D2- P+ D2+ P-D1-^dag D2+dag
|
||||
|
||||
LatticeFermion Din(psi._grid);
|
||||
// Apply Dw
|
||||
DW(psi,Din,DaggerYes);
|
||||
|
||||
for(int s=0;s<Ls;s++){
|
||||
// Collect the terms in DW
|
||||
// Chi = bs Din[s] + cs[s] Din[s+1}
|
||||
// Chi+= -mass*cs[s] psi[s+1}
|
||||
if ( s==0 ) {
|
||||
axpby_ssp_pplus (chi,bs[s],Din,cs[s+1],Din,s,s+1);
|
||||
axpby_ssp_pminus(chi,1.0,chi,-mass*cs[Ls-1],Din,s,Ls-1);
|
||||
} else if ( s==(Ls-1)) {
|
||||
axpby_ssp_pplus (chi,bs[s],Din,-mass*cs[0],Din,s,0);
|
||||
axpby_ssp_pminus(chi,1.0,chi,cs[s-1],Din,s,s-1);
|
||||
} else {
|
||||
axpby_ssp_pplus (chi,bs[s],Din,cs[s+1],Din,s,s+1);
|
||||
axpby_ssp_pminus(chi,1.0,chi,cs[s-1],Din,s,s-1);
|
||||
}
|
||||
// Collect the terms indept of DW
|
||||
if ( s==0 ){
|
||||
axpby_ssp_pplus (chi,1.0,chi,-1.0,psi,s,s+1);
|
||||
axpby_ssp_pminus(chi,1.0,chi,mass,psi,s,Ls-1);
|
||||
} else if ( s==(Ls-1)) {
|
||||
axpby_ssp_pplus (chi,1.0,chi,mass,psi,s,0);
|
||||
axpby_ssp_pminus(chi,1.0,chi,-1.0,psi,s,s-1);
|
||||
} else {
|
||||
axpby_ssp_pplus(chi,1.0,chi,-1.0,psi,s,s+1);
|
||||
axpby_ssp_pminus(chi,1.0,chi,-1.0,psi,s,s-1);
|
||||
}
|
||||
}
|
||||
// ((b D_W + D_w hop terms +1) on s-diag
|
||||
axpby (chi,1.0,1.0,chi,psi);
|
||||
return norm2(chi);
|
||||
}
|
||||
|
||||
// half checkerboard operations
|
||||
void CayleyFermion5D::Meooe (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
LatticeFermion tmp(psi._grid);
|
||||
// Assemble the 5d matrix
|
||||
for(int s=0;s<Ls;s++){
|
||||
if ( s==0 ) {
|
||||
// tmp = bs psi[s] + cs[s] psi[s+1}
|
||||
// tmp+= -mass*cs[s] psi[s+1}
|
||||
axpby_ssp_pminus(tmp,beo[s],psi,-ceo[s],psi ,s, s+1);
|
||||
axpby_ssp_pplus(tmp,1.0,tmp,mass*ceo[s],psi,s,Ls-1);
|
||||
} else if ( s==(Ls-1)) {
|
||||
axpby_ssp_pminus(tmp,beo[s],psi,mass*ceo[s],psi,s,0);
|
||||
axpby_ssp_pplus(tmp,1.0,tmp,-ceo[s],psi,s,s-1);
|
||||
} else {
|
||||
axpby_ssp_pminus(tmp,beo[s],psi,-ceo[s],psi,s,s+1);
|
||||
axpby_ssp_pplus (tmp,1.0,tmp,-ceo[s],psi,s,s-1);
|
||||
}
|
||||
}
|
||||
// Apply 4d dslash
|
||||
if ( psi.checkerboard == Odd ) {
|
||||
DhopEO(tmp,chi,DaggerNo);
|
||||
} else {
|
||||
DhopOE(tmp,chi,DaggerNo);
|
||||
}
|
||||
}
|
||||
|
||||
void CayleyFermion5D::MeooeDag (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
LatticeFermion tmp(psi._grid);
|
||||
// Apply 4d dslash
|
||||
if ( psi.checkerboard == Odd ) {
|
||||
DhopEO(psi,tmp,DaggerYes);
|
||||
} else {
|
||||
DhopOE(psi,tmp,DaggerYes);
|
||||
}
|
||||
// Assemble the 5d matrix
|
||||
for(int s=0;s<Ls;s++){
|
||||
if ( s==0 ) {
|
||||
axpby_ssp_pplus(chi,beo[s],tmp, -ceo[s+1] ,tmp,s,s+1);
|
||||
axpby_ssp_pminus(chi, 1.0,chi,mass*ceo[Ls-1],tmp,s,Ls-1);
|
||||
} else if ( s==(Ls-1)) {
|
||||
axpby_ssp_pplus(chi,beo[s],tmp,mass*ceo[0],tmp,s,0);
|
||||
axpby_ssp_pminus(chi,1.0,chi,-ceo[s-1],tmp,s,s-1);
|
||||
} else {
|
||||
axpby_ssp_pplus(chi,beo[s],tmp,-ceo[s+1],tmp,s,s+1);
|
||||
axpby_ssp_pminus(chi,1.0 ,chi,-ceo[s-1],tmp,s,s-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CayleyFermion5D::Mooee (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
for (int s=0;s<Ls;s++){
|
||||
if ( s==0 ) {
|
||||
axpby_ssp_pminus(chi,bee[s],psi ,-cee[s],psi,s,s+1);
|
||||
axpby_ssp_pplus (chi,1.0,chi,mass*cee[s],psi,s,Ls-1);
|
||||
} else if ( s==(Ls-1)) {
|
||||
axpby_ssp_pminus(chi,bee[s],psi,mass*cee[s],psi,s,0);
|
||||
axpby_ssp_pplus (chi,1.0,chi,-cee[s],psi,s,s-1);
|
||||
} else {
|
||||
axpby_ssp_pminus(chi,bee[s],psi,-cee[s],psi,s,s+1);
|
||||
axpby_ssp_pplus (chi,1.0,chi,-cee[s],psi,s,s-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CayleyFermion5D::MooeeDag (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
for (int s=0;s<Ls;s++){
|
||||
// Assemble the 5d matrix
|
||||
if ( s==0 ) {
|
||||
axpby_ssp_pplus(chi,bee[s],psi,-cee[s+1] ,psi,s,s+1);
|
||||
axpby_ssp_pminus(chi,1.0,chi,mass*cee[Ls-1],psi,s,Ls-1);
|
||||
} else if ( s==(Ls-1)) {
|
||||
axpby_ssp_pplus(chi,bee[s],psi,mass*cee[0],psi,s,0);
|
||||
axpby_ssp_pminus(chi,1.0,chi,-cee[s-1],psi,s,s-1);
|
||||
} else {
|
||||
axpby_ssp_pplus(chi,bee[s],psi,-cee[s+1],psi,s,s+1);
|
||||
axpby_ssp_pminus(chi,1.0 ,chi,-cee[s-1],psi,s,s-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CayleyFermion5D::MooeeInv (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
// Apply (L^{\prime})^{-1}
|
||||
axpby_ssp (chi,1.0,psi, 0.0,psi,0,0); // chi[0]=psi[0]
|
||||
for (int s=1;s<Ls;s++){
|
||||
axpby_ssp_pplus(chi,1.0,psi,-lee[s-1],chi,s,s-1);// recursion Psi[s] -lee P_+ chi[s-1]
|
||||
}
|
||||
// L_m^{-1}
|
||||
for (int s=0;s<Ls-1;s++){ // Chi[ee] = 1 - sum[s<Ls-1] -leem[s]P_- chi
|
||||
axpby_ssp_pminus(chi,1.0,chi,-leem[s],chi,Ls-1,s);
|
||||
}
|
||||
// U_m^{-1} D^{-1}
|
||||
for (int s=0;s<Ls-1;s++){
|
||||
// Chi[s] + 1/d chi[s]
|
||||
axpby_ssp_pplus(chi,1.0/dee[s],chi,-ueem[s]/dee[Ls-1],chi,s,Ls-1);
|
||||
}
|
||||
axpby_ssp(chi,1.0/dee[Ls-1],chi,0.0,chi,Ls-1,Ls-1); // Modest avoidable
|
||||
|
||||
// Apply U^{-1}
|
||||
for (int s=Ls-2;s>=0;s--){
|
||||
axpby_ssp_pminus (chi,1.0,chi,-uee[s],chi,s,s+1); // chi[Ls]
|
||||
}
|
||||
}
|
||||
|
||||
void CayleyFermion5D::MooeeInvDag (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
// Apply (U^{\prime})^{-dagger}
|
||||
axpby_ssp (chi,1.0,psi, 0.0,psi,0,0); // chi[0]=psi[0]
|
||||
for (int s=1;s<Ls;s++){
|
||||
axpby_ssp_pminus(chi,1.0,psi,-uee[s-1],chi,s,s-1);
|
||||
}
|
||||
// U_m^{-\dagger}
|
||||
for (int s=0;s<Ls-1;s++){
|
||||
axpby_ssp_pplus(chi,1.0,chi,-ueem[s],chi,Ls-1,s);
|
||||
}
|
||||
// L_m^{-\dagger} D^{-dagger}
|
||||
for (int s=0;s<Ls-1;s++){
|
||||
axpby_ssp_pminus(chi,1.0/dee[s],chi,-leem[s]/dee[Ls-1],chi,s,Ls-1);
|
||||
}
|
||||
axpby_ssp(chi,1.0/dee[Ls-1],chi,0.0,chi,Ls-1,Ls-1); // Modest avoidable
|
||||
|
||||
// Apply L^{-dagger}
|
||||
for (int s=Ls-2;s>=0;s--){
|
||||
axpby_ssp_pplus (chi,1.0,chi,-lee[s],chi,s,s+1); // chi[Ls]
|
||||
}
|
||||
}
|
||||
|
||||
// Tanh
|
||||
void CayleyFermion5D::SetCoefficientsTanh(Approx::zolotarev_data *zdata,RealD b,RealD c)
|
||||
{
|
||||
SetCoefficientsZolotarev(1.0,zdata,b,c);
|
||||
|
||||
}
|
||||
//Zolo
|
||||
void CayleyFermion5D::SetCoefficientsZolotarev(RealD zolo_hi,Approx::zolotarev_data *zdata,RealD b,RealD c)
|
||||
{
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// The Cayley coeffs (unprec)
|
||||
///////////////////////////////////////////////////////////
|
||||
omega.resize(Ls);
|
||||
bs.resize(Ls);
|
||||
cs.resize(Ls);
|
||||
as.resize(Ls);
|
||||
|
||||
//
|
||||
// Ts = ( [bs+cs]Dw )^-1 ( (bs+cs) Dw )
|
||||
// -(g5 ------- -1 ) ( g5 --------- + 1 )
|
||||
// ( {2+(bs-cs)Dw} ) ( 2+(bs-cs) Dw )
|
||||
//
|
||||
// bs = 1/2( (1/omega_s + 1)*b + (1/omega - 1)*c ) = 1/2( 1/omega(b+c) + (b-c) )
|
||||
// cs = 1/2( (1/omega_s - 1)*b + (1/omega + 1)*c ) = 1/2( 1/omega(b+c) - (b-c) )
|
||||
//
|
||||
// bs+cs = 0.5*( 1/omega(b+c) + (b-c) + 1/omega(b+c) - (b-c) ) = 1/omega(b+c)
|
||||
// bs-cs = 0.5*( 1/omega(b+c) + (b-c) - 1/omega(b+c) + (b-c) ) = b-c
|
||||
//
|
||||
// So
|
||||
//
|
||||
// Ts = ( [b+c]Dw/omega_s )^-1 ( (b+c) Dw /omega_s )
|
||||
// -(g5 ------- -1 ) ( g5 --------- + 1 )
|
||||
// ( {2+(b-c)Dw} ) ( 2+(b-c) Dw )
|
||||
//
|
||||
// Ts = ( [b+c]Dw )^-1 ( (b+c) Dw )
|
||||
// -(g5 ------- -omega_s) ( g5 --------- + omega_s )
|
||||
// ( {2+(b-c)Dw} ) ( 2+(b-c) Dw )
|
||||
//
|
||||
|
||||
double bpc = b+c;
|
||||
double bmc = b-c;
|
||||
for(int i=0; i < Ls; i++){
|
||||
as[i] = 1.0;
|
||||
omega[i] = ((double)zdata->gamma[i])*zolo_hi; //NB reciprocal relative to Chroma NEF code
|
||||
bs[i] = 0.5*(bpc/omega[i] + bmc);
|
||||
cs[i] = 0.5*(bpc/omega[i] - bmc);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// Constants for the preconditioned matrix Cayley form
|
||||
////////////////////////////////////////////////////////
|
||||
bee.resize(Ls);
|
||||
cee.resize(Ls);
|
||||
beo.resize(Ls);
|
||||
ceo.resize(Ls);
|
||||
|
||||
for(int i=0;i<Ls;i++){
|
||||
bee[i]=as[i]*(bs[i]*(4.0-M5) +1.0);
|
||||
cee[i]=as[i]*(1.0-cs[i]*(4.0-M5));
|
||||
beo[i]=as[i]*bs[i];
|
||||
ceo[i]=-as[i]*cs[i];
|
||||
}
|
||||
|
||||
aee.resize(Ls);
|
||||
aeo.resize(Ls);
|
||||
for(int i=0;i<Ls;i++){
|
||||
aee[i]=cee[i];
|
||||
aeo[i]=ceo[i];
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
// LDU decomposition of eeoo
|
||||
//////////////////////////////////////////
|
||||
dee.resize(Ls);
|
||||
lee.resize(Ls);
|
||||
leem.resize(Ls);
|
||||
uee.resize(Ls);
|
||||
ueem.resize(Ls);
|
||||
|
||||
for(int i=0;i<Ls;i++){
|
||||
|
||||
dee[i] = bee[i];
|
||||
|
||||
if ( i < Ls-1 ) {
|
||||
|
||||
lee[i] =-cee[i+1]/bee[i]; // sub-diag entry on the ith column
|
||||
|
||||
leem[i]=mass*cee[Ls-1]/bee[0];
|
||||
for(int j=0;j<i;j++) leem[i]*= aee[j]/bee[j+1];
|
||||
|
||||
uee[i] =-aee[i]/bee[i]; // up-diag entry on the ith row
|
||||
|
||||
ueem[i]=mass;
|
||||
for(int j=1;j<=i;j++) ueem[i]*= cee[j]/bee[j];
|
||||
ueem[i]*= aee[0]/bee[0];
|
||||
|
||||
} else {
|
||||
lee[i] =0.0;
|
||||
leem[i]=0.0;
|
||||
uee[i] =0.0;
|
||||
ueem[i]=0.0;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
double delta_d=mass*cee[Ls-1];
|
||||
for(int j=0;j<Ls-1;j++) delta_d *= cee[j]/bee[j];
|
||||
dee[Ls-1] += delta_d;
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
|
62
lib/qcd/action/fermion/CayleyFermion5D.h
Normal file
62
lib/qcd/action/fermion/CayleyFermion5D.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef GRID_QCD_CAYLEY_FERMION_H
|
||||
#define GRID_QCD_CAYLEY_FERMION_H
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class CayleyFermion5D : public WilsonFermion5D
|
||||
{
|
||||
public:
|
||||
|
||||
// override multiply
|
||||
virtual RealD M (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual RealD Mdag (const LatticeFermion &in, LatticeFermion &out);
|
||||
|
||||
// half checkerboard operations
|
||||
virtual void Meooe (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MeooeDag (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void Mooee (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MooeeDag (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MooeeInv (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MooeeInvDag (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void Instantiatable(void)=0;
|
||||
// protected:
|
||||
RealD mass;
|
||||
|
||||
// Cayley form Moebius (tanh and zolotarev)
|
||||
std::vector<RealD> omega;
|
||||
std::vector<RealD> bs; // S dependent coeffs
|
||||
std::vector<RealD> cs;
|
||||
std::vector<RealD> as;
|
||||
// For preconditioning Cayley form
|
||||
std::vector<RealD> bee;
|
||||
std::vector<RealD> cee;
|
||||
std::vector<RealD> aee;
|
||||
std::vector<RealD> beo;
|
||||
std::vector<RealD> ceo;
|
||||
std::vector<RealD> aeo;
|
||||
// LDU factorisation of the eeoo matrix
|
||||
std::vector<RealD> lee;
|
||||
std::vector<RealD> leem;
|
||||
std::vector<RealD> uee;
|
||||
std::vector<RealD> ueem;
|
||||
std::vector<RealD> dee;
|
||||
|
||||
// Constructors
|
||||
CayleyFermion5D(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5);
|
||||
|
||||
protected:
|
||||
void SetCoefficientsZolotarev(RealD zolohi,Approx::zolotarev_data *zdata,RealD b,RealD c);
|
||||
void SetCoefficientsTanh(Approx::zolotarev_data *zdata,RealD b,RealD c);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
179
lib/qcd/action/fermion/ContinuedFractionFermion5D.cc
Normal file
179
lib/qcd/action/fermion/ContinuedFractionFermion5D.cc
Normal file
@ -0,0 +1,179 @@
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
void ContinuedFractionFermion5D::SetCoefficientsTanh(Approx::zolotarev_data *zdata,RealD scale)
|
||||
{
|
||||
SetCoefficientsZolotarev(1.0/scale,zdata);
|
||||
}
|
||||
void ContinuedFractionFermion5D::SetCoefficientsZolotarev(RealD zolo_hi,Approx::zolotarev_data *zdata)
|
||||
{
|
||||
// How to check Ls matches??
|
||||
// std::cout << Ls << " Ls"<<std::endl;
|
||||
// std::cout << zdata->n << " - n"<<std::endl;
|
||||
// std::cout << zdata->da << " -da "<<std::endl;
|
||||
// std::cout << zdata->db << " -db"<<std::endl;
|
||||
// std::cout << zdata->dn << " -dn"<<std::endl;
|
||||
// std::cout << zdata->dd << " -dd"<<std::endl;
|
||||
|
||||
assert(zdata->db==Ls);// Beta has Ls coeffs
|
||||
|
||||
R=(1+this->mass)/(1-this->mass);
|
||||
|
||||
Beta.resize(Ls);
|
||||
cc.resize(Ls);
|
||||
cc_d.resize(Ls);
|
||||
sqrt_cc.resize(Ls);
|
||||
for(int i=0; i < Ls ; i++){
|
||||
Beta[i] = zdata -> beta[i];
|
||||
cc[i] = 1.0/Beta[i];
|
||||
cc_d[i]=sqrt(cc[i]);
|
||||
}
|
||||
|
||||
cc_d[Ls-1]=1.0;
|
||||
for(int i=0; i < Ls-1 ; i++){
|
||||
sqrt_cc[i]= sqrt(cc[i]*cc[i+1]);
|
||||
}
|
||||
sqrt_cc[Ls-2]=sqrt(cc[Ls-2]);
|
||||
|
||||
|
||||
ZoloHiInv =1.0/zolo_hi;
|
||||
dw_diag = (4.0-M5)*ZoloHiInv;
|
||||
|
||||
See.resize(Ls);
|
||||
Aee.resize(Ls);
|
||||
int sign=1;
|
||||
for(int s=0;s<Ls;s++){
|
||||
Aee[s] = sign * Beta[s] * dw_diag;
|
||||
sign = - sign;
|
||||
}
|
||||
Aee[Ls-1] += R;
|
||||
|
||||
See[0] = Aee[0];
|
||||
for(int s=1;s<Ls;s++){
|
||||
See[s] = Aee[s] - 1.0/See[s-1];
|
||||
}
|
||||
for(int s=0;s<Ls;s++){
|
||||
std::cout <<"s = "<<s<<" Beta "<<Beta[s]<<" Aee "<<Aee[s] <<" See "<<See[s] <<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RealD ContinuedFractionFermion5D::M (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
LatticeFermion D(psi._grid);
|
||||
|
||||
DW(psi,D,DaggerNo);
|
||||
|
||||
int sign=1;
|
||||
for(int s=0;s<Ls;s++){
|
||||
if ( s==0 ) {
|
||||
ag5xpby_ssp(chi,cc[0]*Beta[0]*sign*ZoloHiInv,D,sqrt_cc[0],psi,s,s+1); // Multiplies Dw by G5 so Hw
|
||||
} else if ( s==(Ls-1) ){
|
||||
RealD R=(1.0+mass)/(1.0-mass);
|
||||
ag5xpby_ssp(chi,Beta[s]*ZoloHiInv,D,sqrt_cc[s-1],psi,s,s-1);
|
||||
ag5xpby_ssp(chi,R,psi,1.0,chi,s,s);
|
||||
} else {
|
||||
ag5xpby_ssp(chi,cc[s]*Beta[s]*sign*ZoloHiInv,D,sqrt_cc[s],psi,s,s+1);
|
||||
axpby_ssp(chi,1.0,chi,sqrt_cc[s-1],psi,s,s-1);
|
||||
}
|
||||
sign=-sign;
|
||||
}
|
||||
return norm2(chi);
|
||||
}
|
||||
RealD ContinuedFractionFermion5D::Mdag (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
// This matrix is already hermitian. (g5 Dw) = Dw dag g5 = (g5 Dw)dag
|
||||
// The rest of matrix is symmetric.
|
||||
// Can ignore "dag"
|
||||
return M(psi,chi);
|
||||
}
|
||||
void ContinuedFractionFermion5D::Meooe (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
// Apply 4d dslash
|
||||
if ( psi.checkerboard == Odd ) {
|
||||
DhopEO(psi,chi,DaggerNo); // Dslash on diagonal. g5 Dslash is hermitian
|
||||
} else {
|
||||
DhopOE(psi,chi,DaggerNo); // Dslash on diagonal. g5 Dslash is hermitian
|
||||
}
|
||||
|
||||
int sign=1;
|
||||
for(int s=0;s<Ls;s++){
|
||||
if ( s==(Ls-1) ){
|
||||
ag5xpby_ssp(chi,Beta[s]*ZoloHiInv,chi,0.0,chi,s,s);
|
||||
} else {
|
||||
ag5xpby_ssp(chi,cc[s]*Beta[s]*sign*ZoloHiInv,chi,0.0,chi,s,s);
|
||||
}
|
||||
sign=-sign;
|
||||
}
|
||||
}
|
||||
void ContinuedFractionFermion5D::MeooeDag (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
Meooe(psi,chi);
|
||||
}
|
||||
void ContinuedFractionFermion5D::Mooee (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
int sign=1;
|
||||
for(int s=0;s<Ls;s++){
|
||||
if ( s==0 ) {
|
||||
ag5xpby_ssp(chi,cc[0]*Beta[0]*sign*dw_diag,psi,sqrt_cc[0],psi,s,s+1); // Multiplies Dw by G5 so Hw
|
||||
} else if ( s==(Ls-1) ){
|
||||
// Drop the CC here.
|
||||
double R=(1+mass)/(1-mass);
|
||||
ag5xpby_ssp(chi,Beta[s]*dw_diag,psi,sqrt_cc[s-1],psi,s,s-1);
|
||||
ag5xpby_ssp(chi,R,psi,1.0,chi,s,s);
|
||||
} else {
|
||||
ag5xpby_ssp(chi,cc[s]*Beta[s]*sign*dw_diag,psi,sqrt_cc[s],psi,s,s+1);
|
||||
axpby_ssp(chi,1.0,chi,sqrt_cc[s-1],psi,s,s-1);
|
||||
}
|
||||
sign=-sign;
|
||||
}
|
||||
}
|
||||
|
||||
void ContinuedFractionFermion5D::MooeeDag (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
Mooee(psi,chi);
|
||||
}
|
||||
void ContinuedFractionFermion5D::MooeeInv (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
// Apply Linv
|
||||
axpby_ssp(chi,1.0/cc_d[0],psi,0.0,psi,0,0);
|
||||
for(int s=1;s<Ls;s++){
|
||||
axpbg5y_ssp(chi,1.0/cc_d[s],psi,-1.0/See[s-1],chi,s,s-1);
|
||||
}
|
||||
// Apply Dinv
|
||||
for(int s=0;s<Ls;s++){
|
||||
ag5xpby_ssp(chi,1.0/See[s],chi,0.0,chi,s,s); //only appearance of See[0]
|
||||
}
|
||||
// Apply Uinv = (Linv)^T
|
||||
axpby_ssp(chi,1.0/cc_d[Ls-1],chi,0.0,chi,Ls-1,Ls-1);
|
||||
for(int s=Ls-2;s>=0;s--){
|
||||
axpbg5y_ssp(chi,1.0/cc_d[s],chi,-1.0*cc_d[s+1]/See[s]/cc_d[s],chi,s,s+1);
|
||||
}
|
||||
}
|
||||
void ContinuedFractionFermion5D::MooeeInvDag (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
{
|
||||
MooeeInv(psi,chi);
|
||||
}
|
||||
|
||||
// Constructors
|
||||
ContinuedFractionFermion5D::ContinuedFractionFermion5D(
|
||||
LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD M5) :
|
||||
WilsonFermion5D(_Umu,
|
||||
FiveDimGrid, FiveDimRedBlackGrid,
|
||||
FourDimGrid, FourDimRedBlackGrid,M5),
|
||||
mass(_mass)
|
||||
{
|
||||
assert((Ls&0x1)==1); // Odd Ls required
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
58
lib/qcd/action/fermion/ContinuedFractionFermion5D.h
Normal file
58
lib/qcd/action/fermion/ContinuedFractionFermion5D.h
Normal file
@ -0,0 +1,58 @@
|
||||
#ifndef GRID_QCD_CONTINUED_FRACTION_H
|
||||
#define GRID_QCD_CONTINUED_FRACTION_H
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class ContinuedFractionFermion5D : public WilsonFermion5D
|
||||
{
|
||||
public:
|
||||
|
||||
// override multiply
|
||||
virtual RealD M (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual RealD Mdag (const LatticeFermion &in, LatticeFermion &out);
|
||||
|
||||
// half checkerboard operaions
|
||||
virtual void Meooe (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MeooeDag (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void Mooee (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MooeeDag (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MooeeInv (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MooeeInvDag (const LatticeFermion &in, LatticeFermion &out);
|
||||
|
||||
// virtual void Instantiatable(void)=0;
|
||||
virtual void Instantiatable(void) =0;
|
||||
|
||||
// Constructors
|
||||
ContinuedFractionFermion5D(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD M5);
|
||||
|
||||
protected:
|
||||
|
||||
void SetCoefficientsTanh(Approx::zolotarev_data *zdata,RealD scale);
|
||||
void SetCoefficientsZolotarev(RealD zolo_hi,Approx::zolotarev_data *zdata);;
|
||||
|
||||
// Cont frac
|
||||
RealD dw_diag;
|
||||
RealD mass;
|
||||
RealD R;
|
||||
RealD ZoloHiInv;
|
||||
std::vector<double> Beta;
|
||||
std::vector<double> cc;;
|
||||
std::vector<double> cc_d;;
|
||||
std::vector<double> sqrt_cc;
|
||||
std::vector<double> See;
|
||||
std::vector<double> Aee;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
47
lib/qcd/action/fermion/DomainWallFermion.h
Normal file
47
lib/qcd/action/fermion/DomainWallFermion.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef GRID_QCD_DOMAIN_WALL_FERMION_H
|
||||
#define GRID_QCD_DOMAIN_WALL_FERMION_H
|
||||
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class DomainWallFermion : public CayleyFermion5D
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Instantiatable(void) {};
|
||||
// Constructors
|
||||
DomainWallFermion(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5) :
|
||||
|
||||
CayleyFermion5D(_Umu,
|
||||
FiveDimGrid,
|
||||
FiveDimRedBlackGrid,
|
||||
FourDimGrid,
|
||||
FourDimRedBlackGrid,_mass,_M5)
|
||||
|
||||
{
|
||||
RealD eps = 1.0;
|
||||
|
||||
Approx::zolotarev_data *zdata = Approx::higham(eps,this->Ls);// eps is ignored for higham
|
||||
assert(zdata->n==this->Ls);
|
||||
|
||||
std::cout << "DomainWallFermion with Ls="<<Ls<<std::endl;
|
||||
// Call base setter
|
||||
this->CayleyFermion5D::SetCoefficientsTanh(zdata,1.0,0.0);
|
||||
|
||||
Approx::zolotarev_free(zdata);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
#ifndef GRID_QCD_WILSON_DOP_H
|
||||
#define GRID_QCD_WILSON_DOP_H
|
||||
#ifndef GRID_QCD_FERMION_OPERATOR_H
|
||||
#define GRID_QCD_FERMION_OPERATOR_H
|
||||
|
||||
namespace Grid {
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Grid {
|
||||
// Think about multiple representations
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template<class FermionField,class GaugeField>
|
||||
class FermionAction : public CheckerBoardedSparseMatrixBase<FermionField>
|
||||
class FermionOperator : public CheckerBoardedSparseMatrixBase<FermionField>
|
||||
{
|
||||
public:
|
||||
|
||||
@ -40,6 +40,7 @@ namespace Grid {
|
||||
virtual void DhopOE(const FermionField &in, FermionField &out,int dag)=0;
|
||||
virtual void DhopEO(const FermionField &in, FermionField &out,int dag)=0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
49
lib/qcd/action/fermion/MobiusFermion.h
Normal file
49
lib/qcd/action/fermion/MobiusFermion.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef GRID_QCD_MOBIUS_FERMION_H
|
||||
#define GRID_QCD_MOBIUS_FERMION_H
|
||||
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class MobiusFermion : public CayleyFermion5D
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Instantiatable(void) {};
|
||||
// Constructors
|
||||
MobiusFermion(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5,
|
||||
RealD b, RealD c) :
|
||||
|
||||
CayleyFermion5D(_Umu,
|
||||
FiveDimGrid,
|
||||
FiveDimRedBlackGrid,
|
||||
FourDimGrid,
|
||||
FourDimRedBlackGrid,_mass,_M5)
|
||||
|
||||
{
|
||||
RealD eps = 1.0;
|
||||
|
||||
std::cout << "MobiusFermion (b="<<b<<",c="<<c<<") with Ls= "<<Ls<<" Tanh approx"<<std::endl;
|
||||
Approx::zolotarev_data *zdata = Approx::higham(eps,this->Ls);// eps is ignored for higham
|
||||
assert(zdata->n==this->Ls);
|
||||
|
||||
// Call base setter
|
||||
this->CayleyFermion5D::SetCoefficientsTanh(zdata,b,c);
|
||||
|
||||
Approx::zolotarev_free(zdata);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
50
lib/qcd/action/fermion/MobiusZolotarevFermion.h
Normal file
50
lib/qcd/action/fermion/MobiusZolotarevFermion.h
Normal file
@ -0,0 +1,50 @@
|
||||
#ifndef GRID_QCD_MOBIUS_ZOLOTAREV_FERMION_H
|
||||
#define GRID_QCD_MOBIUS_ZOLOTAREV_FERMION_H
|
||||
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class MobiusZolotarevFermion : public CayleyFermion5D
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Instantiatable(void) {};
|
||||
// Constructors
|
||||
MobiusZolotarevFermion(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5,
|
||||
RealD b, RealD c,
|
||||
RealD lo, RealD hi) :
|
||||
|
||||
CayleyFermion5D(_Umu,
|
||||
FiveDimGrid,
|
||||
FiveDimRedBlackGrid,
|
||||
FourDimGrid,
|
||||
FourDimRedBlackGrid,_mass,_M5)
|
||||
|
||||
{
|
||||
RealD eps = lo/hi;
|
||||
|
||||
Approx::zolotarev_data *zdata = Approx::zolotarev(eps,this->Ls,0);
|
||||
assert(zdata->n==this->Ls);
|
||||
|
||||
std::cout << "MobiusZolotarevFermion (b="<<b<<",c="<<c<<") with Ls= "<<Ls<<" Zolotarev range ["<<lo<<","<<hi<<"]"<<std::endl;
|
||||
|
||||
// Call base setter
|
||||
this->CayleyFermion5D::SetCoefficientsZolotarev(hi,zdata,b,c);
|
||||
|
||||
Approx::zolotarev_free(zdata);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
34
lib/qcd/action/fermion/OverlapWilsonCayleyTanhFermion.h
Normal file
34
lib/qcd/action/fermion/OverlapWilsonCayleyTanhFermion.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef OVERLAP_WILSON_CAYLEY_TANH_FERMION_H
|
||||
#define OVERLAP_WILSON_CAYLEY_TANH_FERMION_H
|
||||
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class OverlapWilsonCayleyTanhFermion : public MobiusFermion
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
OverlapWilsonCayleyTanhFermion(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5,
|
||||
RealD scale) :
|
||||
|
||||
// b+c=scale, b-c = 0 <=> b =c = scale/2
|
||||
MobiusFermion(_Umu,
|
||||
FiveDimGrid,
|
||||
FiveDimRedBlackGrid,
|
||||
FourDimGrid,
|
||||
FourDimRedBlackGrid,_mass,_M5,0.5*scale,0.5*scale)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
37
lib/qcd/action/fermion/OverlapWilsonCayleyZolotarevFermion.h
Normal file
37
lib/qcd/action/fermion/OverlapWilsonCayleyZolotarevFermion.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef OVERLAP_WILSON_CAYLEY_ZOLOTAREV_FERMION_H
|
||||
#define OVERLAP_WILSON_CAYLEY_ZOLOTAREV_FERMION_H
|
||||
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class OverlapWilsonCayleyZolotarevFermion : public MobiusZolotarevFermion
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
OverlapWilsonCayleyZolotarevFermion(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5,
|
||||
RealD lo, RealD hi) :
|
||||
// b+c=1.0, b-c = 0 <=> b =c = 1/2
|
||||
MobiusZolotarevFermion(_Umu,
|
||||
FiveDimGrid,
|
||||
FiveDimRedBlackGrid,
|
||||
FourDimGrid,
|
||||
FourDimRedBlackGrid,_mass,_M5,0.5,0.5,lo,hi)
|
||||
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
40
lib/qcd/action/fermion/OverlapWilsonContfracTanhFermion.h
Normal file
40
lib/qcd/action/fermion/OverlapWilsonContfracTanhFermion.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef OVERLAP_WILSON_CONTFRAC_TANH_FERMION_H
|
||||
#define OVERLAP_WILSON_CONTFRAC_TANH_FERMION_H
|
||||
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class OverlapWilsonContFracTanhFermion : public ContinuedFractionFermion5D
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Instantiatable(void){};
|
||||
// Constructors
|
||||
OverlapWilsonContFracTanhFermion(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5,
|
||||
RealD scale) :
|
||||
|
||||
// b+c=scale, b-c = 0 <=> b =c = scale/2
|
||||
ContinuedFractionFermion5D(_Umu,
|
||||
FiveDimGrid,
|
||||
FiveDimRedBlackGrid,
|
||||
FourDimGrid,
|
||||
FourDimRedBlackGrid,_mass,_M5)
|
||||
{
|
||||
assert((Ls&0x1)==1); // Odd Ls required
|
||||
int nrational=Ls-1;// Even rational order
|
||||
Approx::zolotarev_data *zdata = Approx::higham(1.0,nrational);// eps is ignored for higham
|
||||
SetCoefficientsTanh(zdata,scale);
|
||||
Approx::zolotarev_free(zdata);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
@ -0,0 +1,44 @@
|
||||
#ifndef OVERLAP_WILSON_CONTFRAC_ZOLOTAREV_FERMION_H
|
||||
#define OVERLAP_WILSON_CONTFRAC_ZOLOTAREV_FERMION_H
|
||||
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class OverlapWilsonContFracZolotarevFermion : public ContinuedFractionFermion5D
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Instantiatable(void){};
|
||||
// Constructors
|
||||
OverlapWilsonContFracZolotarevFermion(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5,
|
||||
RealD lo,RealD hi):
|
||||
|
||||
// b+c=scale, b-c = 0 <=> b =c = scale/2
|
||||
ContinuedFractionFermion5D(_Umu,
|
||||
FiveDimGrid,
|
||||
FiveDimRedBlackGrid,
|
||||
FourDimGrid,
|
||||
FourDimRedBlackGrid,_mass,_M5)
|
||||
{
|
||||
assert((Ls&0x1)==1); // Odd Ls required
|
||||
|
||||
int nrational=Ls;// Odd rational order
|
||||
RealD eps = lo/hi;
|
||||
|
||||
Approx::zolotarev_data *zdata = Approx::zolotarev(eps,nrational,0);
|
||||
SetCoefficientsZolotarev(hi,zdata);
|
||||
Approx::zolotarev_free(zdata);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
@ -0,0 +1,40 @@
|
||||
#ifndef OVERLAP_WILSON_PARTFRAC_TANH_FERMION_H
|
||||
#define OVERLAP_WILSON_PARTFRAC_TANH_FERMION_H
|
||||
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class OverlapWilsonPartialFractionTanhFermion : public PartialFractionFermion5D
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Instantiatable(void){};
|
||||
// Constructors
|
||||
OverlapWilsonPartialFractionTanhFermion(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5,
|
||||
RealD scale) :
|
||||
|
||||
// b+c=scale, b-c = 0 <=> b =c = scale/2
|
||||
PartialFractionFermion5D(_Umu,
|
||||
FiveDimGrid,
|
||||
FiveDimRedBlackGrid,
|
||||
FourDimGrid,
|
||||
FourDimRedBlackGrid,_mass,_M5)
|
||||
{
|
||||
assert((Ls&0x1)==1); // Odd Ls required
|
||||
int nrational=Ls-1;// Even rational order
|
||||
Approx::zolotarev_data *zdata = Approx::higham(1.0,nrational);// eps is ignored for higham
|
||||
SetCoefficientsTanh(zdata,scale);
|
||||
Approx::zolotarev_free(zdata);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
@ -0,0 +1,44 @@
|
||||
#ifndef OVERLAP_WILSON_PARTFRAC_ZOLOTAREV_FERMION_H
|
||||
#define OVERLAP_WILSON_PARTFRAC_ZOLOTAREV_FERMION_H
|
||||
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class OverlapWilsonPartialFractionZolotarevFermion : public PartialFractionFermion5D
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Instantiatable(void){};
|
||||
// Constructors
|
||||
OverlapWilsonPartialFractionZolotarevFermion(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5,
|
||||
RealD lo,RealD hi):
|
||||
|
||||
// b+c=scale, b-c = 0 <=> b =c = scale/2
|
||||
PartialFractionFermion5D(_Umu,
|
||||
FiveDimGrid,
|
||||
FiveDimRedBlackGrid,
|
||||
FourDimGrid,
|
||||
FourDimRedBlackGrid,_mass,_M5)
|
||||
{
|
||||
assert((Ls&0x1)==1); // Odd Ls required
|
||||
|
||||
int nrational=Ls;// Odd rational order
|
||||
RealD eps = lo/hi;
|
||||
|
||||
Approx::zolotarev_data *zdata = Approx::zolotarev(eps,nrational,0);
|
||||
SetCoefficientsZolotarev(hi,zdata);
|
||||
Approx::zolotarev_free(zdata);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
310
lib/qcd/action/fermion/PartialFractionFermion5D.cc
Normal file
310
lib/qcd/action/fermion/PartialFractionFermion5D.cc
Normal file
@ -0,0 +1,310 @@
|
||||
#include <Grid.h>
|
||||
namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
void PartialFractionFermion5D::Meooe_internal(const LatticeFermion &psi, LatticeFermion &chi,int dag)
|
||||
{
|
||||
// this does both dag and undag but is trivial; make a common helper routing
|
||||
int sign = dag ? (-1) : 1;
|
||||
|
||||
if ( psi.checkerboard == Odd ) {
|
||||
DhopEO(psi,chi,DaggerNo);
|
||||
} else {
|
||||
DhopOE(psi,chi,DaggerNo);
|
||||
}
|
||||
|
||||
int nblock=(Ls-1)/2;
|
||||
for(int b=0;b<nblock;b++){
|
||||
int s = 2*b;
|
||||
ag5xpby_ssp(chi,-scale,chi,0.0,chi,s,s);
|
||||
ag5xpby_ssp(chi, scale,chi,0.0,chi,s+1,s+1);
|
||||
}
|
||||
ag5xpby_ssp(chi,p[nblock]*scale/amax,chi,0.0,chi,Ls-1,Ls-1);
|
||||
}
|
||||
|
||||
void PartialFractionFermion5D::Mooee_internal(const LatticeFermion &psi, LatticeFermion &chi,int dag)
|
||||
{
|
||||
// again dag and undag are trivially related
|
||||
int sign = dag ? (-1) : 1;
|
||||
|
||||
int nblock=(Ls-1)/2;
|
||||
for(int b=0;b<nblock;b++){
|
||||
|
||||
int s = 2*b;
|
||||
RealD pp = p[nblock-1-b];
|
||||
RealD qq = q[nblock-1-b];
|
||||
|
||||
// Do each 2x2 block aligned at s and multiplies Dw site diagonal by G5 so Hw
|
||||
ag5xpby_ssp(chi,-dw_diag*scale,psi,amax*sqrt(qq)*scale,psi, s ,s+1);
|
||||
ag5xpby_ssp(chi, dw_diag*scale,psi,amax*sqrt(qq)*scale,psi, s+1,s);
|
||||
axpby_ssp (chi, 1.0, chi,sqrt(amax*pp)*scale*sign,psi,s+1,Ls-1);
|
||||
}
|
||||
|
||||
{
|
||||
RealD R=(1+mass)/(1-mass);
|
||||
//R g5 psi[Ls-1] + p[0] H
|
||||
ag5xpbg5y_ssp(chi,R*scale,psi,p[nblock]*scale*dw_diag/amax,psi,Ls-1,Ls-1);
|
||||
|
||||
for(int b=0;b<nblock;b++){
|
||||
int s = 2*b+1;
|
||||
RealD pp = p[nblock-1-b];
|
||||
axpby_ssp(chi,1.0,chi,-sqrt(amax*pp)*scale*sign,psi,Ls-1,s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PartialFractionFermion5D::MooeeInv_internal(const LatticeFermion &psi, LatticeFermion &chi,int dag)
|
||||
{
|
||||
int sign = dag ? (-1) : 1;
|
||||
|
||||
LatticeFermion tmp(psi._grid);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//Linv
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
int nblock=(Ls-1)/2;
|
||||
|
||||
axpy(chi,0.0,psi,psi); // Identity piece
|
||||
|
||||
for(int b=0;b<nblock;b++){
|
||||
int s = 2*b;
|
||||
RealD pp = p[nblock-1-b];
|
||||
RealD qq = q[nblock-1-b];
|
||||
RealD coeff1=sign*sqrt(amax*amax*amax*pp*qq) / ( dw_diag*dw_diag + amax*amax* qq);
|
||||
RealD coeff2=sign*sqrt(amax*pp)*dw_diag / ( dw_diag*dw_diag + amax*amax* qq); // Implicit g5 here
|
||||
axpby_ssp (chi,1.0,chi,coeff1,psi,Ls-1,s);
|
||||
axpbg5y_ssp(chi,1.0,chi,coeff2,psi,Ls-1,s+1);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//Dinv (note D isn't really diagonal -- just diagonal enough that we can still invert)
|
||||
// Compute Seeinv (coeff of gamma5)
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
RealD R=(1+mass)/(1-mass);
|
||||
RealD Seeinv = R + p[nblock]*dw_diag/amax;
|
||||
for(int b=0;b<nblock;b++){
|
||||
Seeinv += p[nblock-1-b]*dw_diag/amax / ( dw_diag*dw_diag/amax/amax + q[nblock-1-b]);
|
||||
}
|
||||
Seeinv = 1.0/Seeinv;
|
||||
|
||||
for(int b=0;b<nblock;b++){
|
||||
int s = 2*b;
|
||||
RealD pp = p[nblock-1-b];
|
||||
RealD qq = q[nblock-1-b];
|
||||
RealD coeff1=dw_diag / ( dw_diag*dw_diag + amax*amax* qq); // Implicit g5 here
|
||||
RealD coeff2=amax*sqrt(qq) / ( dw_diag*dw_diag + amax*amax* qq);
|
||||
ag5xpby_ssp (tmp,-coeff1,chi,coeff2,chi,s,s+1);
|
||||
ag5xpby_ssp (tmp, coeff1,chi,coeff2,chi,s+1,s);
|
||||
}
|
||||
ag5xpby_ssp (tmp, Seeinv,chi,0.0,chi,Ls-1,Ls-1);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// Uinv
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
for(int b=0;b<nblock;b++){
|
||||
int s = 2*b;
|
||||
RealD pp = p[nblock-1-b];
|
||||
RealD qq = q[nblock-1-b];
|
||||
RealD coeff1=-sign*sqrt(amax*amax*amax*pp*qq) / ( dw_diag*dw_diag + amax*amax* qq);
|
||||
RealD coeff2=-sign*sqrt(amax*pp)*dw_diag / ( dw_diag*dw_diag + amax*amax* qq); // Implicit g5 here
|
||||
axpby_ssp (chi,1.0/scale,tmp,coeff1/scale,tmp,s,Ls-1);
|
||||
axpbg5y_ssp(chi,1.0/scale,tmp,coeff2/scale,tmp,s+1,Ls-1);
|
||||
}
|
||||
axpby_ssp (chi, 1.0/scale,tmp,0.0,tmp,Ls-1,Ls-1);
|
||||
}
|
||||
|
||||
void PartialFractionFermion5D::M_internal(const LatticeFermion &psi, LatticeFermion &chi,int dag)
|
||||
{
|
||||
LatticeFermion D(psi._grid);
|
||||
|
||||
int sign = dag ? (-1) : 1;
|
||||
|
||||
// For partial frac Hw case (b5=c5=1) chroma quirkily computes
|
||||
//
|
||||
// Conventions for partfrac appear to be a mess.
|
||||
// Tony's Nara lectures have
|
||||
//
|
||||
// BlockDiag( H/p_i 1 | 1 )
|
||||
// ( 1 p_i H / q_i^2 | 0 )
|
||||
// ---------------------------------
|
||||
// ( -1 0 | R +p0 H )
|
||||
//
|
||||
//Chroma ( -2H 2sqrt(q_i) | 0 )
|
||||
// (2 sqrt(q_i) 2H | 2 sqrt(p_i) )
|
||||
// ---------------------------------
|
||||
// ( 0 -2 sqrt(p_i) | 2 R gamma_5 + p0 2H
|
||||
//
|
||||
// Edwards/Joo/Kennedy/Wenger
|
||||
//
|
||||
// Here, the "beta's" selected by chroma to scale the unphysical bulk constraint fields
|
||||
// incorporate the approx scale factor. This is obtained by propagating the
|
||||
// scale on "H" out to the off diagonal elements as follows:
|
||||
//
|
||||
// BlockDiag( H/p_i 1 | 1 )
|
||||
// ( 1 p_i H / q_i^2 | 0 )
|
||||
// ---------------------------------
|
||||
// ( -1 0 | R + p_0 H )
|
||||
//
|
||||
// becomes:
|
||||
// BlockDiag( H/ sp_i 1 | 1 )
|
||||
// ( 1 sp_i H / s^2q_i^2 | 0 )
|
||||
// ---------------------------------
|
||||
// ( -1 0 | R + p_0/s H )
|
||||
//
|
||||
//
|
||||
// This is implemented in Chroma by
|
||||
// p0' = p0/approxMax
|
||||
// p_i' = p_i*approxMax
|
||||
// q_i' = q_i*approxMax*approxMax
|
||||
//
|
||||
// After the equivalence transform is applied the matrix becomes
|
||||
//
|
||||
//Chroma ( -2H sqrt(q'_i) | 0 )
|
||||
// (sqrt(q'_i) 2H | sqrt(p'_i) )
|
||||
// ---------------------------------
|
||||
// ( 0 -sqrt(p'_i) | 2 R gamma_5 + p'0 2H
|
||||
//
|
||||
// = ( -2H sqrt(q_i)amax | 0 )
|
||||
// (sqrt(q_i)amax 2H | sqrt(p_i*amax) )
|
||||
// ---------------------------------
|
||||
// ( 0 -sqrt(p_i)*amax | 2 R gamma_5 + p0/amax 2H
|
||||
//
|
||||
|
||||
DW(psi,D,DaggerNo);
|
||||
|
||||
int nblock=(Ls-1)/2;
|
||||
for(int b=0;b<nblock;b++){
|
||||
|
||||
int s = 2*b;
|
||||
double pp = p[nblock-1-b];
|
||||
double qq = q[nblock-1-b];
|
||||
|
||||
// Do each 2x2 block aligned at s and
|
||||
ag5xpby_ssp(chi,-1.0*scale,D,amax*sqrt(qq)*scale,psi, s ,s+1); // Multiplies Dw by G5 so Hw
|
||||
ag5xpby_ssp(chi, 1.0*scale,D,amax*sqrt(qq)*scale,psi, s+1,s);
|
||||
|
||||
// Pick up last column
|
||||
axpby_ssp (chi, 1.0, chi,sqrt(amax*pp)*scale*sign,psi,s+1,Ls-1);
|
||||
}
|
||||
|
||||
{
|
||||
double R=(1+this->mass)/(1-this->mass);
|
||||
//R g5 psi[Ls] + p[0] H
|
||||
ag5xpbg5y_ssp(chi,R*scale,psi,p[nblock]*scale/amax,D,Ls-1,Ls-1);
|
||||
|
||||
for(int b=0;b<nblock;b++){
|
||||
int s = 2*b+1;
|
||||
double pp = p[nblock-1-b];
|
||||
axpby_ssp(chi,1.0,chi,-sqrt(amax*pp)*scale*sign,psi,Ls-1,s);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RealD PartialFractionFermion5D::M (const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
M_internal(in,out,DaggerNo);
|
||||
return norm2(out);
|
||||
}
|
||||
RealD PartialFractionFermion5D::Mdag (const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
M_internal(in,out,DaggerYes);
|
||||
return norm2(out);
|
||||
}
|
||||
|
||||
void PartialFractionFermion5D::Meooe (const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
Meooe_internal(in,out,DaggerNo);
|
||||
}
|
||||
void PartialFractionFermion5D::MeooeDag (const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
Meooe_internal(in,out,DaggerYes);
|
||||
}
|
||||
void PartialFractionFermion5D::Mooee (const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
Mooee_internal(in,out,DaggerNo);
|
||||
}
|
||||
void PartialFractionFermion5D::MooeeDag (const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
Mooee_internal(in,out,DaggerYes);
|
||||
}
|
||||
|
||||
void PartialFractionFermion5D::MooeeInv (const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
MooeeInv_internal(in,out,DaggerNo);
|
||||
}
|
||||
void PartialFractionFermion5D::MooeeInvDag (const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
MooeeInv_internal(in,out,DaggerYes);
|
||||
}
|
||||
|
||||
void PartialFractionFermion5D::SetCoefficientsTanh(Approx::zolotarev_data *zdata,RealD scale){
|
||||
SetCoefficientsZolotarev(1.0/scale,zdata);
|
||||
}
|
||||
void PartialFractionFermion5D::SetCoefficientsZolotarev(RealD zolo_hi,Approx::zolotarev_data *zdata){
|
||||
|
||||
// check on degree matching
|
||||
// std::cout << Ls << " Ls"<<std::endl;
|
||||
// std::cout << zdata->n << " - n"<<std::endl;
|
||||
// std::cout << zdata->da << " -da "<<std::endl;
|
||||
// std::cout << zdata->db << " -db"<<std::endl;
|
||||
// std::cout << zdata->dn << " -dn"<<std::endl;
|
||||
// std::cout << zdata->dd << " -dd"<<std::endl;
|
||||
assert(Ls == (2*zdata->da -1) );
|
||||
|
||||
// Part frac
|
||||
// RealD R;
|
||||
R=(1+mass)/(1-mass);
|
||||
dw_diag = (4.0-M5);
|
||||
|
||||
// std::vector<RealD> p;
|
||||
// std::vector<RealD> q;
|
||||
p.resize(zdata->da);
|
||||
q.resize(zdata->dd);
|
||||
|
||||
for(int n=0;n<zdata->da;n++){
|
||||
p[n] = zdata -> alpha[n];
|
||||
}
|
||||
for(int n=0;n<zdata->dd;n++){
|
||||
q[n] = -zdata -> ap[n];
|
||||
}
|
||||
|
||||
scale= part_frac_chroma_convention ? 2.0 : 1.0; // Chroma conventions annoy me
|
||||
|
||||
amax=zolo_hi;
|
||||
}
|
||||
|
||||
// Constructors
|
||||
PartialFractionFermion5D::PartialFractionFermion5D(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD M5) :
|
||||
WilsonFermion5D(_Umu,
|
||||
FiveDimGrid, FiveDimRedBlackGrid,
|
||||
FourDimGrid, FourDimRedBlackGrid,M5),
|
||||
mass(_mass)
|
||||
|
||||
{
|
||||
assert((Ls&0x1)==1); // Odd Ls required
|
||||
int nrational=Ls-1;
|
||||
|
||||
|
||||
Approx::zolotarev_data *zdata = Approx::higham(1.0,nrational);
|
||||
|
||||
// NB: chroma uses a cast to "float" for the zolotarev range(!?).
|
||||
// this creates a real difference in the operator which I do not like but we can replicate here
|
||||
// to demonstrate compatibility
|
||||
// RealD eps = (zolo_lo / zolo_hi);
|
||||
// zdata = bfm_zolotarev(eps,nrational,0);
|
||||
|
||||
SetCoefficientsTanh(zdata,1.0);
|
||||
|
||||
Approx::zolotarev_free(zdata);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
61
lib/qcd/action/fermion/PartialFractionFermion5D.h
Normal file
61
lib/qcd/action/fermion/PartialFractionFermion5D.h
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef GRID_QCD_PARTIAL_FRACTION_H
|
||||
#define GRID_QCD_PARTIAL_FRACTION_H
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class PartialFractionFermion5D : public WilsonFermion5D
|
||||
{
|
||||
public:
|
||||
|
||||
const int part_frac_chroma_convention=1;
|
||||
|
||||
void Meooe_internal(const LatticeFermion &in, LatticeFermion &out,int dag);
|
||||
void Mooee_internal(const LatticeFermion &in, LatticeFermion &out,int dag);
|
||||
void MooeeInv_internal(const LatticeFermion &in, LatticeFermion &out,int dag);
|
||||
void M_internal(const LatticeFermion &in, LatticeFermion &out,int dag);
|
||||
|
||||
// override multiply
|
||||
virtual RealD M (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual RealD Mdag (const LatticeFermion &in, LatticeFermion &out);
|
||||
|
||||
// half checkerboard operaions
|
||||
virtual void Meooe (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MeooeDag (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void Mooee (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MooeeDag (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MooeeInv (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MooeeInvDag (const LatticeFermion &in, LatticeFermion &out);
|
||||
|
||||
virtual void Instantiatable(void) =0; // ensure no make-eee
|
||||
|
||||
// Constructors
|
||||
PartialFractionFermion5D(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD M5);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void SetCoefficientsTanh(Approx::zolotarev_data *zdata,RealD scale);
|
||||
virtual void SetCoefficientsZolotarev(RealD zolo_hi,Approx::zolotarev_data *zdata);
|
||||
|
||||
// Part frac
|
||||
RealD mass;
|
||||
RealD dw_diag;
|
||||
RealD R;
|
||||
RealD amax;
|
||||
RealD scale;
|
||||
std::vector<double> p;
|
||||
std::vector<double> q;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
37
lib/qcd/action/fermion/ScaledShamirFermion.h
Normal file
37
lib/qcd/action/fermion/ScaledShamirFermion.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef GRID_QCD_SCALED_SHAMIR_FERMION_H
|
||||
#define GRID_QCD_SCALED_SHAMIR_FERMION_H
|
||||
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class ScaledShamirFermion : public MobiusFermion
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
ScaledShamirFermion(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5,
|
||||
RealD scale) :
|
||||
|
||||
// b+c=scale, b-c = 1 <=> 2b = scale+1; 2c = scale-1
|
||||
MobiusFermion(_Umu,
|
||||
FiveDimGrid,
|
||||
FiveDimRedBlackGrid,
|
||||
FourDimGrid,
|
||||
FourDimRedBlackGrid,_mass,_M5,0.5*(scale+1.0),0.5*(scale-1.0))
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
39
lib/qcd/action/fermion/ShamirZolotarevFermion.h
Normal file
39
lib/qcd/action/fermion/ShamirZolotarevFermion.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef GRID_QCD_SHAMIR_ZOLOTAREV_FERMION_H
|
||||
#define GRID_QCD_SHAMIR_ZOLOTAREV_FERMION_H
|
||||
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class ShamirZolotarevFermion : public MobiusZolotarevFermion
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
|
||||
ShamirZolotarevFermion(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD _M5,
|
||||
RealD lo, RealD hi) :
|
||||
|
||||
// b+c = 1; b-c = 1 => b=1, c=0
|
||||
MobiusZolotarevFermion(_Umu,
|
||||
FiveDimGrid,
|
||||
FiveDimRedBlackGrid,
|
||||
FourDimGrid,
|
||||
FourDimRedBlackGrid,_mass,_M5,1.0,0.0,lo,hi)
|
||||
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -9,9 +9,9 @@ const std::vector<int> WilsonFermion::displacements({1,1,1,1,-1,-1,-1,-1});
|
||||
int WilsonFermion::HandOptDslash;
|
||||
|
||||
WilsonFermion::WilsonFermion(LatticeGaugeField &_Umu,
|
||||
GridCartesian &Fgrid,
|
||||
GridRedBlackCartesian &Hgrid,
|
||||
double _mass) :
|
||||
GridCartesian &Fgrid,
|
||||
GridRedBlackCartesian &Hgrid,
|
||||
RealD _mass) :
|
||||
_grid(&Fgrid),
|
||||
_cbgrid(&Hgrid),
|
||||
Stencil (&Fgrid,npoint,Even,directions,displacements),
|
||||
|
@ -5,7 +5,7 @@ namespace Grid {
|
||||
|
||||
namespace QCD {
|
||||
|
||||
class WilsonFermion : public FermionAction<LatticeFermion,LatticeGaugeField>
|
||||
class WilsonFermion : public FermionOperator<LatticeFermion,LatticeGaugeField>
|
||||
{
|
||||
public:
|
||||
|
||||
@ -44,7 +44,7 @@ namespace Grid {
|
||||
int dag);
|
||||
|
||||
// Constructor
|
||||
WilsonFermion(LatticeGaugeField &_Umu,GridCartesian &Fgrid,GridRedBlackCartesian &Hgrid,double _mass);
|
||||
WilsonFermion(LatticeGaugeField &_Umu,GridCartesian &Fgrid,GridRedBlackCartesian &Hgrid,RealD _mass);
|
||||
|
||||
// DoubleStore
|
||||
void DoubleStore(LatticeDoubledGaugeField &Uds,const LatticeGaugeField &Umu);
|
||||
@ -57,7 +57,7 @@ namespace Grid {
|
||||
|
||||
protected:
|
||||
|
||||
double mass;
|
||||
RealD mass;
|
||||
|
||||
GridBase * _grid;
|
||||
GridBase * _cbgrid;
|
||||
|
@ -4,18 +4,18 @@ namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
// S-direction is INNERMOST and takes no part in the parity.
|
||||
const std::vector<int> FiveDimWilsonFermion::directions ({1,2,3,4, 1, 2, 3, 4});
|
||||
const std::vector<int> FiveDimWilsonFermion::displacements({1,1,1,1,-1,-1,-1,-1});
|
||||
const std::vector<int> WilsonFermion5D::directions ({1,2,3,4, 1, 2, 3, 4});
|
||||
const std::vector<int> WilsonFermion5D::displacements({1,1,1,1,-1,-1,-1,-1});
|
||||
|
||||
int FiveDimWilsonFermion::HandOptDslash;
|
||||
int WilsonFermion5D::HandOptDslash;
|
||||
|
||||
// 5d lattice for DWF.
|
||||
FiveDimWilsonFermion::FiveDimWilsonFermion(LatticeGaugeField &_Umu,
|
||||
WilsonFermion5D::WilsonFermion5D(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
double _mass) :
|
||||
RealD _M5) :
|
||||
_FiveDimGrid(&FiveDimGrid),
|
||||
_FiveDimRedBlackGrid(&FiveDimRedBlackGrid),
|
||||
_FourDimGrid(&FourDimGrid),
|
||||
@ -23,7 +23,7 @@ namespace QCD {
|
||||
Stencil (_FiveDimGrid,npoint,Even,directions,displacements),
|
||||
StencilEven(_FiveDimRedBlackGrid,npoint,Even,directions,displacements), // source is Even
|
||||
StencilOdd (_FiveDimRedBlackGrid,npoint,Odd ,directions,displacements), // source is Odd
|
||||
mass(_mass),
|
||||
M5(_M5),
|
||||
Umu(_FourDimGrid),
|
||||
UmuEven(_FourDimRedBlackGrid),
|
||||
UmuOdd (_FourDimRedBlackGrid),
|
||||
@ -70,7 +70,7 @@ namespace QCD {
|
||||
pickCheckerboard(Even,UmuEven,Umu);
|
||||
pickCheckerboard(Odd ,UmuOdd,Umu);
|
||||
}
|
||||
void FiveDimWilsonFermion::DoubleStore(LatticeDoubledGaugeField &Uds,const LatticeGaugeField &Umu)
|
||||
void WilsonFermion5D::DoubleStore(LatticeDoubledGaugeField &Uds,const LatticeGaugeField &Umu)
|
||||
{
|
||||
conformable(Uds._grid,GaugeGrid());
|
||||
conformable(Umu._grid,GaugeGrid());
|
||||
@ -82,60 +82,9 @@ void FiveDimWilsonFermion::DoubleStore(LatticeDoubledGaugeField &Uds,const Latti
|
||||
pokeIndex<LorentzIndex>(Uds,U,mu+4);
|
||||
}
|
||||
}
|
||||
|
||||
RealD FiveDimWilsonFermion::M(const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
out.checkerboard=in.checkerboard;
|
||||
Dhop(in,out,DaggerNo);
|
||||
return axpy_norm(out,5.0-M5,in,out);
|
||||
}
|
||||
RealD FiveDimWilsonFermion::Mdag(const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
out.checkerboard=in.checkerboard;
|
||||
Dhop(in,out,DaggerYes);
|
||||
return axpy_norm(out,5.0-M5,in,out);
|
||||
}
|
||||
void FiveDimWilsonFermion::Meooe(const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
if ( in.checkerboard == Odd ) {
|
||||
DhopEO(in,out,DaggerNo);
|
||||
} else {
|
||||
DhopOE(in,out,DaggerNo);
|
||||
}
|
||||
}
|
||||
void FiveDimWilsonFermion::MeooeDag(const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
if ( in.checkerboard == Odd ) {
|
||||
DhopEO(in,out,DaggerYes);
|
||||
} else {
|
||||
DhopOE(in,out,DaggerYes);
|
||||
}
|
||||
}
|
||||
void FiveDimWilsonFermion::Mooee(const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
out.checkerboard = in.checkerboard;
|
||||
out = (5.0-M5)*in;
|
||||
return ;
|
||||
}
|
||||
void FiveDimWilsonFermion::MooeeDag(const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
out.checkerboard = in.checkerboard;
|
||||
Mooee(in,out);
|
||||
}
|
||||
void FiveDimWilsonFermion::MooeeInv(const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
out.checkerboard = in.checkerboard;
|
||||
out = (1.0/(5.0-M5))*in;
|
||||
return ;
|
||||
}
|
||||
void FiveDimWilsonFermion::MooeeInvDag(const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
out.checkerboard = in.checkerboard;
|
||||
MooeeInv(in,out);
|
||||
}
|
||||
void FiveDimWilsonFermion::DhopInternal(CartesianStencil & st, LebesgueOrder &lo,
|
||||
LatticeDoubledGaugeField & U,
|
||||
const LatticeFermion &in, LatticeFermion &out,int dag)
|
||||
void WilsonFermion5D::DhopInternal(CartesianStencil & st, LebesgueOrder &lo,
|
||||
LatticeDoubledGaugeField & U,
|
||||
const LatticeFermion &in, LatticeFermion &out,int dag)
|
||||
{
|
||||
assert((dag==DaggerNo) ||(dag==DaggerYes));
|
||||
|
||||
@ -150,19 +99,21 @@ void FiveDimWilsonFermion::DhopInternal(CartesianStencil & st, LebesgueOrder &lo
|
||||
// - 8 linear access unit stride streams per thread for Fermion for hw prefetchable.
|
||||
if ( dag == DaggerYes ) {
|
||||
if( HandOptDslash ) {
|
||||
for(int ss=0;ss<U._grid->oSites();ss++){
|
||||
int sU=lo.Reorder(ss);
|
||||
PARALLEL_FOR_LOOP
|
||||
for(int ss=0;ss<U._grid->oSites();ss++){
|
||||
for(int s=0;s<Ls;s++){
|
||||
//int sU=lo.Reorder(ss);
|
||||
int sU=ss;
|
||||
int sF = s+Ls*sU;
|
||||
DiracOptHand::DhopSiteDag(st,U,comm_buf,sF,sU,in,out);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(int ss=0;ss<U._grid->oSites();ss++){
|
||||
int sU=lo.Reorder(ss);
|
||||
PARALLEL_FOR_LOOP
|
||||
for(int ss=0;ss<U._grid->oSites();ss++){
|
||||
for(int s=0;s<Ls;s++){
|
||||
// int sU=lo.Reorder(ss);
|
||||
int sU=ss;
|
||||
int sF = s+Ls*sU;
|
||||
DiracOpt::DhopSiteDag(st,U,comm_buf,sF,sU,in,out);
|
||||
}
|
||||
@ -170,21 +121,22 @@ PARALLEL_FOR_LOOP
|
||||
}
|
||||
} else {
|
||||
if( HandOptDslash ) {
|
||||
|
||||
PARALLEL_FOR_LOOP
|
||||
for(int ss=0;ss<U._grid->oSites();ss++){
|
||||
int sU=lo.Reorder(ss);
|
||||
for(int s=0;s<Ls;s++){
|
||||
// int sU=lo.Reorder(ss);
|
||||
int sU=ss;
|
||||
int sF = s+Ls*sU;
|
||||
DiracOptHand::DhopSite(st,U,comm_buf,sF,sU,in,out);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
for(int ss=0;ss<U._grid->oSites();ss++){
|
||||
int sU=lo.Reorder(ss);
|
||||
PARALLEL_FOR_LOOP
|
||||
for(int ss=0;ss<U._grid->oSites();ss++){
|
||||
for(int s=0;s<Ls;s++){
|
||||
// int sU=lo.Reorder(ss);
|
||||
int sU=ss;
|
||||
int sF = s+Ls*sU;
|
||||
DiracOpt::DhopSite(st,U,comm_buf,sF,sU,in,out);
|
||||
}
|
||||
@ -192,7 +144,7 @@ PARALLEL_FOR_LOOP
|
||||
}
|
||||
}
|
||||
}
|
||||
void FiveDimWilsonFermion::DhopOE(const LatticeFermion &in, LatticeFermion &out,int dag)
|
||||
void WilsonFermion5D::DhopOE(const LatticeFermion &in, LatticeFermion &out,int dag)
|
||||
{
|
||||
conformable(in._grid,FermionRedBlackGrid()); // verifies half grid
|
||||
conformable(in._grid,out._grid); // drops the cb check
|
||||
@ -202,7 +154,7 @@ void FiveDimWilsonFermion::DhopOE(const LatticeFermion &in, LatticeFermion &out,
|
||||
|
||||
DhopInternal(StencilEven,LebesgueEvenOdd,UmuOdd,in,out,dag);
|
||||
}
|
||||
void FiveDimWilsonFermion::DhopEO(const LatticeFermion &in, LatticeFermion &out,int dag)
|
||||
void WilsonFermion5D::DhopEO(const LatticeFermion &in, LatticeFermion &out,int dag)
|
||||
{
|
||||
conformable(in._grid,FermionRedBlackGrid()); // verifies half grid
|
||||
conformable(in._grid,out._grid); // drops the cb check
|
||||
@ -212,7 +164,7 @@ void FiveDimWilsonFermion::DhopEO(const LatticeFermion &in, LatticeFermion &out,
|
||||
|
||||
DhopInternal(StencilOdd,LebesgueEvenOdd,UmuEven,in,out,dag);
|
||||
}
|
||||
void FiveDimWilsonFermion::Dhop(const LatticeFermion &in, LatticeFermion &out,int dag)
|
||||
void WilsonFermion5D::Dhop(const LatticeFermion &in, LatticeFermion &out,int dag)
|
||||
{
|
||||
conformable(in._grid,FermionGrid()); // verifies full grid
|
||||
conformable(in._grid,out._grid);
|
||||
@ -221,8 +173,14 @@ void FiveDimWilsonFermion::Dhop(const LatticeFermion &in, LatticeFermion &out,in
|
||||
|
||||
DhopInternal(Stencil,Lebesgue,Umu,in,out,dag);
|
||||
}
|
||||
|
||||
}}
|
||||
void WilsonFermion5D::DW(const LatticeFermion &in, LatticeFermion &out,int dag)
|
||||
{
|
||||
out.checkerboard=in.checkerboard;
|
||||
Dhop(in,out,dag); // -0.5 is included
|
||||
axpy(out,4.0-M5,in,out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef GRID_QCD_DWF_H
|
||||
#define GRID_QCD_DWF_H
|
||||
#ifndef GRID_QCD_WILSON_FERMION_5D_H
|
||||
#define GRID_QCD_WILSON_FERMION_5D_H
|
||||
|
||||
namespace Grid {
|
||||
|
||||
@ -14,8 +14,20 @@ namespace Grid {
|
||||
// i.e. even even contains fifth dim hopping term.
|
||||
//
|
||||
// [DIFFERS from original CPS red black implementation parity = (x+y+z+t+s)|2 ]
|
||||
////////////////////////////
|
||||
//ContFrac:
|
||||
// Ls always odd. Rational poly deg is either Ls or Ls-1
|
||||
//PartFrac
|
||||
// Ls always odd. Rational poly deg is either Ls or Ls-1
|
||||
//
|
||||
//Cayley: Ls always even, Rational poly deg is Ls
|
||||
//
|
||||
// Just set nrational as Ls. Forget about Ls-1 cases.
|
||||
//
|
||||
// Require odd Ls for cont and part frac
|
||||
////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class FiveDimWilsonFermion : public FermionAction<LatticeFermion,LatticeGaugeField>
|
||||
class WilsonFermion5D : public FermionOperator<LatticeFermion,LatticeGaugeField>
|
||||
{
|
||||
public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
@ -26,19 +38,21 @@ namespace Grid {
|
||||
GridBase *FermionGrid(void) { return _FiveDimGrid;}
|
||||
GridBase *FermionRedBlackGrid(void) { return _FiveDimRedBlackGrid;}
|
||||
|
||||
// override multiply
|
||||
virtual RealD M (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual RealD Mdag (const LatticeFermion &in, LatticeFermion &out);
|
||||
// full checkerboard operations; leave unimplemented as abstract for now
|
||||
//virtual RealD M (const LatticeFermion &in, LatticeFermion &out)=0;
|
||||
//virtual RealD Mdag (const LatticeFermion &in, LatticeFermion &out)=0;
|
||||
|
||||
// half checkerboard operaions
|
||||
virtual void Meooe (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MeooeDag (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void Mooee (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MooeeDag (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MooeeInv (const LatticeFermion &in, LatticeFermion &out);
|
||||
virtual void MooeeInvDag (const LatticeFermion &in, LatticeFermion &out);
|
||||
// half checkerboard operations; leave unimplemented as abstract for now
|
||||
// virtual void Meooe (const LatticeFermion &in, LatticeFermion &out)=0;
|
||||
// virtual void MeooeDag (const LatticeFermion &in, LatticeFermion &out)=0;
|
||||
// virtual void Mooee (const LatticeFermion &in, LatticeFermion &out)=0;
|
||||
// virtual void MooeeDag (const LatticeFermion &in, LatticeFermion &out)=0;
|
||||
// virtual void MooeeInv (const LatticeFermion &in, LatticeFermion &out)=0;
|
||||
// virtual void MooeeInvDag (const LatticeFermion &in, LatticeFermion &out)=0;
|
||||
|
||||
// non-hermitian hopping term; half cb or both
|
||||
// Implement hopping term non-hermitian hopping term; half cb or both
|
||||
// Implement s-diagonal DW
|
||||
void DW (const LatticeFermion &in, LatticeFermion &out,int dag);
|
||||
void Dhop (const LatticeFermion &in, LatticeFermion &out,int dag);
|
||||
void DhopOE(const LatticeFermion &in, LatticeFermion &out,int dag);
|
||||
void DhopEO(const LatticeFermion &in, LatticeFermion &out,int dag);
|
||||
@ -54,12 +68,12 @@ namespace Grid {
|
||||
int dag);
|
||||
|
||||
// Constructors
|
||||
FiveDimWilsonFermion(LatticeGaugeField &_Umu,
|
||||
WilsonFermion5D(LatticeGaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
double _mass);
|
||||
double _M5);
|
||||
|
||||
// DoubleStore
|
||||
void DoubleStore(LatticeDoubledGaugeField &Uds,const LatticeGaugeField &Umu);
|
||||
@ -82,7 +96,6 @@ namespace Grid {
|
||||
static const std::vector<int> displacements;
|
||||
|
||||
double M5;
|
||||
double mass;
|
||||
int Ls;
|
||||
|
||||
//Defines the stencils for even and odd
|
Reference in New Issue
Block a user