Bridge++  Ver. 2.0.2
fopr_WilsonGeneral_impl.cpp
Go to the documentation of this file.
1 
15 
16 namespace Org {
17  const std::string Fopr_WilsonGeneral::class_name = "Org::Fopr_WilsonGeneral";
18 
19 #ifdef USE_FACTORY_AUTOREGISTER
20  namespace {
21  bool init = Fopr_WilsonGeneral::register_factory();
22  }
23 #endif
24 
25 //====================================================================
26  void Fopr_WilsonGeneral::init(const std::string repr)
27  {
29 
32 
35  m_boundary.resize(m_Ndim);
36 
37  m_U = 0;
38 
39  m_repr = repr;
40 
41  m_GM.resize(m_Ndim + 1);
42 
43  GammaMatrixSet *gmset = GammaMatrixSet::New(m_repr);
44 
45  m_GM[0] = gmset->get_GM(GammaMatrixSet::GAMMA1);
46  m_GM[1] = gmset->get_GM(GammaMatrixSet::GAMMA2);
47  m_GM[2] = gmset->get_GM(GammaMatrixSet::GAMMA3);
48  m_GM[3] = gmset->get_GM(GammaMatrixSet::GAMMA4);
49  m_GM[4] = gmset->get_GM(GammaMatrixSet::GAMMA5);
50 
51  delete gmset;
52 
55  }
56 
57 
58 //====================================================================
59  void Fopr_WilsonGeneral::set_mode(const std::string mode)
60  {
61  m_mode = mode;
62 
63  if (m_mode == "D") {
66  } else if (m_mode == "Ddag") {
69  } else if (m_mode == "DdagD") {
72  } else if (m_mode == "DDdag") {
75  } else if (m_mode == "H") {
78  } else {
79  vout.crucial(m_vl, "Error at %s: input mode is undefined.\n", class_name.c_str());
80  exit(EXIT_FAILURE);
81  }
82  }
83 
84 
85 //====================================================================
86  std::string Fopr_WilsonGeneral::get_mode() const
87  {
88  return m_mode;
89  }
90 
91 
92 //====================================================================
94  {
95  std::string vlevel;
96  if (!params.fetch_string("verbose_level", vlevel)) {
97  m_vl = vout.set_verbose_level(vlevel);
98  }
99 
100  //- fetch and check input parameters
101  double kappa_s, kappa_t;
102  double nu_s, r_s;
103  std::vector<int> bc;
104 
105  int err = 0;
106  err += params.fetch_double("hopping_parameter_spatial", kappa_s);
107  err += params.fetch_double("hopping_parameter_temporal", kappa_t);
108  err += params.fetch_double("dispersion_parameter_spatial", nu_s);
109  err += params.fetch_double("Wilson_parameter_spatial", r_s);
110  err += params.fetch_int_vector("boundary_condition", bc);
111 
112  if (err) {
113  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
114  exit(EXIT_FAILURE);
115  }
116 
117  set_parameters(kappa_s, kappa_t, nu_s, r_s, bc);
118  }
119 
120 
121 //====================================================================
123  {
124  params.set_double("hopping_parameter_spatial", m_kappa_s);
125  params.set_double("hopping_parameter_temporal", m_kappa_t);
126  params.set_double("dispersion_parameter_spatial", m_nu_s);
127  params.set_double("Wilson_parameter_spatial", m_r_s);
128  params.set_int_vector("boundary_condition", m_boundary);
129 
130  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
131  }
132 
133 
134 //====================================================================
135  void Fopr_WilsonGeneral::set_parameters(const double kappa_s,
136  const double kappa_t,
137  const double nu_s,
138  const double r_s,
139  const std::vector<int> bc)
140  {
141  //- print input parameters
142  vout.general(m_vl, "%s:\n", class_name.c_str());
143  vout.general(m_vl, " kappa_s = %12.8f\n", kappa_s);
144  vout.general(m_vl, " kappa_t = %12.8f\n", kappa_t);
145  vout.general(m_vl, " nu_s = %12.8f\n", nu_s);
146  vout.general(m_vl, " r_s = %12.8f\n", r_s);
147  for (int mu = 0; mu < m_Ndim; ++mu) {
148  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
149  }
150 
151  //- range check
152  // NB. kappa = 0 is allowed.
153  assert(bc.size() == m_Ndim);
154 
155  //- store values
156  m_kappa_s = kappa_s;
157  m_kappa_t = kappa_t;
158  m_nu_s = nu_s;
159  m_r_s = r_s;
160 
161  // m_boundary.resize(m_Ndim); // NB. already resized in init.
162  m_boundary = bc;
163  }
164 
165 
166 //====================================================================
167  void Fopr_WilsonGeneral::D(Field& v, const Field& f)
168  {
169  v.set(0.0);
170 
171  Field_F w(f.nvol(), f.nex());
172  w.set(0.0);
173 
174  for (int mu = 0; mu < m_Ndim; ++mu) {
175  mult_up(mu, w, f);
176  mult_dn(mu, w, f);
177  }
178 
179  v = (Field)w;
180 
181  axpy(v, 1.0, f); // v += f;
182  }
183 
184 
185 //====================================================================
186  void Fopr_WilsonGeneral::D_ex(Field& v, const int ex1, const Field& f, const int ex2)
187  {
188  Field ff(f.nin(), f.nvol(), 1);
189 
190  ff.setpart_ex(0, f, ex2);
191 
192  Field w(f.nin(), f.nvol(), 1);
193 
194  for (int mu = 0; mu < m_Ndim; ++mu) {
195  mult_up(mu, w, ff);
196  mult_dn(mu, w, ff);
197  }
198 
199  v.addpart_ex(ex1, w, 0);
200  }
201 
202 
203 //====================================================================
205  {
206  assert(v.nvol() == f.nvol());
207  assert(v.nex() == f.nex());
208  assert(v.nin() == f.nin());
209 
210  Field_F vt(f.nvol(), f.nex());
211  mult_GM(vt, m_GM[4], (Field_F)f);
212 
213  v = (Field)vt;
214  }
215 
216 
217 //====================================================================
219  const int ex1, const Field& v, const int ex2, const int ipm)
220  {
221  assert(ipm == 1 || ipm == -1);
222 
223  Field vv(v.nin(), v.nvol(), 1);
224  vv.setpart_ex(0, v, ex2);
225 
226  Field ww(v.nin(), v.nvol(), 1);
227  mult_gm5(ww, vv);
228 
229  if (ipm == 1) {
230  } else if (ipm == -1) {
231  scal(ww, -1.0); // ww *= -1.0;
232  }
233 
234  w.addpart_ex(ex1, ww, 0);
235  }
236 
237 
238 //====================================================================
239 
240 /*
241 const Field_F Fopr_WilsonGeneral::mult_gm5p(int mu, const Field_F& w)
242 {
243  Field_F vt, v;
244 
245  vt = 0.0;
246 
247  assert(mu >= 0);
248  assert(mu < m_Ndim);
249 
250  mult_up(mu, vt, w);
251  mult_gm5(v, vt);
252 
253  return v;
254 }
255 */
256 
257 //====================================================================
258  void Fopr_WilsonGeneral::mult_gm5p(const int mu,
259  Field_F& v, const Field_F& w)
260  {
261  assert(mu >= 0);
262  assert(mu < m_Ndim);
263 
264  Field_F vt;
265  mult_up(mu, vt, w);
266 
267  mult_gm5(v, vt);
268  }
269 
270 
271 //====================================================================
272  void Fopr_WilsonGeneral::mult_up(const int mu,
273  Field& w, const Field& f)
274  {
275  if (mu < (m_Ndim - 1)) {
276  for (int ex = 0; ex < f.nex(); ++ex) {
277  Field_F vt(f.nvol(), 1);
278  vt.setpart_ex(0, f, ex);
279 
280  m_shift.backward(m_trf, f, m_boundary[mu], mu); // m_trf(x) = f(x+mu)
281  mult_Field_Gn(m_trf2, 0, *m_U, mu, m_trf, 0); // m_trf2 = U[mu](x) * f(x+mu)
282  mult_GMproj2(vt, m_nu_s, -1, m_r_s, m_GM[mu], m_trf2); // vt = (nu - r * gamma[mu]) * m_trf2
283 
284  w.addpart_ex(ex, vt, 0, -m_kappa_s); // vt *= -kappa_s
285  }
286  } else if (mu == (m_Ndim - 1)) {
287  for (int ex = 0; ex < f.nex(); ++ex) {
288  Field_F vt(f.nvol(), 1);
289  vt.setpart_ex(0, f, ex);
290 
291  m_shift.backward(m_trf, f, m_boundary[mu], mu); // m_trf(x) = f(x+mu)
292  mult_Field_Gn(m_trf2, 0, *m_U, mu, m_trf, 0); // m_trf2 = U[mu](x) * f(x+mu)
293  mult_GMproj2(vt, -1, m_GM[mu], m_trf2); // vt = (1 - gamma[mu]) * m_trf2
294 
295  w.addpart_ex(ex, vt, 0, -m_kappa_t); // vt *= -kappa_t
296  }
297  } else {
298  vout.crucial(m_vl, "Error at %s: mu=%d is out of range.\n", class_name.c_str(), mu);
299  exit(EXIT_FAILURE);
300  }
301  }
302 
303 
304 //====================================================================
305  void Fopr_WilsonGeneral::mult_dn(const int mu,
306  Field& w, const Field& f)
307  {
308  if (mu < (m_Ndim - 1)) {
309  for (int ex = 0; ex < f.nex(); ++ex) {
310  mult_Field_Gd(m_trf, 0, *m_U, mu, (Field_F)f, ex); // m_trf = U[mu]^{dagger}(x) * f(x)
311  m_shift.forward(m_trf2, m_trf, m_boundary[mu], mu); // m_trf2(x) = m_trf(x-mu)
312 
313  Field_F vt(f.nvol(), 1);
314  mult_GMproj2(vt, m_nu_s, 1, m_r_s, m_GM[mu], m_trf2); // vt = (nu + r * gamma[mu]) * m_trf2
315 
316  w.addpart_ex(ex, vt, 0, -m_kappa_s); // vt *= -kappa_s
317  }
318  } else if (mu == (m_Ndim - 1)) {
319  for (int ex = 0; ex < f.nex(); ++ex) {
320  mult_Field_Gd(m_trf, 0, *m_U, mu, (Field_F)f, ex); // m_trf = U[mu]^{dagger}(x) * f(x)
321  m_shift.forward(m_trf2, m_trf, m_boundary[mu], mu); // m_trf2(x) = m_trf(x-mu)
322 
323  Field_F vt(f.nvol(), 1);
324  mult_GMproj2(vt, 1, m_GM[mu], m_trf2); // vt = (1 + gamma[mu]) * m_trf2
325 
326  w.addpart_ex(ex, vt, 0, -m_kappa_t); // vt *= -kappa_t
327  }
328  } else {
329  vout.crucial(m_vl, "Error at %s: mu=%d is out of range.\n", class_name.c_str(), mu);
330  exit(EXIT_FAILURE);
331  }
332  }
333 
334 
335 //====================================================================
337  {
338  // This counting is based on the Org-implementation of ver.1.2.0.
339  // Flop count of mult_GMproj2 is different for upward and downward
340  // directions due to the implemetation in Field_F.cpp.
341  // The present counting is based on rev.1130. [10 Sep 2014 H.Matsufuru]
342 
343  const int Nvol = CommonParameters::Nvol();
344  const int NPE = CommonParameters::NPE();
345 
346  const int Nc = m_Nc;
347  const int Nd = m_Nd;
348 
349  int flop_per_site = Nc * Nd * 2 * 8 * (4 * Nc - 1); // #(mult_Field_Gn/d)
350 
351  flop_per_site += Nc * Nd * 2 * (4 * 3 + 4 * 2); // #(mult_GMproj2)
352  flop_per_site += Nc * Nd * 2 * 8; // #(addpart_ex)
353  flop_per_site += Nc * Nd * 2 * 2; // #(aypx(kappa))
354 
355  double gflop = flop_per_site * (Nvol * (NPE / 1.0e+9));
356 
357  if ((m_mode == "DdagD") || (m_mode == "DDdag")) {
358  gflop *= 2;
359  }
360 
361  return gflop;
362  }
363 
364 
365 //====================================================================
366 }
367 //============================================================END=====
Org::Fopr_WilsonGeneral::get_mode
std::string get_mode() const
Definition: fopr_WilsonGeneral_impl.cpp:86
GammaMatrixSet
Set of Gamma Matrices: basis class.
Definition: gammaMatrixSet.h:37
Org::Fopr_WilsonGeneral::init
void init(const std::string repr)
Definition: fopr_WilsonGeneral_impl.cpp:26
Org::Fopr_WilsonGeneral::m_kappa_s
double m_kappa_s
Definition: fopr_WilsonGeneral_impl.h:50
Org::Fopr_WilsonGeneral::m_kappa_t
double m_kappa_t
Definition: fopr_WilsonGeneral_impl.h:50
Field::setpart_ex
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:201
Org::Fopr_WilsonGeneral::Ddag
void Ddag(Field &w, const Field &f)
Definition: fopr_WilsonGeneral_impl.h:117
GammaMatrixSet::GAMMA5
@ GAMMA5
Definition: gammaMatrixSet.h:48
Org::Fopr_WilsonGeneral::m_repr
std::string m_repr
Definition: fopr_WilsonGeneral_impl.h:55
Org::Fopr_WilsonGeneral::m_r_s
double m_r_s
Definition: fopr_WilsonGeneral_impl.h:51
Org::Fopr_WilsonGeneral::m_nu_s
double m_nu_s
Definition: fopr_WilsonGeneral_impl.h:51
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
GammaMatrixSet::GAMMA1
@ GAMMA1
Definition: gammaMatrixSet.h:48
Org::Fopr_WilsonGeneral::m_trf2
Field_F m_trf2
Definition: fopr_WilsonGeneral_impl.h:65
ShiftField_lex::forward
void forward(Field &, const Field &, const int mu)
Definition: shiftField_lex.cpp:79
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
mult_GM
void mult_GM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication
Definition: field_F_imp.cpp:198
Field::set
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
Parameters
Class for parameters.
Definition: parameters.h:46
Org::Fopr_WilsonGeneral::D_ex
void D_ex(Field &v, const int ex1, const Field &f, const int ex2)
Definition: fopr_WilsonGeneral_impl.cpp:186
Org::Fopr_WilsonGeneral::DdagD
void DdagD(Field &w, const Field &f)
Definition: fopr_WilsonGeneral_impl.h:126
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
Field::nex
int nex() const
Definition: field.h:128
Org::Fopr_WilsonGeneral::mult_undef
void mult_undef(Field &, const Field &f)
Definition: fopr_WilsonGeneral_impl.h:154
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Org::Fopr_WilsonGeneral::m_boundary
std::vector< int > m_boundary
Definition: fopr_WilsonGeneral_impl.h:52
Org::Fopr_WilsonGeneral::mult_up
void mult_up(const int mu, Field &w, const Field &f)
upward nearest neighbor hopping term.
Definition: fopr_WilsonGeneral_impl.cpp:272
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
mult_Field_Gd
void mult_Field_Gd(Field_F &y, const int ex, const Field_G &u, int ex1, const Field_F &x, int ex2)
Definition: field_F_imp.cpp:76
GammaMatrixSet::GAMMA3
@ GAMMA3
Definition: gammaMatrixSet.h:48
Field::nin
int nin() const
Definition: field.h:126
mult_GMproj2
void mult_GMproj2(Field_F &y, const int pm, const GammaMatrix &gm, const Field_F &x)
projection with gamma matrix: (1 \pm gamma)
Definition: field_F_imp.cpp:324
Org::Fopr_WilsonGeneral::m_mult
void(Fopr_WilsonGeneral::* m_mult)(Field &, const Field &)
Definition: fopr_WilsonGeneral_impl.h:57
Org::Fopr_WilsonGeneral::mult_dn
void mult_dn(const int mu, Field &w, const Field &f)
downward nearest neighbor hopping term.
Definition: fopr_WilsonGeneral_impl.cpp:305
Org::Fopr_WilsonGeneral::m_vl
Bridge::VerboseLevel m_vl
Definition: fopr_WilsonGeneral_impl.h:42
Org::Fopr_WilsonGeneral::m_shift
ShiftField_lex m_shift
Definition: fopr_WilsonGeneral_impl.h:64
fopr_WilsonGeneral_impl.h
GammaMatrixSet::GAMMA4
@ GAMMA4
Definition: gammaMatrixSet.h:48
Org::Fopr_WilsonGeneral::D
void D(Field &v, const Field &f)
Definition: fopr_WilsonGeneral_impl.cpp:167
Org::Fopr_WilsonGeneral::H
void H(Field &w, const Field &f)
Definition: fopr_WilsonGeneral_impl.h:146
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Field::addpart_ex
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:208
Parameters::fetch_int_vector
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
Org::Fopr_WilsonGeneral::DDdag
void DDdag(Field &w, const Field &f)
Definition: fopr_WilsonGeneral_impl.h:136
Org::Fopr_WilsonGeneral::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: fopr_WilsonGeneral_impl.cpp:336
Org::Fopr_WilsonGeneral::mult_gm5p
const Field_F mult_gm5p(const int mu, const Field_F &w)
Org::Fopr_WilsonGeneral::class_name
static const std::string class_name
Definition: fopr_WilsonGeneral_impl.h:39
Org::Fopr_WilsonGeneral::m_mult_dag
void(Fopr_WilsonGeneral::* m_mult_dag)(Field &, const Field &)
Definition: fopr_WilsonGeneral_impl.h:58
Field::nvol
int nvol() const
Definition: field.h:127
Org
Clover term operator.
Definition: fopr_CloverTerm_eo_impl.cpp:23
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
Parameters::set_int_vector
void set_int_vector(const string &key, const vector< int > &value)
Definition: parameters.cpp:45
Org::Fopr_WilsonGeneral::m_GM
std::vector< GammaMatrix > m_GM
Definition: fopr_WilsonGeneral_impl.h:62
Org::Fopr_WilsonGeneral::get_parameters
void get_parameters(Parameters &params) const
gets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_WilsonGeneral_impl.cpp:122
Org::Fopr_WilsonGeneral::m_mode
std::string m_mode
Definition: fopr_WilsonGeneral_impl.h:54
CommonParameters::Nd
static int Nd()
Definition: commonParameters.h:116
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition: commonParameters.h:122
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
ShiftField_lex::backward
void backward(Field &, const Field &, const int mu)
Definition: shiftField_lex.cpp:59
Org::Fopr_WilsonGeneral::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_WilsonGeneral_impl.cpp:93
mult_Field_Gn
void mult_Field_Gn(Field_F &y, const int ex, const Field_G &u, int ex1, const Field_F &x, int ex2)
Definition: field_F_imp.cpp:36
scal
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:261
Org::Fopr_WilsonGeneral::proj_chiral
void proj_chiral(Field &w, const int ex1, const Field &v, const int ex2, const int ipm)
Definition: fopr_WilsonGeneral_impl.cpp:218
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Field_F
Wilson-type fermion field.
Definition: field_F.h:37
Parameters::fetch_double
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
Org::Fopr_WilsonGeneral::m_trf
Field_F m_trf
Definition: fopr_WilsonGeneral_impl.h:65
GammaMatrixSet::get_GM
GammaMatrix get_GM(GMspecies spec)
Definition: gammaMatrixSet.h:76
GammaMatrixSet::GAMMA2
@ GAMMA2
Definition: gammaMatrixSet.h:48
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Field
Container of Field-type object.
Definition: field.h:46
Org::Fopr_WilsonGeneral::m_U
const Field_G * m_U
Definition: fopr_WilsonGeneral_impl.h:60
Org::Fopr_WilsonGeneral::m_Ndim
int m_Ndim
Definition: fopr_WilsonGeneral_impl.h:46
Org::Fopr_WilsonGeneral::m_Nd
int m_Nd
Definition: fopr_WilsonGeneral_impl.h:48
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Org::Fopr_WilsonGeneral::set_mode
void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: fopr_WilsonGeneral_impl.cpp:59
Org::Fopr_WilsonGeneral::m_Nc
int m_Nc
Definition: fopr_WilsonGeneral_impl.h:47
Org::Fopr_WilsonGeneral::m_Nvol
int m_Nvol
Definition: fopr_WilsonGeneral_impl.h:45
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:154
Org::Fopr_WilsonGeneral::mult_gm5
void mult_gm5(Field &v, const Field &f)
multiplies gamma_5 matrix.
Definition: fopr_WilsonGeneral_impl.cpp:204