Bridge++  Ver. 1.1.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
wilsonLoop.cpp
Go to the documentation of this file.
1 
14 #include "wilsonLoop.h"
15 
16 #ifdef USE_PARAMETERS_FACTORY
17 #include "parameters_factory.h"
18 #endif
19 
20 using std::valarray;
21 
22 //- parameter entries
23 namespace {
24  void append_entry(Parameters& param)
25  {
26  param.Register_int("max_spatial_loop_size", 0);
27  param.Register_int("max_temporal_loop_size", 0);
28  param.Register_int("number_of_loop_type", 0);
29 
30  param.Register_string("verbose_level", "NULL");
31  }
32 
33 
34 #ifdef USE_PARAMETERS_FACTORY
35  bool init_param = ParametersFactory::Register("WilsonLoop", append_entry);
36 #endif
37 }
38 //- end
39 
40 //- parameters class
42 //- end
43 
44 //====================================================================
46 {
47  const string str_vlevel = params.get_string("verbose_level");
48 
49  m_vl = vout.set_verbose_level(str_vlevel);
50 
51  //- fetch and check input parameters
52  int Nspc_size, Ntmp_size, Ntype;
53 
54  int err = 0;
55  err += params.fetch_int("max_spatial_loop_size", Nspc_size);
56  err += params.fetch_int("max_temporal_loop_size", Ntmp_size);
57  err += params.fetch_int("number_of_loop_type", Ntype);
58 
59  if (err) {
60  vout.crucial(m_vl, "WilsonLoop: fetch error, input parameter not found.\n");
61  abort();
62  }
63 
64 
65  set_parameters(Nspc_size, Ntmp_size, Ntype);
66 }
67 
68 
69 //====================================================================
70 void WilsonLoop::set_parameters(int Nspc_size, int Ntmp_size, int Ntype)
71 {
72  //- print input parameters
73  vout.general(m_vl, "Wilson loop measurement:\n");
74  vout.general(m_vl, " Nspc_size = %d\n", Nspc_size);
75  vout.general(m_vl, " Ntmp_size = %d\n", Ntmp_size);
76  vout.general(m_vl, " Ntype = %d\n", Ntype);
77 
78  //- range check
79  int err = 0;
80  err += ParameterCheck::non_negative(Nspc_size);
81  err += ParameterCheck::non_negative(Ntmp_size);
82  err += ParameterCheck::non_negative(Ntype);
83 
86  if (Ntype > 6) ++err;
87 
88  if (err) {
89  vout.crucial(m_vl, "WilsonLoop: parameter range check failed.\n");
90  abort();
91  }
92 
93  //- store values
94  m_Nspc_size = Nspc_size;
95  m_Ntmp_size = Ntmp_size;
96  m_Ntype = Ntype;
97 
98 
99  //- post-process
100 
101  //- set up internal data members
107 
110  m_Nmax[0] = Nspc_size;
111  m_Nmax[1] = Nspc_size;
112  m_Nmax[2] = Nspc_size / 2;
113  m_Nmax[3] = Nspc_size;
114  m_Nmax[4] = Nspc_size / 2;
115  m_Nmax[5] = Nspc_size / 2;
116 }
117 
118 
119 //====================================================================
121 {
122  int Ndim = CommonParameters::Ndim();
123 
124  assert(Ndim == 4);
125 
126  m_Ntype_max = 6;
127  int Ndim_spc = Ndim - 1;
128 
129  m_Nunit.resize(m_Ntype_max);
130  m_Nmax.resize(m_Ntype_max);
131 
132  for (int i = 0; i < m_Ntype_max; ++i) {
133  m_Nunit[i].resize(Ndim_spc);
134  }
135 
136  // The following setting explicitly depends on the definition
137  // of unit vectors.
138  assert(m_Ntype_max >= 6);
139 
140  m_Nunit[0][0] = 1;
141  m_Nunit[0][1] = 0;
142  m_Nunit[0][2] = 0;
143 
144  m_Nunit[1][0] = 1;
145  m_Nunit[1][1] = 1;
146  m_Nunit[1][2] = 0;
147 
148  m_Nunit[2][0] = 2;
149  m_Nunit[2][1] = 1;
150  m_Nunit[2][2] = 0;
151 
152  m_Nunit[3][0] = 1;
153  m_Nunit[3][1] = 1;
154  m_Nunit[3][2] = 1;
155 
156  m_Nunit[4][0] = 2;
157  m_Nunit[4][1] = 1;
158  m_Nunit[4][2] = 1;
159 
160  m_Nunit[5][0] = 2;
161  m_Nunit[5][1] = 2;
162  m_Nunit[5][2] = 1;
163 }
164 
165 
166 //====================================================================
168 {
169  int Ndim = CommonParameters::Ndim();
170  int Ndim_spc = Ndim - 1;
171 
172  int Nx = CommonParameters::Nx();
173  int Ny = CommonParameters::Ny();
174  int Nz = CommonParameters::Nz();
175  int Nt = CommonParameters::Nt();
176  int Nvol = Nx * Ny * Nz * Nt;
177  int Nc = CommonParameters::Nc();
178 
179  Index_lex index;
181  Field_G Uext(m_Nvol_ext, Ndim);
182 
183  Field_G Uspc(m_Nvol_ext, 1);
184 
185  Mat_SU_N Uunit(Nc);
186 
187  Uunit.unit();
188 
190  set_extfield(Uext, U);
191 
193  gfix_temporal(Uext);
194 
195  valarray<int> unit_v(Ndim_spc);
196 
197  vout.paranoiac(m_vl, "WilsonLoop: measurement start.\n");
198 
199  valarray<double> wloop(m_Nspc_size * m_Ntmp_size * m_Ntype);
200  wloop = 0.0;
201 
203  for (int i_type = 0; i_type < m_Ntype; ++i_type) {
205  for (int nu = 0; nu < Ndim_spc; ++nu) {
206  unit_v[0] = m_Nunit[i_type][nu % Ndim_spc];
207  unit_v[1] = m_Nunit[i_type][(1 + nu) % Ndim_spc];
208  unit_v[2] = m_Nunit[i_type][(2 + nu) % Ndim_spc];
209  int unit_v_max = unit_v[0];
210  if (unit_v_max < unit_v[1]) unit_v_max = unit_v[1];
211  if (unit_v_max < unit_v[2]) unit_v_max = unit_v[2];
212 
213  for (int site = 0; site < m_Nvol_ext; ++site) {
214  Uspc.set_mat(site, 0, Uunit);
215  }
216 
217  int Nmax = m_Nmax[i_type];
218  for (int j = 0; j < Nmax; ++j) {
219  // redef_Uspc(Uspc, Uext, j, unit_v);
220  redef_Uspc(Uspc, Uext, j, nu, unit_v);
221  //- now Uspc is product of linkv in unit_v*j direction.
222 
223  for (int t_sep = 0; t_sep < m_Ntmp_size; ++t_sep) {
224  double wloop1 = calc_wloop(Uspc, t_sep + 1);
225  vout.detailed(m_vl, " %d %d %d %d %f\n",
226  i_type, nu, j + 1, t_sep + 1, wloop1);
227  wloop[index_wloop(j, t_sep, i_type)] += wloop1 / 3.0;
228  }
229  }
230  }
231  }
232 
234  for (int i_type = 0; i_type < m_Ntype; ++i_type) {
235  int Nmax = m_Nmax[i_type];
236  for (int x_sep = 0; x_sep < Nmax; ++x_sep) {
237  for (int t_sep = 0; t_sep < m_Ntmp_size; ++t_sep) {
238  vout.general(m_vl, " %d %d %d %20.14e\n",
239  i_type + 1, x_sep + 1, t_sep + 1, wloop[index_wloop(x_sep, t_sep, i_type)]);
240  }
241  }
242  }
243 
244  vout.paranoiac(m_vl, "WilsonLoop: measurement finished.\n");
245 
246  //- return maximum loop with type=0.
247  return wloop[index_wloop(m_Nmax[0] - 1, m_Ntmp_size - 1, 0)];
248 }
249 
250 
251 //====================================================================
252 double WilsonLoop::calc_wloop(Field_G& Uspc, int t_sep)
253 {
254  int Nx = CommonParameters::Nx();
255  int Ny = CommonParameters::Ny();
256  int Nz = CommonParameters::Nz();
257  int Nt = CommonParameters::Nt();
258 
260 
261  int Nc = CommonParameters::Nc();
262  Mat_SU_N Utmp1(Nc), Utmp2(Nc), Utmp3(Nc);
263 
264  double wloop_r = 0.0;
265  double wloop_i = 0.0;
266 
267  for (int t = 0; t < Nt; ++t) {
268  for (int z = 0; z < Nz; ++z) {
269  for (int y = 0; y < Ny; ++y) {
270  for (int x = 0; x < Nx; ++x) {
271  int site1 = index_ext.site(x, y, z, t);
272  int site2 = index_ext.site(x, y, z, t + t_sep);
273 
274  Utmp1 = Uspc.mat(site1, 0);
275  Utmp2 = Uspc.mat_dag(site2, 0);
276  Utmp3 = Utmp1 * Utmp2;
277 
278  wloop_r += ReTr(Utmp3);
279  wloop_i += ImTr(Utmp3);
280  }
281  }
282  }
283  }
284 
285  wloop_r = Communicator::reduce_sum(wloop_r);
286  wloop_i = Communicator::reduce_sum(wloop_i);
287 
288  int Lvol = CommonParameters::Lvol();
289  wloop_r = wloop_r / double(Nc * Lvol);
290  wloop_i = wloop_i / double(Nc * Lvol);
291 
292  return wloop_r;
293 }
294 
295 
296 //====================================================================
298  int j, int nu, valarray<int>& unit_v)
299 {
300  int Nx = CommonParameters::Nx();
301  int Ny = CommonParameters::Ny();
302  int Nz = CommonParameters::Nz();
303  int Nt = CommonParameters::Nt();
304  int NinG = Uext.nin();
305 
307 
308  int unit_v_max = unit_v[0];
309 
310  if (unit_v_max < unit_v[1]) unit_v_max = unit_v[1];
311  if (unit_v_max < unit_v[2]) unit_v_max = unit_v[2];
312 
313  int Nc = CommonParameters::Nc();
314  Mat_SU_N Utmp1(Nc), Utmp2(Nc), Utmp3(Nc);
315 
316  int imx = 0;
317  int imy = 0;
318  int imz = 0;
319 
321  for (int k = 0; k < 3 * unit_v_max; ++k) {
322  int kmod = (k + 3 - nu) % 3;
323 
324  if ((kmod == 0) && (imx < unit_v[0])) {
325  for (int t = 0; t < m_Nt_ext; ++t) {
326  for (int z = 0; z < Nz; ++z) {
327  for (int y = 0; y < Ny; ++y) {
328  for (int x = 0; x < Nx; ++x) {
329  int x2 = x + unit_v[0] * j + imx;
330  int y2 = y + unit_v[1] * j + imy;
331  int z2 = z + unit_v[2] * j + imz;
332  int site1 = index_ext.site(x, y, z, t);
333  int site2 = index_ext.site(x2, y2, z2, t);
334 
335  Utmp1 = Uspc.mat(site1, 0);
336  Utmp2 = Uext.mat(site2, 0);
337  Utmp3 = Utmp1 * Utmp2;
338  Uspc.set_mat(site1, 0, Utmp3);
339  }
340  }
341  }
342  }
343  ++imx;
344  }
345 
346  if ((kmod == 1) && (imy < unit_v[1])) {
347  for (int t = 0; t < m_Nt_ext; ++t) {
348  for (int z = 0; z < Nz; ++z) {
349  for (int y = 0; y < Ny; ++y) {
350  for (int x = 0; x < Nx; ++x) {
351  int x2 = x + unit_v[0] * j + imx;
352  int y2 = y + unit_v[1] * j + imy;
353  int z2 = z + unit_v[2] * j + imz;
354  int site1 = index_ext.site(x, y, z, t);
355  int site2 = index_ext.site(x2, y2, z2, t);
356 
357  Utmp1 = Uspc.mat(site1, 0);
358  Utmp2 = Uext.mat(site2, 1);
359  Utmp3 = Utmp1 * Utmp2;
360  Uspc.set_mat(site1, 0, Utmp3);
361  }
362  }
363  }
364  }
365  ++imy;
366  }
367 
368  if ((kmod == 2) && (imz < unit_v[2])) {
369  for (int t = 0; t < m_Nt_ext; ++t) {
370  for (int z = 0; z < Nz; ++z) {
371  for (int y = 0; y < Ny; ++y) {
372  for (int x = 0; x < Nx; ++x) {
373  int x2 = x + unit_v[0] * j + imx;
374  int y2 = y + unit_v[1] * j + imy;
375  int z2 = z + unit_v[2] * j + imz;
376  int site1 = index_ext.site(x, y, z, t);
377  int site2 = index_ext.site(x2, y2, z2, t);
378 
379  Utmp1 = Uspc.mat(site1, 0);
380  Utmp2 = Uext.mat(site2, 2);
381  Utmp3 = Utmp1 * Utmp2;
382  Uspc.set_mat(site1, 0, Utmp3);
383  }
384  }
385  }
386  }
387  ++imz;
388  }
389  }
390 }
391 
392 
393 //====================================================================
395 {
396  int Ndim = CommonParameters::Ndim();
397  int Nx = CommonParameters::Nx();
398  int Ny = CommonParameters::Ny();
399  int Nz = CommonParameters::Nz();
400  int Nt = CommonParameters::Nt();
401  int NinG = Uorg.nin();
402 
403  Index_lex index_lex;
405 
406  Uext = 0.0;
407 
408  //- bulk part of extended field same to the original field.
409  for (int it = 0; it < Nt; ++it) {
410  for (int iz = 0; iz < Nz; ++iz) {
411  for (int iy = 0; iy < Ny; ++iy) {
412  for (int ix = 0; ix < Nx; ++ix) {
413  int site1 = index_lex.site(ix, iy, iz, it);
414  int site2 = index_ext.site(ix, iy, iz, it);
415 
416  for (int ex = 0; ex < Ndim; ++ex) {
417  Uext.set_mat(site2, ex, Uorg.mat(site1, ex));
418  }
419  }
420  }
421  }
422  }
423 
424  //- setting maximum size of volume for buffer field.
425  int Nmin_ext = m_Nx_ext;
426  if (m_Ny_ext < Nmin_ext) Nmin_ext = m_Ny_ext;
427  if (m_Nz_ext < Nmin_ext) Nmin_ext = m_Nz_ext;
428  if (m_Nt_ext < Nmin_ext) Nmin_ext = m_Nt_ext;
429  int Nvol_cp = m_Nvol_ext / Nmin_ext;
430 
431  //- buffer field for copy.
432  Field_G Ucp1(Nvol_cp, Ndim);
433  Field_G Ucp2(Nvol_cp, Ndim);
434  int size_ex = NinG * Nvol_cp * Ndim;
435 
436 
437  //- exchange in t-direction
438  for (int it_off = 0; it_off < m_Ntmp_size + 1; ++it_off) {
439  for (int iz = 0; iz < m_Nz_ext; ++iz) {
440  for (int iy = 0; iy < m_Ny_ext; ++iy) {
441  for (int ix = 0; ix < m_Nx_ext; ++ix) {
442  int site1 = index_ext.site(ix, iy, iz, it_off);
443  int site2 = ix + m_Nx_ext * (iy + m_Ny_ext * iz);
444 
445  for (int ex = 0; ex < Ndim; ++ex) {
446  Ucp1.set_mat(site2, ex, Uext.mat(site1, ex));
447  }
448  }
449  }
450  }
451 
452  Communicator::exchange(size_ex, Ucp2.ptr(0), Ucp1.ptr(0), 3, 1, 0);
453 
454  for (int iz = 0; iz < m_Nz_ext; ++iz) {
455  for (int iy = 0; iy < m_Ny_ext; ++iy) {
456  for (int ix = 0; ix < m_Nx_ext; ++ix) {
457  int site1 = ix + m_Nx_ext * (iy + m_Ny_ext * iz);
458  int site2 = index_ext.site(ix, iy, iz, Nt + it_off);
459 
460  for (int ex = 0; ex < Ndim; ++ex) {
461  Uext.set_mat(site2, ex, Ucp2.mat(site1, ex));
462  }
463  }
464  }
465  }
466  } // end of it_off loop.
467 
468  //- exchange in z-direction
469  for (int iz_off = 0; iz_off < m_Nspc_size + 1; ++iz_off) {
470  for (int it = 0; it < m_Nt_ext; ++it) {
471  for (int iy = 0; iy < m_Ny_ext; ++iy) {
472  for (int ix = 0; ix < m_Nx_ext; ++ix) {
473  int site1 = index_ext.site(ix, iy, iz_off, it);
474  int site2 = ix + m_Nx_ext * (iy + m_Ny_ext * it);
475 
476  for (int ex = 0; ex < Ndim; ++ex) {
477  Ucp1.set_mat(site2, ex, Uext.mat(site1, ex));
478  }
479  }
480  }
481  }
482 
483  Communicator::exchange(size_ex, Ucp2.ptr(0), Ucp1.ptr(0), 2, 1, 0);
484 
485  for (int it = 0; it < m_Nt_ext; ++it) {
486  for (int iy = 0; iy < m_Ny_ext; ++iy) {
487  for (int ix = 0; ix < m_Nx_ext; ++ix) {
488  int site1 = ix + m_Nx_ext * (iy + m_Ny_ext * it);
489  int site2 = index_ext.site(ix, iy, Nz + iz_off, it);
490 
491  for (int ex = 0; ex < Ndim; ++ex) {
492  Uext.set_mat(site2, ex, Ucp2.mat(site1, ex));
493  }
494  }
495  }
496  }
497  } // end of iz_off loop.
498 
499  //- exchange in y-direction
500  for (int iy_off = 0; iy_off < m_Nspc_size + 1; ++iy_off) {
501  for (int it = 0; it < m_Nt_ext; ++it) {
502  for (int iz = 0; iz < m_Nz_ext; ++iz) {
503  for (int ix = 0; ix < m_Nx_ext; ++ix) {
504  int site1 = index_ext.site(ix, iy_off, iz, it);
505  int site2 = ix + m_Nx_ext * (iz + m_Nz_ext * it);
506 
507  for (int ex = 0; ex < Ndim; ++ex) {
508  Ucp1.set_mat(site2, ex, Uext.mat(site1, ex));
509  }
510  }
511  }
512  }
513 
514  Communicator::exchange(size_ex, Ucp2.ptr(0), Ucp1.ptr(0), 1, 1, 0);
515 
516  for (int it = 0; it < m_Nt_ext; ++it) {
517  for (int iz = 0; iz < m_Nz_ext; ++iz) {
518  for (int ix = 0; ix < m_Nx_ext; ++ix) {
519  int site1 = ix + m_Nx_ext * (iz + m_Nz_ext * it);
520  int site2 = index_ext.site(ix, Ny + iy_off, iz, it);
521 
522  for (int ex = 0; ex < Ndim; ++ex) {
523  Uext.set_mat(site2, ex, Ucp2.mat(site1, ex));
524  }
525  }
526  }
527  }
528  } // end of iy_off loop.
529 
530  //- exchange in x-direction
531  for (int ix_off = 0; ix_off < m_Nspc_size + 1; ++ix_off) {
532  for (int it = 0; it < m_Nt_ext; ++it) {
533  for (int iz = 0; iz < m_Nz_ext; ++iz) {
534  for (int iy = 0; iy < m_Ny_ext; ++iy) {
535  int site1 = index_ext.site(ix_off, iy, iz, it);
536  int site2 = iy + m_Ny_ext * (iz + m_Nz_ext * it);
537 
538  for (int ex = 0; ex < Ndim; ++ex) {
539  Ucp1.set_mat(site2, ex, Uext.mat(site1, ex));
540  }
541  }
542  }
543  }
544 
545  Communicator::exchange(size_ex, Ucp2.ptr(0), Ucp1.ptr(0), 0, 1, 0);
546 
547  for (int it = 0; it < m_Nt_ext; ++it) {
548  for (int iz = 0; iz < m_Nz_ext; ++iz) {
549  for (int iy = 0; iy < m_Ny_ext; ++iy) {
550  int site1 = iy + m_Ny_ext * (iz + m_Nz_ext * it);
551  int site2 = index_ext.site(Nx + ix_off, iy, iz, it);
552 
553  for (int ex = 0; ex < Ndim; ++ex) {
554  Uext.set_mat(site2, ex, Ucp2.mat(site1, ex));
555  }
556  }
557  }
558  }
559  } // end of ix_off loop.
560 }
561 
562 
563 //====================================================================
565 {
566  int Ndim = CommonParameters::Ndim();
567  int Nc = CommonParameters::Nc();
568 
570  Mat_SU_N Utrf1(Nc), Utrf2(Nc), Utmp(Nc), Utmp2(Nc);
571 
572  int dir_t = Ndim - 1;
573 
574  for (int it = 1; it < m_Nt_ext; ++it) {
575  for (int iz = 0; iz < m_Nz_ext; ++iz) {
576  for (int iy = 0; iy < m_Ny_ext; ++iy) {
577  for (int ix = 0; ix < m_Nx_ext; ++ix) {
578  int site0 = index_ext.site(ix, iy, iz, it - 1);
579 
580  Utrf1 = Uext.mat(site0, dir_t);
581  Utrf2 = Uext.mat_dag(site0, dir_t);
582  Utmp2 = Utrf1 * Utrf2;
583  Uext.set_mat(site0, 3, Utmp2);
584 
585  int site1 = index_ext.site(ix, iy, iz, it);
586 
587  for (int ex = 0; ex < Ndim; ++ex) {
588  Utmp = Uext.mat(site1, ex);
589  Utmp2 = Utrf1 * Utmp;
590  Uext.set_mat(site1, ex, Utmp2);
591  }
592 
593  if (ix > 0) {
594  int site2 = index_ext.site(ix - 1, iy, iz, it);
595 
596  Utmp = Uext.mat(site2, 0);
597  Utmp2 = Utmp * Utrf2;
598  Uext.set_mat(site2, 0, Utmp2);
599  }
600 
601  if (iy > 0) {
602  int site2 = index_ext.site(ix, iy - 1, iz, it);
603 
604  Utmp = Uext.mat(site2, 1);
605  Utmp2 = Utmp * Utrf2;
606  Uext.set_mat(site2, 1, Utmp2);
607  }
608 
609  if (iz > 0) {
610  int site2 = index_ext.site(ix, iy, iz - 1, it);
611 
612  Utmp = Uext.mat(site2, 2);
613  Utmp2 = Utmp * Utrf2;
614  Uext.set_mat(site2, 2, Utmp2);
615  }
616  }
617  }
618  }
619  }
620 }
621 
622 
623 //====================================================================
624 //============================================================END=====