Grid 0.7.0
DWFSlow.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/action/fermion/DWFSlow.h
6
7Copyright (C) 2022
8
9Author: Peter Boyle <pboyle@bnl.gov>
10
11This program is free software; you can redistribute it and/or modify
12it under the terms of the GNU General Public License as published by
13the Free Software Foundation; either version 2 of the License, or
14(at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License along
22with this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25See the full license in the file "LICENSE" in the top level distribution
26directory
27*************************************************************************************/
28 /* END LEGAL */
29#pragma once
30
32
33template <class Impl>
34class DWFSlowFermion : public FermionOperator<Impl>
35{
36public:
38
40 // Implement the abstract base
42 GridBase *GaugeGrid(void) { return _grid4; }
44 GridBase *FermionGrid(void) { return _grid; }
46
47 FermionField _tmp;
48 FermionField &tmp(void) { return _tmp; }
49
51 // override multiply; cut number routines if pass dagger argument
52 // and also make interface more uniformly consistent
54 virtual void M(const FermionField &in, FermionField &out)
55 {
56 FermionField tmp(_grid);
57 out = (5.0 - M5) * in;
58 Dhop(in,tmp,DaggerNo);
59 out = out + tmp;
60 }
61 virtual void Mdag(const FermionField &in, FermionField &out)
62 {
63 FermionField tmp(_grid);
64 out = (5.0 - M5) * in;
65 Dhop(in,tmp,DaggerYes);
66 out = out + tmp;
67 };
68
70 // half checkerboard operations 5D redblack so just site identiy
72 void Meooe(const FermionField &in, FermionField &out)
73 {
74 if ( in.Checkerboard() == Odd ) {
75 this->DhopEO(in,out,DaggerNo);
76 } else {
77 this->DhopOE(in,out,DaggerNo);
78 }
79 }
80 void MeooeDag(const FermionField &in, FermionField &out)
81 {
82 if ( in.Checkerboard() == Odd ) {
83 this->DhopEO(in,out,DaggerYes);
84 } else {
85 this->DhopOE(in,out,DaggerYes);
86 }
87 };
88
89 // allow override for twisted mass and clover
90 virtual void Mooee(const FermionField &in, FermionField &out)
91 {
92 out = (5.0 - M5) * in;
93 }
94 virtual void MooeeDag(const FermionField &in, FermionField &out)
95 {
96 out = (5.0 - M5) * in;
97 }
98 virtual void MooeeInv(const FermionField &in, FermionField &out)
99 {
100 out = (1.0/(5.0 - M5)) * in;
101 };
102 virtual void MooeeInvDag(const FermionField &in, FermionField &out)
103 {
104 out = (1.0/(5.0 - M5)) * in;
105 };
106
107 virtual void MomentumSpacePropagator(FermionField &out,const FermionField &in,RealD _mass,std::vector<double> twist) {} ;
108
110 // Derivative interface
112 // Interface calls an internal routine
113 void DhopDeriv(GaugeField &mat,const FermionField &U,const FermionField &V,int dag) { assert(0);};
114 void DhopDerivOE(GaugeField &mat,const FermionField &U,const FermionField &V,int dag){ assert(0);};
115 void DhopDerivEO(GaugeField &mat,const FermionField &U,const FermionField &V,int dag){ assert(0);};
116
118 // non-hermitian hopping term; half cb or both
120 void Dhop(const FermionField &in, FermionField &out, int dag)
121 {
122 FermionField tmp(in.Grid());
123 Dhop5(in,out,MassField,MassField,dag );
124 for(int mu=0;mu<4;mu++){
125 DhopDirU(in,Umu[mu],Umu[mu],tmp,mu,dag ); out = out + tmp;
126 }
127 };
128 void DhopOE(const FermionField &in, FermionField &out, int dag)
129 {
130 FermionField tmp(in.Grid());
131 assert(in.Checkerboard()==Even);
132 Dhop5(in,out,MassFieldOdd,MassFieldEven,dag);
133 for(int mu=0;mu<4;mu++){
134 DhopDirU(in,UmuOdd[mu],UmuEven[mu],tmp,mu,dag ); out = out + tmp;
135 }
136 };
137 void DhopEO(const FermionField &in, FermionField &out, int dag)
138 {
139 FermionField tmp(in.Grid());
140 assert(in.Checkerboard()==Odd);
141 Dhop5(in,out, MassFieldEven,MassFieldOdd ,dag );
142 for(int mu=0;mu<4;mu++){
143 DhopDirU(in,UmuEven[mu],UmuOdd[mu],tmp,mu,dag ); out = out + tmp;
144 }
145 };
146
148 // Multigrid assistance; force term uses too
150 void Mdir(const FermionField &in, FermionField &out, int dir, int disp){ assert(0);};
151 void MdirAll(const FermionField &in, std::vector<FermionField> &out) { assert(0);};
152 void DhopDir(const FermionField &in, FermionField &out, int dir, int disp) { assert(0);};
153 void DhopDirAll(const FermionField &in, std::vector<FermionField> &out) { assert(0);};
154 void DhopDirCalc(const FermionField &in, FermionField &out, int dirdisp,int gamma, int dag) { assert(0);};
155
156 void DhopDirU(const FermionField &in, const GaugeLinkField &U5e, const GaugeLinkField &U5o, FermionField &out, int mu, int dag)
157 {
158 RealD sgn= 1.0;
159 if (dag ) sgn=-1.0;
160
161 Gamma::Algebra Gmu [] = {
162 Gamma::Algebra::GammaX,
163 Gamma::Algebra::GammaY,
164 Gamma::Algebra::GammaZ,
165 Gamma::Algebra::GammaT
166 };
167
168 // mass is 1,1,1,1,-m has to multiply the round the world term
169 FermionField tmp (in.Grid());
170 tmp = U5e * Cshift(in,mu+1,1);
171 out = tmp - Gamma(Gmu[mu])*tmp*sgn;
172
173 tmp = Cshift(adj(U5o)*in,mu+1,-1);
174 out = out + tmp + Gamma(Gmu[mu])*tmp*sgn;
175
176 out = -0.5*out;
177 };
178
179 void Dhop5(const FermionField &in, FermionField &out, ComplexField &massE, ComplexField &massO, int dag)
180 {
181 // Mass term.... must multiple the round world with mass = 1,1,1,1, -m
182 RealD sgn= 1.0;
183 if (dag ) sgn=-1.0;
184
185 Gamma G5(Gamma::Algebra::Gamma5);
186
187 FermionField tmp (in.Grid());
188 tmp = massE*Cshift(in,0,1);
189 out = tmp - G5*tmp*sgn;
190
191 tmp = Cshift(massO*in,0,-1);
192 out = out + tmp + G5*tmp*sgn;
193 out = -0.5*out;
194 };
195
196 // Constructor
197 DWFSlowFermion(GaugeField &_Umu, GridCartesian &Fgrid,
198 GridRedBlackCartesian &Hgrid, RealD _mass, RealD _M5)
199 :
200 _grid(&Fgrid),
201 _cbgrid(&Hgrid),
202 _grid4(_Umu.Grid()),
203 Umu(Nd,&Fgrid),
204 UmuEven(Nd,&Hgrid),
205 UmuOdd(Nd,&Hgrid),
206 MassField(&Fgrid),
207 MassFieldEven(&Hgrid),
208 MassFieldOdd(&Hgrid),
209 M5(_M5),
210 mass(_mass),
211 _tmp(&Hgrid)
212 {
213 Ls=Fgrid._fdimensions[0];
214 ImportGauge(_Umu);
215
216 typedef typename FermionField::scalar_type scalar;
217
218 Lattice<iScalar<vInteger> > coor(&Fgrid);
219 LatticeCoordinate(coor, 0); // Scoor
220 ComplexField one(&Fgrid);
221 MassField =scalar(-mass);
222 one =scalar(1.0);
223 MassField =where(coor==Integer(Ls-1),MassField,one);
224 for(int mu=0;mu<Nd;mu++){
226 pickCheckerboard(Odd ,UmuOdd[mu],Umu[mu]);
227 }
230
231 }
232
233 // DoubleStore impl dependent
234 void ImportGauge(const GaugeField &_Umu4)
235 {
236 GaugeLinkField U4(_grid4);
237 for(int mu=0;mu<Nd;mu++){
238 U4 = PeekIndex<LorentzIndex>(_Umu4, mu);
239 for(int s=0;s<this->Ls;s++){
240 InsertSlice(U4,Umu[mu],s,0);
241 }
242 }
243 }
244
246 // Data members require to support the functionality
248
249public:
250 virtual RealD Mass(void) { return mass; }
251 virtual int isTrivialEE(void) { return 1; };
254 int Ls;
255
260
261 // Copy of the gauge field , with even and odd subsets
262 std::vector<GaugeLinkField> Umu;
263 std::vector<GaugeLinkField> UmuEven;
264 std::vector<GaugeLinkField> UmuOdd;
265 ComplexField MassField;
266 ComplexField MassFieldEven;
267 ComplexField MassFieldOdd;
268
270 // Conserved current utilities
272 void ContractConservedCurrent(PropagatorField &q_in_1,
273 PropagatorField &q_in_2,
274 PropagatorField &q_out,
275 PropagatorField &phys_src,
276 Current curr_type,
277 unsigned int mu){}
278 void SeqConservedCurrent(PropagatorField &q_in,
279 PropagatorField &q_out,
280 PropagatorField &phys_src,
281 Current curr_type,
282 unsigned int mu,
283 unsigned int tmin,
284 unsigned int tmax,
285 ComplexField &lattice_cmplx){}
286};
287
290
#define one
Definition BGQQPX.h:108
static const int Even
static const int Odd
auto Cshift(const Expression &expr, int dim, int shift) -> decltype(closure(expr))
Definition Cshift.h:55
DWFSlowFermion< WilsonImplF > DWFSlowFermionF
Definition DWFSlow.h:288
DWFSlowFermion< WilsonImplD > DWFSlowFermionD
Definition DWFSlow.h:289
void LatticeCoordinate(Lattice< iobj > &l, int mu)
auto PeekIndex(const Lattice< vobj > &lhs, int i) -> Lattice< decltype(peekIndex< Index >(vobj(), i))>
Lattice< vobj > adj(const Lattice< vobj > &lhs)
void InsertSlice(const Lattice< vobj > &lowDim, Lattice< vobj > &higherDim, int slice, int orthog)
void pickCheckerboard(int cb, Lattice< vobj > &half, const Lattice< vobj > &full)
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
static constexpr int DaggerYes
Definition QCD.h:70
static constexpr int Nd
Definition QCD.h:52
static constexpr int DaggerNo
Definition QCD.h:69
uint32_t Integer
Definition Simd.h:58
double RealD
Definition Simd.h:61
static INTERNAL_PRECISION U
Definition Zolotarev.cc:230
void DhopDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag)
Definition DWFSlow.h:113
virtual void Mooee(const FermionField &in, FermionField &out)
Definition DWFSlow.h:90
virtual int isTrivialEE(void)
Definition DWFSlow.h:251
INHERIT_IMPL_TYPES(Impl)
virtual RealD Mass(void)
Definition DWFSlow.h:250
void DhopDerivOE(GaugeField &mat, const FermionField &U, const FermionField &V, int dag)
Definition DWFSlow.h:114
std::vector< GaugeLinkField > Umu
Definition DWFSlow.h:262
std::vector< GaugeLinkField > UmuEven
Definition DWFSlow.h:263
GridBase * FermionRedBlackGrid(void)
Definition DWFSlow.h:45
FermionField & tmp(void)
Definition DWFSlow.h:48
void DhopDirCalc(const FermionField &in, FermionField &out, int dirdisp, int gamma, int dag)
Definition DWFSlow.h:154
void SeqConservedCurrent(PropagatorField &q_in, PropagatorField &q_out, PropagatorField &phys_src, Current curr_type, unsigned int mu, unsigned int tmin, unsigned int tmax, ComplexField &lattice_cmplx)
Definition DWFSlow.h:278
void Meooe(const FermionField &in, FermionField &out)
Definition DWFSlow.h:72
void DhopDirU(const FermionField &in, const GaugeLinkField &U5e, const GaugeLinkField &U5o, FermionField &out, int mu, int dag)
Definition DWFSlow.h:156
void Dhop5(const FermionField &in, FermionField &out, ComplexField &massE, ComplexField &massO, int dag)
Definition DWFSlow.h:179
virtual void MomentumSpacePropagator(FermionField &out, const FermionField &in, RealD _mass, std::vector< double > twist)
Definition DWFSlow.h:107
void DhopDir(const FermionField &in, FermionField &out, int dir, int disp)
Definition DWFSlow.h:152
void Mdir(const FermionField &in, FermionField &out, int dir, int disp)
Definition DWFSlow.h:150
void MeooeDag(const FermionField &in, FermionField &out)
Definition DWFSlow.h:80
void ImportGauge(const GaugeField &_Umu4)
Definition DWFSlow.h:234
DWFSlowFermion(GaugeField &_Umu, GridCartesian &Fgrid, GridRedBlackCartesian &Hgrid, RealD _mass, RealD _M5)
Definition DWFSlow.h:197
void ContractConservedCurrent(PropagatorField &q_in_1, PropagatorField &q_in_2, PropagatorField &q_out, PropagatorField &phys_src, Current curr_type, unsigned int mu)
Definition DWFSlow.h:272
virtual void M(const FermionField &in, FermionField &out)
Definition DWFSlow.h:54
void DhopEO(const FermionField &in, FermionField &out, int dag)
Definition DWFSlow.h:137
virtual void MooeeInvDag(const FermionField &in, FermionField &out)
Definition DWFSlow.h:102
GridBase * GaugeGrid(void)
Definition DWFSlow.h:42
GridBase * GaugeRedBlackGrid(void)
Definition DWFSlow.h:43
virtual void Mdag(const FermionField &in, FermionField &out)
Definition DWFSlow.h:61
virtual void MooeeInv(const FermionField &in, FermionField &out)
Definition DWFSlow.h:98
void DhopOE(const FermionField &in, FermionField &out, int dag)
Definition DWFSlow.h:128
void DhopDirAll(const FermionField &in, std::vector< FermionField > &out)
Definition DWFSlow.h:153
GridBase * FermionGrid(void)
Definition DWFSlow.h:44
virtual void MooeeDag(const FermionField &in, FermionField &out)
Definition DWFSlow.h:94
void MdirAll(const FermionField &in, std::vector< FermionField > &out)
Definition DWFSlow.h:151
void DhopDerivEO(GaugeField &mat, const FermionField &U, const FermionField &V, int dag)
Definition DWFSlow.h:115
std::vector< GaugeLinkField > UmuOdd
Definition DWFSlow.h:264
void Dhop(const FermionField &in, FermionField &out, int dag)
Definition DWFSlow.h:120
FermionOperator(const ImplParams &p=ImplParams())
Definition Gamma.h:10
Coordinate _fdimensions