Bridge++  Ver. 1.3.x
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 const std::string Fopr_Wilson::Fopr_Wilson_impl::class_name = "Fopr_Wilson";
19 
20 //====================================================================
22 {
24 
27 
30  m_boundary.resize(m_Ndim);
31 
32  m_U = 0;
33 
34  m_repr = repr;
35 
36  m_GM.resize(m_Ndim + 1);
37 
38  GammaMatrixSet *gmset = GammaMatrixSet::New(m_repr);
39 
40  m_GM[0] = gmset->get_GM(GammaMatrixSet::GAMMA1);
41  m_GM[1] = gmset->get_GM(GammaMatrixSet::GAMMA2);
42  m_GM[2] = gmset->get_GM(GammaMatrixSet::GAMMA3);
43  m_GM[3] = gmset->get_GM(GammaMatrixSet::GAMMA4);
44  m_GM[4] = gmset->get_GM(GammaMatrixSet::GAMMA5);
45 
48 
49  delete gmset;
50 }
51 
52 
53 //====================================================================
55 {
56  m_mode = mode;
57 
58  if (m_mode == "D") {
61  } else if (m_mode == "Ddag") {
64  } else if (m_mode == "DdagD") {
67  } else if (m_mode == "DDdag") {
70  } else if (m_mode == "H") {
73  } else {
74  vout.crucial(m_vl, "%s: input mode is undefined.\n", class_name.c_str());
75  exit(EXIT_FAILURE);
76  }
77 }
78 
79 
80 //====================================================================
82 {
83  return m_mode;
84 }
85 
86 
87 //====================================================================
88 void Fopr_Wilson::Fopr_Wilson_impl::set_parameters(const double kappa, 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 = %8.4f\n", kappa);
93  for (int mu = 0; mu < m_Ndim; ++mu) {
94  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
95  }
96 
97  //- range check
98  // NB. kappa = 0 is allowed.
99  assert(bc.size() == m_Ndim);
100 
101  //- store values
102  m_kappa = kappa;
103 
104  // m_boundary.resize(m_Ndim); // already resized in init.
105  for (int mu = 0; mu < m_Ndim; ++mu) {
106  m_boundary[mu] = bc[mu];
107  }
108 }
109 
110 
111 //====================================================================
113 {
114  Field_F w(f.nvol(), f.nex());
115 
116  v = f;
117  w.set(0.0);
118  for (int mu = 0; mu < m_Ndim; ++mu) {
119  mult_up(mu, w, f);
120  mult_dn(mu, w, f);
121  }
122 
123  axpy(v, -m_kappa, w);
124 }
125 
126 
127 //====================================================================
128 void Fopr_Wilson::Fopr_Wilson_impl::D_ex(Field& v, const int ex1, const Field& f, const int ex2)
129 {
130  Field ff(f.nin(), f.nvol(), 1);
131 
132  ff.setpart_ex(0, f, ex2);
133 
134  Field w(f.nin(), f.nvol(), 1);
135 
136  for (int mu = 0; mu < m_Ndim; ++mu) {
137  mult_up(mu, w, ff);
138  mult_dn(mu, w, ff);
139  }
140 
141  scal(w, -m_kappa);
142 
143  v.addpart_ex(ex1, w, 0);
144 }
145 
146 
147 //====================================================================
149 {
150  assert(v.nvol() == f.nvol());
151  assert(v.nex() == f.nex());
152  assert(v.nin() == f.nin());
153 
154  Field_F vt(f.nvol(), f.nex());
155 
156  mult_GM(vt, m_GM[4], (Field_F)f);
157  v = (Field)vt;
158 }
159 
160 
161 //====================================================================
162 void Fopr_Wilson::Fopr_Wilson_impl::proj_chiral(Field& w, const int ex1, const Field& v, const int ex2, const int ipm)
163 {
164  assert(ipm == 1 || ipm == -1);
165 
166  Field vv(v.nin(), v.nvol(), 1);
167  vv.setpart_ex(0, v, ex2);
168 
169  Field ww(v.nin(), v.nvol(), 1);
170  mult_gm5(ww, vv);
171 
172  if (ipm == 1) {
173  } else if (ipm == -1) {
174  scal(ww, -1.0);
175  }
176 
177  w.addpart_ex(ex1, ww, 0);
178 }
179 
180 
181 //====================================================================
182 
183 /*
184 const Field_F Fopr_Wilson::Fopr_Wilson_impl::mult_gm5p(int mu, const Field_F& w)
185 {
186  Field_F vt, v;
187 
188  vt.set(0.0);
189 
190  assert(mu >= 0);
191  assert(mu < m_Ndim);
192 
193  mult_up(mu, vt, w);
194 
195  mult_gm5(v, vt);
196 
197  return v;
198 }
199 */
200 
201 //====================================================================
203 {
204  assert(mu >= 0);
205  assert(mu < m_Ndim);
206 
207  Field_F vt;
208 
209  mult_up(mu, vt, w);
210  mult_gm5(v, vt);
211 }
212 
213 
214 //====================================================================
215 void Fopr_Wilson::Fopr_Wilson_impl::mult_up(int mu, Field& w, const Field& f)
216 {
217  Field_F vt(f.nvol(), 1);
218 
219  for (int ex = 0; ex < f.nex(); ++ex) {
220  vt.setpart_ex(0, f, ex);
221  shift.backward(trf, f, m_boundary[mu], mu);
222  mult_Field_Gn(trf2, 0, *m_U, mu, trf, 0);
223  mult_GMproj2(vt, -1, m_GM[mu], trf2);
224  w.addpart_ex(ex, vt, 0);
225  }
226 }
227 
228 
229 //====================================================================
230 void Fopr_Wilson::Fopr_Wilson_impl::mult_dn(int mu, Field& w, const Field& f)
231 {
232  Field_F vt(f.nvol(), 1);
233 
234  for (int ex = 0; ex < f.nex(); ++ex) {
235  mult_Field_Gd(trf, 0, *m_U, mu, (Field_F)f, ex);
236  shift.forward(trf2, trf, m_boundary[mu], mu);
237  mult_GMproj2(vt, 1, m_GM[mu], trf2);
238  w.addpart_ex(ex, vt, 0);
239  }
240 }
241 
242 
243 //====================================================================
245 {
246  // This counting is based on the Org-implementation of ver.1.2.0.
247  // Flop count of mult_GMproj2 is different for upward and downward
248  // directions due to the implemetation in Field_F.cpp.
249  // The present counting is based on rev.1130. [10 Sep 2014 H.Matsufuru]
250 
251  int Lvol = CommonParameters::Lvol();
252  int Nc = m_Nc;
253  int Nd = m_Nd;
254 
255  int flop_per_site = Nc * Nd * 2 * 8 * (4 * Nc - 1); // #(mult_Field_Gn/d)
256 
257  flop_per_site += Nc * Nd * 2 * (4 * 3 + 4 * 2); // #(mult_GMproj2)
258  flop_per_site += Nc * Nd * 2 * 8; // #(addpart_ex)
259  flop_per_site += Nc * Nd * 2 * 2; // #(aypx(kappa))
260 
261  double flop = static_cast<double>(flop_per_site) *
262  static_cast<double>(Lvol);
263 
264  if ((m_mode == "DdagD") || (m_mode == "DDdag")) {
265  flop *= 2.0;
266  }
267 
268  return flop;
269 }
270 
271 
272 //====================================================================
273 //============================================================END=====
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:282
std::vector< GammaMatrix > m_GM
gamma matrices.
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_parameters(const double kappa, const std::vector< int > bc)
std::vector< int > m_boundary
boundary condition.
void proj_chiral(Field &w, const int ex1, const Field &v, const int ex2, const int ipm)
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
GammaMatrix get_GM(GMspecies spec)
static Bridge::VerboseLevel Vlevel()
int shift(void)
Container of Field-type object.
Definition: field.h:39
void D_ex(Field &v, const int ex1, const Field &f, const int ex2)
void D(Field &v, const Field &f)
int nvol() const
Definition: field.h:116
void(Fopr_Wilson::Fopr_Wilson_impl::* m_mult_dag)(Field &, const Field &)
void mult_up(int mu, Field &w, const Field &v)
adding the hopping to nearest neighbor site in mu-th direction.
static int m_Ndim
void H(Field &w, const Field &f)
static int Lvol()
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:189
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)
void DdagD(Field &w, const Field &f)
int nin() const
Definition: field.h:115
const Field_G * m_U
gauge configuration.
void(Fopr_Wilson::Fopr_Wilson_impl::* m_mult)(Field &, const Field &)
void DDdag(Field &w, const Field &f)
Bridge::VerboseLevel m_vl
Definition: fopr.h:113
void mult_dn(int mu, Field &w, const Field &v)
Set of Gamma Matrices: basis class.
int nex() const
Definition: field.h:117
static const std::string class_name
Definition: fopr_Wilson.h:57
static const std::string class_name
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
const Field_F mult_gm5p(int mu, const Field_F &w)
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 set_mode(std::string mode)
void mult_GM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication
void mult_gm5(Field &w, const Field &v)
void mult_up(int mu, Field &, const Field &)
void mult_gm5(Field &v, const Field &f)
void mult_undef(Field &, const Field &f)
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:177
void mult_dn(int mu, Field &, const Field &)
void Ddag(Field &w, const Field &f)
void init(std::string repr)