Bridge++  Ver. 1.2.x
 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::valarray;
17 using std::string;
18 
19 const std::string Fopr_Wilson::Fopr_Wilson_impl::class_name = "Fopr_Wilson";
20 
21 //====================================================================
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  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  delete gmset;
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  abort();
76  }
77 
78 }
79 
80 //====================================================================
82 {
83  return m_mode;
84 }
85 
86 //====================================================================
87 void Fopr_Wilson::Fopr_Wilson_impl::set_parameters(const double kappa, const valarray<int> bc)
88 {
89  //- print input parameters
90  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
91  vout.general(m_vl, " kappa = %8.4f\n", kappa);
92  for (int mu = 0; mu < m_Ndim; ++mu) {
93  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
94  }
95 
96  //- range check
97  // NB. kappa = 0 is allowed.
98  assert(bc.size() == m_Ndim);
99 
100  //- store values
101  m_kappa = kappa;
102 
103  // m_boundary.resize(m_Ndim); // already resized in init.
104  for (int mu = 0; mu < m_Ndim; ++mu) {
105  m_boundary[mu] = bc[mu];
106  }
107 }
108 
109 //====================================================================
111 {
112  Field_F w(f.nvol(), f.nex());
113 
114  v = 0.0;
115  w = 0.0;
116  for (int mu = 0; mu < m_Ndim; ++mu) {
117  mult_up(mu, w, f);
118  mult_dn(mu, w, f);
119  }
120 
121  v = (Field)w;
122 
123  v *= -m_kappa;
124  v += f;
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  w *= -m_kappa;
142 
143  v.addpart_ex(ex1, w, 0);
144 }
145 
146 //====================================================================
148 {
149  assert(v.nvol() == f.nvol());
150  assert(v.nex() == f.nex());
151  assert(v.nin() == f.nin());
152 
153  Field_F vt(f.nvol(), f.nex());
154 
155  mult_GM(vt, m_GM[4], (Field_F)f);
156  v = (Field)vt;
157 }
158 
159 //====================================================================
160 void Fopr_Wilson::Fopr_Wilson_impl::proj_chiral(Field& w, const int ex1, const Field& v, const int ex2, const int ipm)
161 {
162  assert(ipm == 1 || ipm == -1);
163 
164  Field vv(v.nin(), v.nvol(), 1);
165  vv.setpart_ex(0, v, ex2);
166 
167  Field ww(v.nin(), v.nvol(), 1);
168  mult_gm5(ww, vv);
169 
170  if (ipm == 1) {
171  } else if (ipm == -1) {
172  ww *= -1;
173  }
174 
175  w.addpart_ex(ex1, ww, 0);
176 }
177 
178 //====================================================================
180 {
181  Field_F vt, v;
182 
183  vt = 0.0;
184 
185  assert(mu >= 0);
186  assert(mu < m_Ndim);
187 
188  mult_up(mu, vt, w);
189 
190  mult_gm5(v, vt);
191 
192  return v;
193 }
194 
195 //====================================================================
197 {
198  assert(mu >= 0);
199  assert(mu < m_Ndim);
200 
201  Field_F vt;
202 
203  mult_up(mu, vt, w);
204  mult_gm5(v, vt);
205 }
206 
207 //====================================================================
208 void Fopr_Wilson::Fopr_Wilson_impl::mult_up(int mu, Field& w, const Field& f)
209 {
210  Field_F vt(f.nvol(), 1);
211 
212  for (int ex = 0; ex < f.nex(); ++ex) {
213  vt.setpart_ex(0, f, ex);
214  shift.backward(trf, f, m_boundary[mu], mu);
215  mult_Field_Gn(trf2, 0, *m_U, mu, trf, 0);
216  mult_GMproj2(vt, -1, m_GM[mu], trf2);
217  w.addpart_ex(ex, vt, 0);
218  }
219 
220 }
221 
222 //====================================================================
223 void Fopr_Wilson::Fopr_Wilson_impl::mult_dn(int mu, Field& w, const Field& f)
224 {
225  Field_F vt(f.nvol(), 1);
226 
227  for (int ex = 0; ex < f.nex(); ++ex) {
228  mult_Field_Gd(trf, 0, *m_U, mu, (Field_F)f, ex);
229  shift.forward(trf2, trf, m_boundary[mu], mu);
230  mult_GMproj2(vt, 1, m_GM[mu], trf2);
231  w.addpart_ex(ex, vt, 0);
232  }
233 
234 }
235 
236 //====================================================================
238 {
239  // This counting is based on the Org-implementation of ver.1.2.0.
240  // Flop count of mult_GMproj2 is different for upward and downward
241  // directions due to the implemetation in Field_F.cpp.
242  // The present counting is based on rev.1130. [10 Sep 2014 H.Matsufuru]
243 
244  int Lvol = CommonParameters::Lvol();
245  int Nc = m_Nc;
246  int Nd = m_Nd;
247 
248  int flop_per_site = Nc * Nd * 2 * 8 * (4 * Nc - 1); // #(mult_Field_Gn/d)
249 
250  flop_per_site += Nc * Nd * 2 * (4 * 3 + 4 * 2); // #(mult_GMproj2)
251  flop_per_site += Nc * Nd * 2 * 8; // #(addpart_ex)
252  flop_per_site += Nc * Nd * 2 * 2; // #(aypx(kappa))
253 
254  double flop = static_cast<double>(flop_per_site) *
255  static_cast<double>(Lvol);
256 
257  if ((m_mode == "DdagD") || (m_mode == "DDdag")) {
258  flop *= 2.0;
259  }
260 
261  return flop;
262 }
263 
264 //====================================================================
265 //============================================================END=====
void mult_Field_Gd(Field_F &y, const int ex, const Field_G &u, int ex1, const Field_F &x, int ex2)
BridgeIO vout
Definition: bridgeIO.cpp:207
void set_parameters(const double kappa, const std::valarray< int > bc)
void proj_chiral(Field &w, const int ex1, const Field &v, const int ex2, const int ipm)
void general(const char *format,...)
Definition: bridgeIO.cpp:38
GammaMatrix get_GM(GMspecies spec)
static Bridge::VerboseLevel Vlevel()
int shift(void)
Container of Field-type object.
Definition: field.h:37
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:101
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.
void H(Field &w, const Field &f)
static int Lvol()
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:162
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:100
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:99
void mult_dn(int mu, Field &w, const Field &v)
std::valarray< GammaMatrix > m_GM
gamma matrices.
Set of Gamma Matrices: basis class.
int nex() const
Definition: field.h:102
static const std::string class_name
Definition: fopr_Wilson.h:56
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)
const Field_F mult_gm5p(int mu, const Field_F &w)
void crucial(const char *format,...)
Definition: bridgeIO.cpp:26
void set_mode(std::string mode)
void mult_GM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication
Definition: field_F_imp.cpp:39
std::valarray< int > m_boundary
boundary condition.
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:150
void mult_dn(int mu, Field &, const Field &)
void Ddag(Field &w, const Field &f)
void init(std::string repr)
const Field mult_gm5(const Field &f)
Definition: fopr_Wilson.h:91