1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-13 04:37:05 +01:00
This commit is contained in:
Guido Cossu
2017-10-24 16:48:05 +01:00
9 changed files with 836 additions and 137 deletions

View File

@ -39,30 +39,33 @@ namespace QCD
template <class Impl>
RealD WilsonCloverFermion<Impl>::M(const FermionField &in, FermionField &out)
{
FermionField temp(out._grid);
// Wilson term
out.checkerboard = in.checkerboard;
this->Dhop(in, out, DaggerNo);
// Clover term
// apply the sigma and Fmunu
FermionField temp(out._grid);
Mooee(in, temp);
// overall factor
out += temp;
return axpy_norm(out, 4 + this->mass, in, out);
return norm2(out);
}
template <class Impl>
RealD WilsonCloverFermion<Impl>::Mdag(const FermionField &in, FermionField &out)
{
FermionField temp(out._grid);
// Wilson term
out.checkerboard = in.checkerboard;
this->Dhop(in, out, DaggerYes);
// Clover term
// apply the sigma and Fmunu
FermionField temp(out._grid);
MooeeDag(in, temp);
out+=temp;
return axpy_norm(out, 4 + this->mass, in, out);
out += temp;
return norm2(out);
}
template <class Impl>
@ -72,22 +75,23 @@ void WilsonCloverFermion<Impl>::ImportGauge(const GaugeField &_Umu)
GridBase *grid = _Umu._grid;
typename Impl::GaugeLinkField Bx(grid), By(grid), Bz(grid), Ex(grid), Ey(grid), Ez(grid);
// Compute the field strength terms
WilsonLoops<Impl>::FieldStrength(Bx, _Umu, Ydir, Zdir);
// Compute the field strength terms mu>nu
WilsonLoops<Impl>::FieldStrength(Bx, _Umu, Zdir, Ydir);
WilsonLoops<Impl>::FieldStrength(By, _Umu, Zdir, Xdir);
WilsonLoops<Impl>::FieldStrength(Bz, _Umu, Xdir, Ydir);
WilsonLoops<Impl>::FieldStrength(Bz, _Umu, Ydir, Xdir);
WilsonLoops<Impl>::FieldStrength(Ex, _Umu, Tdir, Xdir);
WilsonLoops<Impl>::FieldStrength(Ey, _Umu, Tdir, Ydir);
WilsonLoops<Impl>::FieldStrength(Ez, _Umu, Tdir, Zdir);
// Compute the Clover Operator acting on Colour and Spin
CloverTerm = fillCloverYZ(Bx);
CloverTerm = fillCloverYZ(Bx);
CloverTerm += fillCloverXZ(By);
CloverTerm += fillCloverXY(Bz);
CloverTerm += fillCloverXT(Ex);
CloverTerm += fillCloverYT(Ey);
CloverTerm += fillCloverZT(Ez) ;
CloverTerm *= csw;
CloverTerm += fillCloverZT(Ez);
CloverTerm *= (0.5) * csw;
CloverTerm += (4.0 + this->mass);
int lvol = _Umu._grid->lSites();
int DimRep = Impl::Dimension;
@ -104,13 +108,13 @@ void WilsonCloverFermion<Impl>::ImportGauge(const GaugeField &_Umu)
EigenCloverOp = Eigen::MatrixXcd::Zero(Ns * DimRep, Ns * DimRep);
peekLocalSite(Qx, CloverTerm, lcoor);
Qxinv = zero;
//if (csw!=0){
for (int j = 0; j < Ns; j++)
for (int k = 0; k < Ns; k++)
for (int a = 0; a < DimRep; a++)
for (int b = 0; b < DimRep; b++)
EigenCloverOp(a + j * DimRep, b + k * DimRep) = Qx()(j, k)(a, b);
//std::cout << EigenCloverOp << std::endl;
// if (site==0) std::cout << "site =" << site << "\n" << EigenCloverOp << std::endl;
EigenInvCloverOp = EigenCloverOp.inverse();
//std::cout << EigenInvCloverOp << std::endl;
@ -119,31 +123,36 @@ void WilsonCloverFermion<Impl>::ImportGauge(const GaugeField &_Umu)
for (int a = 0; a < DimRep; a++)
for (int b = 0; b < DimRep; b++)
Qxinv()(j, k)(a, b) = EigenInvCloverOp(a + j * DimRep, b + k * DimRep);
// if (site==0) std::cout << "site =" << site << "\n" << EigenInvCloverOp << std::endl;
// }
pokeLocalSite(Qxinv, CloverTermInv, lcoor);
}
// Separate the even and odd parts.
// Separate the even and odd parts
pickCheckerboard(Even, CloverTermEven, CloverTerm);
pickCheckerboard( Odd, CloverTermOdd, CloverTerm);
pickCheckerboard(Odd, CloverTermOdd, CloverTerm);
pickCheckerboard(Even, CloverTermDagEven, adj(CloverTerm));
pickCheckerboard(Odd, CloverTermDagOdd, adj(CloverTerm));
pickCheckerboard(Even, CloverTermInvEven, CloverTermInv);
pickCheckerboard( Odd, CloverTermInvOdd, CloverTermInv);
pickCheckerboard(Odd, CloverTermInvOdd, CloverTermInv);
pickCheckerboard(Even, CloverTermInvDagEven, adj(CloverTermInv));
pickCheckerboard(Odd, CloverTermInvDagOdd, adj(CloverTermInv));
}
template <class Impl>
void WilsonCloverFermion<Impl>::Mooee(const FermionField &in, FermionField &out)
{
conformable(in,out);
conformable(in, out);
this->MooeeInternal(in, out, DaggerNo, InverseNo);
}
template <class Impl>
void WilsonCloverFermion<Impl>::MooeeDag(const FermionField &in, FermionField &out)
{
conformable(in,out);
this->MooeeInternal(in, out, DaggerYes, InverseYes);
this->MooeeInternal(in, out, DaggerYes, InverseNo);
}
template <class Impl>
@ -167,35 +176,58 @@ void WilsonCloverFermion<Impl>::MooeeInternal(const FermionField &in, FermionFie
CloverFieldType *Clover;
assert(in.checkerboard == Odd || in.checkerboard == Even);
if (in._grid->_isCheckerBoarded)
if (dag)
{
if (in.checkerboard == Odd)
if (in._grid->_isCheckerBoarded)
{
std::cout << "Calling clover term Odd" << std::endl;
Clover = (inv) ? &CloverTermInvOdd : &CloverTermOdd;
if (in.checkerboard == Odd)
{
Clover = (inv) ? &CloverTermInvDagOdd : &CloverTermDagOdd;
}
else
{
Clover = (inv) ? &CloverTermInvDagEven : &CloverTermDagEven;
}
out = *Clover * in;
}
else
{
std::cout << "Calling clover term Even" << std::endl;
Clover = (inv) ? &CloverTermInvEven : &CloverTermEven;
Clover = (inv) ? &CloverTermInv : &CloverTerm;
out = adj(*Clover) * in;
}
}
else
{
Clover = (inv) ? &CloverTermInv : &CloverTerm;
if (in._grid->_isCheckerBoarded)
{
if (in.checkerboard == Odd)
{
// std::cout << "Calling clover term Odd" << std::endl;
Clover = (inv) ? &CloverTermInvOdd : &CloverTermOdd;
}
else
{
// std::cout << "Calling clover term Even" << std::endl;
Clover = (inv) ? &CloverTermInvEven : &CloverTermEven;
}
out = *Clover * in;
// std::cout << GridLogMessage << "*Clover.checkerboard " << (*Clover).checkerboard << std::endl;
}
else
{
Clover = (inv) ? &CloverTermInv : &CloverTerm;
out = *Clover * in;
}
}
std::cout << GridLogMessage << "*Clover.checkerboard " << (*Clover).checkerboard << std::endl;
std::cout << GridLogMessage << "in.checkerboard " << in.checkerboard << std::endl;
std::cout << GridLogMessage << "out.checkerboard " << out.checkerboard << std::endl;
out = *Clover * in;
//if (dag){ out = adj(*Clover) * in;} else { out = *Clover * in;}
} // MooeeInternal
// Derivative parts
template <class Impl>
void WilsonCloverFermion<Impl>::MDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag)
{
GaugeField tmp(mat._grid);
conformable(U._grid, V._grid);
@ -211,10 +243,90 @@ void WilsonCloverFermion<Impl>::MDeriv(GaugeField &mat, const FermionField &U, c
// Derivative parts
template <class Impl>
void WilsonCloverFermion<Impl>::MooDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag)
void WilsonCloverFermion<Impl>::MooDeriv(GaugeField &mat, const FermionField &X, const FermionField &Y, int dag)
{
// Compute the 8 terms of the derivative
assert(0); // not implemented yet
GridBase *grid = mat._grid;
//GaugeLinkField Lambdaodd(grid), Lambdaeven(grid), tmp(grid);
//Lambdaodd = zero; //Yodd*dag(Xodd)+Xodd*dag(Yodd); // I have to peek spin and decide the color structure
//Lambdaeven = zero; //Teven*dag(Xeven)+Xeven*dag(Yeven) + 2*(Dee^-1)
GaugeLinkField Lambda(grid), tmp(grid);
Lambda = zero;
conformable(mat._grid, X._grid);
conformable(Y._grid, X._grid);
std::vector<GaugeLinkField> C1p(Nd, grid), C2p(Nd, grid), C3p(Nd, grid), C4p(Nd, grid);
std::vector<GaugeLinkField> C1m(Nd, grid), C2m(Nd, grid), C3m(Nd, grid), C4m(Nd, grid);
std::vector<GaugeLinkField> U(Nd, mat._grid);
for (int mu = 0; mu < Nd; mu++)
{
U[mu] = PeekIndex<LorentzIndex>(mat, mu);
C1p[mu] = zero;
C2p[mu] = zero;
C3p[mu] = zero;
C4p[mu] = zero;
C1m[mu] = zero;
C2m[mu] = zero;
C3m[mu] = zero;
C4m[mu] = zero;
}
/*
PARALLEL_FOR_LOOP
for (int i = 0; i < CloverTerm._grid->oSites(); i++)
{
T._odata[i]()(0, 1) = timesMinusI(F._odata[i]()());
T._odata[i]()(1, 0) = timesMinusI(F._odata[i]()());
T._odata[i]()(2, 3) = timesMinusI(F._odata[i]()());
T._odata[i]()(3, 2) = timesMinusI(F._odata[i]()());
}
*/
for (int i = 0; i < 4; i++)
{ //spin
for (int j = 0; j < 4; j++)
{ //spin
for (int mu = 0; mu < 4; mu++)
{ //color
for (int nu = 0; nu < 4; nu++)
{ //color
// insertion in upper staple
tmp = Lambda * U[nu];
C1p[mu] += Impl::ShiftStaple(Impl::CovShiftForward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu);
tmp = Lambda * U[mu];
C2p[mu] += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu);
tmp = Impl::CovShiftIdentityForward(Lambda, nu) * U[nu];
C3p[mu] += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(tmp, nu))), mu);
tmp = Lambda;
C4p[mu] += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu) * tmp;
// insertion in lower staple
tmp = Lambda * U[nu];
C1m[mu] += Impl::ShiftStaple(Impl::CovShiftBackward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu);
tmp = Lambda * U[mu];
C2m[mu] += Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, U[nu])), mu);
tmp = Lambda * U[nu];
C3m[mu] += Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, tmp)), mu);
tmp = Lambda;
C4m[mu] += Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu) * tmp;
}
}
}
}
//Still implementing. Have to be tested, and understood how to project EO
}
// Derivative parts

View File

@ -26,6 +26,7 @@
See the full license in the file "LICENSE" in the top level distribution directory
*************************************************************************************/
/* END LEGAL */
#ifndef GRID_QCD_WILSON_CLOVER_FERMION_H
#define GRID_QCD_WILSON_CLOVER_FERMION_H
@ -42,9 +43,11 @@ class WilsonCloverFermion : public WilsonFermion<Impl>
public:
// Types definitions
INHERIT_IMPL_TYPES(Impl);
template <typename vtype> using iImplClover = iScalar<iMatrix<iMatrix<vtype, Impl::Dimension>, Ns> >;
typedef iImplClover<Simd> SiteCloverType;
typedef Lattice<SiteCloverType> CloverFieldType;
template <typename vtype>
using iImplClover = iScalar<iMatrix<iMatrix<vtype, Impl::Dimension>, Ns>>;
typedef iImplClover<Simd> SiteCloverType;
typedef Lattice<SiteCloverType> CloverFieldType;
public:
typedef WilsonFermion<Impl> WilsonBase;
@ -58,15 +61,21 @@ public:
Fgrid,
Hgrid,
_mass, p),
CloverTerm(&Fgrid),
CloverTermInv(&Fgrid),
CloverTermEven(&Hgrid),
CloverTermOdd(&Hgrid),
CloverTermInvEven(&Hgrid),
CloverTermInvOdd(&Hgrid)
CloverTerm(&Fgrid),
CloverTermInv(&Fgrid),
CloverTermEven(&Hgrid),
CloverTermOdd(&Hgrid),
CloverTermInvEven(&Hgrid),
CloverTermInvOdd(&Hgrid),
CloverTermDagEven(&Hgrid),
CloverTermDagOdd(&Hgrid),
CloverTermInvDagEven(&Hgrid),
CloverTermInvDagOdd(&Hgrid)
{
csw = _csw;
assert(Nd == 4); // require 4 dimensions
if (csw == 0) std::cout << GridLogWarning << "Initializing WilsonCloverFermion with csw = 0" << std::endl;
}
virtual RealD M(const FermionField &in, FermionField &out);
@ -87,10 +96,13 @@ public:
private:
// here fixing the 4 dimensions, make it more general?
RealD csw; // Clover coefficient
CloverFieldType CloverTerm, CloverTermInv; // Clover term
CloverFieldType CloverTermEven, CloverTermOdd;
CloverFieldType CloverTermInvEven, CloverTermInvOdd; // Clover term
RealD csw; // Clover coefficient
CloverFieldType CloverTerm, CloverTermInv; // Clover term
CloverFieldType CloverTermEven, CloverTermOdd; // Clover term EO
CloverFieldType CloverTermInvEven, CloverTermInvOdd; // Clover term Inv EO
CloverFieldType CloverTermDagEven, CloverTermDagOdd; // Clover term Dag EO
CloverFieldType CloverTermInvDagEven, CloverTermInvDagOdd; // Clover term Inv Dag EO
// eventually these two can be compressed into 6x6 blocks instead of the 12x12
// using the DeGrand-Rossi basis for the gamma matrices
@ -106,9 +118,9 @@ private:
T._odata[i]()(2, 3) = timesMinusI(F._odata[i]()());
T._odata[i]()(3, 2) = timesMinusI(F._odata[i]()());
}
return T;
}
return T;
}
CloverFieldType fillCloverXZ(const GaugeLinkField &F)
{
@ -122,9 +134,9 @@ private:
T._odata[i]()(2, 3) = -F._odata[i]()();
T._odata[i]()(3, 2) = F._odata[i]()();
}
return T;
}
return T;
}
CloverFieldType fillCloverXY(const GaugeLinkField &F)
{
@ -138,9 +150,9 @@ private:
T._odata[i]()(2, 2) = timesMinusI(F._odata[i]()());
T._odata[i]()(3, 3) = timesI(F._odata[i]()());
}
return T;
}
return T;
}
CloverFieldType fillCloverXT(const GaugeLinkField &F)
{
@ -149,14 +161,14 @@ private:
PARALLEL_FOR_LOOP
for (int i = 0; i < CloverTerm._grid->oSites(); i++)
{
T._odata[i]()(0, 1) = timesMinusI(F._odata[i]()());
T._odata[i]()(1, 0) = timesMinusI(F._odata[i]()());
T._odata[i]()(2, 3) = timesI(F._odata[i]()());
T._odata[i]()(3, 2) = timesI(F._odata[i]()());
T._odata[i]()(0, 1) = timesI(F._odata[i]()());
T._odata[i]()(1, 0) = timesI(F._odata[i]()());
T._odata[i]()(2, 3) = timesMinusI(F._odata[i]()());
T._odata[i]()(3, 2) = timesMinusI(F._odata[i]()());
}
return T;
}
return T;
}
CloverFieldType fillCloverYT(const GaugeLinkField &F)
{
@ -165,14 +177,14 @@ private:
PARALLEL_FOR_LOOP
for (int i = 0; i < CloverTerm._grid->oSites(); i++)
{
T._odata[i]()(0, 1) = (F._odata[i]()());
T._odata[i]()(1, 0) = -(F._odata[i]()());
T._odata[i]()(2, 3) = -(F._odata[i]()());
T._odata[i]()(3, 2) = (F._odata[i]()());
T._odata[i]()(0, 1) = -(F._odata[i]()());
T._odata[i]()(1, 0) = (F._odata[i]()());
T._odata[i]()(2, 3) = (F._odata[i]()());
T._odata[i]()(3, 2) = -(F._odata[i]()());
}
return T;
}
return T;
}
CloverFieldType fillCloverZT(const GaugeLinkField &F)
{
@ -181,17 +193,16 @@ private:
PARALLEL_FOR_LOOP
for (int i = 0; i < CloverTerm._grid->oSites(); i++)
{
T._odata[i]()(0, 0) = timesMinusI(F._odata[i]()());
T._odata[i]()(1, 1) = timesI(F._odata[i]()());
T._odata[i]()(2, 2) = timesI(F._odata[i]()());
T._odata[i]()(3, 3) = timesMinusI(F._odata[i]()());
T._odata[i]()(0, 0) = timesI(F._odata[i]()());
T._odata[i]()(1, 1) = timesMinusI(F._odata[i]()());
T._odata[i]()(2, 2) = timesMinusI(F._odata[i]()());
T._odata[i]()(3, 3) = timesI(F._odata[i]()());
}
return T;
}
return T;
}
};
}
}
#endif // GRID_QCD_WILSON_CLOVER_FERMION_H
#endif // GRID_QCD_WILSON_CLOVER_FERMION_H

View File

@ -337,7 +337,9 @@ static void StapleMult(GaugeMat &staple, const GaugeLorentz &Umu, int mu) {
GaugeMat v = Vup - Vdn;
GaugeMat u = PeekIndex<LorentzIndex>(Umu, mu); // some redundant copies
GaugeMat vu = v*u;
FS = 0.25*Ta(u*v + Cshift(vu, mu, -1));
//FS = 0.25*Ta(u*v + Cshift(vu, mu, -1));
FS = (u*v + Cshift(vu, mu, -1));
FS = 0.125*(FS - adj(FS));
}
static Real TopologicalCharge(GaugeLorentz &U){