Bridge++  Version 1.4.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 using std::string;
17 
18 namespace Org {
19  const std::string Fopr_Wilson::class_name = "Org::Fopr_Wilson";
20 
21 //====================================================================
22  void Fopr_Wilson::init(string repr)
23  {
25 
28 
31  m_boundary.resize(m_Ndim);
32 
33  m_U = 0;
34 
35  m_repr = repr;
36 
37  m_GM.resize(m_Ndim + 1);
38 
39  unique_ptr<GammaMatrixSet> gmset(GammaMatrixSet::New(m_repr));
40 
41  m_GM[0] = gmset->get_GM(GammaMatrixSet::GAMMA1);
42  m_GM[1] = gmset->get_GM(GammaMatrixSet::GAMMA2);
43  m_GM[2] = gmset->get_GM(GammaMatrixSet::GAMMA3);
44  m_GM[3] = gmset->get_GM(GammaMatrixSet::GAMMA4);
45  m_GM[4] = gmset->get_GM(GammaMatrixSet::GAMMA5);
46 
49  }
50 
51 
52 //====================================================================
53  void Fopr_Wilson::set_mode(string mode)
54  {
55  m_mode = mode;
56 
57  if (m_mode == "D") {
60  } else if (m_mode == "Ddag") {
63  } else if (m_mode == "DdagD") {
66  } else if (m_mode == "DDdag") {
69  } else if (m_mode == "H") {
72  } else {
73  vout.crucial(m_vl, "Error at %s: input mode is undefined.\n", class_name.c_str());
74  exit(EXIT_FAILURE);
75  }
76  }
77 
78 
79 //====================================================================
80  string Fopr_Wilson::get_mode() const
81  {
82  return m_mode;
83  }
84 
85 
86 //====================================================================
88  {
89  const string str_vlevel = params.get_string("verbose_level");
90 
91  m_vl = vout.set_verbose_level(str_vlevel);
92 
93  //- fetch and check input parameters
94  double kappa;
95  std::vector<int> bc;
96 
97  int err = 0;
98  err += params.fetch_double("hopping_parameter", kappa);
99  err += params.fetch_int_vector("boundary_condition", bc);
100 
101  if (err) {
102  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
103  exit(EXIT_FAILURE);
104  }
105 
106  set_parameters(kappa, bc);
107  }
108 
109 
110 //====================================================================
111  void Fopr_Wilson::set_parameters(const double kappa, const std::vector<int> bc)
112  {
113  //- print input parameters
114  vout.general(m_vl, "%s:\n", class_name.c_str());
115  vout.general(m_vl, " kappa = %12.8f\n", kappa);
116  for (int mu = 0; mu < m_Ndim; ++mu) {
117  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
118  }
119 
120  //- range check
121  // NB. kappa = 0 is allowed.
122  assert(bc.size() == m_Ndim);
123 
124  //- store values
125  m_kappa = kappa;
126 
127  // m_boundary.resize(m_Ndim); // already resized in init.
128  for (int mu = 0; mu < m_Ndim; ++mu) {
129  m_boundary[mu] = bc[mu];
130  }
131  }
132 
133 
134 //====================================================================
135  void Fopr_Wilson::D(Field& v, const Field& f)
136  {
137  Field_F w(f.nvol(), f.nex());
138 
139  v = f;
140  w.set(0.0);
141  for (int mu = 0; mu < m_Ndim; ++mu) {
142  mult_up(mu, w, f);
143  mult_dn(mu, w, f);
144  }
145 
146  axpy(v, -m_kappa, w);
147  }
148 
149 
150 //====================================================================
151  void Fopr_Wilson::D_ex(Field& v, const int ex1, const Field& f, const int ex2)
152  {
153  Field ff(f.nin(), f.nvol(), 1);
154 
155  ff.setpart_ex(0, f, ex2);
156 
157  Field w(f.nin(), f.nvol(), 1);
158 
159  for (int mu = 0; mu < m_Ndim; ++mu) {
160  mult_up(mu, w, ff);
161  mult_dn(mu, w, ff);
162  }
163 
164  scal(w, -m_kappa);
165 
166  v.addpart_ex(ex1, w, 0);
167  }
168 
169 
170 //====================================================================
171  void Fopr_Wilson::mult_gm5(Field& v, const Field& f)
172  {
173  assert(v.nvol() == f.nvol());
174  assert(v.nex() == f.nex());
175  assert(v.nin() == f.nin());
176 
177  Field_F vt(f.nvol(), f.nex());
178 
179  mult_GM(vt, m_GM[4], (Field_F)f);
180  v = (Field)vt;
181  }
182 
183 
184 //====================================================================
185  void Fopr_Wilson::proj_chiral(Field& w, const int ex1, const Field& v, const int ex2, const int ipm)
186  {
187  assert(ipm == 1 || ipm == -1);
188 
189  Field vv(v.nin(), v.nvol(), 1);
190  vv.setpart_ex(0, v, ex2);
191 
192  Field ww(v.nin(), v.nvol(), 1);
193  mult_gm5(ww, vv);
194 
195  if (ipm == 1) {
196  } else if (ipm == -1) {
197  scal(ww, -1.0);
198  }
199 
200  w.addpart_ex(ex1, ww, 0);
201  }
202 
203 
204 //====================================================================
205 
206 /*
207 const Field_F Fopr_Wilson::mult_gm5p(int mu, const Field_F& w)
208 {
209  Field_F vt, v;
210 
211  vt.set(0.0);
212 
213  assert(mu >= 0);
214  assert(mu < m_Ndim);
215 
216  mult_up(mu, vt, w);
217 
218  mult_gm5(v, vt);
219 
220  return v;
221 }
222 */
223 
224 //====================================================================
225  void Fopr_Wilson::mult_gm5p(int mu, Field_F& v, const Field_F& w)
226  {
227  assert(mu >= 0);
228  assert(mu < m_Ndim);
229 
230  Field_F vt;
231 
232  mult_up(mu, vt, w);
233  mult_gm5(v, vt);
234  }
235 
236 
237 //====================================================================
238  void Fopr_Wilson::mult_up(int mu, Field& w, const Field& f)
239  {
240  Field_F vt(f.nvol(), 1);
241 
242  for (int ex = 0; ex < f.nex(); ++ex) {
243  vt.setpart_ex(0, f, ex);
244  shift.backward(trf, f, m_boundary[mu], mu);
245  mult_Field_Gn(trf2, 0, *m_U, mu, trf, 0);
246  mult_GMproj2(vt, -1, m_GM[mu], trf2);
247  w.addpart_ex(ex, vt, 0);
248  }
249  }
250 
251 
252 //====================================================================
253  void Fopr_Wilson::mult_dn(int mu, Field& w, const Field& f)
254  {
255  Field_F vt(f.nvol(), 1);
256 
257  for (int ex = 0; ex < f.nex(); ++ex) {
258  mult_Field_Gd(trf, 0, *m_U, mu, (Field_F)f, ex);
259  shift.forward(trf2, trf, m_boundary[mu], mu);
260  mult_GMproj2(vt, 1, m_GM[mu], trf2);
261  w.addpart_ex(ex, vt, 0);
262  }
263  }
264 
265 
266 //====================================================================
268  {
269  // This counting is based on the Org-implementation of ver.1.2.0.
270  // Flop count of mult_GMproj2 is different for upward and downward
271  // directions due to the implemetation in Field_F.cpp.
272  // The present counting is based on rev.1130. [10 Sep 2014 H.Matsufuru]
273 
274  int Lvol = CommonParameters::Lvol();
275  int Nc = m_Nc;
276  int Nd = m_Nd;
277 
278  int flop_per_site = Nc * Nd * 2 * 8 * (4 * Nc - 1); // #(mult_Field_Gn/d)
279 
280  flop_per_site += Nc * Nd * 2 * (4 * 3 + 4 * 2); // #(mult_GMproj2)
281  flop_per_site += Nc * Nd * 2 * 8; // #(addpart_ex)
282  flop_per_site += Nc * Nd * 2 * 2; // #(aypx(kappa))
283 
284  double flop = static_cast<double>(flop_per_site) *
285  static_cast<double>(Lvol);
286 
287  if ((m_mode == "DdagD") || (m_mode == "DDdag")) {
288  flop *= 2.0;
289  }
290 
291  return flop;
292  }
293 
294 
295 //====================================================================
296 }
297 //============================================================END=====
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:282
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:83
BridgeIO vout
Definition: bridgeIO.cpp:495
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:164
static const std::string class_name
Bridge::VerboseLevel m_vl
void general(const char *format,...)
Definition: bridgeIO.cpp:195
static Bridge::VerboseLevel Vlevel()
const Field_F mult_gm5p(int mu, const Field_F &w)
Container of Field-type object.
Definition: field.h:39
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:211
void proj_chiral(Field &w, const int ex1, const Field &v, const int ex2, const int ipm)
int nvol() const
Definition: field.h:116
void mult_gm5(Field &v, const Field &f)
gamma_5 multiplication. [31 Mar 2017 H.Matsufuru]
Class for parameters.
Definition: parameters.h:46
ShiftField_lex shift
void H(Field &w, const Field &f)
static int Lvol()
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:193
std::string get_mode() const
only for Fopr_Overlap
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:115
void set_parameters(const Parameters &params)
std::vector< int > m_boundary
void(Fopr_Wilson::* m_mult)(Field &, const Field &)
void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
void D(Field &v, const Field &f)
void mult_up(int mu, Field &w, const Field &f)
nearest neighbor hopping term: temporary entry [H.Matsufuru]
void init(std::string repr)
void backward(Field &, const Field &, const int mu)
int nex() const
Definition: field.h:117
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:39
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:168
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
void DDdag(Field &w, const Field &f)
void(Fopr_Wilson::* m_mult_dag)(Field &, const Field &)
void mult_dn(int mu, Field &w, const Field &f)
const Field_G * m_U
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:186
string get_string(const string &key) const
Definition: parameters.cpp:116
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:294
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)
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)