Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
energyDensity.cpp
Go to the documentation of this file.
1 
14 #include "energyDensity.h"
15 
16 const std::string EnergyDensity::class_name = "EnergyDensity";
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 EnergyDensity::set_parameters(const double c_plaq, const double c_rect)
48 {
49  //- print input parameters
50  vout.general(m_vl, "Energy density 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  const double plaq = m_staple.plaquette(U);
67  const double E_plaq = 36.0 * (1.0 - plaq);
68 
69  //- output
70  std::ostream& log_file_previous = vout.getStream();
71  std::ofstream log_file;
72 
73  if (m_filename_output != "stdout") {
74  log_file.open(m_filename_output.c_str(), std::ios::app);
75  vout.init(log_file);
76  }
77 
78  vout.general(m_vl, " E_plaq = %20.16e\n", E_plaq);
79 
80  if (m_filename_output != "stdout") {
81  log_file.close();
82  vout.init(log_file_previous);
83  }
84 
85  return E_plaq;
86 }
87 
88 
89 //====================================================================
91 {
92  const int Ndim = CommonParameters::Ndim();
93  const int Nvol = CommonParameters::Nvol();
94  const int NPE = CommonParameters::NPE();
95 
96  static const double eps = CommonParameters::epsilon_criterion();
97 
98  //--- 1x1 part ---
99  double E_clover_1x1 = 0.0;
100 
101  {
102  // NB. #(mu,nu)=6 i.e. (1,2),(1,3),(1,4),(2,3),(2,4),(3,4)
103  std::vector<Field_G> Fmunu_1x1(6);
104 
105  int i_munu = 0;
106 
107  for (int mu = 0; mu < Ndim; ++mu) {
108  for (int nu = mu + 1; nu < Ndim; ++nu) {
109  m_field_strength.construct_Fmunu_1x1(Fmunu_1x1[i_munu], mu, nu, U);
110 
111  ++i_munu;
112  }
113  }
114 
115  double F2_1x1 = 0.0;
116  for (int site = 0; site < Nvol; ++site) {
117  for (int i_munu = 0; i_munu < 6; i_munu++) {
118  F2_1x1 += ReTr(Fmunu_1x1[i_munu].mat(site) * Fmunu_1x1[i_munu].mat(site));
119  }
120  }
121  E_clover_1x1 = Communicator::reduce_sum(F2_1x1) / Nvol / NPE;
122  }
123  //----------------
124 
125 
126  //--- 1x2 part ---
127  double E_clover_1x2 = 0.0;
128 
129  {
130  // NB. skip this part, if m_c_rect = 0.0
131  if (fabs(m_c_rect) > eps) {
132  // NB. #(mu,nu)=6 i.e. (1,2),(1,3),(1,4),(2,3),(2,4),(3,4)
133  std::vector<Field_G> Fmunu_1x2(6);
134 
135  int i_munu = 0;
136  for (int mu = 0; mu < Ndim; ++mu) {
137  for (int nu = mu + 1; nu < Ndim; ++nu) {
138  m_field_strength.construct_Fmunu_1x2(Fmunu_1x2[i_munu], mu, nu, U);
139 
140  ++i_munu;
141  }
142  }
143 
144  double F2_1x2 = 0.0;
145  for (int site = 0; site < Nvol; ++site) {
146  for (int i_munu = 0; i_munu < 6; i_munu++) {
147  F2_1x2 += ReTr(Fmunu_1x2[i_munu].mat(site) * Fmunu_1x2[i_munu].mat(site));
148  }
149  }
150  E_clover_1x2 = Communicator::reduce_sum(F2_1x2) / Nvol / NPE;
151 
152  // extra factor "2" for 1x2
153  E_clover_1x2 *= 2.0;
154  }
155  }
156  //----------------
157 
158 
159  const double E_clover = (m_c_plaq * E_clover_1x1 + m_c_rect * E_clover_1x2);
160 
161 
162  //- output
163  std::ostream& log_file_previous = vout.getStream();
164  std::ofstream log_file;
165 
166  if (m_filename_output != "stdout") {
167  log_file.open(m_filename_output.c_str(), std::ios::app);
168  vout.init(log_file);
169  }
170 
171  vout.general(m_vl, " E_clover_1x1 = %20.16e\n", E_clover_1x1);
172  if (fabs(m_c_rect) > eps) {
173  vout.general(m_vl, " E_clover_1x2 = %20.16e\n", E_clover_1x2);
174  }
175  vout.general(m_vl, " E_clover = %20.16e\n", E_clover);
176 
177  if (m_filename_output != "stdout") {
178  log_file.close();
179  vout.init(log_file_previous);
180  }
181 
182 
183  return E_clover;
184 }
185 
186 
187 //====================================================================
188 //============================================================END=====
void construct_Fmunu_1x2(Field_G &Fmunu, const int mu, const int nu, const Field_G &U)
Constructs the anti-Hermitian field strength with eight 1x2 rectangular clover leaves.
FieldStrength m_field_strength
Definition: energyDensity.h:43
BridgeIO vout
Definition: bridgeIO.cpp:503
std::string m_filename_output
Definition: energyDensity.h:38
static double epsilon_criterion()
double E_plaq(const Field_G &U)
void general(const char *format,...)
Definition: bridgeIO.cpp:197
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
double E_clover(const Field_G &U)
double plaquette(const Field_G &)
calculates plaquette value.
Definition: staple_lex.cpp:38
void init(const std::string &filename)
Definition: bridgeIO.cpp:51
Class for parameters.
Definition: parameters.h:46
virtual void set_parameters(const Parameters &params)
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)
Constructs the anti-Hermitian field strength with four 1x1 plquette clover leaves.
Staple_lex m_staple
Definition: energyDensity.h:44
Bridge::VerboseLevel m_vl
Definition: energyDensity.h:35
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
std::ostream & getStream()
Definition: bridgeIO.cpp:391
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...
static const std::string class_name
Definition: energyDensity.h:32
string get_string(const string &key) const
Definition: parameters.cpp:221
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