Grid 0.7.0
DomainWallFermion.h
Go to the documentation of this file.
1/*************************************************************************************
2
3 Grid physics library, www.github.com/paboyle/Grid
4
5 Source file: ./lib/qcd/action/fermion/DomainWallFermion.h
6
7 Copyright (C) 2015
8
9Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
10Author: Peter Boyle <paboyle@ph.ed.ac.uk>
11Author: Vera Guelpers <V.M.Guelpers@soton.ac.uk>
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License along
24 with this program; if not, write to the Free Software Foundation, Inc.,
25 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26
27 See the full license in the file "LICENSE" in the top level distribution directory
28*************************************************************************************/
29/* END LEGAL */
30#ifndef GRID_QCD_DOMAIN_WALL_FERMION_H
31#define GRID_QCD_DOMAIN_WALL_FERMION_H
32
34
36
37template<class Impl>
39{
40public:
42public:
43
44 void FreePropagator(const FermionField &in,FermionField &out,RealD mass,std::vector<Complex> boundary, std::vector<double> twist, bool fiveD) {
45 FermionField in_k(in.Grid());
46 FermionField prop_k(in.Grid());
47
48 FFT theFFT((GridCartesian *) in.Grid());
49
50 //phase for boundary condition
51 ComplexField coor(in.Grid());
52 ComplexField ph(in.Grid()); ph = Zero();
53 FermionField in_buf(in.Grid()); in_buf = Zero();
54 typedef typename Simd::scalar_type Scalar;
55 Scalar ci(0.0,1.0);
56 assert(twist.size() == Nd);//check that twist is Nd
57 assert(boundary.size() == Nd);//check that boundary conditions is Nd
58 int shift = 0;
59 if(fiveD) shift = 1;
60 for(unsigned int nu = 0; nu < Nd; nu++)
61 {
62 // Shift coordinate lattice index by 1 to account for 5th dimension.
63 LatticeCoordinate(coor, nu + shift);
64 double boundary_phase = ::acos(real(boundary[nu]));
65 ph = ph + boundary_phase*coor*((1./(in.Grid()->_fdimensions[nu+shift])));
66 //momenta for propagator shifted by twist+boundary
67 twist[nu] = twist[nu] + boundary_phase/((2.0*M_PI));
68 }
69 in_buf = exp(ci*ph*(-1.0))*in;
70
71 if(fiveD){//FFT only on temporal and spatial dimensions
72 std::vector<int> mask(Nd+1,1); mask[0] = 0;
73 theFFT.FFT_dim_mask(in_k,in_buf,mask,FFT::forward);
74 this->MomentumSpacePropagatorHt_5d(prop_k,in_k,mass,twist);
75 theFFT.FFT_dim_mask(out,prop_k,mask,FFT::backward);
76 }
77 else{
78 theFFT.FFT_all_dim(in_k,in,FFT::forward);
79 this->MomentumSpacePropagatorHt(prop_k,in_k,mass,twist);
80 theFFT.FFT_all_dim(out,prop_k,FFT::backward);
81 }
82 //phase for boundary condition
83 out = out * exp(ci*ph);
84 };
85
86 virtual void FreePropagator(const FermionField &in,FermionField &out,RealD mass,std::vector<Complex> boundary,std::vector<double> twist) {
87 bool fiveD = true; //5d propagator by default
88 FreePropagator(in,out,mass,boundary,twist,fiveD);
89 };
90
91 virtual void FreePropagator(const FermionField &in,FermionField &out,RealD mass, bool fiveD) {
92 std::vector<double> twist(Nd,0.0); //default: periodic boundarys in all directions
93 std::vector<Complex> boundary;
94 for(int i=0;i<Nd;i++) boundary.push_back(1);//default: periodic boundary conditions
95 FreePropagator(in,out,mass,boundary,twist,fiveD);
96 };
97
98 virtual void FreePropagator(const FermionField &in,FermionField &out,RealD mass) {
99 bool fiveD = true; //5d propagator by default
100 std::vector<double> twist(Nd,0.0); //default: twist angle 0
101 std::vector<Complex> boundary;
102 for(int i=0;i<Nd;i++) boundary.push_back(1); //default: periodic boundary conditions
103 FreePropagator(in,out,mass,boundary,twist,fiveD);
104 };
105
106 virtual void Instantiatable(void) {};
107 // Constructors
108 DomainWallFermion(GaugeField &_Umu,
109 GridCartesian &FiveDimGrid,
110 GridRedBlackCartesian &FiveDimRedBlackGrid,
111 GridCartesian &FourDimGrid,
112 GridRedBlackCartesian &FourDimRedBlackGrid,
113 RealD _mass,RealD _M5,const ImplParams &p= ImplParams()) :
114
115
116 CayleyFermion5D<Impl>(_Umu,
117 FiveDimGrid,
118 FiveDimRedBlackGrid,
119 FourDimGrid,
120 FourDimRedBlackGrid,_mass,_M5,p)
121
122 {
123 RealD eps = 1.0;
124
125 Approx::zolotarev_data *zdata = Approx::higham(eps,this->Ls);// eps is ignored for higham
126 assert(zdata->n==this->Ls);
127
128 // std::cout<<GridLogMessage << "DomainWallFermion with Ls="<<this->Ls<<std::endl;
129 // Call base setter
130 this->SetCoefficientsTanh(zdata,1.0,0.0);
131
132 Approx::zolotarev_free(zdata);
133 }
134
135};
136
138
139#endif
accelerator_inline Grid_simd< S, V > acos(const Grid_simd< S, V > &r)
accelerator_inline Grid_simd< S, V > exp(const Grid_simd< S, V > &r)
void LatticeCoordinate(Lattice< iobj > &l, int mu)
Lattice< vobj > real(const Lattice< vobj > &lhs)
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
static constexpr int Nd
Definition QCD.h:52
double RealD
Definition Simd.h:61
#define M_PI
Definition Zolotarev.cc:41
CayleyFermion5D(GaugeField &_Umu, GridCartesian &FiveDimGrid, GridRedBlackCartesian &FiveDimRedBlackGrid, GridCartesian &FourDimGrid, GridRedBlackCartesian &FourDimRedBlackGrid, RealD _mass, RealD _M5, const ImplParams &p=ImplParams())
virtual void SetCoefficientsTanh(Approx::zolotarev_data *zdata, RealD b, RealD c)
virtual void FreePropagator(const FermionField &in, FermionField &out, RealD mass)
void FreePropagator(const FermionField &in, FermionField &out, RealD mass, std::vector< Complex > boundary, std::vector< double > twist, bool fiveD)
virtual void Instantiatable(void)
virtual void FreePropagator(const FermionField &in, FermionField &out, RealD mass, std::vector< Complex > boundary, std::vector< double > twist)
virtual void FreePropagator(const FermionField &in, FermionField &out, RealD mass, bool fiveD)
DomainWallFermion(GaugeField &_Umu, GridCartesian &FiveDimGrid, GridRedBlackCartesian &FiveDimRedBlackGrid, GridCartesian &FourDimGrid, GridRedBlackCartesian &FourDimRedBlackGrid, RealD _mass, RealD _M5, const ImplParams &p=ImplParams())
Definition FFT.h:105
static const int backward
Definition FFT.h:123
void FFT_dim_mask(Lattice< vobj > &result, const Lattice< vobj > &source, Coordinate mask, int sign)
Definition FFT.h:147
static const int forward
Definition FFT.h:122
void FFT_all_dim(Lattice< vobj > &result, const Lattice< vobj > &source, int sign)
Definition FFT.h:162
void MomentumSpacePropagatorHt(FermionField &out, const FermionField &in, RealD mass, std::vector< double > twist)
void MomentumSpacePropagatorHt_5d(FermionField &out, const FermionField &in, RealD mass, std::vector< double > twist)
Definition Simd.h:194