Bridge++  Ver. 1.1.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fopr_Staggered_eo.cpp
Go to the documentation of this file.
1 
15 #include "fopr_Staggered_eo.h"
16 
17 #ifdef USE_PARAMETERS_FACTORY
18 #include "parameters_factory.h"
19 #endif
20 
21 using std::valarray;
22 
23 //- parameter entries
24 namespace {
25  void append_entry(Parameters& param)
26  {
27  param.Register_double("quark_mass", 0.0);
28  param.Register_int_vector("boundary_condition", std::valarray<int>());
29 
30  param.Register_string("verbose_level", "NULL");
31  }
32 
33 
34 #ifdef USE_PARAMETERS_FACTORY
35  bool init_param = ParametersFactory::Register("Fopr.Staggered_eo", append_entry);
36 #endif
37 }
38 //- end
39 
40 //- parameters class
42 //- end
43 
44 //====================================================================
46 {
47  const string str_vlevel = params.get_string("verbose_level");
48 
49  m_vl = vout.set_verbose_level(str_vlevel);
50 
51  //- fetch and check input parameters
52  double mq;
53  valarray<int> bc;
54 
55  int err = 0;
56  err += params.fetch_double("quark_mass", mq);
57  err += params.fetch_int_vector("boundary_condition", bc);
58 
59  if (err) {
60  vout.crucial(m_vl, "Fopr_Staggered_eo: fetch error, input parameter not found.\n");
61  abort();
62  }
63 
64 
65  set_parameters(mq, bc);
66 }
67 
68 
69 //====================================================================
70 void Fopr_Staggered_eo::set_parameters(const double mq, const std::valarray<int> bc)
71 {
72  //- print input parameters
73  vout.general(m_vl, "Parameters of staggered fermion operator:\n");
74  vout.general(m_vl, " mq = %8.4f\n", mq);
75  for (int mu = 0; mu < m_Ndim; ++mu) {
76  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
77  }
78 
79  //- range check
80  int err = 0;
81  err += ParameterCheck::non_zero(mq);
82 
83  if (err) {
84  vout.crucial(m_vl, "Fopr_Staggered_eo: parameter range check failed.\n");
85  abort();
86  }
87 
88  assert(bc.size() == m_Ndim);
89 
90  //- store values
91  m_mq = mq;
92  // m_boundary.resize(m_Ndim); // already resized in the constructor.
93  for (int mu = 0; mu < m_Ndim; ++mu) {
94  m_boundary[mu] = bc[mu];
95  }
96 }
97 
98 
99 //====================================================================
101 {
102  int Nt = CommonParameters::Nt();
103  int Nz = CommonParameters::Nz();
104  int Ny = CommonParameters::Ny();
105  int Nx = CommonParameters::Nx();
106  int Nvol = CommonParameters::Nvol();
107 
108  Field phase_lex(1, Nvol, m_Ndim);
109  Index_lex idx_lex;
110 
111  int ipex = Communicator::ipe(0);
112  int ipey = Communicator::ipe(1);
113  int ipez = Communicator::ipe(2);
114  int ipet = Communicator::ipe(3);
115 
116  for (int t = 0; t < Nt; ++t) {
117  int t2 = t + ipet * Nt;
118  for (int z = 0; z < Nz; ++z) {
119  int z2 = z + ipez * Nz;
120  for (int y = 0; y < Ny; ++y) {
121  int y2 = y + ipey * Ny;
122  for (int x = 0; x < Nx; ++x) {
123  int x2 = x + ipex * Nx;
124  int is = idx_lex.site(x, y, z, t);
125 
126  phase_lex.set(0, is, 0, 1.0);
127  phase_lex.set(0, is, 1, 1.0);
128  phase_lex.set(0, is, 2, 1.0);
129  phase_lex.set(0, is, 3, 1.0);
130 
131  if (((x2 + 1) % 2) == 1) phase_lex.set(0, is, 1, -1.0);
132  if (((x2 + y2 + 2) % 2) == 1) phase_lex.set(0, is, 2, -1.0);
133  if (((x2 + y2 + z2 + 3) % 2) == 1) phase_lex.set(0, is, 3, -1.0);
134  }
135  }
136  }
137  }
138 
140 }
141 
142 
143 //====================================================================
145 {
146  int Nvol = CommonParameters::Nvol();
147  int Nvol2 = Nvol / 2;
148 
149  int Nin = v.nin();
150  int Nex = v.nex();
151 
152  assert(v.nvol() == Nvol2);
153 
154  for (int ex = 0; ex < Nex; ++ex) {
155  for (int site = 0; site < Nvol2; ++site) {
156  int site2 = m_idx.site(site, ieo);
157 
158  for (int in = 0; in < Nin; ++in) {
159  double vt = m_staggered_phase.cmp(0, site2, mu) * v.cmp(in, site, ex);
160  v.set(in, site, ex, vt);
161  }
162  }
163  }
164 }
165 
166 
167 //====================================================================
169 {
170  int Nc = CommonParameters::Nc();
171  double ur, ui;
172 
173  for (int mu = 0; mu < m_Ndim; ++mu) {
174  for (int site = 0; site < m_Nvol; ++site) {
175  for (int cc = 0; cc < Nc * Nc; ++cc) {
176  ur = m_staggered_phase.cmp(0, site, mu) * Ueo->cmp_r(cc, site, mu);
177  ui = m_staggered_phase.cmp(0, site, mu) * Ueo->cmp_i(cc, site, mu);
178 
179  m_Ueo->set_ri(cc, site, mu, ur, ui);
180  }
181  }
182  }
183 }
184 
185 
186 //====================================================================
187 const Field Fopr_Staggered_eo::Meo(const Field& f, const int ieo)
188 {
189  int NinF = 2 * CommonParameters::Nc();
190 
191  assert(f.nin() == NinF);
192  assert(f.nvol() == m_Nvol2);
193  assert(f.nex() == 1);
194 
195  Field_F_1spinor w(m_Nvol2, 1);
196  w = 0.0;
197 
198  mult_xp(w, (Field_F_1spinor)f, ieo);
199  mult_xm(w, (Field_F_1spinor)f, ieo);
200 
201  mult_yp(w, (Field_F_1spinor)f, ieo);
202  mult_ym(w, (Field_F_1spinor)f, ieo);
203 
204  mult_zp(w, (Field_F_1spinor)f, ieo);
205  mult_zm(w, (Field_F_1spinor)f, ieo);
206 
207  mult_tp(w, (Field_F_1spinor)f, ieo);
208  mult_tm(w, (Field_F_1spinor)f, ieo);
209 
210  w *= 0.5 / m_mq;
211 
212  return (Field)w;
213 }
214 
215 
216 //====================================================================
218  const int ieo)
219 {
220  shift.backward_h(*tr, f, m_boundary[0], 0, ieo);
221 
222  for (int ix = 0; ix < m_Nvol2; ++ix) {
223  int gx = m_idx.site(ix, ieo);
224  w.add_vec(ix, 0, m_Ueo->mat(gx, 0) * tr->vec(ix));
225  }
226 }
227 
228 
229 //====================================================================
231  const int ieo)
232 {
233  for (int ix = 0; ix < m_Nvol2; ++ix) {
234  int gx = m_idx.site(ix, 1 - ieo);
235  tr->set_vec(ix, 0, m_Ueo->mat_dag(gx, 0) * f.vec(ix));
236  }
237 
238  shift.forward_h(*tr2, *tr, m_boundary[0], 0, ieo);
239  w -= *tr2;
240 }
241 
242 
243 //====================================================================
245  const int ieo)
246 {
247  shift.backward_h(*tr, f, m_boundary[1], 1, ieo);
248 
249  for (int ix = 0; ix < m_Nvol2; ++ix) {
250  int gx = m_idx.site(ix, ieo);
251  w.add_vec(ix, 0, m_Ueo->mat(gx, 1) * tr->vec(ix));
252  }
253 }
254 
255 
256 //====================================================================
258  const int ieo)
259 {
260  for (int ix = 0; ix < m_Nvol2; ++ix) {
261  int gx = m_idx.site(ix, 1 - ieo);
262  tr->set_vec(ix, 0, m_Ueo->mat_dag(gx, 1) * f.vec(ix));
263  }
264 
265  shift.forward_h(*tr2, *tr, m_boundary[1], 1, ieo);
266 
267  w -= *tr2;
268 }
269 
270 
271 //====================================================================
273  const int ieo)
274 {
275  shift.backward_h(*tr, f, m_boundary[2], 2, ieo);
276 
277  for (int ix = 0; ix < m_Nvol2; ++ix) {
278  int gx = m_idx.site(ix, ieo);
279  w.add_vec(ix, 0, m_Ueo->mat(gx, 2) * tr->vec(ix));
280  }
281 }
282 
283 
284 //====================================================================
286  const int ieo)
287 {
288  for (int ix = 0; ix < m_Nvol2; ++ix) {
289  int gx = m_idx.site(ix, 1 - ieo);
290  tr->set_vec(ix, 0, m_Ueo->mat_dag(gx, 2) * f.vec(ix));
291  }
292 
293  shift.forward_h(*tr2, *tr, m_boundary[2], 2, ieo);
294 
295  w -= *tr2;
296 }
297 
298 
299 //====================================================================
301  const int ieo)
302 {
303  shift.backward_h(*tr, f, m_boundary[3], 3, ieo);
304 
305  for (int ix = 0; ix < m_Nvol2; ++ix) {
306  int gx = m_idx.site(ix, ieo);
307  w.add_vec(ix, 0, m_Ueo->mat(gx, 3) * tr->vec(ix));
308  }
309 }
310 
311 
312 //====================================================================
314  const int ieo)
315 {
316  for (int ix = 0; ix < m_Nvol2; ++ix) {
317  int gx = m_idx.site(ix, 1 - ieo);
318  tr->set_vec(ix, 0, m_Ueo->mat_dag(gx, 3) * f.vec(ix));
319  }
320 
321  shift.forward_h(*tr2, *tr, m_boundary[3], 3, ieo);
322 
323  w -= *tr2;
324 }
325 
326 
327 //====================================================================
328 //============================================================END=====