Bridge++  Version 1.4.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(double c_plaq, 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  double plaq = m_staple.plaquette(U);
67  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  int Lvol = CommonParameters::Lvol();
93  int Ndim = CommonParameters::Ndim();
94  int Nvol = CommonParameters::Nvol();
95 
96  static const double eps = CommonParameters::epsilon_criterion();
97 
98  double E_clover_1x1 = 0.0;
99  double E_clover_1x2 = 0.0;
100 
101 
102  //--- 1x1 part ---
103  // NB. #(mu,nu)=6 i.e. (1,2),(1,3),(1,4),(2,3),(2,4),(3,4)
104  std::vector<Field_G> Fmunu_1x1(6);
105 
106  int i_munu = 0;
107 
108  for (int mu = 0; mu < Ndim; ++mu) {
109  for (int nu = mu + 1; nu < Ndim; ++nu) {
110  m_field_strength.construct_Fmunu_1x1(Fmunu_1x1[i_munu], mu, nu, U);
111 
112  ++i_munu;
113  }
114  }
115 
116  double F2_1x1 = 0.0;
117  for (int site = 0; site < Nvol; ++site) {
118  for (int i_munu = 0; i_munu < 6; i_munu++) {
119  F2_1x1 += ReTr(Fmunu_1x1[i_munu].mat(site) * Fmunu_1x1[i_munu].mat(site));
120  }
121  }
122  E_clover_1x1 = Communicator::reduce_sum(F2_1x1) / Lvol;
123  //----------------
124 
125 
126  //--- 1x2 part ---
127  // NB. skip this part, if m_c_rect = 0.0
128  if (fabs(m_c_rect) > eps) {
129  // NB. #(mu,nu)=6 i.e. (1,2),(1,3),(1,4),(2,3),(2,4),(3,4)
130  std::vector<Field_G> Fmunu_1x2(6);
131 
132  int i_munu = 0;
133  for (int mu = 0; mu < Ndim; ++mu) {
134  for (int nu = mu + 1; nu < Ndim; ++nu) {
135  m_field_strength.construct_Fmunu_1x2(Fmunu_1x2[i_munu], mu, nu, U);
136 
137  ++i_munu;
138  }
139  }
140 
141  double F2_1x2 = 0.0;
142  for (int site = 0; site < Nvol; ++site) {
143  for (int i_munu = 0; i_munu < 6; i_munu++) {
144  F2_1x2 += ReTr(Fmunu_1x2[i_munu].mat(site) * Fmunu_1x2[i_munu].mat(site));
145  }
146  }
147  E_clover_1x2 = Communicator::reduce_sum(F2_1x2) / Lvol;
148 
149  // extra factor "2" for 1x2
150  E_clover_1x2 *= 2.0;
151  }
152  //----------------
153 
154 
155  double E_clover = (m_c_plaq * E_clover_1x1 + m_c_rect * E_clover_1x2);
156 
157 
158  //- output
159  std::ostream& log_file_previous = vout.getStream();
160  std::ofstream log_file;
161 
162  if (m_filename_output != "stdout") {
163  log_file.open(m_filename_output.c_str(), std::ios::app);
164  vout.init(log_file);
165  }
166 
167  vout.general(m_vl, " E_clover_1x1 = %20.16e\n", E_clover_1x1);
168  if (fabs(m_c_rect) > eps) {
169  vout.general(m_vl, " E_clover_1x2 = %20.16e\n", E_clover_1x2);
170  }
171  vout.general(m_vl, " E_clover = %20.16e\n", E_clover);
172 
173  if (m_filename_output != "stdout") {
174  log_file.close();
175  vout.init(log_file_previous);
176  }
177 
178 
179  return E_clover;
180 }
181 
182 
183 //====================================================================
184 //============================================================END=====
void construct_Fmunu_1x2(Field_G &Fmunu, const int mu, const int nu, const Field_G &U)
FieldStrength m_field_strength
Definition: energyDensity.h:46
BridgeIO vout
Definition: bridgeIO.cpp:495
std::string m_filename_output
Definition: energyDensity.h:41
static double epsilon_criterion()
double E_plaq(const Field_G &U)
void general(const char *format,...)
Definition: bridgeIO.cpp:195
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:211
double E_clover(const Field_G &U)
double plaquette(const Field_G &)
calculates plaquette value.
Definition: staple_lex.cpp:46
void init(const std::string &filename)
Definition: bridgeIO.cpp:51
Class for parameters.
Definition: parameters.h:46
static int Lvol()
virtual void set_parameters(const Parameters &params)
setting parameters.
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)
Staple_lex m_staple
Definition: energyDensity.h:47
Bridge::VerboseLevel m_vl
Definition: energyDensity.h:38
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
std::ostream & getStream()
Definition: bridgeIO.cpp:383
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:35
string get_string(const string &key) const
Definition: parameters.cpp:116
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