Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  unique_ptr<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 
53  }
54 
55 
56 //====================================================================
57  void Fopr_WilsonGeneral::set_mode(const std::string mode)
58  {
59  m_mode = mode;
60 
61  if (m_mode == "D") {
64  } else if (m_mode == "Ddag") {
67  } else if (m_mode == "DdagD") {
70  } else if (m_mode == "DDdag") {
73  } else if (m_mode == "H") {
76  } else {
77  vout.crucial(m_vl, "Error at %s: input mode is undefined.\n", class_name.c_str());
78  exit(EXIT_FAILURE);
79  }
80  }
81 
82 
83 //====================================================================
84  std::string Fopr_WilsonGeneral::get_mode() const
85  {
86  return m_mode;
87  }
88 
89 
90 //====================================================================
92  {
93  const string str_vlevel = params.get_string("verbose_level");
94 
95  m_vl = vout.set_verbose_level(str_vlevel);
96 
97  //- fetch and check input parameters
98  double kappa_s, kappa_t;
99  double nu_s, r_s;
100  std::vector<int> bc;
101 
102  int err = 0;
103  err += params.fetch_double("hopping_parameter_spatial", kappa_s);
104  err += params.fetch_double("hopping_parameter_temporal", kappa_t);
105  err += params.fetch_double("dispersion_parameter_spatial", nu_s);
106  err += params.fetch_double("Wilson_parameter_spatial", r_s);
107  err += params.fetch_int_vector("boundary_condition", bc);
108 
109  if (err) {
110  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
111  exit(EXIT_FAILURE);
112  }
113 
114  set_parameters(kappa_s, kappa_t, nu_s, r_s, bc);
115  }
116 
117 
118 //====================================================================
119  void Fopr_WilsonGeneral::set_parameters(const double kappa_s,
120  const double kappa_t,
121  const double nu_s,
122  const double r_s,
123  const std::vector<int> bc)
124  {
125  //- print input parameters
126  vout.general(m_vl, "%s:\n", class_name.c_str());
127  vout.general(m_vl, " kappa_s = %12.8f\n", kappa_s);
128  vout.general(m_vl, " kappa_t = %12.8f\n", kappa_t);
129  vout.general(m_vl, " nu_s = %12.8f\n", nu_s);
130  vout.general(m_vl, " r_s = %12.8f\n", r_s);
131  for (int mu = 0; mu < m_Ndim; ++mu) {
132  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
133  }
134 
135  //- range check
136  // NB. kappa = 0 is allowed.
137  assert(bc.size() == m_Ndim);
138 
139  //- store values
140  m_kappa_s = kappa_s;
141  m_kappa_t = kappa_t;
142  m_nu_s = nu_s;
143  m_r_s = r_s;
144 
145  // m_boundary.resize(m_Ndim); // NB. already resized in init.
146  m_boundary = bc;
147  }
148 
149 
150 //====================================================================
151  void Fopr_WilsonGeneral::D(Field& v, const Field& f)
152  {
153  v.set(0.0);
154 
155  Field_F w(f.nvol(), f.nex());
156  w.set(0.0);
157 
158  for (int mu = 0; mu < m_Ndim; ++mu) {
159  mult_up(mu, w, f);
160  mult_dn(mu, w, f);
161  }
162 
163  v = (Field)w;
164 
165  axpy(v, 1.0, f); // v += f;
166  }
167 
168 
169 //====================================================================
170  void Fopr_WilsonGeneral::D_ex(Field& v, const int ex1, const Field& f, const int ex2)
171  {
172  Field ff(f.nin(), f.nvol(), 1);
173 
174  ff.setpart_ex(0, f, ex2);
175 
176  Field w(f.nin(), f.nvol(), 1);
177 
178  for (int mu = 0; mu < m_Ndim; ++mu) {
179  mult_up(mu, w, ff);
180  mult_dn(mu, w, ff);
181  }
182 
183  v.addpart_ex(ex1, w, 0);
184  }
185 
186 
187 //====================================================================
189  {
190  assert(v.nvol() == f.nvol());
191  assert(v.nex() == f.nex());
192  assert(v.nin() == f.nin());
193 
194  Field_F vt(f.nvol(), f.nex());
195  mult_GM(vt, m_GM[4], (Field_F)f);
196 
197  v = (Field)vt;
198  }
199 
200 
201 //====================================================================
203  const int ex1, const Field& v, const int ex2, const int ipm)
204  {
205  assert(ipm == 1 || ipm == -1);
206 
207  Field vv(v.nin(), v.nvol(), 1);
208  vv.setpart_ex(0, v, ex2);
209 
210  Field ww(v.nin(), v.nvol(), 1);
211  mult_gm5(ww, vv);
212 
213  if (ipm == 1) {
214  } else if (ipm == -1) {
215  scal(ww, -1.0); // ww *= -1.0;
216  }
217 
218  w.addpart_ex(ex1, ww, 0);
219  }
220 
221 
222 //====================================================================
223 
224 /*
225 const Field_F Fopr_WilsonGeneral::mult_gm5p(int mu, const Field_F& w)
226 {
227  Field_F vt, v;
228 
229  vt = 0.0;
230 
231  assert(mu >= 0);
232  assert(mu < m_Ndim);
233 
234  mult_up(mu, vt, w);
235  mult_gm5(v, vt);
236 
237  return v;
238 }
239 */
240 
241 //====================================================================
242  void Fopr_WilsonGeneral::mult_gm5p(const int mu,
243  Field_F& v, const Field_F& w)
244  {
245  assert(mu >= 0);
246  assert(mu < m_Ndim);
247 
248  Field_F vt;
249  mult_up(mu, vt, w);
250 
251  mult_gm5(v, vt);
252  }
253 
254 
255 //====================================================================
256  void Fopr_WilsonGeneral::mult_up(const int mu,
257  Field& w, const Field& f)
258  {
259  if (mu < (m_Ndim - 1)) {
260  for (int ex = 0; ex < f.nex(); ++ex) {
261  Field_F vt(f.nvol(), 1);
262  vt.setpart_ex(0, f, ex);
263 
264  m_shift.backward(m_trf, f, m_boundary[mu], mu); // m_trf(x) = f(x+mu)
265  mult_Field_Gn(m_trf2, 0, *m_U, mu, m_trf, 0); // m_trf2 = U[mu](x) * f(x+mu)
266  mult_GMproj2(vt, m_nu_s, -1, m_r_s, m_GM[mu], m_trf2); // vt = (nu - r * gamma[mu]) * m_trf2
267 
268  w.addpart_ex(ex, vt, 0, -m_kappa_s); // vt *= -kappa_s
269  }
270  } else if (mu == (m_Ndim - 1)) {
271  for (int ex = 0; ex < f.nex(); ++ex) {
272  Field_F vt(f.nvol(), 1);
273  vt.setpart_ex(0, f, ex);
274 
275  m_shift.backward(m_trf, f, m_boundary[mu], mu); // m_trf(x) = f(x+mu)
276  mult_Field_Gn(m_trf2, 0, *m_U, mu, m_trf, 0); // m_trf2 = U[mu](x) * f(x+mu)
277  mult_GMproj2(vt, -1, m_GM[mu], m_trf2); // vt = (1 - gamma[mu]) * m_trf2
278 
279  w.addpart_ex(ex, vt, 0, -m_kappa_t); // vt *= -kappa_t
280  }
281  } else {
282  vout.crucial(m_vl, "Error at %s: mu=%d is out of range.\n", class_name.c_str(), mu);
283  exit(EXIT_FAILURE);
284  }
285  }
286 
287 
288 //====================================================================
289  void Fopr_WilsonGeneral::mult_dn(const int mu,
290  Field& w, const Field& f)
291  {
292  if (mu < (m_Ndim - 1)) {
293  for (int ex = 0; ex < f.nex(); ++ex) {
294  mult_Field_Gd(m_trf, 0, *m_U, mu, (Field_F)f, ex); // m_trf = U[mu]^{dagger}(x) * f(x)
295  m_shift.forward(m_trf2, m_trf, m_boundary[mu], mu); // m_trf2(x) = m_trf(x-mu)
296 
297  Field_F vt(f.nvol(), 1);
298  mult_GMproj2(vt, m_nu_s, 1, m_r_s, m_GM[mu], m_trf2); // vt = (nu + r * gamma[mu]) * m_trf2
299 
300  w.addpart_ex(ex, vt, 0, -m_kappa_s); // vt *= -kappa_s
301  }
302  } else if (mu == (m_Ndim - 1)) {
303  for (int ex = 0; ex < f.nex(); ++ex) {
304  mult_Field_Gd(m_trf, 0, *m_U, mu, (Field_F)f, ex); // m_trf = U[mu]^{dagger}(x) * f(x)
305  m_shift.forward(m_trf2, m_trf, m_boundary[mu], mu); // m_trf2(x) = m_trf(x-mu)
306 
307  Field_F vt(f.nvol(), 1);
308  mult_GMproj2(vt, 1, m_GM[mu], m_trf2); // vt = (1 + gamma[mu]) * m_trf2
309 
310  w.addpart_ex(ex, vt, 0, -m_kappa_t); // vt *= -kappa_t
311  }
312  } else {
313  vout.crucial(m_vl, "Error at %s: mu=%d is out of range.\n", class_name.c_str(), mu);
314  exit(EXIT_FAILURE);
315  }
316  }
317 
318 
319 //====================================================================
321  {
322  // This counting is based on the Org-implementation of ver.1.2.0.
323  // Flop count of mult_GMproj2 is different for upward and downward
324  // directions due to the implemetation in Field_F.cpp.
325  // The present counting is based on rev.1130. [10 Sep 2014 H.Matsufuru]
326 
327  const int Nvol = CommonParameters::Nvol();
328  const int NPE = CommonParameters::NPE();
329 
330  const int Nc = m_Nc;
331  const int Nd = m_Nd;
332 
333  int flop_per_site = Nc * Nd * 2 * 8 * (4 * Nc - 1); // #(mult_Field_Gn/d)
334 
335  flop_per_site += Nc * Nd * 2 * (4 * 3 + 4 * 2); // #(mult_GMproj2)
336  flop_per_site += Nc * Nd * 2 * 8; // #(addpart_ex)
337  flop_per_site += Nc * Nd * 2 * 2; // #(aypx(kappa))
338 
339  double gflop = flop_per_site * (Nvol * (NPE / 1.0e+9));
340 
341  if ((m_mode == "DdagD") || (m_mode == "DDdag")) {
342  gflop *= 2;
343  }
344 
345  return gflop;
346  }
347 
348 
349 //====================================================================
350 }
351 //============================================================END=====
void(Fopr_WilsonGeneral::* m_mult_dag)(Field &, const Field &)
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:433
void proj_chiral(Field &w, const int ex1, const Field &v, const int ex2, const int ipm)
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:79
BridgeIO vout
Definition: bridgeIO.cpp:503
void mult_undef(Field &, const Field &f)
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
void general(const char *format,...)
Definition: bridgeIO.cpp:197
GammaMatrix get_GM(GMspecies spec)
static Bridge::VerboseLevel Vlevel()
void mult_up(const int mu, Field &w, const Field &f)
nearest neighbor hopping term: temporary entry [H.Matsufuru]
Container of Field-type object.
Definition: field.h:45
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
void init(const std::string repr)
int nvol() const
Definition: field.h:127
void H(Field &w, const Field &f)
Class for parameters.
Definition: parameters.h:46
std::string get_mode() const
only for Fopr_Overlap
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:204
void set_parameters(const Parameters &params)
Wilson-type fermion field.
Definition: field_F.h:37
void mult_GMproj2(Field_F &y, const int pm, const GammaMatrix &gm, const Field_F &x)
projection with gamma matrix: (1 gamma)
int nin() const
Definition: field.h:126
void mult_dn(const int mu, Field &w, const Field &f)
static const std::string class_name
std::vector< GammaMatrix > m_GM
const Field_F mult_gm5p(const int mu, const Field_F &w)
void DDdag(Field &w, const Field &f)
double flop_count()
this returns the number of floating point operations.
void backward(Field &, const Field &, const int mu)
int nex() const
Definition: field.h:128
void DdagD(Field &w, const Field &f)
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:35
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:319
void mult_gm5(Field &v, const Field &f)
gamma_5 multiplication. [31 Mar 2017 H.Matsufuru]
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
void(Fopr_WilsonGeneral::* m_mult)(Field &, const Field &)
void mult_GM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication
void Ddag(Field &w, const Field &f)
void D_ex(Field &v, const int ex1, const Field &f, const int ex2)
void D(Field &v, const Field &f)
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:197
string get_string(const string &key) const
Definition: parameters.cpp:221
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
void forward(Field &, const Field &, const int mu)