Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
topologicalCharge.cpp
Go to the documentation of this file.
1 
14 #include "topologicalCharge.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_double("c_plaq", 0.0);
27  param.Register_double("c_rect", 0.0);
28 
29  param.Register_string("verbose_level", "NULL");
30  }
31 
32 
33 #ifdef USE_PARAMETERS_FACTORY
34  bool init_param = ParametersFactory::Register("TopologicalCharge", append_entry);
35 #endif
36 }
37 //- end
38 
39 //- parameters class
41 //- end
42 
43 const std::string TopologicalCharge::class_name = "TopologicalCharge";
44 
45 //====================================================================
47 {
48  const string str_vlevel = params.get_string("verbose_level");
49 
50  m_vl = vout.set_verbose_level(str_vlevel);
51 
52  //- fetch and check input parameters
53  double c_plaq, c_rect;
54 
55  int err = 0;
56  err += params.fetch_double("c_plaq", c_plaq);
57  err += params.fetch_double("c_rect", c_rect);
58 
59  if (err) {
60  vout.crucial(m_vl, "%s: fetch error, input parameter not found.\n", class_name.c_str());
61  abort();
62  }
63 
64 
65  set_parameters(c_plaq, c_rect);
66 }
67 
68 
69 //====================================================================
70 void TopologicalCharge::set_parameters(double c_plaq, double c_rect)
71 {
72  //- print input parameters
73  vout.general(m_vl, "Topological Charge measurement:\n");
74  vout.general(m_vl, " c_plaq = %12.6f\n", c_plaq);
75  vout.general(m_vl, " c_rect = %12.6f\n", c_rect);
76 
77  //- range check
78  // NB. beta,c_plaq,c_rect == 0 is allowed.
79 
80  //- store values
81  m_c_plaq = c_plaq;
82  m_c_rect = c_rect;
83 
84  //- post-process
85 }
86 
87 
88 //====================================================================
90 {
91  int Ndim = CommonParameters::Ndim();
92  int Nvol = CommonParameters::Nvol();
93  static const double PI = 4.0 * atan(1.0);
94  static const double PI2 = PI * PI;
95 
96  // NB. #(mu,nu)=6 i.e. (1,2),(1,3),(1,4),(2,3),(2,4),(3,4)
97  std::vector<Field_G> Fmunu_1x1(6), Fmunu_1x2(6);
98 
99 
100  vout.paranoiac(m_vl, "%s: measurement start.\n", class_name.c_str());
101 
102  int i_munu = 0;
103  for (int mu = 0; mu < Ndim; ++mu) {
104  for (int nu = mu + 1; nu < Ndim; ++nu) {
105  construct_Fmunu_1x1(Fmunu_1x1[i_munu], mu, nu, U);
106  construct_Fmunu_1x2(Fmunu_1x2[i_munu], mu, nu, U);
107 
108  ++i_munu;
109  }
110  }
111 
112 
113  double Q_1x1 = 0.0;
114 
115  // (mu,nu, rho,sigma) = (1,2, 3,4)
116  Q_1x1 += contract_epsilon_tensor(Fmunu_1x1[0], Fmunu_1x1[5]);
117 
118  // (mu,nu, rho,sigma) = (1,3, 2,4)
119  Q_1x1 -= contract_epsilon_tensor(Fmunu_1x1[1], Fmunu_1x1[4]);
120 
121  // (mu,nu, rho,sigma) = (1,4, 2,3)
122  Q_1x1 += contract_epsilon_tensor(Fmunu_1x1[2], Fmunu_1x1[3]);
123 
124  // #degeneracy of (mu,nu, rho,sigma) is 8
125  Q_1x1 *= 8.0;
126 
127 
128  double Q_1x2 = 0.0;
129  Q_1x2 += contract_epsilon_tensor(Fmunu_1x2[0], Fmunu_1x2[5]);
130  Q_1x2 -= contract_epsilon_tensor(Fmunu_1x2[1], Fmunu_1x2[4]);
131  Q_1x2 += contract_epsilon_tensor(Fmunu_1x2[2], Fmunu_1x2[3]);
132  Q_1x2 *= 8.0;
133 
134 
135  double Q_topo = (m_c_plaq * Q_1x1 + m_c_rect * Q_1x2 / 2.0) / (32.0 * PI2);
136 
137 
138 
139  vout.general(m_vl, " Q_1x1,Q_1x2 = %20.16e %20.16e\n",
140  Q_1x1 / (32.0 * PI2),
141  Q_1x2 / (2.0 * (32.0 * PI2)));
142 
143  vout.paranoiac(m_vl, "%s: measurement finished.\n", class_name.c_str());
144 
145 
146  return Q_topo;
147 }
148 
149 
150 //====================================================================
152  const int mu, const int nu, Field_G& U)
153 {
154  int Nvol = CommonParameters::Nvol();
155 
156  Staples staple;
157 
158  Field_G Cup(Nvol, 1), Cdn(Nvol, 1);
159  Field_G Umu(Nvol, 1);
160  Field_G v(Nvol, 1), v2(Nvol, 1);
161 
162 
163  //- building blocks
164  // (1) mu (2)
165  // +->-+
166  // nu | |
167  // i+ +
168  Cup = staple.upper(U, mu, nu);
169 
170  // (1) mu (2)
171  // i+ +
172  // nu | |
173  // +->-+
174  Cdn = staple.lower(U, mu, nu);
175  Umu.setpart_ex(0, U, mu);
176 
177 
178  //- right clover leaf
179  // (2) +-<-+
180  // nu | |
181  // i+->-+
182  // mu (1)
183  mult_Field_Gnd(Fmunu_1x1, 0, Umu, 0, Cup, 0);
184 
185  // (1) i+-<-+
186  // nu | |
187  // +->-+
188  // mu (2)
189  multadd_Field_Gnd(Fmunu_1x1, 0, Cdn, 0, Umu, 0, 1.0);
190 
191 
192  //- left clover leaf
193  // mu (2)
194  // +-<-+ (1)
195  // | | nu mu (1)
196  // +->-+i + +-<-+i (2)
197  // | | nu
198  // +->-+
199  mult_Field_Gdn(v, 0, Cup, 0, Umu, 0);
200  multadd_Field_Gdn(v, 0, Umu, 0, Cdn, 0, 1.0);
201 
202  // NB. shift.forward(mu)
203  // mu (2) mu (2)
204  // +-<-+ (1) +-<-+ (1)
205  // | | nu -> | | nu
206  // i+->-+ +->-+i
207  m_shift.forward(v2, v, mu);
208 
209  Fmunu_1x1 += v2;
210 
211 
212  ah_Field_G(Fmunu_1x1, 0);
213 
214  Fmunu_1x1 *= -0.25;
215  Fmunu_1x1.xI();
216 }
217 
218 
219 //====================================================================
221  const int mu, const int nu, Field_G& U)
222 {
223  int Nvol = CommonParameters::Nvol();
224 
225  Staples staple;
226 
227  Field_G Cup1(Nvol, 1), Cup2(Nvol, 1);
228  Field_G Cdn1(Nvol, 1), Cdn2(Nvol, 1);
229  Field_G Umu(Nvol, 1), Unu(Nvol, 1);
230  Field_G Umu_nu(Nvol, 1), Unu_mu(Nvol, 1);
231  Field_G rect(Nvol, 1);
232  Field_G v(Nvol, 1), w(Nvol, 1), c(Nvol, 1);
233 
234  //-- building blocks
235  // mu (2)
236  // (1) +->-+
237  // nu | |
238  // i+ +
239  Cup1 = staple.upper(U, mu, nu);
240 
241  // +-<-+ (2)
242  // | nu
243  // i+->-+
244  // mu (1)
245  Cup2 = staple.upper(U, nu, mu);
246 
247  // (1) i+ +
248  // nu | |
249  // +->-+
250  // mu (2)
251  Cdn1 = staple.lower(U, mu, nu);
252 
253  // (2) +->-+
254  // nu |
255  // +-<-+i
256  // mu (1)
257  Cdn2 = staple.lower(U, nu, mu);
258 
259  Umu.setpart_ex(0, U, mu);
260  Unu.setpart_ex(0, U, nu);
261 
262  // +->-+
263  //
264  // i+
265  m_shift.backward(Umu_nu, Umu, nu);
266 
267  // +
268  // |
269  // i+ +
270  m_shift.backward(Unu_mu, Unu, mu);
271 
272  //============================================================
273  //-- 2x1 part
274 
275  //- upper-right(2x1)
276  // +---<---+ + +-<-+ <---+
277  // nu | | = | + + | +
278  // i+--->---+ i+ i+ i+ >---+ i+->-+
279  m_shift.backward(c, Cup2, mu);
280 
281  mult_Field_Gdd(v, 0, Umu_nu, 0, Unu, 0);
282  mult_Field_Gnn(w, 0, c, 0, v, 0);
283 
284  mult_Field_Gnn(rect, 0, Umu, 0, w, 0);
285 
286  Fmunu_1x2 = rect;
287 
288 
289  //- lower-right(2x1)
290  // (1) +---<---+ (1) i+---<---+
291  // nu | | -> nu | |
292  // i+--->---+ +--->---+
293  // mu (2) mu (2)
294  mult_Field_Gnd(v, 0, c, 0, Umu_nu, 0);
295  mult_Field_Gnn(w, 0, Umu, 0, v, 0);
296 
297  mult_Field_Gdn(rect, 0, Unu, 0, w, 0);
298 
299  m_shift.forward(v, rect, nu);
300 
301  Fmunu_1x2 += v;
302 
303 
304  //- upper-left(2x1)
305  // mu (2)
306  // +---<---+ (1) +-<-+ +-<-+ +
307  // | | nu = + | + + |
308  // +---i---+ i+->-+ +->-+i +i +i +
309  //
310  // NB. shift.forward(mu)
311  // mu (2) mu (2)
312  // +---<---+ (1) +---<---+ (1)
313  // | | nu -> | | nu
314  // +---i---+ +--->---+i
315  mult_Field_Gdn(v, 0, Cdn2, 0, Umu, 0);
316  mult_Field_Gdn(w, 0, Umu_nu, 0, v, 0);
317 
318  mult_Field_Gnn(rect, 0, Unu_mu, 0, w, 0);
319 
320  m_shift.forward(v, rect, mu);
321 
322  Fmunu_1x2 += v;
323 
324 
325  //- lower-left(2x1)
326  // mu (1)
327  // +---<---+ (2) + +-<-+ +-<-+
328  // | | nu = | + + | +
329  // +---i---+ +i + i+->-+ +->-+i +i
330  //
331  // NB. shift.forward(mu+nu)
332  // mu (1) mu (1) mu (1)
333  // +---<---+ (2) +---<---+ (2) +---<---+i (2)
334  // | | nu -> | | nu -> | | nu
335  // +---i---+ +--->---+i +--->---+
336  mult_Field_Gnn(v, 0, Umu, 0, Unu_mu, 0);
337  mult_Field_Gdn(w, 0, Cdn2, 0, v, 0);
338 
339  mult_Field_Gdn(rect, 0, Umu_nu, 0, w, 0);
340 
341  m_shift.forward(w, rect, mu);
342  m_shift.forward(v, w, nu);
343 
344  Fmunu_1x2 += v;
345  //============================================================
346 
347 
348  //============================================================
349  //-- 1x2 part
350 
351  //- upper-right(1x2)
352  // +-<-+ +-<-+
353  // | | | |
354  // (2) + + = + + + + + + +
355  // nu | | | |
356  // i+->-+ i+ i+ i+ + i+->-+
357  // mu (1)
358  m_shift.backward(c, Cup1, nu);
359 
360  mult_Field_Gdd(v, 0, c, 0, Unu, 0);
361  mult_Field_Gnn(w, 0, Unu_mu, 0, v, 0);
362 
363  mult_Field_Gnn(rect, 0, Umu, 0, w, 0);
364 
365  Fmunu_1x2 += rect;
366 
367 
368  //- lower-right(1x2)
369  // mu (2)
370  // (1) +-<-+ +-<-+ + +
371  // nu | | | |
372  // i+ + = i+ + i+ + + i+ + + i+
373  // | | | |
374  // +->-+ +->-+
375  //
376  // NB. shift.forward(nu)
377  // mu (2) mu (2)
378  // (1) +-<-+ (1) i+-<-+
379  // nu | | nu | |
380  // i+ + -> + +
381  // | | | |
382  // +->-+ +->-+
383  mult_Field_Gnd(v, 0, Unu_mu, 0, Umu_nu, 0);
384  mult_Field_Gnn(w, 0, Cdn1, 0, v, 0);
385 
386  mult_Field_Gdn(rect, 0, Unu, 0, w, 0);
387 
388  m_shift.forward(v, rect, nu);
389 
390  Fmunu_1x2 += v;
391 
392 
393  //- upper-left(1x2)
394  // +-<-+ +-<-+
395  // | | | |
396  // + + (1) = + + + + + + +
397  // | | nu | |
398  // i+->-+ i+->-+ i+ i+ i+ +
399  // mu (2)
400  //
401  // NB. shift.forward(mu)
402  // +-<-+ +-<-+
403  // | | | |
404  // + + (1) -> + + (1)
405  // | | nu | | nu
406  // i+->-+ +->-+i
407  // mu (2) mu (2)
408  mult_Field_Gdn(v, 0, Unu, 0, Umu, 0);
409  mult_Field_Gdn(w, 0, c, 0, v, 0);
410 
411  mult_Field_Gnn(rect, 0, Unu_mu, 0, w, 0);
412 
413  m_shift.forward(v, rect, mu);
414 
415  Fmunu_1x2 += v;
416 
417 
418  //- lower-left(1x2)
419  // mu (1)
420  // (2) +-<-+ + + +-<-+
421  // nu | | | |
422  // i+ + = i+ + + i+ + + i+ + i+
423  // | | | |
424  // +->-+ +->-+
425  //
426  // NB. shift.forward(mu+nu)
427  // mu (1) mu (1)
428  // (2) +-<-+ (2) +-<-+i
429  // nu | | nu | |
430  // i+ + -> + +
431  // | | | |
432  // +->-+ +->-+
433  mult_Field_Gnn(v, 0, Cdn1, 0, Unu_mu, 0);
434  mult_Field_Gdn(w, 0, Unu, 0, v, 0);
435 
436  mult_Field_Gdn(rect, 0, Umu_nu, 0, w, 0);
437 
438  m_shift.forward(w, rect, mu);
439  m_shift.forward(v, w, nu);
440 
441  Fmunu_1x2 += v;
442  //============================================================
443 
444 
445  ah_Field_G(Fmunu_1x2, 0);
446 
447  Fmunu_1x2 *= -0.25;
448  Fmunu_1x2.xI();
449 }
450 
451 
452 //====================================================================
454 {
455  int Nvol = CommonParameters::Nvol();
456 
457  double Q_topo = 0.0;
458 
459  for (int site = 0; site < Nvol; ++site) {
460  Q_topo += ReTr(Fmunu_1.mat(site) * Fmunu_2.mat(site));
461  }
462  double result = Communicator::reduce_sum(Q_topo);
463 
464  return result;
465 }
466 
467 
468 //====================================================================
469 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:207
void Register_string(const string &, const string &)
Definition: parameters.cpp:352
Staple construction.
Definition: staples.h:40
void mult_Field_Gdn(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2)
static const std::string class_name
Field_G upper(const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane (wrapping void version).
Definition: staples.cpp:118
void general(const char *format,...)
Definition: bridgeIO.cpp:38
double measure(Field_G &U)
main function to measure Topological Charge.
ShiftField_lex m_shift
void construct_Fmunu_1x2(Field_G &Fmunu, int mu, int nu, Field_G &U)
void construct_Fmunu_1x1(Field_G &Fmunu, int mu, int nu, Field_G &U)
Class for parameters.
Definition: parameters.h:40
void mult_Field_Gdd(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2)
double contract_epsilon_tensor(Field_G &Fmunu_1, Field_G &Fmunu_2)
void ah_Field_G(Field_G &w, const int ex)
SU(N) gauge field.
Definition: field_G.h:36
void multadd_Field_Gdn(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2, const double ff)
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)
void backward(Field &, const Field &, const int mu)
void paranoiac(const char *format,...)
Definition: bridgeIO.cpp:62
void multadd_Field_Gnd(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2, const double ff)
void crucial(const char *format,...)
Definition: bridgeIO.cpp:26
static bool Register(const std::string &realm, const creator_callback &cb)
Bridge::VerboseLevel m_vl
Field_G lower(const Field_G &, const int mu, const int nu)
constructs lower staple in mu-nu plane (wrapping void version).
Definition: staples.cpp:128
virtual void set_parameters(const Parameters &params)
setting parameters.
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 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
string get_string(const string &key) const
Definition: parameters.cpp:85
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:110
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 forward(Field &, const Field &, const int mu)
void xI()
Definition: field_G.h:180