Bridge++  Ver. 1.3.x
fopr_CloverTerm.cpp
Go to the documentation of this file.
1 
14 #include "fopr_CloverTerm.h"
15 
16 #ifdef USE_PARAMETERS_FACTORY
17 #include "parameters_factory.h"
18 #endif
19 
20 using std::string;
21 
22 const std::string Fopr_CloverTerm::class_name = "Fopr_CloverTerm";
23 
24 //====================================================================
25 //- parameter entries
26 namespace {
27  void append_entry(Parameters& param)
28  {
29  param.Register_double("hopping_parameter", 0.0);
30  param.Register_double("clover_coefficient", 0.0);
31  param.Register_int_vector("boundary_condition", std::vector<int>());
32 
33  param.Register_string("verbose_level", "NULL");
34  }
35 
36 
37 #ifdef USE_PARAMETERS_FACTORY
38  bool init_param = ParametersFactory::Register("", append_entry);
39 #endif
40 }
41 //- end
42 
43 //- parameters class
45 //- end
46 
47 //====================================================================
49 {
50  const string str_vlevel = params.get_string("verbose_level");
51 
52  m_vl = vout.set_verbose_level(str_vlevel);
53 
54  //- fetch and check input parameters
55  double kappa, cSW;
56  std::vector<int> bc;
57 
58  int err = 0;
59  err += params.fetch_double("hopping_parameter", kappa);
60  err += params.fetch_double("clover_coefficient", cSW);
61  err += params.fetch_int_vector("boundary_condition", bc);
62 
63  if (err) {
64  vout.crucial(m_vl, "%s: fetch error, input parameter not found.\n", class_name.c_str());
65  exit(EXIT_FAILURE);
66  }
67 
68 
69  set_parameters(kappa, cSW, bc);
70 }
71 
72 
73 //====================================================================
74 void Fopr_CloverTerm::set_parameters(double kappa, double cSW,
75  std::vector<int> bc)
76 {
77  //- print input parameters
78  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
79  vout.general(m_vl, " kappa = %8.4f\n", kappa);
80  vout.general(m_vl, " cSW = %8.4f\n", cSW);
81  for (int mu = 0; mu < m_Ndim; ++mu) {
82  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
83  }
84 
85  //- range check
86  // NB. kappa,cSW == 0 is allowed.
87  assert(bc.size() == m_Ndim);
88 
89  //- store values
90  m_kappa = kappa;
91  m_cSW = cSW;
92 
93  // m_boundary.resize(m_Ndim); // already resized in init.
94  for (int mu = 0; mu < m_Ndim; ++mu) {
95  m_boundary[mu] = bc[mu];
96  }
97 }
98 
99 
100 //====================================================================
102 {
103  m_U = (Field_G *)U;
104  set_csw();
105 }
106 
107 
108 //====================================================================
109 void Fopr_CloverTerm::init(string repr)
110 {
112  m_Ndim = CommonParameters::Ndim();
115  m_NinF = 2 * m_Nc * m_Nd;
116 
117  m_U = 0;
118 
119  m_repr = repr;
120 
121  m_boundary.resize(m_Ndim);
122  m_SG.resize(m_Ndim * m_Ndim);
123 
124  GammaMatrixSet *gmset = GammaMatrixSet::New(m_repr);
125 
126  m_GM5 = gmset->get_GM(gmset->GAMMA5);
127 
128  m_SG[sg_index(0, 1)] = gmset->get_GM(gmset->SIGMA12);
129  m_SG[sg_index(1, 2)] = gmset->get_GM(gmset->SIGMA23);
130  m_SG[sg_index(2, 0)] = gmset->get_GM(gmset->SIGMA31);
131  m_SG[sg_index(3, 0)] = gmset->get_GM(gmset->SIGMA41);
132  m_SG[sg_index(3, 1)] = gmset->get_GM(gmset->SIGMA42);
133  m_SG[sg_index(3, 2)] = gmset->get_GM(gmset->SIGMA43);
134 
135  m_SG[sg_index(1, 0)] = m_SG[sg_index(0, 1)].mult(-1);
136  m_SG[sg_index(2, 1)] = m_SG[sg_index(1, 2)].mult(-1);
137  m_SG[sg_index(0, 2)] = m_SG[sg_index(2, 0)].mult(-1);
138  m_SG[sg_index(0, 3)] = m_SG[sg_index(3, 0)].mult(-1);
139  m_SG[sg_index(1, 3)] = m_SG[sg_index(3, 1)].mult(-1);
140  m_SG[sg_index(2, 3)] = m_SG[sg_index(3, 2)].mult(-1);
141 
142  m_SG[sg_index(0, 0)] = gmset->get_GM(gmset->UNITY);
143  m_SG[sg_index(1, 1)] = gmset->get_GM(gmset->UNITY);
144  m_SG[sg_index(2, 2)] = gmset->get_GM(gmset->UNITY);
145  m_SG[sg_index(3, 3)] = gmset->get_GM(gmset->UNITY);
146  // these 4 gamma matrices are actually not used.
147 
148  delete gmset;
149 }
150 
151 
152 //====================================================================
154 {
155  // nothing to do.
156 }
157 
158 
159 //====================================================================
160 void Fopr_CloverTerm::mult_gm5(Field& v, const Field& f)
161 {
162  assert(v.nvol() == f.nvol());
163  assert(v.nex() == f.nex());
164  assert(v.nin() == f.nin());
165 
166  Field_F vt(f.nvol(), f.nex());
167 
168  mult_GM(vt, m_GM5, (Field_F)f);
169  v = (Field)vt;
170 }
171 
172 
173 //====================================================================
175  const int mu, const int nu)
176 {
177  assert(mu != nu);
178  mult_iGM(v, m_SG[sg_index(mu, nu)], w);
179 }
180 
181 
182 //====================================================================
183 void Fopr_CloverTerm::mult_sigmaF(Field& v, const Field& f)
184 {
185  mult_csw(v, f);
186 }
187 
188 
189 //====================================================================
190 void Fopr_CloverTerm::mult_csw(Field& v, const Field& w)
191 {
192  int Nc = CommonParameters::Nc();
193  int Nd = CommonParameters::Nd();
194  int Nvol = w.nvol();
195 
196  Field_F wt(Nvol, 1), vt(Nvol, 1);
197 
198  vt.set(0.0);
199 
200  mult_iGM(wt, m_SG[sg_index(1, 2)], (Field_F)w);
201  multadd_Field_Gn(vt, 0, m_Bx, 0, wt, 0, 1.0);
202 
203  mult_iGM(wt, m_SG[sg_index(2, 0)], (Field_F)w);
204  multadd_Field_Gn(vt, 0, m_By, 0, wt, 0, 1.0);
205 
206  mult_iGM(wt, m_SG[sg_index(0, 1)], (Field_F)w);
207  multadd_Field_Gn(vt, 0, m_Bz, 0, wt, 0, 1.0);
208 
209  mult_iGM(wt, m_SG[sg_index(3, 0)], (Field_F)w);
210  multadd_Field_Gn(vt, 0, m_Ex, 0, wt, 0, 1.0);
211 
212  mult_iGM(wt, m_SG[sg_index(3, 1)], (Field_F)w);
213  multadd_Field_Gn(vt, 0, m_Ey, 0, wt, 0, 1.0);
214 
215  mult_iGM(wt, m_SG[sg_index(3, 2)], (Field_F)w);
216  multadd_Field_Gn(vt, 0, m_Ez, 0, wt, 0, 1.0);
217 
218  scal(vt, m_kappa * m_cSW);
219 
220  v = (Field)vt;
221 }
222 
223 
224 //====================================================================
226 {
227  set_fieldstrength(m_Bx, 1, 2);
228  set_fieldstrength(m_By, 2, 0);
229  set_fieldstrength(m_Bz, 0, 1);
230  set_fieldstrength(m_Ex, 3, 0);
231  set_fieldstrength(m_Ey, 3, 1);
232  set_fieldstrength(m_Ez, 3, 2);
233 }
234 
235 
236 //====================================================================
238  const int mu, const int nu)
239 {
240  int Nvol = CommonParameters::Nvol();
241 
242  Staples staple;
243 
244  Field_G Cup(Nvol, 1), Cdn(Nvol, 1);
245  Field_G Umu(Nvol, 1);
246  Field_G v(Nvol, 1), v2(Nvol, 1);
247 
248  staple.upper(Cup, *m_U, mu, nu);
249  staple.lower(Cdn, *m_U, mu, nu);
250  Umu.setpart_ex(0, *m_U, mu);
251 
252  mult_Field_Gnd(Fst, 0, Umu, 0, Cup, 0);
253  multadd_Field_Gnd(Fst, 0, Umu, 0, Cdn, 0, -1.0);
254 
255  mult_Field_Gdn(v, 0, Cup, 0, Umu, 0);
256  multadd_Field_Gdn(v, 0, Cdn, 0, Umu, 0, -1.0);
257 
258  m_shift.forward(v2, v, mu);
259 
260  axpy(Fst, 1, v2);
261 
262  ah_Field_G(Fst, 0);
263  scal(Fst, 0.25);
264 }
265 
266 
267 //====================================================================
269 {
270  // The following counting explicitly depends on the implementation
271  // and to be recalculated when the code is modified.
272  // Present counting is based on rev.1131. [10 Sep 2014 H.Matsufuru]
273 
274  int Lvol = CommonParameters::Lvol();
275 
276  double flop_site
277  = static_cast<double>(m_Nc * m_Nd * (2 + 12 + 48 * m_Nc));
278  double flop = flop_site * static_cast<double>(Lvol);
279 
280  return flop;
281 }
282 
283 
284 //====================================================================
285 //============================================================END=====
void Register_int_vector(const string &, const std::vector< int > &)
Definition: parameters.cpp:344
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:282
void set_config(Field *U)
setting pointer to the gauge configuration.
BridgeIO vout
Definition: bridgeIO.cpp:278
void Register_string(const string &, const string &)
Definition: parameters.cpp:351
Staple construction.
Definition: staples.h:40
void mult_sigmaF(Field &, const Field &)
Field_G m_Ez
field strength.
GammaMatrix m_GM5
void mult_Field_Gdn(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2)
void general(const char *format,...)
Definition: bridgeIO.cpp:65
GammaMatrix get_GM(GMspecies spec)
Container of Field-type object.
Definition: field.h:39
void set_parameters(const Parameters &params)
int nvol() const
Definition: field.h:116
void set_fieldstrength(Field_G &, const int, const int)
Class for parameters.
Definition: parameters.h:38
static int Lvol()
void multadd_Field_Gn(Field_F &y, const int ex, const Field_G &u, int ex1, const Field_F &x, int ex2, const double a)
Wilson-type fermion field.
Definition: field_F.h:37
int nin() const
Definition: field.h:115
void ah_Field_G(Field_G &w, const int ex)
SU(N) gauge field.
Definition: field_G.h:38
void mult_gm5(Field &v, const Field &w)
void multadd_Field_Gdn(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2, const double ff)
void mult_Field_Gnd(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2)
void mult_iGM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication (i is multiplied)
Bridge::VerboseLevel m_vl
Definition: fopr.h:113
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
Set of Gamma Matrices: basis class.
int nex() const
Definition: field.h:117
void init(std::string repr)
void multadd_Field_Gnd(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2, const double ff)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:168
std::string m_repr
void crucial(const char *format,...)
Definition: bridgeIO.cpp:48
double flop_count()
this returns the number of floating point operations.
void mult_GM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication
ShiftField_lex m_shift
void mult_csw(Field &, const Field &)
void lower(Field_G &, const Field_G &, const int mu, const int nu)
constructs lower staple in mu-nu plane.
Definition: staples.cpp:152
static bool Register(const std::string &realm, const creator_callback &cb)
const Field_G * m_U
pointer to gauge configuration.
static const std::string class_name
int sg_index(int mu, int nu)
void Register_double(const string &, const double)
Definition: parameters.cpp:323
std::vector< int > m_boundary
int fetch_double(const string &key, double &val) const
Definition: parameters.cpp:124
string get_string(const string &key) const
Definition: parameters.cpp:87
void upper(Field_G &, const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane.
Definition: staples.cpp:128
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:28
int fetch_int_vector(const string &key, std::vector< int > &val) const
Definition: parameters.cpp:176
void forward(Field &, const Field &, const int mu)
std::vector< GammaMatrix > m_SG