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