Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fopr_Wilson_impl.cpp
Go to the documentation of this file.
1 
14 #include "fopr_Wilson_impl.h"
15 
16 namespace Org {
17 #ifdef USE_FACTORY_AUTOREGISTER
18  namespace {
19  bool init = Fopr_Wilson::register_factory();
20  }
21 #endif
22 
23  const std::string Fopr_Wilson::class_name = "Org::Fopr_Wilson";
24 
25 //====================================================================
26  void Fopr_Wilson::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_Wilson::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_Wilson::get_mode() const
85  {
86  return m_mode;
87  }
88 
89 
90 //====================================================================
92  {
93  const std::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;
99  std::vector<int> bc;
100 
101  int err = 0;
102  err += params.fetch_double("hopping_parameter", kappa);
103  err += params.fetch_int_vector("boundary_condition", bc);
104 
105  if (err) {
106  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
107  exit(EXIT_FAILURE);
108  }
109 
110  set_parameters(kappa, bc);
111  }
112 
113 
114 //====================================================================
115  void Fopr_Wilson::set_parameters(const double kappa, const std::vector<int> bc)
116  {
117  //- print input parameters
118  vout.general(m_vl, "%s:\n", class_name.c_str());
119  vout.general(m_vl, " kappa = %12.8f\n", kappa);
120  for (int mu = 0; mu < m_Ndim; ++mu) {
121  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
122  }
123 
124  //- range check
125  // NB. kappa = 0 is allowed.
126  assert(bc.size() == m_Ndim);
127 
128  //- store values
129  m_kappa = kappa;
130 
131  // m_boundary.resize(m_Ndim); // NB. already resized in init.
132  m_boundary = bc;
133  }
134 
135 
136 //====================================================================
137  void Fopr_Wilson::D(Field& v, const Field& f)
138  {
139  v = f;
140 
141  Field_F w(f.nvol(), f.nex());
142  w.set(0.0);
143 
144  for (int mu = 0; mu < m_Ndim; ++mu) {
145  mult_up(mu, w, f);
146  mult_dn(mu, w, f);
147  }
148 
149  axpy(v, -m_kappa, w);
150  }
151 
152 
153 //====================================================================
154  void Fopr_Wilson::D_ex(Field& v, const int ex1, const Field& f, const int ex2)
155  {
156  Field ff(f.nin(), f.nvol(), 1);
157 
158  ff.setpart_ex(0, f, ex2);
159 
160  Field w(f.nin(), f.nvol(), 1);
161 
162  for (int mu = 0; mu < m_Ndim; ++mu) {
163  mult_up(mu, w, ff);
164  mult_dn(mu, w, ff);
165  }
166 
167  scal(w, -m_kappa);
168 
169  v.addpart_ex(ex1, w, 0);
170  }
171 
172 
173 //====================================================================
174  void Fopr_Wilson::mult_gm5(Field& v, const Field& f)
175  {
176  assert(v.nvol() == f.nvol());
177  assert(v.nex() == f.nex());
178  assert(v.nin() == f.nin());
179 
180  Field_F vt(f.nvol(), f.nex());
181  mult_GM(vt, m_GM[4], (Field_F)f);
182  v = (Field)vt;
183  }
184 
185 
186 //====================================================================
188  const int ex1, const Field& v, const int ex2, const int ipm)
189  {
190  assert(ipm == 1 || ipm == -1);
191 
192  Field vv(v.nin(), v.nvol(), 1);
193  vv.setpart_ex(0, v, ex2);
194 
195  Field ww(v.nin(), v.nvol(), 1);
196  mult_gm5(ww, vv);
197 
198  if (ipm == 1) {
199  } else if (ipm == -1) {
200  scal(ww, -1.0);
201  }
202 
203  w.addpart_ex(ex1, ww, 0);
204  }
205 
206 
207 //====================================================================
208 
209 /*
210 const Field_F Fopr_Wilson::mult_gm5p(int mu, const Field_F& w)
211 {
212  Field_F vt, v;
213 
214  vt.set(0.0);
215 
216  assert(mu >= 0);
217  assert(mu < m_Ndim);
218 
219  mult_up(mu, vt, w);
220 
221  mult_gm5(v, vt);
222 
223  return v;
224 }
225 */
226 
227 //====================================================================
228  void Fopr_Wilson::mult_gm5p(const int mu, Field_F& v, const Field_F& w)
229  {
230  assert(mu >= 0);
231  assert(mu < m_Ndim);
232 
233  Field_F vt;
234  mult_up(mu, vt, w);
235  mult_gm5(v, vt);
236  }
237 
238 
239 //====================================================================
240  void Fopr_Wilson::mult_up(const int mu, Field& w, const Field& f)
241  {
242  for (int ex = 0; ex < f.nex(); ++ex) {
243  Field_F vt(f.nvol(), 1);
244  vt.setpart_ex(0, f, ex);
245 
246  m_shift.backward(m_trf, f, m_boundary[mu], mu);
247 
248  mult_Field_Gn(m_trf2, 0, *m_U, mu, m_trf, 0);
249  mult_GMproj2(vt, -1, m_GM[mu], m_trf2);
250 
251  w.addpart_ex(ex, vt, 0);
252  }
253  }
254 
255 
256 //====================================================================
257  void Fopr_Wilson::mult_dn(const int mu, Field& w, const Field& f)
258  {
259  for (int ex = 0; ex < f.nex(); ++ex) {
260  mult_Field_Gd(m_trf, 0, *m_U, mu, (Field_F)f, ex);
262 
263  Field_F vt(f.nvol(), 1);
264  mult_GMproj2(vt, 1, m_GM[mu], m_trf2);
265 
266  w.addpart_ex(ex, vt, 0);
267  }
268  }
269 
270 
271 //====================================================================
273  {
274  // This counting is based on the Org-implementation of ver.1.2.0.
275  // Flop count of mult_GMproj2 is different for upward and downward
276  // directions due to the implemetation in Field_F.cpp.
277  // The present counting is based on rev.1130. [10 Sep 2014 H.Matsufuru]
278 
279  const int Nvol = CommonParameters::Nvol();
280  const int NPE = CommonParameters::NPE();
281 
282  const int Nc = m_Nc;
283  const int Nd = m_Nd;
284 
285  int flop_per_site = Nc * Nd * 2 * 8 * (4 * Nc - 1); // #(mult_Field_Gn/d)
286 
287  flop_per_site += Nc * Nd * 2 * (4 * 3 + 4 * 2); // #(mult_GMproj2)
288  flop_per_site += Nc * Nd * 2 * 8; // #(addpart_ex)
289  flop_per_site += Nc * Nd * 2 * 2; // #(aypx(kappa))
290 
291  double gflop = flop_per_site * (Nvol * (NPE / 1.0e+9));
292 
293  if ((m_mode == "DdagD") || (m_mode == "DDdag")) {
294  gflop *= 2;
295  }
296 
297  return gflop;
298  }
299 
300 
301 //====================================================================
302 }
303 //============================================================END=====
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:433
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 set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
static const std::string class_name
Bridge::VerboseLevel m_vl
void general(const char *format,...)
Definition: bridgeIO.cpp:197
GammaMatrix get_GM(GMspecies spec)
static Bridge::VerboseLevel Vlevel()
Container of Field-type object.
Definition: field.h:45
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
void proj_chiral(Field &w, const int ex1, const Field &v, const int ex2, const int ipm)
int nvol() const
Definition: field.h:127
void mult_gm5(Field &v, const Field &f)
gamma_5 multiplication. [31 Mar 2017 H.Matsufuru]
Class for parameters.
Definition: parameters.h:46
void H(Field &w, const Field &f)
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:204
Wilson-type fermion field.
Definition: field_F.h:37
ShiftField_lex m_shift
void mult_GMproj2(Field_F &y, const int pm, const GammaMatrix &gm, const Field_F &x)
projection with gamma matrix: (1 gamma)
void mult_dn(const int mu, Field &w, const Field &f)
int nin() const
Definition: field.h:126
void set_parameters(const Parameters &params)
std::vector< int > m_boundary
void(Fopr_Wilson::* m_mult)(Field &, const Field &)
void D(Field &v, const Field &f)
const Field_F mult_gm5p(const int mu, const Field_F &w)
std::string m_repr
void init(std::string repr)
void backward(Field &, const Field &, const int mu)
int nex() const
Definition: field.h:128
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 DdagD(Field &w, const Field &f)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:319
void mult_up(const int mu, Field &w, const Field &f)
nearest neighbor hopping term: temporary entry [H.Matsufuru]
std::vector< GammaMatrix > m_GM
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
void mult_GM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication
std::string m_mode
void DDdag(Field &w, const Field &f)
void(Fopr_Wilson::* m_mult_dag)(Field &, const Field &)
const Field_G * m_U
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
double flop_count()
this returns the number of floating point operations.
void D_ex(Field &v, const int ex1, const Field &f, const int ex2)
void Ddag(Field &w, const Field &f)
std::string get_mode() const
only for Fopr_Overlap
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
void mult_undef(Field &, const Field &f)
void forward(Field &, const Field &, const int mu)
void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...