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