2017-03-28 09:49:30 +01:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
/*************************************************************************************
|
2016-01-02 14:51:32 +00:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
2016-01-02 14:51:32 +00:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
Source file: ./lib/qcd/action/fermion/WilsonFermion.cc
|
2016-01-02 14:51:32 +00:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
Copyright (C) 2015
|
2016-01-02 14:51:32 +00:00
|
|
|
|
|
|
|
Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
|
|
|
|
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
|
|
|
Author: Peter Boyle <peterboyle@Peters-MacBook-Pro-2.local>
|
|
|
|
Author: paboyle <paboyle@ph.ed.ac.uk>
|
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
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.
|
2016-01-02 14:51:32 +00:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
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.
|
2016-01-02 14:51:32 +00:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
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.
|
2016-01-02 14:51:32 +00:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
See the full license in the file "LICENSE" in the top level distribution
|
|
|
|
directory
|
|
|
|
*************************************************************************************/
|
|
|
|
/* END LEGAL */
|
2017-02-22 18:09:33 +00:00
|
|
|
#include <Grid/qcd/action/fermion/FermionCore.h>
|
|
|
|
#include <Grid/qcd/action/fermion/WilsonFermion.h>
|
2015-05-31 15:09:02 +01:00
|
|
|
|
|
|
|
namespace Grid {
|
|
|
|
namespace QCD {
|
|
|
|
|
2017-02-22 18:09:33 +00:00
|
|
|
const std::vector<int> WilsonFermionStatic::directions({0, 1, 2, 3, 0, 1, 2, 3});
|
|
|
|
const std::vector<int> WilsonFermionStatic::displacements({1, 1, 1, 1, -1, -1, -1, -1});
|
2016-07-06 11:41:27 +01:00
|
|
|
int WilsonFermionStatic::HandOptDslash;
|
2015-05-31 15:09:02 +01:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
/////////////////////////////////
|
|
|
|
// Constructor and gauge import
|
|
|
|
/////////////////////////////////
|
2015-05-31 15:09:02 +01:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
template <class Impl>
|
|
|
|
WilsonFermion<Impl>::WilsonFermion(GaugeField &_Umu, GridCartesian &Fgrid,
|
|
|
|
GridRedBlackCartesian &Hgrid, RealD _mass,
|
|
|
|
const ImplParams &p)
|
|
|
|
: Kernels(p),
|
|
|
|
_grid(&Fgrid),
|
|
|
|
_cbgrid(&Hgrid),
|
|
|
|
Stencil(&Fgrid, npoint, Even, directions, displacements),
|
2017-02-22 18:09:33 +00:00
|
|
|
StencilEven(&Hgrid, npoint, Even, directions,displacements), // source is Even
|
|
|
|
StencilOdd(&Hgrid, npoint, Odd, directions,displacements), // source is Odd
|
2016-07-06 11:41:27 +01:00
|
|
|
mass(_mass),
|
|
|
|
Lebesgue(_grid),
|
|
|
|
LebesgueEvenOdd(_cbgrid),
|
|
|
|
Umu(&Fgrid),
|
|
|
|
UmuEven(&Hgrid),
|
2016-12-08 17:28:28 +00:00
|
|
|
UmuOdd(&Hgrid),
|
|
|
|
_tmp(&Hgrid)
|
|
|
|
{
|
2016-07-06 11:41:27 +01:00
|
|
|
// Allocate the required comms buffer
|
|
|
|
ImportGauge(_Umu);
|
|
|
|
}
|
2015-05-31 15:09:02 +01:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
template <class Impl>
|
|
|
|
void WilsonFermion<Impl>::ImportGauge(const GaugeField &_Umu) {
|
|
|
|
GaugeField HUmu(_Umu._grid);
|
|
|
|
HUmu = _Umu * (-0.5);
|
|
|
|
Impl::DoubleStore(GaugeGrid(), Umu, HUmu);
|
|
|
|
pickCheckerboard(Even, UmuEven, Umu);
|
|
|
|
pickCheckerboard(Odd, UmuOdd, Umu);
|
|
|
|
}
|
2015-07-26 02:54:38 +01:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
/////////////////////////////
|
|
|
|
// Implement the interface
|
|
|
|
/////////////////////////////
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
RealD WilsonFermion<Impl>::M(const FermionField &in, FermionField &out) {
|
|
|
|
out.checkerboard = in.checkerboard;
|
|
|
|
Dhop(in, out, DaggerNo);
|
|
|
|
return axpy_norm(out, 4 + mass, in, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
RealD WilsonFermion<Impl>::Mdag(const FermionField &in, FermionField &out) {
|
|
|
|
out.checkerboard = in.checkerboard;
|
|
|
|
Dhop(in, out, DaggerYes);
|
|
|
|
return axpy_norm(out, 4 + mass, in, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void WilsonFermion<Impl>::Meooe(const FermionField &in, FermionField &out) {
|
|
|
|
if (in.checkerboard == Odd) {
|
|
|
|
DhopEO(in, out, DaggerNo);
|
|
|
|
} else {
|
|
|
|
DhopOE(in, out, DaggerNo);
|
2015-08-10 20:47:44 +01:00
|
|
|
}
|
2016-07-06 11:41:27 +01:00
|
|
|
}
|
2016-10-19 18:35:18 +01:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
template <class Impl>
|
|
|
|
void WilsonFermion<Impl>::MeooeDag(const FermionField &in, FermionField &out) {
|
|
|
|
if (in.checkerboard == Odd) {
|
|
|
|
DhopEO(in, out, DaggerYes);
|
|
|
|
} else {
|
|
|
|
DhopOE(in, out, DaggerYes);
|
2015-08-10 20:47:44 +01:00
|
|
|
}
|
2016-07-06 11:41:27 +01:00
|
|
|
}
|
2015-08-10 20:47:44 +01:00
|
|
|
|
2017-02-22 18:09:33 +00:00
|
|
|
template <class Impl>
|
|
|
|
void WilsonFermion<Impl>::Mooee(const FermionField &in, FermionField &out) {
|
|
|
|
out.checkerboard = in.checkerboard;
|
|
|
|
typename FermionField::scalar_type scal(4.0 + mass);
|
|
|
|
out = scal * in;
|
|
|
|
}
|
2016-07-06 11:41:27 +01:00
|
|
|
|
2017-02-22 18:09:33 +00:00
|
|
|
template <class Impl>
|
|
|
|
void WilsonFermion<Impl>::MooeeDag(const FermionField &in, FermionField &out) {
|
|
|
|
out.checkerboard = in.checkerboard;
|
|
|
|
Mooee(in, out);
|
|
|
|
}
|
2016-07-06 11:41:27 +01:00
|
|
|
|
2017-02-22 18:09:33 +00:00
|
|
|
template<class Impl>
|
|
|
|
void WilsonFermion<Impl>::MooeeInv(const FermionField &in, FermionField &out) {
|
|
|
|
out.checkerboard = in.checkerboard;
|
|
|
|
out = (1.0/(4.0+mass))*in;
|
|
|
|
}
|
2015-08-10 20:47:44 +01:00
|
|
|
|
2017-02-22 18:09:33 +00:00
|
|
|
template<class Impl>
|
|
|
|
void WilsonFermion<Impl>::MooeeInvDag(const FermionField &in, FermionField &out) {
|
|
|
|
out.checkerboard = in.checkerboard;
|
|
|
|
MooeeInv(in,out);
|
|
|
|
}
|
|
|
|
template<class Impl>
|
|
|
|
void WilsonFermion<Impl>::MomentumSpacePropagator(FermionField &out, const FermionField &in,RealD _m)
|
|
|
|
{
|
|
|
|
typedef typename FermionField::vector_type vector_type;
|
|
|
|
typedef typename FermionField::scalar_type ScalComplex;
|
|
|
|
typedef Lattice<iSinglet<vector_type> > LatComplex;
|
|
|
|
|
|
|
|
// what type LatticeComplex
|
|
|
|
conformable(_grid,out._grid);
|
|
|
|
|
2017-02-23 00:25:29 +00:00
|
|
|
Gamma::Algebra Gmu [] = {
|
|
|
|
Gamma::Algebra::GammaX,
|
|
|
|
Gamma::Algebra::GammaY,
|
|
|
|
Gamma::Algebra::GammaZ,
|
|
|
|
Gamma::Algebra::GammaT
|
2017-02-22 18:09:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<int> latt_size = _grid->_fdimensions;
|
|
|
|
|
|
|
|
FermionField num (_grid); num = zero;
|
|
|
|
LatComplex wilson(_grid); wilson= zero;
|
|
|
|
LatComplex one (_grid); one = ScalComplex(1.0,0.0);
|
|
|
|
|
|
|
|
LatComplex denom(_grid); denom= zero;
|
|
|
|
LatComplex kmu(_grid);
|
|
|
|
ScalComplex ci(0.0,1.0);
|
|
|
|
// momphase = n * 2pi / L
|
|
|
|
for(int mu=0;mu<Nd;mu++) {
|
|
|
|
|
|
|
|
LatticeCoordinate(kmu,mu);
|
|
|
|
|
|
|
|
RealD TwoPiL = M_PI * 2.0/ latt_size[mu];
|
|
|
|
|
|
|
|
kmu = TwoPiL * kmu;
|
|
|
|
|
|
|
|
wilson = wilson + 2.0*sin(kmu*0.5)*sin(kmu*0.5); // Wilson term
|
|
|
|
|
|
|
|
num = num - sin(kmu)*ci*(Gamma(Gmu[mu])*in); // derivative term
|
|
|
|
|
|
|
|
denom=denom + sin(kmu)*sin(kmu);
|
2016-08-31 00:26:36 +01:00
|
|
|
}
|
2017-02-22 18:09:33 +00:00
|
|
|
|
|
|
|
wilson = wilson + _m; // 2 sin^2 k/2 + m
|
|
|
|
|
|
|
|
num = num + wilson*in; // -i gmu sin k + 2 sin^2 k/2 + m
|
|
|
|
|
|
|
|
denom= denom+wilson*wilson; // sin^2 k + (2 sin^2 k/2 + m)^2
|
|
|
|
|
|
|
|
denom= one/denom;
|
|
|
|
|
|
|
|
out = num*denom; // [ -i gmu sin k + 2 sin^2 k/2 + m] / [ sin^2 k + (2 sin^2 k/2 + m)^2 ]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-08-14 00:01:04 +01:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
///////////////////////////////////
|
|
|
|
// Internal
|
|
|
|
///////////////////////////////////
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void WilsonFermion<Impl>::DerivInternal(StencilImpl &st, DoubledGaugeField &U,
|
|
|
|
GaugeField &mat, const FermionField &A,
|
|
|
|
const FermionField &B, int dag) {
|
|
|
|
assert((dag == DaggerNo) || (dag == DaggerYes));
|
|
|
|
|
|
|
|
Compressor compressor(dag);
|
|
|
|
|
|
|
|
FermionField Btilde(B._grid);
|
|
|
|
FermionField Atilde(B._grid);
|
|
|
|
Atilde = A;
|
|
|
|
|
|
|
|
st.HaloExchange(B, compressor);
|
|
|
|
|
|
|
|
for (int mu = 0; mu < Nd; mu++) {
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// Flip gamma (1+g)<->(1-g) if dag
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
int gamma = mu;
|
|
|
|
if (!dag) gamma += Nd;
|
|
|
|
|
|
|
|
////////////////////////
|
|
|
|
// Call the single hop
|
|
|
|
////////////////////////
|
2017-02-21 10:24:27 +00:00
|
|
|
parallel_for (int sss = 0; sss < B._grid->oSites(); sss++) {
|
2017-02-22 18:09:33 +00:00
|
|
|
Kernels::DhopDir(st, U, st.CommBuf(), sss, sss, B, Btilde, mu, gamma);
|
2015-08-10 20:47:44 +01:00
|
|
|
}
|
2015-07-26 02:54:38 +01:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// spin trace outer product
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
Impl::InsertForce4D(mat, Btilde, Atilde, mu);
|
2015-08-10 20:47:44 +01:00
|
|
|
}
|
2016-07-06 11:41:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void WilsonFermion<Impl>::DhopDeriv(GaugeField &mat, const FermionField &U,
|
|
|
|
const FermionField &V, int dag) {
|
|
|
|
conformable(U._grid, _grid);
|
|
|
|
conformable(U._grid, V._grid);
|
|
|
|
conformable(U._grid, mat._grid);
|
|
|
|
|
|
|
|
mat.checkerboard = U.checkerboard;
|
|
|
|
|
|
|
|
DerivInternal(Stencil, Umu, mat, U, V, dag);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void WilsonFermion<Impl>::DhopDerivOE(GaugeField &mat, const FermionField &U,
|
|
|
|
const FermionField &V, int dag) {
|
|
|
|
conformable(U._grid, _cbgrid);
|
|
|
|
conformable(U._grid, V._grid);
|
|
|
|
conformable(U._grid, mat._grid);
|
|
|
|
|
|
|
|
assert(V.checkerboard == Even);
|
|
|
|
assert(U.checkerboard == Odd);
|
|
|
|
mat.checkerboard = Odd;
|
|
|
|
|
|
|
|
DerivInternal(StencilEven, UmuOdd, mat, U, V, dag);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void WilsonFermion<Impl>::DhopDerivEO(GaugeField &mat, const FermionField &U,
|
|
|
|
const FermionField &V, int dag) {
|
|
|
|
conformable(U._grid, _cbgrid);
|
|
|
|
conformable(U._grid, V._grid);
|
|
|
|
conformable(U._grid, mat._grid);
|
|
|
|
|
|
|
|
assert(V.checkerboard == Odd);
|
|
|
|
assert(U.checkerboard == Even);
|
|
|
|
mat.checkerboard = Even;
|
|
|
|
|
|
|
|
DerivInternal(StencilOdd, UmuEven, mat, U, V, dag);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
2017-02-22 18:09:33 +00:00
|
|
|
void WilsonFermion<Impl>::Dhop(const FermionField &in, FermionField &out, int dag) {
|
2016-07-06 11:41:27 +01:00
|
|
|
conformable(in._grid, _grid); // verifies full grid
|
|
|
|
conformable(in._grid, out._grid);
|
|
|
|
|
|
|
|
out.checkerboard = in.checkerboard;
|
|
|
|
|
|
|
|
DhopInternal(Stencil, Lebesgue, Umu, in, out, dag);
|
|
|
|
}
|
2016-01-03 01:38:11 +00:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
template <class Impl>
|
2017-02-22 18:09:33 +00:00
|
|
|
void WilsonFermion<Impl>::DhopOE(const FermionField &in, FermionField &out, int dag) {
|
2016-07-06 11:41:27 +01:00
|
|
|
conformable(in._grid, _cbgrid); // verifies half grid
|
|
|
|
conformable(in._grid, out._grid); // drops the cb check
|
2015-07-26 02:54:38 +01:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
assert(in.checkerboard == Even);
|
|
|
|
out.checkerboard = Odd;
|
2015-12-17 22:34:28 +00:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
DhopInternal(StencilEven, LebesgueEvenOdd, UmuOdd, in, out, dag);
|
|
|
|
}
|
2015-05-31 15:09:02 +01:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
template <class Impl>
|
2017-02-22 18:09:33 +00:00
|
|
|
void WilsonFermion<Impl>::DhopEO(const FermionField &in, FermionField &out,int dag) {
|
2016-07-06 11:41:27 +01:00
|
|
|
conformable(in._grid, _cbgrid); // verifies half grid
|
|
|
|
conformable(in._grid, out._grid); // drops the cb check
|
2015-05-31 15:09:02 +01:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
assert(in.checkerboard == Odd);
|
|
|
|
out.checkerboard = Even;
|
|
|
|
|
|
|
|
DhopInternal(StencilOdd, LebesgueEvenOdd, UmuEven, in, out, dag);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
2017-02-22 18:09:33 +00:00
|
|
|
void WilsonFermion<Impl>::Mdir(const FermionField &in, FermionField &out, int dir, int disp) {
|
2016-07-06 11:41:27 +01:00
|
|
|
DhopDir(in, out, dir, disp);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
2017-02-22 18:09:33 +00:00
|
|
|
void WilsonFermion<Impl>::DhopDir(const FermionField &in, FermionField &out, int dir, int disp) {
|
2016-07-06 11:41:27 +01:00
|
|
|
int skip = (disp == 1) ? 0 : 1;
|
|
|
|
int dirdisp = dir + skip * 4;
|
|
|
|
int gamma = dir + (1 - skip) * 4;
|
|
|
|
|
|
|
|
DhopDirDisp(in, out, dirdisp, gamma, DaggerNo);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class Impl>
|
2017-02-22 18:09:33 +00:00
|
|
|
void WilsonFermion<Impl>::DhopDirDisp(const FermionField &in, FermionField &out,int dirdisp, int gamma, int dag) {
|
2016-07-06 11:41:27 +01:00
|
|
|
Compressor compressor(dag);
|
|
|
|
|
|
|
|
Stencil.HaloExchange(in, compressor);
|
|
|
|
|
2017-02-21 10:24:27 +00:00
|
|
|
parallel_for (int sss = 0; sss < in._grid->oSites(); sss++) {
|
2017-02-07 06:37:10 +00:00
|
|
|
Kernels::DhopDir(Stencil, Umu, Stencil.CommBuf(), sss, sss, in, out, dirdisp, gamma);
|
2015-08-10 20:47:44 +01:00
|
|
|
}
|
2016-07-06 11:41:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void WilsonFermion<Impl>::DhopInternal(StencilImpl &st, LebesgueOrder &lo,
|
|
|
|
DoubledGaugeField &U,
|
|
|
|
const FermionField &in,
|
|
|
|
FermionField &out, int dag) {
|
|
|
|
assert((dag == DaggerNo) || (dag == DaggerYes));
|
|
|
|
|
|
|
|
Compressor compressor(dag);
|
|
|
|
st.HaloExchange(in, compressor);
|
|
|
|
|
|
|
|
if (dag == DaggerYes) {
|
2017-02-21 10:24:27 +00:00
|
|
|
parallel_for (int sss = 0; sss < in._grid->oSites(); sss++) {
|
2017-02-07 06:37:10 +00:00
|
|
|
Kernels::DhopSiteDag(st, lo, U, st.CommBuf(), sss, sss, 1, 1, in, out);
|
2015-05-31 15:09:02 +01:00
|
|
|
}
|
2016-07-06 11:41:27 +01:00
|
|
|
} else {
|
2017-02-21 10:24:27 +00:00
|
|
|
parallel_for (int sss = 0; sss < in._grid->oSites(); sss++) {
|
2017-02-07 06:37:10 +00:00
|
|
|
Kernels::DhopSite(st, lo, U, st.CommBuf(), sss, sss, 1, 1, in, out);
|
2016-07-06 11:41:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-05-31 15:09:02 +01:00
|
|
|
|
2016-07-06 11:41:27 +01:00
|
|
|
FermOpTemplateInstantiate(WilsonFermion);
|
2016-07-18 16:36:28 +01:00
|
|
|
AdjointFermOpTemplateInstantiate(WilsonFermion);
|
2016-09-22 14:17:37 +01:00
|
|
|
TwoIndexFermOpTemplateInstantiate(WilsonFermion);
|
2016-07-06 11:41:27 +01:00
|
|
|
GparityFermOpTemplateInstantiate(WilsonFermion);
|
|
|
|
}
|
|
|
|
}
|