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