Bridge++  Version 1.4.4
 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 const std::string TopologicalCharge::class_name = "TopologicalCharge";
17 
18 //====================================================================
20 {
21  m_filename_output = params.get_string("filename_output");
22  if (m_filename_output.empty()) {
23  m_filename_output = "stdout";
24  }
25 
26  const string str_vlevel = params.get_string("verbose_level");
27  m_vl = vout.set_verbose_level(str_vlevel);
28 
29  //- fetch and check input parameters
30  double c_plaq, c_rect;
31 
32  int err = 0;
33  err += params.fetch_double("c_plaq", c_plaq);
34  err += params.fetch_double("c_rect", c_rect);
35 
36  if (err) {
37  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
38  exit(EXIT_FAILURE);
39  }
40 
41 
42  set_parameters(c_plaq, c_rect);
43 }
44 
45 
46 //====================================================================
47 void TopologicalCharge::set_parameters(double c_plaq, double c_rect)
48 {
49  //- print input parameters
50  vout.general(m_vl, "Topological Charge measurement:\n");
51  vout.general(m_vl, " c_plaq = %12.6f\n", c_plaq);
52  vout.general(m_vl, " c_rect = %12.6f\n", c_rect);
53 
54  //- range check
55  // NB. beta,c_plaq,c_rect == 0 is allowed.
56 
57  //- store values
58  m_c_plaq = c_plaq;
59  m_c_rect = c_rect;
60 }
61 
62 
63 //====================================================================
65 {
66  int Ndim = CommonParameters::Ndim();
67  static const double eps = CommonParameters::epsilon_criterion();
68  static const double PI = 4.0 * atan(1.0);
69  static const double PI2 = PI * PI;
70 
71  double Q_1x1 = 0.0;
72  double Q_1x2 = 0.0;
73 
74 
75  //--- 1x1 part ---
76  // NB. #(mu,nu)=6 i.e. (1,2),(1,3),(1,4),(2,3),(2,4),(3,4)
77  std::vector<Field_G> Fmunu_1x1(6);
78 
79  int i_munu = 0;
80 
81  for (int mu = 0; mu < Ndim; ++mu) {
82  for (int nu = mu + 1; nu < Ndim; ++nu) {
83  m_field_strength.construct_Fmunu_1x1(Fmunu_1x1[i_munu], mu, nu, U);
84 
85  ++i_munu;
86  }
87  }
88 
89  // (mu,nu, rho,sigma) = (1,2, 3,4)
90  Q_1x1 += contract_epsilon_tensor(Fmunu_1x1[0], Fmunu_1x1[5]);
91 
92  // (mu,nu, rho,sigma) = (1,3, 2,4)
93  Q_1x1 -= contract_epsilon_tensor(Fmunu_1x1[1], Fmunu_1x1[4]);
94 
95  // (mu,nu, rho,sigma) = (1,4, 2,3)
96  Q_1x1 += contract_epsilon_tensor(Fmunu_1x1[2], Fmunu_1x1[3]);
97 
98  // #degeneracy of (mu,nu, rho,sigma) is 8
99  Q_1x1 *= 8.0;
100 
101  // overall factor
102  Q_1x1 /= (32.0 * PI2);
103  //----------------
104 
105 
106  //--- 1x2 part ---
107  // NB. skip this part, if m_c_rect = 0.0
108  if (fabs(m_c_rect) > eps) {
109  // NB. #(mu,nu)=6 i.e. (1,2),(1,3),(1,4),(2,3),(2,4),(3,4)
110  std::vector<Field_G> Fmunu_1x2(6);
111 
112  int i_munu = 0;
113  for (int mu = 0; mu < Ndim; ++mu) {
114  for (int nu = mu + 1; nu < Ndim; ++nu) {
115  m_field_strength.construct_Fmunu_1x2(Fmunu_1x2[i_munu], mu, nu, U);
116 
117  ++i_munu;
118  }
119  }
120 
121  Q_1x2 += contract_epsilon_tensor(Fmunu_1x2[0], Fmunu_1x2[5]);
122  Q_1x2 -= contract_epsilon_tensor(Fmunu_1x2[1], Fmunu_1x2[4]);
123  Q_1x2 += contract_epsilon_tensor(Fmunu_1x2[2], Fmunu_1x2[3]);
124  Q_1x2 *= 8.0;
125  // extra factor "2" for 1x2
126  Q_1x2 *= 2.0;
127  Q_1x2 /= (32.0 * PI2);
128  }
129  //----------------
130 
131 
132  double Q_topo = m_c_plaq * Q_1x1 + m_c_rect * Q_1x2;
133 
134 
135  //- output
136  std::ostream& log_file_previous = vout.getStream();
137  std::ofstream log_file;
138 
139  if (m_filename_output != "stdout") {
140  log_file.open(m_filename_output.c_str(), std::ios::app);
141  vout.init(log_file);
142  }
143 
144  vout.general(m_vl, " Q_1x1 = %20.16e\n", Q_1x1);
145  if (fabs(m_c_rect) > eps) {
146  vout.general(m_vl, " Q_1x2 = %20.16e\n", Q_1x2);
147  }
148  vout.general(m_vl, " Q_topo = %20.16e\n", Q_topo);
149 
150  if (m_filename_output != "stdout") {
151  log_file.close();
152  vout.init(log_file_previous);
153  }
154 
155 
156  return Q_topo;
157 }
158 
159 
160 //====================================================================
162 {
163  int Nvol = CommonParameters::Nvol();
164 
165  double Q_topo = 0.0;
166 
167  for (int site = 0; site < Nvol; ++site) {
168  Q_topo += ReTr(Fmunu_1.mat(site) * Fmunu_2.mat(site));
169  }
170  double result = Communicator::reduce_sum(Q_topo);
171 
172  return result;
173 }
174 
175 
176 //====================================================================
177 //============================================================END=====
void construct_Fmunu_1x2(Field_G &Fmunu, const int mu, const int nu, const Field_G &U)
BridgeIO vout
Definition: bridgeIO.cpp:495
std::string m_filename_output
static double epsilon_criterion()
static const std::string class_name
void general(const char *format,...)
Definition: bridgeIO.cpp:195
double measure(Field_G &U)
main function to measure Topological Charge.
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:211
void init(const std::string &filename)
Definition: bridgeIO.cpp:51
Class for parameters.
Definition: parameters.h:46
double contract_epsilon_tensor(Field_G &Fmunu_1, Field_G &Fmunu_2)
SU(N) gauge field.
Definition: field_G.h:38
void construct_Fmunu_1x1(Field_G &Fmunu, const int mu, const int nu, const Field_G &U)
FieldStrength m_field_strength
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
Bridge::VerboseLevel m_vl
std::ostream & getStream()
Definition: bridgeIO.cpp:383
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...
string get_string(const string &key) const
Definition: parameters.cpp:116
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:113
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
double ReTr(const Mat_SU_N &m)
Definition: mat_SU_N.h:488