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