Bridge++  Ver. 1.3.x
fopr_Wilson_General_impl.cpp
Go to the documentation of this file.
1 
15 
16 const std::string Fopr_Wilson_General::Fopr_Wilson_General_impl::class_name = "Fopr_Wilson_General";
17 
18 //====================================================================
20 {
22 
25 
28  m_boundary.resize(m_Ndim);
29 
30  m_U = 0;
31 
32  m_repr = repr;
33 
34  m_GM.resize(m_Ndim + 1);
35 
36  unique_ptr<GammaMatrixSet> gmset(GammaMatrixSet::New(m_repr));
37 
38  m_GM[0] = gmset->get_GM(GammaMatrixSet::GAMMA1);
39  m_GM[1] = gmset->get_GM(GammaMatrixSet::GAMMA2);
40  m_GM[2] = gmset->get_GM(GammaMatrixSet::GAMMA3);
41  m_GM[3] = gmset->get_GM(GammaMatrixSet::GAMMA4);
42  m_GM[4] = gmset->get_GM(GammaMatrixSet::GAMMA5);
43 
46 }
47 
48 
49 //====================================================================
51 {
52  m_mode = mode;
53 
54  if (m_mode == "D") {
57  } else if (m_mode == "Ddag") {
60  } else if (m_mode == "DdagD") {
63  } else if (m_mode == "DDdag") {
66  } else if (m_mode == "H") {
69  } else {
70  vout.crucial(m_vl, "%s: input mode is undefined.\n", class_name.c_str());
71  exit(EXIT_FAILURE);
72  }
73 }
74 
75 
76 //====================================================================
78 {
79  return m_mode;
80 }
81 
82 
83 //====================================================================
85  const double kappa_t,
86  const double nu_s,
87  const double r_s,
88  const std::vector<int> bc)
89 {
90  //- print input parameters
91  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
92  vout.general(m_vl, " kappa_s = %12.8f\n", kappa_s);
93  vout.general(m_vl, " kappa_t = %12.8f\n", kappa_t);
94  vout.general(m_vl, " nu_s = %12.8f\n", nu_s);
95  vout.general(m_vl, " r_s = %12.8f\n", r_s);
96  for (int mu = 0; mu < m_Ndim; ++mu) {
97  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
98  }
99 
100  //- range check
101  // NB. kappa = 0 is allowed.
102  assert(bc.size() == m_Ndim);
103 
104  //- store values
105  m_kappa_s = kappa_s;
106  m_kappa_t = kappa_t;
107  m_nu_s = nu_s;
108  m_r_s = r_s;
109 
110  // m_boundary.resize(m_Ndim); // already resized in init.
111  for (int mu = 0; mu < m_Ndim; ++mu) {
112  m_boundary[mu] = bc[mu];
113  }
114 }
115 
116 
117 //====================================================================
119 {
120  Field_F w(f.nvol(), f.nex());
121 
122  v.set(0.0);
123  w.set(0.0);
124  for (int mu = 0; mu < m_Ndim; ++mu) {
125  mult_up(mu, w, f);
126  mult_dn(mu, w, f);
127  }
128 
129  v = (Field)w;
130 
131  axpy(v, 1.0, f); // v += f;
132 }
133 
134 
135 //====================================================================
136 void Fopr_Wilson_General::Fopr_Wilson_General_impl::D_ex(Field& v, const int ex1, const Field& f, const int ex2)
137 {
138  Field ff(f.nin(), f.nvol(), 1);
139 
140  ff.setpart_ex(0, f, ex2);
141 
142  Field w(f.nin(), f.nvol(), 1);
143 
144  for (int mu = 0; mu < m_Ndim; ++mu) {
145  mult_up(mu, w, ff);
146  mult_dn(mu, w, ff);
147  }
148 
149  v.addpart_ex(ex1, w, 0);
150 }
151 
152 
153 //====================================================================
155 {
156  assert(v.nvol() == f.nvol());
157  assert(v.nex() == f.nex());
158  assert(v.nin() == f.nin());
159 
160  Field_F vt(f.nvol(), f.nex());
161 
162  mult_GM(vt, m_GM[4], (Field_F)f);
163  v = (Field)vt;
164 }
165 
166 
167 //====================================================================
168 void Fopr_Wilson_General::Fopr_Wilson_General_impl::proj_chiral(Field& w, const int ex1, const Field& v, const int ex2, const int ipm)
169 {
170  assert(ipm == 1 || ipm == -1);
171 
172  Field vv(v.nin(), v.nvol(), 1);
173  vv.setpart_ex(0, v, ex2);
174 
175  Field ww(v.nin(), v.nvol(), 1);
176  mult_gm5(ww, vv);
177 
178  if (ipm == 1) {
179  } else if (ipm == -1) {
180  scal(ww, -1.0); // ww *= -1.0;
181  }
182 
183  w.addpart_ex(ex1, ww, 0);
184 }
185 
186 
187 //====================================================================
188 
189 /*
190 const Field_F Fopr_Wilson_General::Fopr_Wilson_General_impl::mult_gm5p(int mu, const Field_F& w)
191 {
192  Field_F vt, v;
193 
194  vt = 0.0;
195 
196  assert(mu >= 0);
197  assert(mu < m_Ndim);
198 
199  mult_up(mu, vt, w);
200  mult_gm5(v, vt);
201 
202  return v;
203 }
204 */
205 
206 //====================================================================
208 {
209  assert(mu >= 0);
210  assert(mu < m_Ndim);
211 
212  Field_F vt;
213 
214  mult_up(mu, vt, w);
215  mult_gm5(v, vt);
216 }
217 
218 
219 //====================================================================
221  const Field& f)
222 {
223  Field_F vt(f.nvol(), 1);
224 
225  if (mu < (m_Ndim - 1)) {
226  for (int ex = 0; ex < f.nex(); ++ex) {
227  vt.setpart_ex(0, f, ex);
228  m_shift.backward(m_trf, f, m_boundary[mu], mu); // m_trf(x) = f(x+mu)
229  mult_Field_Gn(m_trf2, 0, *m_U, mu, m_trf, 0); // m_trf2 = U[mu](x) * f(x+mu)
230  mult_GMproj2(vt, m_nu_s, -1, m_r_s, m_GM[mu], m_trf2); // vt = (nu - r * gamma[mu]) * m_trf2
231  w.addpart_ex(ex, vt, 0, -m_kappa_s); // vt *= -kappa_s
232  }
233  } else if (mu == (m_Ndim - 1)) {
234  for (int ex = 0; ex < f.nex(); ++ex) {
235  vt.setpart_ex(0, f, ex);
236  m_shift.backward(m_trf, f, m_boundary[mu], mu); // m_trf(x) = f(x+mu)
237  mult_Field_Gn(m_trf2, 0, *m_U, mu, m_trf, 0); // m_trf2 = U[mu](x) * f(x+mu)
238  mult_GMproj2(vt, -1, m_GM[mu], m_trf2); // vt = (1 - gamma[mu]) * m_trf2
239  w.addpart_ex(ex, vt, 0, -m_kappa_t); // vt *= -kappa_t
240  }
241  } else {
242  vout.crucial(m_vl, "%s: mu=%d is out of range.\n", class_name.c_str(), mu);
243  exit(EXIT_FAILURE);
244  }
245 }
246 
247 
248 //====================================================================
250  const Field& f)
251 {
252  Field_F vt(f.nvol(), 1);
253 
254  if (mu < (m_Ndim - 1)) {
255  for (int ex = 0; ex < f.nex(); ++ex) {
256  mult_Field_Gd(m_trf, 0, *m_U, mu, (Field_F)f, ex); // m_trf = U[mu]^{dagger}(x) * f(x)
257  m_shift.forward(m_trf2, m_trf, m_boundary[mu], mu); // m_trf2(x) = m_trf(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  mult_Field_Gd(m_trf, 0, *m_U, mu, (Field_F)f, ex); // m_trf = U[mu]^{dagger}(x) * f(x)
264  m_shift.forward(m_trf2, m_trf, m_boundary[mu], mu); // m_trf2(x) = m_trf(x-mu)
265  mult_GMproj2(vt, 1, m_GM[mu], m_trf2); // vt = (1 + gamma[mu]) * m_trf2
266  w.addpart_ex(ex, vt, 0, -m_kappa_t); // vt *= -kappa_t
267  }
268  } else {
269  vout.crucial(m_vl, "%s: mu=%d is out of range.\n", class_name.c_str(), mu);
270  exit(EXIT_FAILURE);
271  }
272 }
273 
274 
275 //====================================================================
277 {
278  // This counting is based on the Org-implementation of ver.1.2.0.
279  // Flop count of mult_GMproj2 is different for upward and downward
280  // directions due to the implemetation in Field_F.cpp.
281  // The present counting is based on rev.1130. [10 Sep 2014 H.Matsufuru]
282 
283  int Lvol = CommonParameters::Lvol();
284  int Nc = m_Nc;
285  int Nd = m_Nd;
286 
287  int flop_per_site = Nc * Nd * 2 * 8 * (4 * Nc - 1); // #(mult_Field_Gn/d)
288 
289  flop_per_site += Nc * Nd * 2 * (4 * 3 + 4 * 2); // #(mult_GMproj2)
290  flop_per_site += Nc * Nd * 2 * 8; // #(addpart_ex)
291  flop_per_site += Nc * Nd * 2 * 2; // #(aypx(kappa))
292 
293  double flop = static_cast<double>(flop_per_site) *
294  static_cast<double>(Lvol);
295 
296  if ((m_mode == "DdagD") || (m_mode == "DDdag")) {
297  flop *= 2.0;
298  }
299 
300  return flop;
301 }
302 
303 
304 //====================================================================
305 //============================================================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:278
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:155
void general(const char *format,...)
Definition: bridgeIO.cpp:65
void(Fopr_Wilson_General::Fopr_Wilson_General_impl::* m_mult)(Field &, const Field &)
std::vector< GammaMatrix > m_GM
gamma matrices.
static Bridge::VerboseLevel Vlevel()
Container of Field-type object.
Definition: field.h:39
int nvol() const
Definition: field.h:116
static int m_Ndim
static int Lvol()
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:189
void set_parameters(const double kappa_s, const double kappa_t, const double nu_s, const double r_s, const std::vector< int > bc)
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
const Field_F mult_gm5p(int mu, const Field_F &w)
void mult_dn(int mu, Field &w, const Field &v)
Bridge::VerboseLevel m_vl
Definition: fopr.h:113
void mult_up(int mu, Field &w, const Field &v)
adding the hopping to nearest neighbor site in mu-th direction.
int nex() const
Definition: field.h:117
std::vector< int > m_boundary
boundary condition.
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 mult_gm5(Field &w, const Field &v)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:168
void crucial(const char *format,...)
Definition: bridgeIO.cpp:48
void mult_GM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication
void(Fopr_Wilson_General::Fopr_Wilson_General_impl::* m_mult_dag)(Field &, const Field &)
void D_ex(Field &v, const int ex1, const Field &f, const int ex2)
void proj_chiral(Field &w, const int ex1, const Field &v, const int ex2, const int ipm)
static const std::string class_name
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:177