Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
projection_Stout_SU3.cpp
Go to the documentation of this file.
1 
14 #include "projection_Stout_SU3.h"
15 
16 #ifdef USE_PARAMETERS_FACTORY
17 #include "parameters_factory.h"
18 #endif
19 
20 #ifdef USE_FACTORY
21 namespace {
22  Projection *create_object()
23  {
24  return new Projection_Stout_SU3();
25  }
26 
27 
28  bool init = Projection::Factory::Register("Stout_SU3", create_object);
29 }
30 #endif
31 
32 //- parameter entries
33 namespace {
34  void append_entry(Parameters& param)
35  {
36  param.Register_string("verbose_level", "NULL");
37  }
38 
39 
40 #ifdef USE_PARAMETERS_FACTORY
41  bool init_param = ParametersFactory::Register("Projection.Stout_SU3", append_entry);
42 #endif
43 }
44 //- end
45 
46 //- parameters class
48 //- end
49 
50 const std::string Projection_Stout_SU3::class_name = "Projection_Stout_SU3";
51 
52 //====================================================================
54 {
55  const string str_vlevel = params.get_string("verbose_level");
56 
57  m_vl = vout.set_verbose_level(str_vlevel);
58 }
59 
60 
61 //====================================================================
63 {
64  m_flop = 0;
65  m_time = 0.0;
66 
67  assert(CommonParameters::Nc() == NC);
68 }
69 
70 
71 //====================================================================
73 {
74  double gflops = 1.e-9 * double(m_flop) / m_time;
75 
76  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
77  vout.general(m_vl, " total time: %f\n", m_time);
78  vout.general(m_vl, " total flop: %d\n", m_flop);
79  vout.general(m_vl, " GFlops : %f\n", gflops);
80 }
81 
82 
83 //====================================================================
85  double alpha,
86  const Field_G& Cst, const Field_G& Uorg)
87 {
88  // int id = 31;
89  // KEK_FopCountStart(id);
90  double time0 = Communicator::get_time();
91 
92  // in stout projection, parameter alpha is dummy.
93 
94  int Nex = Uorg.nex();
95  int Nvol = Uorg.nvol();
96 
97  assert(Cst.nex() == Nex);
98  assert(Cst.nvol() == Nvol);
99  assert(U.nex() == Nex);
100  assert(U.nvol() == Nvol);
101 
102  int NinG = Uorg.nin();
103 
104  Mat_SU_N iQ0(NC), iQ1(NC), iQ2(NC), iQ3(NC);
105  Mat_SU_N ct(NC), ut(NC), ut2(NC), e_iQ(NC);
106  iQ0.unit();
107 
108  double u, w;
109  dcomplex f0, f1, f2, qt;
110 
111  for (int mu = 0; mu < Nex; ++mu) {
112  for (int site = 0; site < Nvol; ++site) {
113  Uorg.mat(ut, site, mu);
114  Cst.mat(ct, site, mu);
115  iQ1.mult_nd(ct, ut);
116  iQ1.at();
117  iQ2.mult_nn(iQ1, iQ1);
118  iQ3.mult_nn(iQ1, iQ2);
119 
120  double norm = iQ1.norm2();
121  if (norm > 1.0e-10) {
122  set_uw(u, w, iQ2, iQ3);
123  set_fj(f0, f1, f2, u, w);
124 
125  for (int cc = 0; cc < NC * NC; ++cc) {
126  qt = f0 * cmplx(iQ0.r(cc), iQ0.i(cc))
127  + f1 *cmplx(iQ1.i(cc), -iQ1.r(cc))
128  - f2 *cmplx(iQ2.r(cc), iQ2.i(cc));
129  e_iQ.setr(cc, real(qt));
130  e_iQ.seti(cc, imag(qt));
131  }
132  } else {
133  // vout.general(m_vl,"project: |iQ1|^2 too small: %lf. Set e_iQ=1.\n",norm);
134  e_iQ.unit();
135  }
136 
137  ut2.mult_nn(e_iQ, ut);
138  U.set_mat(site, mu, ut2);
139  }
140  }
141 
142  /*
143  unsigned long count;
144  double time;
145  KEK_FopCountFinish(id,&count,&time);
146  m_time += time;
147  m_flop += count;
148  */
149  double time1 = Communicator::get_time();
150  m_time += time1 - time0;
151 }
152 
153 
154 //====================================================================
156 {
157  int Nvol = iQ.nvol();
158  int Nex = iQ.nex();
159 
160  Mat_SU_N iQ0(NC), iQ1(NC), iQ2(NC), iQ3(NC);
161 
162  iQ0.unit();
163 
164  double u, w;
165  dcomplex f0, f1, f2, qt;
166 
167  for (int mu = 0; mu < Nex; ++mu) {
168  for (int site = 0; site < Nvol; ++site) {
169  iQ1 = iQ.mat(site, mu);
170  iQ2 = iQ1 * iQ1;
171  iQ3 = iQ1 * iQ2;
172 
173  double norm = iQ1.norm2();
174  if (norm > 1.0e-10) {
175  set_uw(u, w, iQ2, iQ3);
176  set_fj(f0, f1, f2, u, w);
177 
178  for (int cc = 0; cc < NC * NC; ++cc) {
179  qt = f0 * cmplx(iQ0.r(cc), iQ0.i(cc))
180  + f1 *cmplx(iQ1.i(cc), -iQ1.r(cc))
181  - f2 *cmplx(iQ2.r(cc), iQ2.i(cc));
182  e_iQ.set_ri(cc, site, mu, real(qt), imag(qt));
183  }
184  } else {
185  // vout.general(m_vl,"exp_iQ: |iQ1|^2 too small: %lf. Set e_iQ=1.\n",norm);
186  e_iQ.set_mat(site, mu, iQ0);
187  }
188  }
189  }
190 }
191 
192 
193 //====================================================================
194 
207 //====================================================================
209  double alpha, const Field_G& Sigmap,
210  const Field_G& Cst, const Field_G& Uorg)
211 {
212  // in stout projection, parameter alpha is dummy.
213 
214  // int id = 31;
215  // KEK_FopCountStart(id);
216  double time0 = Communicator::get_time();
217 
218  int Nvol = CommonParameters::Nvol();
219  // int NinG = 2 * NC * NC;
220  int Nex = Xi.nex();
221 
222  assert(Xi.nvol() == Nvol);
223  assert(iTheta.nvol() == Nvol);
224  assert(Sigmap.nvol() == Nvol);
225  assert(Cst.nvol() == Nvol);
226  assert(Uorg.nvol() == Nvol);
227  assert(iTheta.nex() == Nex);
228  assert(Sigmap.nex() == Nex);
229  assert(Cst.nex() == Nex);
230  assert(Uorg.nex() == Nex);
231 
232  Mat_SU_N C_tmp(NC), U_tmp(NC), Sigmap_tmp(NC);
233  Mat_SU_N iQ0(NC), iQ1(NC), iQ2(NC), iQ3(NC), e_iQ(NC);
234  Mat_SU_N B1(NC), B2(NC);
235  Mat_SU_N USigmap(NC), iQUS(NC), iUSQ(NC), iGamma(NC);
236  Mat_SU_N Xi_tmp(NC), iTheta_tmp(NC);
237  Mat_SU_N tmp1(NC), tmp2(NC);
238  iQ0.unit();
239 
240  double u, w, u2, w2, cos_w, xi0, xi1, fden;
241  dcomplex f0, f1, f2, h0, h1, h2, e2iu, emiu, qt;
242  dcomplex r01, r11, r21, r02, r12, r22, tr1, tr2;
243  dcomplex b10, b11, b12, b20, b21, b22;
244 
245  for (int mu = 0; mu < Nex; ++mu) {
246  for (int site = 0; site < Nvol; ++site) {
248  Cst.mat(C_tmp, site, mu);
250  Uorg.mat(U_tmp, site, mu);
251  // Sigmap_tmp \f$=\Sigma_\mu'(x)\f$
252  Sigmap.mat(Sigmap_tmp, site, mu);
253 
255  iQ1.mult_nd(C_tmp, U_tmp);
256  iQ1.at();
257  iQ2.mult_nn(iQ1, iQ1);
258  iQ3.mult_nn(iQ1, iQ2);
259 
260  // In order to aviod 1Q1=0
261  double norm = iQ1.norm2();
262  if (norm > 1.0e-10) {
263  set_uw(u, w, iQ2, iQ3);
264  set_fj(f0, f1, f2, u, w);
265 
266  for (int cc = 0; cc < NC * NC; ++cc) {
267  qt = f0 * cmplx(iQ0.r(cc), iQ0.i(cc))
268  + f1 *cmplx(iQ1.i(cc), -iQ1.r(cc))
269  - f2 *cmplx(iQ2.r(cc), iQ2.i(cc));
270  e_iQ.set(cc, real(qt), imag(qt));
271  }
272 
273  xi0 = func_xi0(w);
274  xi1 = func_xi1(w);
275  u2 = u * u;
276  w2 = w * w;
277  cos_w = cos(w);
278 
279  emiu = cmplx(cos(u), -sin(u));
280  e2iu = cmplx(cos(2.0 * u), sin(2.0 * u));
281 
282  r01 = cmplx(2.0 * u, 2.0 * (u2 - w2)) * e2iu
283  + emiu *cmplx(16.0 * u * cos_w + 2.0 * u * (3.0 * u2 + w2) * xi0,
284  -8.0 * u2 * cos_w + 2.0 * (9.0 * u2 + w2) * xi0);
285 
286  r11 = cmplx(2.0, 4.0 * u) * e2iu
287  + emiu *cmplx(-2.0 * cos_w + (3.0 * u2 - w2) * xi0,
288  2.0 * u * cos_w + 6.0 * u * xi0);
289 
290  r21 = cmplx(0.0, 2.0) * e2iu
291  + emiu *cmplx(-3.0 * u * xi0, cos_w - 3.0 * xi0);
292 
293  r02 = cmplx(-2.0, 0.0) * e2iu
294  + emiu *cmplx(-8.0 * u2 * xi0,
295  2.0 * u * (cos_w + xi0 + 3.0 * u2 * xi1));
296 
297  r12 = emiu * cmplx(2.0 * u * xi0,
298  -cos_w - xi0 + 3.0 * u2 * xi1);
299 
300  r22 = emiu * cmplx(xi0, -3.0 * u * xi1);
301 
302  fden = 1.0 / (2 * (9.0 * u2 - w2) * (9.0 * u2 - w2));
303 
304  b10 = cmplx(2.0 * u, 0.0) * r01 + cmplx(3.0 * u2 - w2, 0.0) * r02
305  - cmplx(30.0 * u2 + 2.0 * w2, 0.0) * f0;
306 
307  b11 = cmplx(2.0 * u, 0.0) * r11 + cmplx(3.0 * u2 - w2, 0.0) * r12
308  - cmplx(30.0 * u2 + 2.0 * w2, 0.0) * f1;
309 
310  b12 = cmplx(2.0 * u, 0.0) * r21 + cmplx(3.0 * u2 - w2, 0.0) * r22
311  - cmplx(30.0 * u2 + 2.0 * w2, 0.0) * f2;
312 
313  b20 = r01 - cmplx(3.0 * u, 0.0) * r02 - cmplx(24.0 * u, 0.0) * f0;
314 
315  b21 = r11 - cmplx(3.0 * u, 0.0) * r12 - cmplx(24.0 * u, 0.0) * f1;
316 
317  b22 = r21 - cmplx(3.0 * u, 0.0) * r22 - cmplx(24.0 * u, 0.0) * f2;
318 
319  b10 *= cmplx(fden, 0.0);
320  b11 *= cmplx(fden, 0.0);
321  b12 *= cmplx(fden, 0.0);
322  b20 *= cmplx(fden, 0.0);
323  b21 *= cmplx(fden, 0.0);
324  b22 *= cmplx(fden, 0.0);
325 
326  for (int cc = 0; cc < NC * NC; ++cc) {
327  qt = b10 * cmplx(iQ0.r(cc), iQ0.i(cc))
328  + b11 *cmplx(iQ1.i(cc), -iQ1.r(cc))
329  - b12 *cmplx(iQ2.r(cc), iQ2.i(cc));
330  B1.set(cc, real(qt), imag(qt));
331  qt = b20 * cmplx(iQ0.r(cc), iQ0.i(cc))
332  + b21 *cmplx(iQ1.i(cc), -iQ1.r(cc))
333  - b22 *cmplx(iQ2.r(cc), iQ2.i(cc));
334  B2.set(cc, real(qt), imag(qt));
335  }
336 
337  USigmap.mult_nn(U_tmp, Sigmap_tmp);
338 
339  tmp1.mult_nn(USigmap, B1);
340  tmp2.mult_nn(USigmap, B2);
341  tr1 = cmplx(tmp1.r(0) + tmp1.r(4) + tmp1.r(8),
342  tmp1.i(0) + tmp1.i(4) + tmp1.i(8));
343  tr2 = cmplx(tmp2.r(0) + tmp2.r(4) + tmp2.r(8),
344  tmp2.i(0) + tmp2.i(4) + tmp2.i(8));
345 
346  iQUS.mult_nn(iQ1, USigmap);
347  iUSQ.mult_nn(USigmap, iQ1);
348 
349  for (int cc = 0; cc < NC * NC; ++cc) {
350  qt = tr1 * cmplx(iQ1.i(cc), -iQ1.r(cc))
351  - tr2 *cmplx(iQ2.r(cc), iQ2.i(cc))
352  + f1 *cmplx(USigmap.r(cc), USigmap.i(cc))
353  + f2 *cmplx(iQUS.i(cc), -iQUS.r(cc))
354  + f2 *cmplx(iUSQ.i(cc), -iUSQ.r(cc));
355  iGamma.set(cc, -imag(qt), real(qt));
356  }
357  } else {
358  // vout.general(m_vl,"force_recursive: |iQ1|^2 too small: %lf. Set e_iQ=1.\n",norm);
359  iGamma.zero();
360  e_iQ.unit();
361  }
362 
364  iGamma.at();
365  iTheta_tmp.mult_nn(iGamma, U_tmp);
367  iTheta.set_mat(site, mu, iTheta_tmp);
368 
369  Xi_tmp.mult_nn(Sigmap_tmp, e_iQ);
370  Xi_tmp.multadd_dn(C_tmp, iGamma);
372  Xi.set_mat(site, mu, Xi_tmp);
373  }
374  }
375 
376  /*
377  unsigned long count;
378  double time;
379  KEK_FopCountFinish(id,&count,&time);
380  m_time += time;
381  m_flop += count;
382  */
383  double time1 = Communicator::get_time();
384  m_time += time1 - time0;
385 }
386 
387 
388 //====================================================================
389 void Projection_Stout_SU3::set_fj(dcomplex& f0, dcomplex& f1, dcomplex& f2,
390  const double& u, const double& w)
391 {
392  dcomplex h0, h1, h2, e2iu, emiu, ixi0, qt;
393  double xi0, u2, w2, cos_w, fden;
394  // double c0, c1, c0max;
395 
396  xi0 = func_xi0(w);
397  u2 = u * u;
398  w2 = w * w;
399  cos_w = cos(w);
400 
401  double cos_u = cos(u);
402  double sin_u = sin(u);
403  emiu = cmplx(cos_u, -sin_u);
404  e2iu = cmplx(cos_u * cos_u - sin_u * sin_u, 2.0 * sin_u * cos_u);
405 
406  h0 = e2iu * cmplx(u2 - w2, 0.0)
407  + emiu *cmplx(8.0 * u2 * cos_w, 2.0 * u * (3.0 * u2 + w2) * xi0);
408  h1 = cmplx(2 * u, 0.0) * e2iu
409  - emiu *cmplx(2.0 * u * cos_w, -(3.0 * u2 - w2) * xi0);
410  h2 = e2iu - emiu *cmplx(cos_w, 3.0 * u * xi0);
411 
412  fden = 1.0 / (9.0 * u2 - w2);
413  f0 = h0 * fden;
414  f1 = h1 * fden;
415  f2 = h2 * fden;
416 }
417 
418 
419 //====================================================================
420 void Projection_Stout_SU3::set_uw(double& u, double& w,
421  const Mat_SU_N& iQ2, const Mat_SU_N& iQ3)
422 {
423  double c0, c1, c0max, theta;
424 
425  c0 = -(iQ3.i(0, 0) + iQ3.i(1, 1) + iQ3.i(2, 2)) / 3.0;
426  c1 = -0.5 * (iQ2.r(0, 0) + iQ2.r(1, 1) + iQ2.r(2, 2));
427  double c13r = sqrt(c1 / 3.0);
428  c0max = 2.0 * c13r * c13r * c13r;
429 
430  theta = acos(c0 / c0max);
431  u = c13r * cos(theta / 3.0);
432  w = sqrt(c1) * sin(theta / 3.0);
433 }
434 
435 
436 //====================================================================
438 {
439  double epsilon_criterion = CommonParameters::epsilon_criterion();
440 
441  double xi0 = sin(w) / w;
442 
443  if (w < epsilon_criterion) {
444  vout.general(m_vl, "%s: too small w = %18.6e\n", class_name.c_str(), w);
445  }
446 
447  return xi0;
448 }
449 
450 
451 //====================================================================
453 {
454  double epsilon_criterion = CommonParameters::epsilon_criterion();
455 
456  double xi1 = cos(w) / (w * w) - sin(w) / (w * w * w);
457 
458  if (w < epsilon_criterion) {
459  vout.general(m_vl, "%s: too small w = %18.6e\n", class_name.c_str(), w);
460  }
461 
462  return xi1;
463 }
464 
465 
466 //====================================================================
468 {
469  // brute force version of exponentiation: for check
470 
471  int Nprec = 32;
472 
473  int Nvol = iQ.nvol();
474  int Nex = iQ.nex();
475 
476  Mat_SU_N u0(NC), u1(NC), u2(NC);
477  Mat_SU_N h1(NC);
478 
479  for (int ex = 0; ex < Nex; ++ex) {
480  for (int site = 0; site < Nvol; ++site) {
481  u0.unit();
482  u1.unit();
483  h1 = iQ.mat(site, ex);
484 
485  for (int iprec = 0; iprec < Nprec; ++iprec) {
486  double exf = 1.0 / (Nprec - iprec);
487  u2 = h1 * u1;
488  u2 *= exf;
489  u1 = u2;
490  u1 += u0;
491  }
492 
493  u1.reunit();
494  e_iQ.set_mat(site, ex, u1);
495  }
496  }
497 }
498 
499 
500 //====================================================================
501 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:207
double i(int c) const
Definition: mat_SU_N.h:115
void Register_string(const string &, const string &)
Definition: parameters.cpp:352
static double epsilon_criterion()
unsigned long int m_flop
void seti(int c, const double &im)
Definition: mat_SU_N.h:121
void setr(int c, const double &re)
Definition: mat_SU_N.h:120
void general(const char *format,...)
Definition: bridgeIO.cpp:38
Mat_SU_N & zero()
Definition: mat_SU_N.h:383
int nvol() const
Definition: field.h:101
void force_recursive(Field_G &Xi, Field_G &iTheta, double alpha, const Field_G &Sigmap, const Field_G &C, const Field_G &U)
determination of fields for force calculation
void set_uw(double &u, double &w, const Mat_SU_N &iQ1, const Mat_SU_N &iQ2)
Class for parameters.
Definition: parameters.h:40
Mat_SU_N & at()
antihermitian traceless
Definition: mat_SU_N.h:329
Mat_SU_N & reunit()
Definition: mat_SU_N.h:71
int nin() const
Definition: field.h:100
void project(Field_G &U, double alpha, const Field_G &C, const Field_G &Uorg)
projection U = P[alpha, C, Uorg]
SU(N) gauge field.
Definition: field_G.h:36
int nex() const
Definition: field.h:102
void mult_nd(const Mat_SU_N &u1, const Mat_SU_N &u2)
Definition: mat_SU_N.h:197
void set_fj(dcomplex &f0, dcomplex &f1, dcomplex &f2, const double &u, const double &w)
double norm2()
Definition: mat_SU_N.h:155
base class for projection operator into gauge group.
Definition: projection.h:33
void set_parameters(const Parameters &param)
void exp_iQ(Field_G &e_iQ, const Field_G &iQ)
void exp_iQ_bf(Field_G &e_iQ, const Field_G &iQ)
static bool Register(const std::string &realm, const creator_callback &cb)
static const std::string class_name
static double get_time()
obtain a wall-clock time.
Mat_SU_N & unit()
Definition: mat_SU_N.h:373
double r(int c) const
Definition: mat_SU_N.h:114
#define NC
Definition: tensorProd.cpp:14
void set(int c, double re, const double &im)
Definition: mat_SU_N.h:133
string get_string(const string &key) const
Definition: parameters.cpp:85
void set_mat(const int site, const int mn, const Mat_SU_N &U)
Definition: field_G.h:156
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:110
void mult_nn(const Mat_SU_N &u1, const Mat_SU_N &u2)
Definition: mat_SU_N.h:163
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:191
Bridge::VerboseLevel m_vl
Definition: projection.h:36
void set_ri(const int cc, const int site, const int mn, const double re, const double im)
Definition: field_G.h:103