Bridge++  Version 1.4.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gaugeFixing_Landau.cpp
Go to the documentation of this file.
1 
14 #include "gaugeFixing_Landau.h"
15 
16 #include "staple_lex.h"
17 
18 #ifdef USE_FACTORY
19 namespace {
20  GaugeFixing *create_object()
21  {
22  return new GaugeFixing_Landau();
23  }
24 
25  bool init = GaugeFixing::Factory::Register("Landau", create_object);
26 }
27 #endif
28 
29 const std::string GaugeFixing_Landau::class_name = "GaugeFixing_Landau";
30 
31 //====================================================================
33 {
34  const string str_vlevel = params.get_string("verbose_level");
35 
36  m_vl = vout.set_verbose_level(str_vlevel);
37 
38  //- fetch and check input parameters
39  int Niter, Nnaive, Nmeas, Nreset;
40  double Enorm, wp;
41 
42  int err = 0;
43  err += params.fetch_int("maximum_number_of_iteration", Niter);
44  err += params.fetch_int("number_of_naive_iteration", Nnaive);
45  err += params.fetch_int("interval_of_measurement", Nmeas);
46  err += params.fetch_int("iteration_to_reset", Nreset);
47  err += params.fetch_double("convergence_criterion_squared", Enorm);
48  err += params.fetch_double("overrelaxation_parameter", wp);
49 
50  if (err) {
51  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
52  exit(EXIT_FAILURE);
53  }
54 
55  set_parameters(Niter, Nnaive, Nmeas, Nreset, Enorm, wp);
56 }
57 
58 
59 //====================================================================
60 void GaugeFixing_Landau::set_parameters(const int Niter, const int Nnaive,
61  const int Nmeas, const int Nreset,
62  const double Enorm, const double wp)
63 {
64  //- print input parameters
65  vout.general(m_vl, "%s:\n", class_name.c_str());
66  vout.general(m_vl, " Niter = %d\n", Niter);
67  vout.general(m_vl, " Nnaive = %d\n", Nnaive);
68  vout.general(m_vl, " Nmeas = %d\n", Nmeas);
69  vout.general(m_vl, " Nreset = %d\n", Nreset);
70  vout.general(m_vl, " Enorm = %12.4e\n", Enorm);
71  vout.general(m_vl, " wp = %8.4f\n", wp);
72 
73  //- range check
74  int err = 0;
75  err += ParameterCheck::non_negative(Niter);
76  err += ParameterCheck::non_negative(Nnaive);
77  err += ParameterCheck::non_negative(Nmeas);
78  err += ParameterCheck::non_negative(Nreset);
79  err += ParameterCheck::square_non_zero(Enorm);
80  err += ParameterCheck::non_zero(wp);
81 
82  if (err) {
83  vout.crucial(m_vl, "Error at %s: parameter range check failed.\n", class_name.c_str());
84  exit(EXIT_FAILURE);
85  }
86 
87  //- store values
88  m_Niter = Niter;
89  m_Nnaive = Nnaive;
90  m_Nmeas = Nmeas;
91  m_Nreset = Nreset;
92  m_Enorm = Enorm;
93  m_wp = wp;
94 }
95 
96 
97 //====================================================================
98 void GaugeFixing_Landau::fix(Field_G& Ufix, const Field_G& Uorg)
99 {
100  const int Nvol = Uorg.nvol();
101  const int Nex = Uorg.nex();
102 
103  const int Nvol2 = Nvol / 2;
104 
105  Field_G Ue(Nvol2, Nex);
106  m_index.convertField(Ue, Uorg, 0);
107 
108  Field_G Uo(Nvol2, Nex);
109  m_index.convertField(Uo, Uorg, 1);
110 
111  int Nconv = -1;
112 
113  Staple_lex staple;
114  const double plaq = staple.plaquette(Uorg);
115 
116  vout.general(m_vl, "plaq(original) = %18.14f\n", plaq);
117 
118 
119  //- gauge fixing iteration
120  for (int iter = 0; iter < m_Niter; ++iter) {
121  if ((iter % m_Nmeas) == 0) {
122  double sg, Fval;
123  calc_SG(sg, Fval, Ue, Uo);
124 
125  vout.detailed(m_vl, " iter = %6d sg = %16.8e Fval = %16.8e\n",
126  iter, sg, Fval);
127 
128  if (sg < m_Enorm) {
129  Nconv = iter;
130  vout.general(m_vl, "converged at iter = %d\n", Nconv);
131  break;
132  }
133  }
134 
135  double wp2 = m_wp;
136  if ((iter % m_Nreset) < m_Nnaive) wp2 = 1.0;
137 
138  gfix_step(Ue, Uo, wp2);
139 
140  if (((iter % m_Nreset) == 0) && (iter > 0)) {
141  vout.detailed(m_vl, " random gauge transformation performed.\n");
142 
143  Field_G Ge(Nvol2, 1);
145  gauge_trans_eo(Ue, Uo, Ge, 0);
146 
147  Field_G Go(Nvol2, 1);
149  gauge_trans_eo(Ue, Uo, Go, 1);
150  }
151  }
152 
153  if (Nconv < 0) {
154  vout.crucial(m_vl, "Error at %s: not converged.\n", class_name.c_str());
155  exit(EXIT_FAILURE);
156  }
157 
158  m_index.reverseField(Ufix, Ue, 0);
159  m_index.reverseField(Ufix, Uo, 1);
160 
161 
162  const double plaq2 = staple.plaquette(Ufix);
163  const double plaq_diff = abs(plaq - plaq2);
164 
165  vout.general(m_vl, "plaq(fixed) = %18.14f\n", plaq2);
166  vout.general(m_vl, "plaq(diff) = %18.10e\n", plaq_diff);
167 
168  if ( plaq_diff > sqrt(m_Enorm) ) {
169  vout.crucial(m_vl, "Error at %s: too large plaq(diff) = %20.14e\n",
170  class_name.c_str(), plaq_diff);
171  exit(EXIT_FAILURE);
172  }
173 }
174 
175 
176 //====================================================================
178  const double wp)
179 {
180  const int Nc = CommonParameters::Nc();
181  const int Nvol2 = Ue.nvol();
182 
183  Mat_SU_N uwp(Nc);
184  uwp.unit();
185  uwp *= (1.0 - wp);
186 
187  for (int ieo = 0; ieo < 2; ++ieo) {
188  Field_G Weo(Nvol2, 1);
189  calc_W(Weo, Ue, Uo, ieo);
190 
191  Field_G Geo(Nvol2, 1);
192  maxTr(Geo, Weo);
193  scal(Geo, wp);
194 
195  // double wp_sbt = 1.0 - wp;
196  for (int site = 0; site < Nvol2; ++site) {
197  Mat_SU_N ut(Nc);
198  ut = Geo.mat(site, 0);
199  ut += uwp;
200  ut.reunit();
201  Geo.set_mat(site, 0, ut);
202  }
203 
204  gauge_trans_eo(Ue, Uo, Geo, ieo);
205  }
206 }
207 
208 
209 //====================================================================
211 {
212  const int Nvol = Geo.nvol();
213  const int Nex = Geo.nex();
214 
215  const int Nc = CommonParameters::Nc();
216 
217  for (int ex = 0; ex < Nex; ++ex) {
218  for (int site = 0; site < Nvol; ++site) {
219  Mat_SU_N gt(Nc);
220  gt.set_random(m_rand);
221  Geo.set_mat(site, ex, gt);
222  }
223  }
224 }
225 
226 
227 //====================================================================
229  const Field_G& Geo, const int Ieo)
230 {
231  // Ieo = 0: gauge transformation on even sites.
232  // Ieo = 1: on odd sites.
233 
234  const int Nvol2 = Geo.nvol();
235  const int Ndim = CommonParameters::Ndim();
236 
238 
239  if (Ieo == 0) {
240  for (int mu = 0; mu < Ndim; ++mu) {
241  Field_G Ut(Nvol2, 1);
242  mult_Field_Gnn(Ut, 0, Geo, 0, Ue, mu);
243  Ue.setpart_ex(mu, Ut, 0);
244 
245  Field_G Gt(Nvol2, 1);
246  shift.backward_h(Gt, Geo, mu, 1);
247  mult_Field_Gnd(Ut, 0, Uo, mu, Gt, 0);
248  Uo.setpart_ex(mu, Ut, 0);
249  }
250  } else {
251  for (int mu = 0; mu < Ndim; ++mu) {
252  Field_G Ut(Nvol2, 1);
253  mult_Field_Gnn(Ut, 0, Geo, 0, Uo, mu);
254  Uo.setpart_ex(mu, Ut, 0);
255 
256  Field_G Gt(Nvol2, 1);
257  shift.backward_h(Gt, Geo, mu, 0);
258  mult_Field_Gnd(Ut, 0, Ue, mu, Gt, 0);
259  Ue.setpart_ex(mu, Ut, 0);
260  }
261  }
262 }
263 
264 
265 //====================================================================
266 void GaugeFixing_Landau::calc_SG(double& sg, double& Fval,
267  const Field_G& Ue, const Field_G& Uo)
268 {
269  const int Nc = CommonParameters::Nc();
270  const int NPE = CommonParameters::NPE();
271  const int Nvol2 = Ue.nvol();
272  const int Nex = Ue.nex();
273 
274  sg = 0.0;
275  Fval = 0.0;
276 
277  for (int ieo = 0; ieo < 2; ++ieo) {
278  Field_G DLT(Nvol2, 1);
279  calc_DLT(DLT, Ue, Uo, ieo);
280  double tsg = DLT.norm2();
281  sg += tsg;
282  }
283  sg = sg / (Nex * Nc * 2 * Nvol2 * NPE);
284 
285  for (int mu = 0; mu < Nex; ++mu) {
286  for (int site = 0; site < Nvol2; ++site) {
287  Mat_SU_N ut(Nc);
288  ut = Ue.mat(site, mu);
289  Fval += ReTr(ut);
290 
291  ut = Uo.mat(site, mu);
292  Fval += ReTr(ut);
293  }
294  }
295  Fval = Communicator::reduce_sum(Fval);
296  Fval = Fval / (Nex * 2 * Nvol2 * NPE);
297 }
298 
299 
300 //====================================================================
302  const Field_G& Ue, const Field_G& Uo,
303  const int Ieo)
304 {
305  const int Nvol2 = Ue.nvol();
306  const int Nc = CommonParameters::Nc();
307  const int Ndim = CommonParameters::Ndim();
308 
310 
311  DLT.set(0.0);
312 
313  if (Ieo == 0) { // on even sites
314  for (int mu = 0; mu < Ndim; ++mu) {
315  DLT.addpart_ex(0, Ue, mu, -1.0);
316 
317  Field_G Ut1(Nvol2, 1);
318  Ut1.setpart_ex(0, Uo, mu);
319 
320  Field_G Ut2(Nvol2, 1);
321  shift.forward_h(Ut2, Ut1, mu, 0);
322  DLT.addpart_ex(0, Ut2, 0);
323  }
324  } else { // on odd sites
325  for (int mu = 0; mu < Ndim; ++mu) {
326  DLT.addpart_ex(0, Uo, mu, -1.0);
327 
328  Field_G Ut1(Nvol2, 1);
329  Ut1.setpart_ex(0, Ue, mu);
330 
331  Field_G Ut2(Nvol2, 1);
332  shift.forward_h(Ut2, Ut1, mu, 1);
333  DLT.addpart_ex(0, Ut2, 0);
334  }
335  }
336 
337  for (int site = 0; site < Nvol2; ++site) {
338  Mat_SU_N u_tmp(Nc);
339  u_tmp = DLT.mat(site, 0);
340  u_tmp.at();
341  u_tmp *= 2.0;
342  DLT.set_mat(site, 0, u_tmp);
343  }
344 }
345 
346 
347 //====================================================================
349  const Field_G& Ue, const Field_G& Uo,
350  const int Ieo)
351 {
352  const int Nvol2 = Ue.nvol();
353  const int Nc = CommonParameters::Nc();
354  const int Ndim = CommonParameters::Ndim();
355 
356  assert(Weo.nex() == 1);
357 
359 
360  Weo.set(0.0);
361 
362  if (Ieo == 0) { // on even sites
363  for (int mu = 0; mu < Ndim; ++mu) {
364  Weo.addpart_ex(0, Ue, mu);
365 
366  Field_G Ut1(Nvol2, 1);
367  Ut1.setpart_ex(0, Uo, mu);
368 
369  Field_G Ut2(Nvol2, 1);
370  shift.forward_h(Ut2, Ut1, mu, 0);
371  for (int site = 0; site < Nvol2; ++site) {
372  Mat_SU_N u_tmp(Nc);
373  u_tmp = Ut2.mat_dag(site, 0);
374  Weo.add_mat(site, 0, u_tmp);
375  }
376  }
377  } else if (Ieo == 1) { // on odd sites
378  for (int mu = 0; mu < Ndim; ++mu) {
379  Weo.addpart_ex(0, Uo, mu);
380 
381  Field_G Ut1(Nvol2, 1);
382  Ut1.setpart_ex(0, Ue, mu);
383 
384  Field_G Ut2(Nvol2, 1);
385  shift.forward_h(Ut2, Ut1, mu, 1);
386  for (int site = 0; site < Nvol2; ++site) {
387  Mat_SU_N u_tmp(Nc);
388  u_tmp = Ut2.mat_dag(site, 0);
389  Weo.add_mat(site, 0, u_tmp);
390  }
391  }
392  } else {
393  vout.crucial(m_vl, "Error at %s: Wrong ieo=%d.\n", class_name.c_str(), Ieo);
394  exit(EXIT_FAILURE);
395  }
396 }
397 
398 
399 //====================================================================
401 {
402  // Present implementation only applys to SU(3) case.
403  const int Nc = CommonParameters::Nc();
404  const int Nvol2 = G0.nvol();
405 
406  const int Nmt = 1;
407 
408  Mat_SU_N unity(Nc);
409  unity.unit();
410 
411  for (int site = 0; site < Nvol2; ++site) {
412  G0.set_mat(site, 0, unity);
413  }
414 
415  for (int imt = 0; imt < Nmt; ++imt) {
416  maxTr1(G0, W);
417  maxTr2(G0, W);
418  maxTr3(G0, W);
419  }
420 }
421 
422 
423 //====================================================================
425 {
426  const int Nc = CommonParameters::Nc();
427  const int Nvol2 = W.nvol();
428 
429  for (int site = 0; site < Nvol2; ++site) {
430  Mat_SU_N wt(Nc);
431  wt = W.mat(site, 0);
432 
433  Mat_SU_N gt(Nc);
434  gt.set(2, 0.0, 0.0);
435  gt.set(5, 0.0, 0.0);
436  gt.set(6, 0.0, 0.0);
437  gt.set(7, 0.0, 0.0);
438  gt.set(8, 1.0, 0.0);
439 
440  double fn1 = (wt.r(0) + wt.r(4)) * (wt.r(0) + wt.r(4))
441  + (wt.i(0) - wt.i(4)) * (wt.i(0) - wt.i(4));
442  double fn2 = (wt.r(1) - wt.r(3)) * (wt.r(1) - wt.r(3))
443  + (wt.i(1) + wt.i(3)) * (wt.i(1) + wt.i(3));
444  double fn = 1.0 / sqrt(fn1 + fn2);
445 
446  gt.set(0, fn * (wt.r(0) + wt.r(4)), fn * (-wt.i(0) + wt.i(4)));
447  gt.set(1, fn * (-wt.r(1) + wt.r(3)), fn * (-wt.i(1) - wt.i(3)));
448  gt.set(3, fn * (wt.r(1) - wt.r(3)), fn * (-wt.i(1) - wt.i(3)));
449  gt.set(4, fn * (wt.r(0) + wt.r(4)), fn * (wt.i(0) - wt.i(4)));
450 
451  Mat_SU_N wt2(Nc);
452  wt2 = gt * wt;
453  W.set_mat(site, 0, wt2);
454 
455  Mat_SU_N gt2(Nc);
456  gt2 = G.mat(site, 0);
457  wt2 = gt * gt2;
458  G.set_mat(site, 0, wt2);
459  }
460 }
461 
462 
463 //====================================================================
465 {
466  const int Nc = CommonParameters::Nc();
467  const int Nvol2 = W.nvol();
468 
469  for (int site = 0; site < Nvol2; ++site) {
470  Mat_SU_N wt(Nc);
471  wt = W.mat(site, 0);
472 
473  Mat_SU_N gt(Nc);
474  gt.set(1, 0.0, 0.0);
475  gt.set(3, 0.0, 0.0);
476  gt.set(4, 1.0, 0.0);
477  gt.set(5, 0.0, 0.0);
478  gt.set(7, 0.0, 0.0);
479 
480  double fn1 = (wt.r(8) + wt.r(0)) * (wt.r(8) + wt.r(0))
481  + (wt.i(8) - wt.i(0)) * (wt.i(8) - wt.i(0));
482  double fn2 = (wt.r(2) - wt.r(6)) * (wt.r(2) - wt.r(6))
483  + (wt.i(2) + wt.i(6)) * (wt.i(2) + wt.i(6));
484  double fn = 1.0 / sqrt(fn1 + fn2);
485 
486  gt.set(0, fn * (wt.r(8) + wt.r(0)), fn * (wt.i(8) - wt.i(0)));
487  gt.set(2, fn * (wt.r(6) - wt.r(2)), fn * (-wt.i(6) - wt.i(2)));
488  gt.set(6, fn * (-wt.r(6) + wt.r(2)), fn * (-wt.i(6) - wt.i(2)));
489  gt.set(8, fn * (wt.r(8) + wt.r(0)), fn * (-wt.i(8) + wt.i(0)));
490 
491  Mat_SU_N wt2(Nc);
492  wt2 = gt * wt;
493  W.set_mat(site, 0, wt2);
494 
495  Mat_SU_N gt2(Nc);
496  gt2 = G.mat(site, 0);
497  wt2 = gt * gt2;
498  G.set_mat(site, 0, wt2);
499  }
500 }
501 
502 
503 //====================================================================
505 {
506  const int Nc = CommonParameters::Nc();
507  const int Nvol2 = W.nvol();
508 
509  Mat_SU_N gt2(Nc), wt2(Nc);
510 
511  for (int site = 0; site < Nvol2; ++site) {
512  Mat_SU_N wt(Nc);
513  wt = W.mat(site, 0);
514 
515  Mat_SU_N gt(Nc);
516  gt.set(0, 1.0, 0.0);
517  gt.set(1, 0.0, 0.0);
518  gt.set(2, 0.0, 0.0);
519  gt.set(3, 0.0, 0.0);
520  gt.set(6, 0.0, 0.0);
521 
522  double fn1 = (wt.r(4) + wt.r(8)) * (wt.r(4) + wt.r(8))
523  + (wt.i(4) - wt.i(8)) * (wt.i(4) - wt.i(8));
524  double fn2 = (wt.r(7) - wt.r(5)) * (wt.r(7) - wt.r(5))
525  + (wt.i(7) + wt.i(5)) * (wt.i(7) + wt.i(5));
526  double fn = 1.0 / sqrt(fn1 + fn2);
527 
528  gt.set(4, fn * (wt.r(4) + wt.r(8)), fn * (-wt.i(4) + wt.i(8)));
529  gt.set(5, fn * (-wt.r(5) + wt.r(7)), fn * (-wt.i(5) - wt.i(7)));
530  gt.set(7, fn * (wt.r(5) - wt.r(7)), fn * (-wt.i(5) - wt.i(7)));
531  gt.set(8, fn * (wt.r(4) + wt.r(8)), fn * (wt.i(4) - wt.i(8)));
532 
533  Mat_SU_N wt2(Nc);
534  wt2 = gt * wt;
535  W.set_mat(site, 0, wt2);
536 
537  Mat_SU_N gt2(Nc);
538  gt2 = G.mat(site, 0);
539  wt2 = gt * gt2;
540  G.set_mat(site, 0, wt2);
541  }
542 }
543 
544 
545 //====================================================================
546 //============================================================END=====
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:282
BridgeIO vout
Definition: bridgeIO.cpp:495
double i(int c) const
Definition: mat_SU_N.h:115
void detailed(const char *format,...)
Definition: bridgeIO.cpp:212
Mat_SU_N & set_random(RandomNumbers *rand)
Definition: mat_SU_N.h:76
double norm2() const
Definition: field.cpp:441
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:164
void maxTr2(Field_G &, Field_G &)
void general(const char *format,...)
Definition: bridgeIO.cpp:195
static const std::string class_name
int shift(void)
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:211
double plaquette(const Field_G &)
calculates plaquette value.
Definition: staple_lex.cpp:46
int nvol() const
Definition: field.h:116
Class for parameters.
Definition: parameters.h:46
Mat_SU_N & at()
antihermitian traceless
Definition: mat_SU_N.h:329
void convertField(Field &eo, const Field &lex)
Definition: index_eo.cpp:20
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:193
void gauge_trans_eo(Field_G &Ue, Field_G &Uo, const Field_G &Geo, const int Ieo)
Mat_SU_N & reunit()
Definition: mat_SU_N.h:71
int square_non_zero(const double v)
Definition: checker.cpp:41
Staple construction.
Definition: staple_lex.h:39
SU(N) gauge field.
Definition: field_G.h:38
void maxTr1(Field_G &, Field_G &)
void calc_DLT(Field_G &Weo, const Field_G &Ue, const Field_G &Uo, const int Ieo)
int fetch_int(const string &key, int &value) const
Definition: parameters.cpp:230
int nex() const
Definition: field.h:117
void maxTr3(Field_G &, Field_G &)
void set_parameters(const Parameters &params)
Methods to shift the even-odd field.
Definition: shiftField_eo.h:45
void mult_Field_Gnn(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
Bridge::VerboseLevel m_vl
Definition: gaugeFixing.h:57
void reverseField(Field &lex, const Field &eo)
Definition: index_eo.cpp:110
int non_zero(const double v)
Definition: checker.cpp:31
RandomNumbers * m_rand
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:126
int non_negative(const int v)
Definition: checker.cpp:21
Landau gauge fixing.
Mat_SU_N & unit()
Definition: mat_SU_N.h:373
static int reduce_sum(int count, double *recv_buf, double *send_buf, int pattern=0)
make a global sum of an array of double over the communicator. pattern specifies the dimensions to be...
void backward_h(Field &, const Field &, const int mu, const int ieo)
void calc_W(Field_G &Weo, const Field_G &Ue, const Field_G &Uo, const int Ieo)
double r(int c) const
Definition: mat_SU_N.h:114
gauge fixing.
Definition: gaugeFixing.h:36
void set(int c, double re, const double &im)
Definition: mat_SU_N.h:133
void fix(Field_G &Ufix, const Field_G &Uorg)
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:186
void maxTr(Field_G &, Field_G &)
string get_string(const string &key) const
Definition: parameters.cpp:116
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
void add_mat(const int site, const int mn, const Mat_SU_N &U)
Definition: field_G.h:167
void forward_h(Field &, const Field &, const int mu, const int ieo)
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
void calc_SG(double &sg, double &Fval, const Field_G &Ue, const Field_G &Uo)
double ReTr(const Mat_SU_N &m)
Definition: mat_SU_N.h:488
void gfix_step(Field_G &Ue, Field_G &Uo, const double wp)
one step of gauge fixing with overrelaxation parameter wp.
void set_randomGaugeTrans(Field_G &Geo)
static int NPE()
void mult_Field_Gnd(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)