-
Notifications
You must be signed in to change notification settings - Fork 0
/
mom_gaus_quark_smearing.cc
166 lines (136 loc) · 4.52 KB
/
mom_gaus_quark_smearing.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*! \file
* \brief Gaussian smearing of color std::vector
*/
#include "chromabase.h"
#include "meas/smear/quark_smearing_factory.h"
#include "mom_gaus_quark_smearing.h"
#include "meas/smear/gaus_smear.h"
namespace Chroma
{
// Read parameters
void read(XMLReader& xml, const std::string& path, MomGausQuarkSmearingEnv::Params& param)
{
MomGausQuarkSmearingEnv::Params tmp(xml, path);
param = tmp;
}
//! Parameters for running code
void write(XMLWriter& xml, const std::string& path, const MomGausQuarkSmearingEnv::Params& param)
{
param.writeXML(xml, path);
}
//! Hooks to register the class
namespace MomGausQuarkSmearingEnv
{
namespace
{
//! Callback function
QuarkSmearing<LatticePropagator>* createProp(XMLReader& xml_in,
const std::string& path)
{
return new QuarkSmear<LatticePropagator>(Params(xml_in, path));
}
//! Callback function
QuarkSmearing<LatticeStaggeredPropagator>* createStagProp(XMLReader& xml_in,
const std::string& path)
{
return new QuarkSmear<LatticeStaggeredPropagator>(Params(xml_in, path));
}
//! Callback function
QuarkSmearing<LatticeFermion>* createFerm(XMLReader& xml_in,
const std::string& path)
{
return new QuarkSmear<LatticeFermion>(Params(xml_in, path));
}
//! Callback function
QuarkSmearing<LatticeColorVector>* createColorVec(XMLReader& xml_in,
const std::string& path)
{
return new QuarkSmear<LatticeColorVector>(Params(xml_in, path));
}
//! Local registration flag
bool registered = false;
//! Name to be used
const std::string name = "MOM_GAUGE_INV_GAUSSIAN";
}
//! Return the name
std::string getName() {return name;}
//! Register all the factories
bool registerAll()
{
bool success = true;
if (! registered)
{
success &= Chroma::ThePropSmearingFactory::Instance().registerObject(name, createProp);
success &= Chroma::TheStagPropSmearingFactory::Instance().registerObject(name, createStagProp);
success &= Chroma::TheFermSmearingFactory::Instance().registerObject(name, createFerm);
success &= Chroma::TheColorVecSmearingFactory::Instance().registerObject(name, createColorVec);
registered = true;
}
return success;
}
//! Parameters for running code
Params::Params(XMLReader& xml, const std::string& path)
{
XMLReader paramtop(xml, path);
read(paramtop, "wvf_param", wvf_param);
read(paramtop,"MOM",mom);
read(paramtop, "wvfIntPar", wvfIntPar);
read(paramtop, "no_smear_dir", no_smear_dir);
}
//! Parameters for running code
void Params::writeXML(XMLWriter& xml, const std::string& path) const
{
push(xml, path);
write(xml, "wvf_kind", MomGausQuarkSmearingEnv::getName());
write(xml, "wvf_param", wvf_param);
write(xml,"MOM",mom);
write(xml, "wvfIntPar", wvfIntPar);
write(xml, "no_smear_dir", no_smear_dir);
pop(xml);
}
//! Smear the quark
template<>
void
QuarkSmear<LatticePropagator>::operator()(LatticePropagator& quark,
const multi1d<LatticeColorMatrix>& u) const
{
multi1d<LatticeColorMatrix> u_smr(Nd);
for(int mu=0; mu<Nd; mu++)
{
Real K= params.mom[mu]*twopi/Layout::lattSize()[mu];
QDPIO::cout<< mu << ":"<< cos(K)<<"+"<<-sin(K)<<"I"<<std::endl;
if(mu<Nd-1){
u_smr[mu]=u[mu]*cmplx(cos(K),-sin(K));
}
else if(mu==Nd-1){
u_smr[mu]=u[mu];
}
}
gausSmear(u_smr, quark, params.wvf_param, params.wvfIntPar, params.no_smear_dir);
}
//! Smear the quark
template<>
void
QuarkSmear<LatticeStaggeredPropagator>::operator()(LatticeStaggeredPropagator& quark,
const multi1d<LatticeColorMatrix>& u) const
{
gausSmear(u, quark, params.wvf_param, params.wvfIntPar, params.no_smear_dir);
}
//! Smear the quark
template<>
void
QuarkSmear<LatticeFermion>::operator()(LatticeFermion& quark,
const multi1d<LatticeColorMatrix>& u) const
{
gausSmear(u, quark, params.wvf_param, params.wvfIntPar, params.no_smear_dir);
}
//! Smear the color-std::vector
template<>
void
QuarkSmear<LatticeColorVector>::operator()(LatticeColorVector& quark,
const multi1d<LatticeColorMatrix>& u) const
{
gausSmear(u, quark, params.wvf_param, params.wvfIntPar, params.no_smear_dir);
}
} // end namespace
} // end namespace Chroma