Bridge++  Ver. 1.1.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 //====================================================================
59 {
60  const string str_vlevel = params.get_string("verbose_level");
61 
62  m_vl = vout.set_verbose_level(str_vlevel);
63 
64  //- fetch and check input parameters
65  int Niter, Nnaive, Nmeas, Nreset;
66  double Enorm, wp;
67 
68  int err = 0;
69  err += params.fetch_int("maximum_number_of_iteration", Niter);
70  err += params.fetch_int("number_of_naive_iteration", Nnaive);
71  err += params.fetch_int("interval_of_measurement", Nmeas);
72  err += params.fetch_int("iteration_to_reset", Nreset);
73  err += params.fetch_double("convergence_criterion_squared", Enorm);
74  err += params.fetch_double("overrelaxation_parameter", wp);
75 
76  if (err) {
77  vout.crucial(m_vl, "GaugeFixing_Landau: fetch error, input parameter not found.\n");
78  abort();
79  }
80 
81 
82  set_parameters(Niter, Nnaive, Nmeas, Nreset, Enorm, wp);
83 }
84 
85 
86 //====================================================================
87 void GaugeFixing_Landau::set_parameters(const int Niter, const int Nnaive,
88  const int Nmeas, const int Nreset,
89  const double Enorm, const double wp)
90 {
91  //- print input parameters
92  vout.general(m_vl, "Landau gauge fixing:\n");
93  vout.general(m_vl, " Niter = %d\n", Niter);
94  vout.general(m_vl, " Nnaive = %d\n", Nnaive);
95  vout.general(m_vl, " Nmeas = %d\n", Nmeas);
96  vout.general(m_vl, " Nreset = %d\n", Nreset);
97  vout.general(m_vl, " Enorm = %12.4e\n", Enorm);
98  vout.general(m_vl, " wp = %8.4f\n", wp);
99 
100  //- range check
101  int err = 0;
102  err += ParameterCheck::non_negative(Niter);
103  err += ParameterCheck::non_negative(Nnaive);
104  err += ParameterCheck::non_negative(Nmeas);
105  err += ParameterCheck::non_negative(Nreset);
106  err += ParameterCheck::square_non_zero(Enorm);
107  err += ParameterCheck::non_zero(wp);
108 
109  if (err) {
110  vout.crucial(m_vl, "GaugeFixing_Landau: parameter range check failed.\n");
111  abort();
112  }
113 
114  //- store values
115  m_Niter = Niter;
116  m_Nnaive = Nnaive;
117  m_Nmeas = Nmeas;
118  m_Nreset = Nreset;
119  m_Enorm = Enorm;
120  m_wp = wp;
121 }
122 
123 
124 //====================================================================
125 void GaugeFixing_Landau::fix(Field_G& Ufix, const Field_G& Uorg)
126 {
127  int Nvol = Uorg.nvol();
128  int Nex = Uorg.nex();
129 
130  int Nvol2 = Nvol / 2;
131  Field_G Ue(Nvol2, Nex), Uo(Nvol2, Nex);
132 
133  Field_G Ge(Nvol2, 1), Go(Nvol2, 1);
134 
135  m_index.convertField(Ue, Uorg, 0);
136  m_index.convertField(Uo, Uorg, 1);
137 
138  int Nconv = -1;
139 
140  // gauge fixing iteration
141  for (int iter = 0; iter < m_Niter; ++iter) {
142  if ((iter % m_Nmeas) == 0) {
143  double sg, Fval;
144  calc_SG(sg, Fval, Ue, Uo);
145 
146  vout.paranoiac(m_vl, " iter = %6d sg = %16.8e Fval = %16.8e\n",
147  iter, sg, Fval);
148 
149  if (sg < m_Enorm) {
150  Nconv = iter;
151  vout.general(m_vl, "converged at iter = %d\n", Nconv);
152  break;
153  }
154  }
155 
156  double wp2 = m_wp;
157  if ((iter % m_Nreset) < m_Nnaive) wp2 = 1.0;
158 
159  gfix_step(Ue, Uo, wp2);
160 
161  if (((iter % m_Nreset) == 0) && (iter > 0)) {
162  // random gauge transformation
163  vout.general(m_vl, " random gauge transformation performed.\n");
164 
166  gauge_trans_eo(Ue, Uo, Ge, 0);
167 
169  gauge_trans_eo(Ue, Uo, Go, 1);
170  }
171  }
172 
173  m_index.reverseField(Ufix, Ue, 0);
174  m_index.reverseField(Ufix, Uo, 1);
175 }
176 
177 
178 //====================================================================
180  double wp)
181 {
182  int Nc = CommonParameters::Nc();
183  int Nvol2 = Ue.nvol();
184  int Nex = Ue.nex();
185 
186  Field_G Weo(Nvol2, 1), Geo(Nvol2, 1);
187  Mat_SU_N ut(Nc), uwp(Nc);
188 
189  uwp.unit();
190  uwp *= (1.0 - wp);
191 
192  for (int ieo = 0; ieo < 2; ++ieo) {
193  calc_W(Weo, Ue, Uo, ieo);
194  maxTr(Geo, Weo);
195  Geo *= wp;
196 
197  double wp_sbt = 1.0 - wp;
198  for (int site = 0; site < Nvol2; ++site) {
199  ut = Geo.mat(site, 0);
200  ut += uwp;
201  ut.reunit();
202  Geo.set_mat(site, 0, ut);
203  }
204 
205  gauge_trans_eo(Ue, Uo, Geo, ieo);
206  }
207 }
208 
209 
210 //====================================================================
212 {
213  int Nvol = Geo.nvol();
214  int Nex = Geo.nex();
215 
216  int Nc = CommonParameters::Nc();
217  Mat_SU_N gt(Nc);
218 
219  for (int ex = 0; ex < Nex; ++ex) {
220  for (int site = 0; site < Nvol; ++site) {
221  //gt = Geo.mat(site,ex);
222  gt.set_random(m_rand);
223  Geo.set_mat(site, ex, gt);
224  }
225  }
226 }
227 
228 
229 //====================================================================
231  Field_G& Geo, int Ieo)
232 {
233  // Ieo = 0: gauge transformation on even sites.
234  // Ieo = 1: on odd sites.
235 
236  int Nvol2 = Geo.nvol();
237  int Nex = Geo.nex();
238  int Ndim = CommonParameters::Ndim();
239 
241 
242  Field_G Ut(Nvol2, 1), Gt(Nvol2, 1);
243  Field_G Ut2(Nvol2, 1);
244 
245  if (Ieo == 0) {
246  for (int mu = 0; mu < Ndim; ++mu) {
247  Ut.mult_Field_Gnn(0, Geo, 0, Ue, mu);
248  Ue.setpart_ex(mu, Ut, 0);
249 
250  shift.backward_h(Gt, Geo, mu, 1);
251  Ut.mult_Field_Gnd(0, Uo, mu, Gt, 0);
252  Uo.setpart_ex(mu, Ut, 0);
253  }
254  } else {
255  for (int mu = 0; mu < Ndim; ++mu) {
256  Ut.mult_Field_Gnn(0, Geo, 0, Uo, mu);
257  Uo.setpart_ex(mu, Ut, 0);
258 
259  shift.backward_h(Gt, Geo, mu, 0);
260  Ut.mult_Field_Gnd(0, Ue, mu, Gt, 0);
261  Ue.setpart_ex(mu, Ut, 0);
262  }
263  }
264 }
265 
266 
267 //====================================================================
268 void GaugeFixing_Landau::calc_SG(double& sg, double& Fval,
269  Field_G& Ue, Field_G& Uo)
270 {
271  int Nc = CommonParameters::Nc();
272  int NPE = CommonParameters::NPE();
273  int Nvol2 = Ue.nvol();
274  int Nex = Ue.nex();
275 
276  Field_G DLT(Nvol2, 1);
277  Mat_SU_N ut(Nc);
278 
279  sg = 0.0;
280  Fval = 0.0;
281 
282  for (int ieo = 0; ieo < 2; ++ieo) {
283  calc_DLT(DLT, Ue, Uo, ieo);
284  double tsg = DLT.norm2();
285  sg += tsg;
286  }
287  sg = sg / (Nex * Nc * 2 * Nvol2 * NPE);
288 
289  for (int mu = 0; mu < Nex; ++mu) {
290  for (int site = 0; site < Nvol2; ++site) {
291  ut = Ue.mat(site, mu);
292  Fval += ReTr(ut);
293  ut = Uo.mat(site, mu);
294  Fval += ReTr(ut);
295  }
296  }
297  Fval = Communicator::reduce_sum(Fval);
298  Fval = Fval / (Nex * 2 * Nvol2 * NPE);
299 }
300 
301 
302 //====================================================================
304  Field_G& Ue, Field_G& Uo, int Ieo)
305 {
306  int Nvol2 = Ue.nvol();
307  int Nc = CommonParameters::Nc();
308  int Ndim = CommonParameters::Ndim();
309 
311 
312  Field_G Ut1(Nvol2, 1), Ut2(Nvol2, 1);
313  Mat_SU_N u_tmp(Nc);
314 
315  DLT = 0.0;
316 
317  if (Ieo == 0) { // on even sites
318  for (int mu = 0; mu < Ndim; ++mu) {
319  DLT.addpart_ex(0, Ue, mu, -1.0);
320  Ut1.setpart_ex(0, Uo, mu);
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  Ut1.setpart_ex(0, Ue, mu);
328  shift.forward_h(Ut2, Ut1, mu, 1);
329  DLT.addpart_ex(0, Ut2, 0);
330  }
331  }
332 
333  for (int site = 0; site < Nvol2; ++site) {
334  u_tmp = DLT.mat(site, 0);
335  u_tmp.at();
336  u_tmp *= 2.0;
337  DLT.set_mat(site, 0, u_tmp);
338  }
339 }
340 
341 
342 //====================================================================
344  Field_G& Ue, Field_G& Uo, int Ieo)
345 {
346  int Nvol2 = Ue.nvol();
347  int Nc = CommonParameters::Nc();
348  int Ndim = CommonParameters::Ndim();
349 
350  assert(Weo.nex() == 1);
351 
353 
354  Field_G Ut1(Nvol2, 1), Ut2(Nvol2, 1);
355  Mat_SU_N u_tmp(Nc);
356 
357  Weo = 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  Ut1.setpart_ex(0, Uo, mu);
363  shift.forward_h(Ut2, Ut1, mu, 0);
364  for (int site = 0; site < Nvol2; ++site) {
365  u_tmp = Ut2.mat_dag(site, 0);
366  Weo.add_mat(site, 0, u_tmp);
367  }
368  }
369  } else if (Ieo == 1) { // on odd sites
370  for (int mu = 0; mu < Ndim; ++mu) {
371  Weo.addpart_ex(0, Uo, mu);
372  Ut1.setpart_ex(0, Ue, mu);
373  shift.forward_h(Ut2, Ut1, mu, 1);
374  for (int site = 0; site < Nvol2; ++site) {
375  u_tmp = Ut2.mat_dag(site, 0);
376  Weo.add_mat(site, 0, u_tmp);
377  }
378  }
379  } else {
380  vout.crucial(m_vl, "gaugeFixing_Landau: Wrong ieo.\n");
381  abort();
382  }
383 }
384 
385 
386 //====================================================================
388 {
389  // Present implementation only applys to SU(3) case.
390 
391  int Nc = CommonParameters::Nc();
392  int Nvol2 = G0.nvol();
393 
394  int Nmt = 1;
395 
396  Mat_SU_N unity(Nc);
397 
398  unity.unit();
399 
400  for (int site = 0; site < Nvol2; ++site) {
401  G0.set_mat(site, 0, unity);
402  }
403 
404  for (int imt = 0; imt < Nmt; ++imt) {
405  maxTr1(G0, W);
406  maxTr2(G0, W);
407  maxTr3(G0, W);
408  }
409 }
410 
411 
412 //====================================================================
414 {
415  int Nc = CommonParameters::Nc();
416  int Nvol2 = W.nvol();
417 
418  Mat_SU_N gt(Nc), wt(Nc), gt2(Nc), wt2(Nc);
419 
420  for (int site = 0; site < Nvol2; ++site) {
421  wt = W.mat(site, 0);
422 
423  gt.set(2, 0.0, 0.0);
424  gt.set(5, 0.0, 0.0);
425  gt.set(6, 0.0, 0.0);
426  gt.set(7, 0.0, 0.0);
427  gt.set(8, 1.0, 0.0);
428 
429  double fn1 = (wt.r(0) + wt.r(4)) * (wt.r(0) + wt.r(4))
430  + (wt.i(0) - wt.i(4)) * (wt.i(0) - wt.i(4));
431  double fn2 = (wt.r(1) - wt.r(3)) * (wt.r(1) - wt.r(3))
432  + (wt.i(1) + wt.i(3)) * (wt.i(1) + wt.i(3));
433  double fn = 1.0 / sqrt(fn1 + fn2);
434 
435  gt.set(0, fn * (wt.r(0) + wt.r(4)), fn * (-wt.i(0) + wt.i(4)));
436  gt.set(1, fn * (-wt.r(1) + wt.r(3)), fn * (-wt.i(1) - wt.i(3)));
437  gt.set(3, fn * (wt.r(1) - wt.r(3)), fn * (-wt.i(1) - wt.i(3)));
438  gt.set(4, fn * (wt.r(0) + wt.r(4)), fn * (wt.i(0) - wt.i(4)));
439 
440  wt2 = gt * wt;
441  W.set_mat(site, 0, wt2);
442  gt2 = G.mat(site, 0);
443  wt2 = gt * gt2;
444  G.set_mat(site, 0, wt2);
445  }
446 }
447 
448 
449 //====================================================================
451 {
452  int Nc = CommonParameters::Nc();
453  int Nvol2 = W.nvol();
454 
455  Mat_SU_N gt(Nc), wt(Nc), gt2(Nc), wt2(Nc);
456 
457  for (int site = 0; site < Nvol2; ++site) {
458  wt = W.mat(site, 0);
459 
460  gt.set(1, 0.0, 0.0);
461  gt.set(3, 0.0, 0.0);
462  gt.set(4, 1.0, 0.0);
463  gt.set(5, 0.0, 0.0);
464  gt.set(7, 0.0, 0.0);
465 
466  double fn1 = (wt.r(8) + wt.r(0)) * (wt.r(8) + wt.r(0))
467  + (wt.i(8) - wt.i(0)) * (wt.i(8) - wt.i(0));
468  double fn2 = (wt.r(2) - wt.r(6)) * (wt.r(2) - wt.r(6))
469  + (wt.i(2) + wt.i(6)) * (wt.i(2) + wt.i(6));
470  double fn = 1.0 / sqrt(fn1 + fn2);
471 
472  gt.set(0, fn * (wt.r(8) + wt.r(0)), fn * (wt.i(8) - wt.i(0)));
473  gt.set(2, fn * (wt.r(6) - wt.r(2)), fn * (-wt.i(6) - wt.i(2)));
474  gt.set(6, fn * (-wt.r(6) + wt.r(2)), fn * (-wt.i(6) - wt.i(2)));
475  gt.set(8, fn * (wt.r(8) + wt.r(0)), fn * (-wt.i(8) + wt.i(0)));
476 
477  wt2 = gt * wt;
478  W.set_mat(site, 0, wt2);
479  gt2 = G.mat(site, 0);
480  wt2 = gt * gt2;
481  G.set_mat(site, 0, wt2);
482  }
483 }
484 
485 
486 //====================================================================
488 {
489  int Nc = CommonParameters::Nc();
490  int Nvol2 = W.nvol();
491 
492  Mat_SU_N gt(Nc), wt(Nc), gt2(Nc), wt2(Nc);
493 
494  for (int site = 0; site < Nvol2; ++site) {
495  wt = W.mat(site, 0);
496 
497  gt.set(0, 1.0, 0.0);
498  gt.set(1, 0.0, 0.0);
499  gt.set(2, 0.0, 0.0);
500  gt.set(3, 0.0, 0.0);
501  gt.set(6, 0.0, 0.0);
502 
503  double fn1 = (wt.r(4) + wt.r(8)) * (wt.r(4) + wt.r(8))
504  + (wt.i(4) - wt.i(8)) * (wt.i(4) - wt.i(8));
505  double fn2 = (wt.r(7) - wt.r(5)) * (wt.r(7) - wt.r(5))
506  + (wt.i(7) + wt.i(5)) * (wt.i(7) + wt.i(5));
507  double fn = 1.0 / sqrt(fn1 + fn2);
508 
509  gt.set(4, fn * (wt.r(4) + wt.r(8)), fn * (-wt.i(4) + wt.i(8)));
510  gt.set(5, fn * (-wt.r(5) + wt.r(7)), fn * (-wt.i(5) - wt.i(7)));
511  gt.set(7, fn * (wt.r(5) - wt.r(7)), fn * (-wt.i(5) - wt.i(7)));
512  gt.set(8, fn * (wt.r(4) + wt.r(8)), fn * (wt.i(4) - wt.i(8)));
513 
514  wt2 = gt * wt;
515  W.set_mat(site, 0, wt2);
516  gt2 = G.mat(site, 0);
517  wt2 = gt * gt2;
518  G.set_mat(site, 0, wt2);
519  }
520 }
521 
522 
523 //====================================================================
524 //============================================================END=====