Bridge++  Ver. 1.3.x
fopr_CloverTerm_eo.cpp
Go to the documentation of this file.
1 
14 #include "fopr_CloverTerm_eo.h"
15 
16 #include "threadManager_OpenMP.h"
17 #include "solver_CG.h"
18 
19 #ifdef USE_PARAMETERS_FACTORY
20 #include "parameters_factory.h"
21 #endif
22 
23 
24 #if defined USE_GROUP_SU3
25 #include "fopr_Wilson_impl_SU3.inc"
26 #elif defined USE_GROUP_SU2
27 #include "fopr_Wilson_impl_SU2.inc"
28 #elif defined USE_GROUP_SU_N
29 #include "fopr_Wilson_impl_SU_N.inc"
30 #endif
31 
32 //====================================================================
33 //- parameter entry
34 namespace {
35  void append_entry(Parameters& param)
36  {
37  param.Register_double("hopping_parameter", 0.0);
38  param.Register_double("clover_coefficient", 0.0);
39  param.Register_int_vector("boundary_condition", std::vector<int>());
40 
41  param.Register_string("verbose_level", "NULL");
42  }
43 
44 
45 #ifdef USE_PARAMETERS_FACTORY
46  bool init_param = ParametersFactory::Register("Fopr.CloverTerm_eo",
47  append_entry);
48 #endif
49 }
50 //- end
51 
52 //- parameters class
54 { append_entry(*this); }
55 //- end
56 
57 const std::string Fopr_CloverTerm_eo::class_name = "Fopr_CloverTerm_eo";
58 
59 //====================================================================
60 void Fopr_CloverTerm_eo::init(std::string repr)
61 {
62  m_repr = repr;
63 
67  m_NinF = 2 * m_Nc * m_Nd;
69  m_Nvol2 = m_Nvol / 2;
70 
71  m_boundary.resize(m_Ndim);
72 
73  m_Ueo = 0;
74 
75  m_GM.resize(m_Ndim + 1);
76  m_SG.resize(m_Ndim * m_Ndim);
77 
78  GammaMatrixSet *gmset = GammaMatrixSet::New(m_repr);
79 
80  m_GM[0] = gmset->get_GM(gmset->GAMMA1);
81  m_GM[1] = gmset->get_GM(gmset->GAMMA2);
82  m_GM[2] = gmset->get_GM(gmset->GAMMA3);
83  m_GM[3] = gmset->get_GM(gmset->GAMMA4);
84  m_GM[4] = gmset->get_GM(gmset->GAMMA5);
85 
86  m_SG[sg_index(0, 1)] = gmset->get_GM(gmset->SIGMA12);
87  m_SG[sg_index(1, 2)] = gmset->get_GM(gmset->SIGMA23);
88  m_SG[sg_index(2, 0)] = gmset->get_GM(gmset->SIGMA31);
89  m_SG[sg_index(3, 0)] = gmset->get_GM(gmset->SIGMA41);
90  m_SG[sg_index(3, 1)] = gmset->get_GM(gmset->SIGMA42);
91  m_SG[sg_index(3, 2)] = gmset->get_GM(gmset->SIGMA43);
92 
93  m_SG[sg_index(1, 0)] = m_SG[sg_index(0, 1)].mult(-1);
94  m_SG[sg_index(2, 1)] = m_SG[sg_index(1, 2)].mult(-1);
95  m_SG[sg_index(0, 2)] = m_SG[sg_index(2, 0)].mult(-1);
96  m_SG[sg_index(0, 3)] = m_SG[sg_index(3, 0)].mult(-1);
97  m_SG[sg_index(1, 3)] = m_SG[sg_index(3, 1)].mult(-1);
98  m_SG[sg_index(2, 3)] = m_SG[sg_index(3, 2)].mult(-1);
99 
100  m_SG[sg_index(0, 0)] = gmset->get_GM(gmset->UNITY);
101  m_SG[sg_index(1, 1)] = gmset->get_GM(gmset->UNITY);
102  m_SG[sg_index(2, 2)] = gmset->get_GM(gmset->UNITY);
103  m_SG[sg_index(3, 3)] = gmset->get_GM(gmset->UNITY);
104  // these 4 gamma matrices are actually not used.
105 
106  delete gmset;
107 
108  m_fee_inv = new Field_F(m_Nvol2, m_Nc * m_Nd);
109  m_foo_inv = new Field_F(m_Nvol2, m_Nc * m_Nd);
110 
111  m_vf.reset(m_Nvol2, 1);
112  m_ff.reset(m_Nvol2, 1);
113 }
114 
115 
116 //====================================================================
118 {
119  delete m_foo_inv;
120  delete m_fee_inv;
121 }
122 
123 
124 //====================================================================
126 {
127  const string str_vlevel = params.get_string("verbose_level");
128 
129  m_vl = vout.set_verbose_level(str_vlevel);
130 
131  //- fetch and check input parameters
132  double kappa, cSW;
133  std::vector<int> bc;
134 
135  int err = 0;
136  err += params.fetch_double("hopping_parameter", kappa);
137  err += params.fetch_double("clover_coefficient", cSW);
138  err += params.fetch_int_vector("boundary_condition", bc);
139 
140  if (err) {
141  vout.crucial(m_vl, "%s: fetch error, input parameter not found.\n", class_name.c_str());
142  exit(EXIT_FAILURE);
143  }
144 
145  set_parameters(kappa, cSW, bc);
146 }
147 
148 
149 //====================================================================
150 void Fopr_CloverTerm_eo::set_parameters(const double kappa, const double cSW,
151  const std::vector<int> bc)
152 {
153  //- print input parameters
154  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
155  vout.general(m_vl, " kappa = %8.4f\n", kappa);
156  vout.general(m_vl, " cSW = %8.4f\n", cSW);
157  for (int mu = 0; mu < m_Ndim; ++mu) {
158  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
159  }
160 
161  //- range check
162  // NB. kappa,cSW == 0 is allowed.
163  assert(bc.size() == m_Ndim);
164 
165  //- store values
166  m_kappa = kappa;
167  m_cSW = cSW;
168  assert(bc.size() == m_Ndim);
169  for (int mu = 0; mu < m_Ndim; ++mu) {
170  m_boundary[mu] = bc[mu];
171  }
172 }
173 
174 
175 //====================================================================
177 {
178  m_Ueo = (Field_G *)Ueo;
179 
180  set_csw();
181  solve_csw_inv();
182 }
183 
184 
185 //====================================================================
187 {
188  double eps2 = CommonParameters::epsilon_criterion2();
189 
190  Parameters *params_solver = ParametersFactory::New("Solver");
191 
192  params_solver->set_string("solver_type", "CG");
193  params_solver->set_int("maximum_number_of_iteration", 1000);
194  params_solver->set_double("convergence_criterion_squared", 1.0e-30);
195  //- NB. set VerboseLevel to CRUCIAL to suppress frequent messages.
196  params_solver->set_string("verbose_level", "Crucial");
197 
198  int Nconv;
199  double diff;
200 
201  Solver *solver = new Solver_CG(this);
202  solver->set_parameters(*params_solver);
203 
204  Field_F w(m_Nvol2);
205  Field_F w2(m_Nvol2);
206 
207  for (int ispin = 0; ispin < m_Nd; ++ispin) {
208  for (int icolor = 0; icolor < m_Nc; ++icolor) {
209  int spin_color = icolor + m_Nc * ispin;
210  w.set(0.0);
211  for (int isite = 0; isite < m_Nvol2; ++isite) {
212  w.set_ri(icolor, ispin, isite, 0, 1, 0);
213  }
214 
215  if (m_cSW * m_cSW < eps2) {
216  m_fee_inv->setpart_ex(spin_color, w, 0);
217  m_foo_inv->setpart_ex(spin_color, w, 0);
218  } else {
219  set_mode("even");
220  solver->solve(w2, w, Nconv, diff);
221  m_fee_inv->setpart_ex(spin_color, w2, 0);
222  vout.detailed(m_vl, " Nconv,diff = %d %12.4e\n", Nconv, diff);
223 
224  set_mode("odd");
225  solver->solve(w2, w, Nconv, diff);
226  m_foo_inv->setpart_ex(spin_color, w2, 0);
227  vout.detailed(m_vl, " Nconv,diff = %d %12.4e\n", Nconv, diff);
228  }
229  }
230  }
231 
232  delete params_solver;
233  delete solver;
234 
235  // redefine the inverse matrix with its dagger.
236  double re, im;
237  for (int ics = 0; ics < m_Nc * m_Nd; ++ics) {
238  for (int site = 0; site < m_Nvol2; ++site) {
239  for (int id = 0; id < m_Nd; ++id) {
240  for (int ic = 0; ic < m_Nc; ++ic) {
241  re = m_foo_inv->cmp_r(ic, id, site, ics);
242  im = m_foo_inv->cmp_i(ic, id, site, ics);
243  m_foo_inv->set_ri(ic, id, site, ics, re, -im);
244 
245  re = m_fee_inv->cmp_r(ic, id, site, ics);
246  im = m_fee_inv->cmp_i(ic, id, site, ics);
247  m_fee_inv->set_ri(ic, id, site, ics, re, -im);
248  }
249  }
250  }
251  }
252 }
253 
254 
255 //====================================================================
256 
257 /*
258 const Field_F Fopr_CloverTerm_eo::mult_csw_inv(const Field_F& f, const int ieo)
259 {
260  int nex = f.nex();
261  Field_F w(m_Nvol2, nex);
262 
263  mult_csw_inv(w, f, ieo);
264 
265  return w;
266 }
267 */
268 
269 //====================================================================
271  const Field& f, const int ieo)
272 {
273  if (m_repr == "Dirac") {
274  mult_csw_inv_dirac(v, f, ieo);
275  } else if (m_repr == "Chiral") {
276  mult_csw_inv_chiral(v, f, ieo);
277  }
278 }
279 
280 
281 //====================================================================
283  const Field& f, const int ieo)
284 {
285  int Nvc = 2 * m_Nc;
286 
287  const double *v1 = f.ptr(0);
288  double *v2 = v.ptr(0);
289  double *csw_inv;
290 
291  if (ieo == 0) {
292  csw_inv = m_fee_inv->ptr(0);
293  } else if (ieo == 1) {
294  csw_inv = m_foo_inv->ptr(0);
295 
296  /*
297  } else {
298  vout.crucial(m_vl, "%s: wrong parameter, ieo = %d.\n",
299  class_name.c_str(), ieo);
300  exit(EXIT_FAILURE);
301  */
302  }
303 
304 #pragma omp barrier
305 
306  // threadding applied.
309  int is = m_Nvol2 * ith / nth;
310  int ns = m_Nvol2 * (ith + 1) / nth;
311 
312  int Nd2 = m_Nd / 2;
313  for (int site = is; site < ns; ++site) {
314  for (int icd = 0; icd < m_Nc * Nd2; ++icd) {
315  int iv2 = 2 * icd + m_NinF * site;
316  v2[iv2] = 0.0;
317  v2[iv2 + 1] = 0.0;
318  for (int jd = 0; jd < m_Nd; ++jd) {
319  int jcd = Nvc * jd;
320  int iv = jcd + m_NinF * site;
321  int ig = jcd + m_NinF * (site + m_Nvol2 * icd);
322  v2[iv2] += mult_uv_r(&csw_inv[ig], &v1[iv], m_Nc);
323  v2[iv2 + 1] += mult_uv_i(&csw_inv[ig], &v1[iv], m_Nc);
324  }
325  }
326 
327  for (int icd = 0; icd < m_Nc * Nd2; ++icd) {
328  int iv2 = 2 * (icd + m_Nc * Nd2) + m_NinF * site;
329  v2[iv2] = 0.0;
330  v2[iv2 + 1] = 0.0;
331  for (int jd = 0; jd < m_Nd; ++jd) {
332  int jd2 = (jd + Nd2) % m_Nd;
333  int iv = Nvc * jd + m_NinF * site;
334  int ig = Nvc * jd2 + m_NinF * (site + m_Nvol2 * icd);
335  v2[iv2] += mult_uv_r(&csw_inv[ig], &v1[iv], m_Nc);
336  v2[iv2 + 1] += mult_uv_i(&csw_inv[ig], &v1[iv], m_Nc);
337  }
338  }
339  }
340 #pragma omp barrier
341 }
342 
343 
344 //====================================================================
346  const Field& f, const int ieo)
347 {
348  int Nvc = 2 * m_Nc;
349 
350  const double *v1 = f.ptr(0);
351  double *v2 = v.ptr(0);
352  double *csw_inv;
353 
354  if (ieo == 0) {
355  csw_inv = m_fee_inv->ptr(0);
356  } else if (ieo == 1) {
357  csw_inv = m_foo_inv->ptr(0);
358 
359  /*
360  } else {
361  vout.crucial(m_vl, "%s: wrong parameter, ieo = %d.\n",
362  class_name.c_str(), ieo);
363  exit(EXIT_FAILURE);
364  */
365  }
366 
367 #pragma omp barrier
368 
369  // threadding applied.
372  int is = m_Nvol2 * ith / nth;
373  int ns = m_Nvol2 * (ith + 1) / nth;
374 
375  for (int site = is; site < ns; ++site) {
376  for (int icd = 0; icd < m_Nc * m_Nd / 2; ++icd) {
377  int iv2 = 2 * icd + m_NinF * site;
378  v2[iv2] = 0.0;
379  v2[iv2 + 1] = 0.0;
380 
381  for (int jd = 0; jd < m_Nd / 2; ++jd) {
382  int jcd = Nvc * jd;
383  int iv = jcd + m_NinF * site;
384  int ig = jcd + m_NinF * (site + m_Nvol2 * icd);
385  v2[iv2] += mult_uv_r(&csw_inv[ig], &v1[iv], m_Nc);
386  v2[iv2 + 1] += mult_uv_i(&csw_inv[ig], &v1[iv], m_Nc);
387  }
388  }
389 
390  for (int icd = m_Nc * m_Nd / 2; icd < m_Nc * m_Nd; ++icd) {
391  int iv2 = 2 * icd + m_NinF * site;
392  v2[iv2] = 0.0;
393  v2[iv2 + 1] = 0.0;
394 
395  for (int jd = m_Nd / 2; jd < m_Nd; ++jd) {
396  int jcd = Nvc * jd;
397  int iv = jcd + m_NinF * site;
398  int ig = jcd + m_NinF * (site + m_Nvol2 * icd);
399  v2[iv2] += mult_uv_r(&csw_inv[ig], &v1[iv], m_Nc);
400  v2[iv2 + 1] += mult_uv_i(&csw_inv[ig], &v1[iv], m_Nc);
401  }
402  }
403  }
404 #pragma omp barrier
405 }
406 
407 
408 //====================================================================
409 std::vector<double> Fopr_CloverTerm_eo::csmatrix(const int& site)
410 {
411  std::vector<double> matrix(m_Nc * m_Nc * m_Nd * m_Nd * 2);
412 
413  for (int ispin = 0; ispin < m_Nd / 2; ++ispin) {
414  for (int icolor = 0; icolor < m_Nc; ++icolor) {
415  int ics = icolor + ispin * m_Nc;
416  for (int jspin = 0; jspin < m_Nd; ++jspin) {
417  int js2 = (jspin + m_Nd / 2) % m_Nd;
418  for (int jcolor = 0; jcolor < m_Nc; ++jcolor) {
419  int cs1 = jcolor + m_Nc * (jspin + m_Nd * ics);
420  int cs2 = jcolor + m_Nc * (jspin + m_Nd * (ics + m_Nc * m_Nd / 2));
421  int cc = jcolor + icolor * m_Nc;
422  int ss1 = jspin + ispin * m_Nd;
423  int ss2 = js2 + ispin * m_Nd;
424 
425  matrix[2 * cs1] = m_T.cmp_r(cc, site, ss1);
426  matrix[2 * cs1 + 1] = m_T.cmp_i(cc, site, ss1);
427 
428  matrix[2 * cs2] = m_T.cmp_r(cc, site, ss2);
429  matrix[2 * cs2 + 1] = m_T.cmp_i(cc, site, ss2);
430  }
431  }
432  }
433  }
434 
435  return matrix;
436 }
437 
438 
439 //====================================================================
440 void Fopr_CloverTerm_eo::D(Field& v, const Field& f, const int ieo)
441 {
442  if (m_repr == "Dirac") {
443  D_dirac(v, f, ieo);
444  } else if (m_repr == "Chiral") {
445  D_chiral(v, f, ieo);
446  }
447 }
448 
449 
450 //====================================================================
451 void Fopr_CloverTerm_eo::D_dirac(Field& v, const Field& f, const int ieo)
452 {
453  // assert(f.nvol() == m_Nvol2);
454  // assert(f.nex() == 1);
455  // assert(v.nvol() == m_Nvol2);
456  // assert(v.nex() == 1);
457 
458  const double *fp = f.ptr(0);
459  double *vp = v.ptr(0);
460  double *tp = m_T.ptr(0, m_Nvol2 * ieo, 0);
461 
464  int is = m_Nvol2 * ith / nth;
465  int ns = m_Nvol2 * (ith + 1) / nth;
466 
467  int Nvc = 2 * m_Nc;
468  int Nd2 = m_Nd / 2;
469  int NinF = 2 * m_Nc * m_Nd;
470  int NinG = 2 * m_Nc * m_Nc;
471 
472  for (int site = is; site < ns; ++site) {
473  for (int id = 0; id < Nd2; ++id) {
474  for (int ic = 0; ic < m_Nc; ++ic) {
475  int icd = ic + m_Nc * id;
476 
477  int iv2 = 2 * icd + NinF * site;
478  vp[iv2] = 0.0;
479  vp[iv2 + 1] = 0.0;
480  for (int jd = 0; jd < m_Nd; ++jd) {
481  int iv = Nvc * jd + NinF * site;
482  int ig = Nvc * ic + NinG * (site + m_Nvol * (id * m_Nd + jd));
483  vp[iv2] += mult_uv_r(&tp[ig], &fp[iv], m_Nc);
484  vp[iv2 + 1] += mult_uv_i(&tp[ig], &fp[iv], m_Nc);
485  }
486 
487  iv2 += Nvc * Nd2;
488  vp[iv2] = 0.0;
489  vp[iv2 + 1] = 0.0;
490  for (int jd = 0; jd < m_Nd; ++jd) {
491  int jd2 = (2 + jd) % m_Nd;
492  int iv = Nvc * jd + NinF * site;
493  int ig = Nvc * ic + NinG * (site + m_Nvol * (id * m_Nd + jd2));
494  vp[iv2] += mult_uv_r(&tp[ig], &fp[iv], m_Nc);
495  vp[iv2 + 1] += mult_uv_i(&tp[ig], &fp[iv], m_Nc);
496  }
497  }
498  }
499  }
500 #pragma omp barrier
501 }
502 
503 
504 //====================================================================
505 void Fopr_CloverTerm_eo::D_chiral(Field& v, const Field& f, const int ieo)
506 {
507  const double *fp = f.ptr(0);
508  double *vp = v.ptr(0);
509  double *tp = m_T.ptr(0, m_Nvol2 * ieo, 0);
510 
513  int is = m_Nvol2 * ith / nth;
514  int ns = m_Nvol2 * (ith + 1) / nth;
515 
516  int Nvc = 2 * m_Nc;
517  int Nd2 = m_Nd / 2;
518  int NinF = 2 * m_Nc * m_Nd;
519  int NinG = 2 * m_Nc * m_Nc;
520 
521  for (int site = is; site < ns; ++site) {
522  for (int id = 0; id < Nd2; ++id) {
523  for (int ic = 0; ic < m_Nc; ++ic) {
524  int icd = ic + m_Nc * id;
525 
526  int iv2 = 2 * icd + NinF * site;
527  vp[iv2] = 0.0;
528  vp[iv2 + 1] = 0.0;
529  for (int jd = 0; jd < Nd2; ++jd) {
530  int iv = Nvc * jd + NinF * site;
531  int ig = Nvc * ic + NinG * (site + m_Nvol * (id * Nd2 + jd));
532  vp[iv2] += mult_uv_r(&tp[ig], &fp[iv], m_Nc);
533  vp[iv2 + 1] += mult_uv_i(&tp[ig], &fp[iv], m_Nc);
534  }
535 
536  iv2 += Nvc * Nd2;
537  vp[iv2] = 0.0;
538  vp[iv2 + 1] = 0.0;
539  for (int jd = 0; jd < Nd2; ++jd) {
540  int iv = Nvc * (Nd2 + jd) + NinF * site;
541  int ig = Nvc * ic + NinG * (site + m_Nvol * (m_Nd + id * Nd2 + jd));
542  vp[iv2] += mult_uv_r(&tp[ig], &fp[iv], m_Nc);
543  vp[iv2 + 1] += mult_uv_i(&tp[ig], &fp[iv], m_Nc);
544  }
545  }
546  }
547  }
548 #pragma omp barrier
549 }
550 
551 
552 //====================================================================
554  const int mu, const int nu)
555 {
556  assert(mu != nu);
557  mult_iGM(v, m_SG[sg_index(mu, nu)], w);
558 }
559 
560 
561 //====================================================================
563 {
564  if (m_repr == "Dirac") {
565  set_csw_dirac();
566  } else if (m_repr == "Chiral") {
567  set_csw_chiral();
568  } else {
569  vout.crucial(m_vl, "%s: unsupported gamma matrix repr. %s.\n",
570  class_name.c_str(), m_repr.c_str());
571  exit(EXIT_FAILURE);
572  }
573 }
574 
575 
576 //====================================================================
578 {
579  // The clover term in the Dirac representation is as spin-space
580  // matrix
581  // [ P Q ]
582  // [ Q P ],
583  // where P and Q are 2x2 block matrices as
584  // P = [ iF(1,2) F(3,1) + iF(2,3) ]
585  // [-F(3,1) + iF(2,3) - iF(1,2) ]
586  // and
587  // Q = [ - iF(4,3) -F(4,2) - iF(4,1) ]
588  // [ F(4,2) - iF(4,1) iF(4,3) ]
589  // up to the coefficient.
590  // in the following what defined is
591  // [ P Q ] = [ T(0) T(1) T(2) T(3) ]
592  // [ T(4) T(5) T(6) T(7) ].
593 
594  m_T.set(0.0);
595 
596  //- sigma23
597  Field_G F;
598  set_fieldstrength(F, 1, 2);
599  F.xI();
600  axpy(m_T, 1, 1.0, F, 0);
601  axpy(m_T, 4, 1.0, F, 0);
602 
603  //- sigma31
604  set_fieldstrength(F, 2, 0);
605  axpy(m_T, 1, 1.0, F, 0);
606  axpy(m_T, 4, -1.0, F, 0);
607 
608  //- sigma12
609  set_fieldstrength(F, 0, 1);
610  F.xI();
611  axpy(m_T, 0, 1.0, F, 0);
612  axpy(m_T, 5, -1.0, F, 0);
613 
614  //- sigma41
615  set_fieldstrength(F, 3, 0);
616  F.xI();
617  axpy(m_T, 3, -1.0, F, 0);
618  axpy(m_T, 6, -1.0, F, 0);
619 
620  //- sigma42
621  set_fieldstrength(F, 3, 1);
622  axpy(m_T, 3, -1.0, F, 0);
623  axpy(m_T, 6, 1.0, F, 0);
624 
625  //- sigma43
626  set_fieldstrength(F, 3, 2);
627  F.xI();
628  axpy(m_T, 2, -1.0, F, 0);
629  axpy(m_T, 7, 1.0, F, 0);
630 
631  scal(m_T, -m_kappa * m_cSW);
632 
633  Field_G Unity(m_Nvol, 1);
634  Unity.set_unit();
635  axpy(m_T, 0, 1.0, Unity, 0);
636  axpy(m_T, 5, 1.0, Unity, 0);
637 }
638 
639 
640 //====================================================================
642 {
643  // The clover term in the Dirac representation is
644  // as spin-space matrix
645  // [ P+Q 0 ]
646  // [ 0 P-Q ],
647  // where P and Q are 2x2 block matrices as
648  // [ iF(1,2) | F(3,1) + iF(2,3) ]
649  // P = [ -----------------+------------------ ]
650  // [-F(3,1) + iF(2,3) | - iF(1,2) ]
651  // and
652  // [ - iF(4,3) | -F(4,2) - iF(4,1) ]
653  // Q = [ -----------------+------------------ ]
654  // [ F(4,2) - iF(4,1) | iF(4,3) ]
655  // up to the coefficient.
656  // in the following what defined is
657  // [ T(0) | T(1) ] [ T(4) | T(5) ]
658  // P+Q = [ -----+----- ] P - Q = [ -----+----- ]
659  // [ T(2) | T(3) ] [ T(6) | T(7) ]
660 
661  m_T.set(0.0);
662 
663  Field_G F;
664 
665  //- sigma23
666  set_fieldstrength(F, 1, 2);
667  F.xI();
668  axpy(m_T, 1, 1.0, F, 0);
669  axpy(m_T, 2, 1.0, F, 0);
670  axpy(m_T, 5, 1.0, F, 0);
671  axpy(m_T, 6, 1.0, F, 0);
672 
673  //- sigma31
674  set_fieldstrength(F, 2, 0);
675  axpy(m_T, 1, 1.0, F, 0);
676  axpy(m_T, 2, -1.0, F, 0);
677  axpy(m_T, 5, 1.0, F, 0);
678  axpy(m_T, 6, -1.0, F, 0);
679 
680  //- sigma12
681  set_fieldstrength(F, 0, 1);
682  F.xI();
683  axpy(m_T, 0, 1.0, F, 0);
684  axpy(m_T, 3, -1.0, F, 0);
685  axpy(m_T, 4, 1.0, F, 0);
686  axpy(m_T, 7, -1.0, F, 0);
687 
688  //- sigma41
689  set_fieldstrength(F, 3, 0);
690  F.xI();
691  axpy(m_T, 1, -1.0, F, 0);
692  axpy(m_T, 2, -1.0, F, 0);
693  axpy(m_T, 5, 1.0, F, 0);
694  axpy(m_T, 6, 1.0, F, 0);
695 
696  //- sigma42
697  set_fieldstrength(F, 3, 1);
698  axpy(m_T, 1, -1.0, F, 0);
699  axpy(m_T, 2, 1.0, F, 0);
700  axpy(m_T, 5, 1.0, F, 0);
701  axpy(m_T, 6, -1.0, F, 0);
702 
703  //- sigma43
704  set_fieldstrength(F, 3, 2);
705  F.xI();
706  axpy(m_T, 0, -1.0, F, 0);
707  axpy(m_T, 3, 1.0, F, 0);
708  axpy(m_T, 4, 1.0, F, 0);
709  axpy(m_T, 7, -1.0, F, 0);
710 
711  scal(m_T, -m_kappa * m_cSW);
712 
713  Field_G Unity(m_Nvol, 1);
714  Unity.set_unit();
715  axpy(m_T, 0, 1.0, Unity, 0);
716  axpy(m_T, 3, 1.0, Unity, 0);
717  axpy(m_T, 4, 1.0, Unity, 0);
718  axpy(m_T, 7, 1.0, Unity, 0);
719 }
720 
721 
722 //====================================================================
724  const int mu, const int nu)
725 {
726  Staples_eo staple;
727 
728  Field_G Cup(m_Nvol, 1), Cdn(m_Nvol, 1);
729  Field_G Umu(m_Nvol, 1);
730  Field_G w(m_Nvol, 1), v(m_Nvol, 1), v2(m_Nvol, 1);
731 
732  staple.upper(Cup, m_Ueo, mu, nu);
733  staple.lower(Cdn, m_Ueo, mu, nu);
734  Umu.setpart_ex(0, *m_Ueo, mu);
735 
736  for (int site = 0; site < m_Nvol; ++site) {
737  w.set_mat(site, 0, Umu.mat(site) * Cup.mat_dag(site));
738  }
739 
740  for (int site = 0; site < m_Nvol; ++site) {
741  v2.set_mat(site, 0, Umu.mat(site) * Cdn.mat_dag(site));
742  }
743 
744  axpy(w, -1.0, v2);
745 
746  for (int site = 0; site < m_Nvol; ++site) {
747  v.set_mat(site, 0, Cup.mat_dag(site) * Umu.mat(site));
748  }
749 
750  for (int site = 0; site < m_Nvol; ++site) {
751  v2.set_mat(site, 0, Cdn.mat_dag(site) * Umu.mat(site));
752  }
753 
754  axpy(v, -1.0, v2);
755 
756  m_shift_eo.forward(v2, v, mu);
757 
758  axpy(w, 1.0, v2);
759 
760  for (int site = 0; site < m_Nvol; ++site) {
761  Fst.set_mat(site, 0, w.mat(site).ah());
762  }
763 
764  scal(Fst, 0.25);
765 }
766 
767 
768 //====================================================================
769 void Fopr_CloverTerm_eo::trSigmaInv(Field_G& tr_sigma_inv, const int mu, const int nu)
770 {
771  int nex_finv = m_fee_inv->nex();
772  Vec_SU_N v;
773  Field_F sigma_inv(m_Nvol, nex_finv);
774 
775  assert(tr_sigma_inv.nvol() == m_Nvol);
776  assert(tr_sigma_inv.nex() == 1);
777 
778  {
779  Field_F sigma_eo_inv(m_Nvol2, nex_finv);
780  mult_isigma(sigma_eo_inv, *m_fee_inv, mu, nu);
781  m_idx.reverseField(sigma_inv, sigma_eo_inv, 0);
782  mult_isigma(sigma_eo_inv, *m_foo_inv, mu, nu);
783  m_idx.reverseField(sigma_inv, sigma_eo_inv, 1);
784  }
785 
786  for (int isite = 0; isite < m_Nvol; ++isite) {
787  for (int ispin = 0; ispin < m_Nd; ++ispin) {
788  for (int icolor = 0; icolor < m_Nc; ++icolor) {
789  v = sigma_inv.vec(ispin, isite, icolor + m_Nc * ispin);
790  for (int jcolor = 0; jcolor < m_Nc; ++jcolor) {
791  int cc = icolor + m_Nc * jcolor;
792  tr_sigma_inv.set_r(cc, isite, 0, v.r(jcolor));
793  tr_sigma_inv.set_i(cc, isite, 0, v.i(jcolor));
794  }
795  }
796  }
797  }
798 }
799 
800 
801 //====================================================================
803 {
804  // The following counting explicitly depends on the implementation
805  // and to be recalculated when the code is modified.
806  // Present counting is based on rev.1107. [24 Aug 2014 H.Matsufuru]
807 
808  int Lvol = CommonParameters::Lvol();
809  double flop_site = 0.0;
810 
811  if (m_repr == "Dirac") {
812  flop_site = static_cast<double>(8 * m_Nc * m_Nc * m_Nd * m_Nd);
813  } else if (m_repr == "Chiral") {
814  flop_site = static_cast<double>(4 * m_Nc * m_Nc * m_Nd * m_Nd);
815  }
816 
817  double flop = flop_site * static_cast<double>(Lvol / 2);
818 
819  return flop;
820 }
821 
822 
823 //====================================================================
824 //============================================================END=====
void Register_int_vector(const string &, const std::vector< int > &)
Definition: parameters.cpp:344
Staple construction.
Definition: staples_eo.h:33
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:282
void D_chiral(Field &v, const Field &f, const int ieo)
explicit implementation for Chiral representation (for Imp-version).
BridgeIO vout
Definition: bridgeIO.cpp:278
void init(std::string repr)
double cmp_i(const int cc, const int s, const int site, const int e=0) const
Definition: field_F.h:101
void detailed(const char *format,...)
Definition: bridgeIO.cpp:82
static int get_num_threads()
returns available number of threads.
void Register_string(const string &, const string &)
Definition: parameters.cpp:351
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:133
double r(const int c) const
Definition: vec_SU_N.h:65
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)
void set_int(const string &key, const int value)
Definition: parameters.cpp:262
Container of Field-type object.
Definition: field.h:39
void D_dirac(Field &v, const Field &f, const int ieo)
explicit implementation for Dirac representation (for Imp-version).
int nvol() const
Definition: field.h:116
double cmp_i(const int cc, const int site, const int mn=0) const
Definition: field_G.h:91
Field_G m_T
m_T = 1 - kappa c_SW sigma F / 2
void set_csw_dirac()
explicit implementation for Dirac representation (for Imp-version).
const Field_G * m_Ueo
Class for parameters.
Definition: parameters.h:38
void mult_csw_inv_chiral(Field &, const Field &, const int ieo)
static int Lvol()
void set_parameters(const Parameters &params)
void mult_csw_inv(Field &, const Field &, const int ieo)
static Parameters * New(const std::string &realm)
Standard Conjugate Gradient solver algorithm.
Definition: solver_CG.h:43
std::vector< GammaMatrix > m_SG
static int get_thread_id()
returns thread id.
Wilson-type fermion field.
Definition: field_F.h:37
virtual void set_parameters(const Parameters &params)=0
void D(Field &v, const Field &f, const int ieo)
void set_string(const string &key, const string &value)
Definition: parameters.cpp:298
SU(N) gauge field.
Definition: field_G.h:38
static double epsilon_criterion2()
void reset(int Nvol, int Nex)
Definition: field_F.h:81
static const std::string class_name
void mult_iGM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication (i is multiplied)
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
double i(const int c) const
Definition: vec_SU_N.h:67
void set_ri(const int cc, const int s, const int site, const int e, const double re, const double im)
Definition: field_F.h:117
Bridge::VerboseLevel m_vl
Definition: fopr.h:113
void set_i(const int cc, const int site, const int mn, const double im)
Definition: field_G.h:101
Set of Gamma Matrices: basis class.
int nex() const
Definition: field.h:117
void set_fieldstrength(Field_G &, const int, const int)
void set_r(const int cc, const int site, const int mn, const double re)
Definition: field_G.h:96
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
std::vector< GammaMatrix > m_GM
Gamma Matrix and Sigma_{mu,nu} = -i [Gamma_mu, Gamma_nu] /2.
void trSigmaInv(Field_G &, const int mu, const int nu)
std::vector< int > m_boundary
Base class for linear solver class family.
Definition: solver.h:38
static bool Register(const std::string &realm, const creator_callback &cb)
void set_double(const string &key, const double value)
Definition: parameters.cpp:271
void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
void reverseField(Field &lex, const Field &eo)
Definition: index_eo.cpp:110
void upper(Field_G &, const Field_G *, const int, const int)
Definition: staples_eo.cpp:88
void forward(Field &, const Field &, const int mu)
void Register_double(const string &, const double)
Definition: parameters.cpp:323
double cmp_r(const int cc, const int site, const int mn=0) const
Definition: field_G.h:86
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:177
int fetch_double(const string &key, double &val) const
Definition: parameters.cpp:124
string get_string(const string &key) const
Definition: parameters.cpp:87
void set_mat(const int site, const int mn, const Mat_SU_N &U)
Definition: field_G.h:159
void set_csw_chiral()
explicit implementation for Chiral representation (for Imp-version).
void mult_csw_inv_dirac(Field &, const Field &, const int ieo)
double flop_count()
retuns number of floating point number operations.
std::vector< double > csmatrix(const int &)
void lower(Field_G &, const Field_G *, const int, const int)
Definition: staples_eo.cpp:107
int sg_index(int mu, int nu)
ShiftField_eo m_shift_eo
virtual void solve(Field &solution, const Field &source, int &Nconv, double &diff)=0
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:28
void set_config(Field *Ueo)
setting pointer to the gauge configuration.
int fetch_int_vector(const string &key, std::vector< int > &val) const
Definition: parameters.cpp:176
void xI()
Definition: field_G.h:183
double cmp_r(const int cc, const int s, const int site, const int e=0) const
Definition: field_F.h:95