Bridge++  Ver. 1.2.x
 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 #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  abort();
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  abort();
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  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 = Geo.mat(site,ex);
224  gt.set_random(m_rand);
225  Geo.set_mat(site, ex, gt);
226  }
227  }
228 }
229 
230 
231 //====================================================================
233  Field_G& Geo, int Ieo)
234 {
235  // Ieo = 0: gauge transformation on even sites.
236  // Ieo = 1: on odd sites.
237 
238  int Nvol2 = Geo.nvol();
239  int Nex = Geo.nex();
240  int Ndim = CommonParameters::Ndim();
241 
243 
244  Field_G Ut(Nvol2, 1), Gt(Nvol2, 1);
245  Field_G Ut2(Nvol2, 1);
246 
247  if (Ieo == 0) {
248  for (int mu = 0; mu < Ndim; ++mu) {
249  mult_Field_Gnn(Ut, 0, Geo, 0, Ue, mu);
250  Ue.setpart_ex(mu, Ut, 0);
251 
252  shift.backward_h(Gt, Geo, mu, 1);
253  mult_Field_Gnd(Ut, 0, Uo, mu, Gt, 0);
254  Uo.setpart_ex(mu, Ut, 0);
255  }
256  } else {
257  for (int mu = 0; mu < Ndim; ++mu) {
258  mult_Field_Gnn(Ut, 0, Geo, 0, Uo, mu);
259  Uo.setpart_ex(mu, Ut, 0);
260 
261  shift.backward_h(Gt, Geo, mu, 0);
262  mult_Field_Gnd(Ut, 0, Ue, mu, Gt, 0);
263  Ue.setpart_ex(mu, Ut, 0);
264  }
265  }
266 }
267 
268 
269 //====================================================================
270 void GaugeFixing_Landau::calc_SG(double& sg, double& Fval,
271  Field_G& Ue, Field_G& Uo)
272 {
273  int Nc = CommonParameters::Nc();
274  int NPE = CommonParameters::NPE();
275  int Nvol2 = Ue.nvol();
276  int Nex = Ue.nex();
277 
278  Field_G DLT(Nvol2, 1);
279  Mat_SU_N ut(Nc);
280 
281  sg = 0.0;
282  Fval = 0.0;
283 
284  for (int ieo = 0; ieo < 2; ++ieo) {
285  calc_DLT(DLT, Ue, Uo, ieo);
286  double tsg = DLT.norm2();
287  sg += tsg;
288  }
289  sg = sg / (Nex * Nc * 2 * Nvol2 * NPE);
290 
291  for (int mu = 0; mu < Nex; ++mu) {
292  for (int site = 0; site < Nvol2; ++site) {
293  ut = Ue.mat(site, mu);
294  Fval += ReTr(ut);
295  ut = Uo.mat(site, mu);
296  Fval += ReTr(ut);
297  }
298  }
299  Fval = Communicator::reduce_sum(Fval);
300  Fval = Fval / (Nex * 2 * Nvol2 * NPE);
301 }
302 
303 
304 //====================================================================
306  Field_G& Ue, Field_G& Uo, int Ieo)
307 {
308  int Nvol2 = Ue.nvol();
309  int Nc = CommonParameters::Nc();
310  int Ndim = CommonParameters::Ndim();
311 
313 
314  Field_G Ut1(Nvol2, 1), Ut2(Nvol2, 1);
315  Mat_SU_N u_tmp(Nc);
316 
317  DLT = 0.0;
318 
319  if (Ieo == 0) { // on even sites
320  for (int mu = 0; mu < Ndim; ++mu) {
321  DLT.addpart_ex(0, Ue, mu, -1.0);
322  Ut1.setpart_ex(0, Uo, mu);
323  shift.forward_h(Ut2, Ut1, mu, 0);
324  DLT.addpart_ex(0, Ut2, 0);
325  }
326  } else { // on odd sites
327  for (int mu = 0; mu < Ndim; ++mu) {
328  DLT.addpart_ex(0, Uo, mu, -1.0);
329  Ut1.setpart_ex(0, Ue, mu);
330  shift.forward_h(Ut2, Ut1, mu, 1);
331  DLT.addpart_ex(0, Ut2, 0);
332  }
333  }
334 
335  for (int site = 0; site < Nvol2; ++site) {
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  Field_G& Ue, Field_G& Uo, int Ieo)
347 {
348  int Nvol2 = Ue.nvol();
349  int Nc = CommonParameters::Nc();
350  int Ndim = CommonParameters::Ndim();
351 
352  assert(Weo.nex() == 1);
353 
355 
356  Field_G Ut1(Nvol2, 1), Ut2(Nvol2, 1);
357  Mat_SU_N u_tmp(Nc);
358 
359  Weo = 0.0;
360 
361  if (Ieo == 0) { // on even sites
362  for (int mu = 0; mu < Ndim; ++mu) {
363  Weo.addpart_ex(0, Ue, mu);
364  Ut1.setpart_ex(0, Uo, mu);
365  shift.forward_h(Ut2, Ut1, mu, 0);
366  for (int site = 0; site < Nvol2; ++site) {
367  u_tmp = Ut2.mat_dag(site, 0);
368  Weo.add_mat(site, 0, u_tmp);
369  }
370  }
371  } else if (Ieo == 1) { // on odd sites
372  for (int mu = 0; mu < Ndim; ++mu) {
373  Weo.addpart_ex(0, Uo, mu);
374  Ut1.setpart_ex(0, Ue, mu);
375  shift.forward_h(Ut2, Ut1, mu, 1);
376  for (int site = 0; site < Nvol2; ++site) {
377  u_tmp = Ut2.mat_dag(site, 0);
378  Weo.add_mat(site, 0, u_tmp);
379  }
380  }
381  } else {
382  vout.crucial(m_vl, "%s: Wrong ieo.\n", class_name.c_str());
383  abort();
384  }
385 }
386 
387 
388 //====================================================================
390 {
391  // Present implementation only applys to SU(3) case.
392 
393  int Nc = CommonParameters::Nc();
394  int Nvol2 = G0.nvol();
395 
396  int Nmt = 1;
397 
398  Mat_SU_N unity(Nc);
399 
400  unity.unit();
401 
402  for (int site = 0; site < Nvol2; ++site) {
403  G0.set_mat(site, 0, unity);
404  }
405 
406  for (int imt = 0; imt < Nmt; ++imt) {
407  maxTr1(G0, W);
408  maxTr2(G0, W);
409  maxTr3(G0, W);
410  }
411 }
412 
413 
414 //====================================================================
416 {
417  int Nc = CommonParameters::Nc();
418  int Nvol2 = W.nvol();
419 
420  Mat_SU_N gt(Nc), wt(Nc), gt2(Nc), wt2(Nc);
421 
422  for (int site = 0; site < Nvol2; ++site) {
423  wt = W.mat(site, 0);
424 
425  gt.set(2, 0.0, 0.0);
426  gt.set(5, 0.0, 0.0);
427  gt.set(6, 0.0, 0.0);
428  gt.set(7, 0.0, 0.0);
429  gt.set(8, 1.0, 0.0);
430 
431  double fn1 = (wt.r(0) + wt.r(4)) * (wt.r(0) + wt.r(4))
432  + (wt.i(0) - wt.i(4)) * (wt.i(0) - wt.i(4));
433  double fn2 = (wt.r(1) - wt.r(3)) * (wt.r(1) - wt.r(3))
434  + (wt.i(1) + wt.i(3)) * (wt.i(1) + wt.i(3));
435  double fn = 1.0 / sqrt(fn1 + fn2);
436 
437  gt.set(0, fn * (wt.r(0) + wt.r(4)), fn * (-wt.i(0) + wt.i(4)));
438  gt.set(1, fn * (-wt.r(1) + wt.r(3)), fn * (-wt.i(1) - wt.i(3)));
439  gt.set(3, fn * (wt.r(1) - wt.r(3)), fn * (-wt.i(1) - wt.i(3)));
440  gt.set(4, fn * (wt.r(0) + wt.r(4)), fn * (wt.i(0) - wt.i(4)));
441 
442  wt2 = gt * wt;
443  W.set_mat(site, 0, wt2);
444  gt2 = G.mat(site, 0);
445  wt2 = gt * gt2;
446  G.set_mat(site, 0, wt2);
447  }
448 }
449 
450 
451 //====================================================================
453 {
454  int Nc = CommonParameters::Nc();
455  int Nvol2 = W.nvol();
456 
457  Mat_SU_N gt(Nc), wt(Nc), gt2(Nc), wt2(Nc);
458 
459  for (int site = 0; site < Nvol2; ++site) {
460  wt = W.mat(site, 0);
461 
462  gt.set(1, 0.0, 0.0);
463  gt.set(3, 0.0, 0.0);
464  gt.set(4, 1.0, 0.0);
465  gt.set(5, 0.0, 0.0);
466  gt.set(7, 0.0, 0.0);
467 
468  double fn1 = (wt.r(8) + wt.r(0)) * (wt.r(8) + wt.r(0))
469  + (wt.i(8) - wt.i(0)) * (wt.i(8) - wt.i(0));
470  double fn2 = (wt.r(2) - wt.r(6)) * (wt.r(2) - wt.r(6))
471  + (wt.i(2) + wt.i(6)) * (wt.i(2) + wt.i(6));
472  double fn = 1.0 / sqrt(fn1 + fn2);
473 
474  gt.set(0, fn * (wt.r(8) + wt.r(0)), fn * (wt.i(8) - wt.i(0)));
475  gt.set(2, fn * (wt.r(6) - wt.r(2)), fn * (-wt.i(6) - wt.i(2)));
476  gt.set(6, fn * (-wt.r(6) + wt.r(2)), fn * (-wt.i(6) - wt.i(2)));
477  gt.set(8, fn * (wt.r(8) + wt.r(0)), fn * (-wt.i(8) + wt.i(0)));
478 
479  wt2 = gt * wt;
480  W.set_mat(site, 0, wt2);
481  gt2 = G.mat(site, 0);
482  wt2 = gt * gt2;
483  G.set_mat(site, 0, wt2);
484  }
485 }
486 
487 
488 //====================================================================
490 {
491  int Nc = CommonParameters::Nc();
492  int Nvol2 = W.nvol();
493 
494  Mat_SU_N gt(Nc), wt(Nc), gt2(Nc), wt2(Nc);
495 
496  for (int site = 0; site < Nvol2; ++site) {
497  wt = W.mat(site, 0);
498 
499  gt.set(0, 1.0, 0.0);
500  gt.set(1, 0.0, 0.0);
501  gt.set(2, 0.0, 0.0);
502  gt.set(3, 0.0, 0.0);
503  gt.set(6, 0.0, 0.0);
504 
505  double fn1 = (wt.r(4) + wt.r(8)) * (wt.r(4) + wt.r(8))
506  + (wt.i(4) - wt.i(8)) * (wt.i(4) - wt.i(8));
507  double fn2 = (wt.r(7) - wt.r(5)) * (wt.r(7) - wt.r(5))
508  + (wt.i(7) + wt.i(5)) * (wt.i(7) + wt.i(5));
509  double fn = 1.0 / sqrt(fn1 + fn2);
510 
511  gt.set(4, fn * (wt.r(4) + wt.r(8)), fn * (-wt.i(4) + wt.i(8)));
512  gt.set(5, fn * (-wt.r(5) + wt.r(7)), fn * (-wt.i(5) - wt.i(7)));
513  gt.set(7, fn * (wt.r(5) - wt.r(7)), fn * (-wt.i(5) - wt.i(7)));
514  gt.set(8, fn * (wt.r(4) + wt.r(8)), fn * (wt.i(4) - wt.i(8)));
515 
516  wt2 = gt * wt;
517  W.set_mat(site, 0, wt2);
518  gt2 = G.mat(site, 0);
519  wt2 = gt * gt2;
520  G.set_mat(site, 0, wt2);
521  }
522 }
523 
524 
525 //====================================================================
526 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:207
void Register_string(const string &, const string &)
Definition: parameters.cpp:352
double norm2() const
Definition: field.cpp:469
void maxTr2(Field_G &, Field_G &)
void general(const char *format,...)
Definition: bridgeIO.cpp:38
void Register_int(const string &, const int)
Definition: parameters.cpp:331
static const std::string class_name
int shift(void)
int nvol() const
Definition: field.h:101
Class for parameters.
Definition: parameters.h:40
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:162
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:36
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:102
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:62
Methods to shift the even-odd field.
Definition: shiftField_eo.h:45
void crucial(const char *format,...)
Definition: bridgeIO.cpp:26
Bridge::VerboseLevel m_vl
Definition: gaugeFixing.h:49
static bool Register(const std::string &realm, const creator_callback &cb)
Base class of random number generators.
Definition: randomNumbers.h:40
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:123
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:324
void backward_h(Field &, const Field &, const int mu, const int ieo)
Mat_SU_N & set_random(RandomNumbers *rnd)
Definition: mat_SU_N.h:76
gauge fixing.
Definition: gaugeFixing.h:34
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:150
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:85
void set_mat(const int site, const int mn, const Mat_SU_N &U)
Definition: field_G.h:156
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:110
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:164
void forward_h(Field &, const Field &, const int mu, const int ieo)
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:191
double ReTr(const Mat_SU_N &m)
Definition: mat_SU_N.h:488
void set_randomGaugeTrans(Field_G &Geo)
static int NPE()