Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
staple_lex.cpp
Go to the documentation of this file.
1 
14 #include "staple_lex.h"
15 
16 #ifdef USE_FACTORY_AUTOREGISTER
17 namespace {
18  bool init = Staple_lex::register_factory();
19 }
20 #endif
21 
22 const std::string Staple_lex::class_name = "Staple_lex";
23 
24 //====================================================================
26 {
27  m_filename_output = params.get_string("filename_output");
28  if (m_filename_output.empty()) {
29  m_filename_output = "stdout";
30  }
31 
32  const string str_vlevel = params.get_string("verbose_level");
33  m_vl = vout.set_verbose_level(str_vlevel);
34 }
35 
36 
37 //====================================================================
39 {
40  const double result = (plaq_s(U) + plaq_t(U)) / 2;
41 
42  std::ostream& log_file_previous = vout.getStream();
43  std::ofstream log_file;
44 
45  if (m_filename_output != "stdout") {
46  log_file.open(m_filename_output.c_str(), std::ios::app);
47  vout.init(log_file);
48  }
49 
50  vout.general(m_vl, "plaq = %20.16e\n", result);
51 
52  if (m_filename_output != "stdout") {
53  log_file.close();
54  vout.init(log_file_previous);
55  }
56 
57  return result;
58 }
59 
60 
61 //====================================================================
62 double Staple_lex::plaq_s(const Field_G& U)
63 {
64  const int Nc = CommonParameters::Nc();
65  const int Ndim = CommonParameters::Ndim();
66  const int Ndim_spc = Ndim - 1;
67 
68  const int Nvol = CommonParameters::Nvol();
69  const int NPE = CommonParameters::NPE();
70 
71  double plaq = 0.0;
72 
73  for (int mu = 0; mu < Ndim_spc; ++mu) {
74  int nu = (mu + 1) % Ndim_spc;
75 
76  Field_G Umu;
77  Umu.setpart_ex(0, U, mu);
78 
79  upper(m_staple, U, mu, nu);
80 
81  // #pragma omp parallel
82  {
83  double plaq1 = real(dotc(m_staple, Umu));
84 
85 #pragma omp master
86  plaq += plaq1;
87  }
88  }
89 
90  return plaq / Nvol / NPE / Nc / Ndim_spc;
91 }
92 
93 
94 //====================================================================
95 double Staple_lex::plaq_t(const Field_G& U)
96 {
97  const int Nc = CommonParameters::Nc();
98  const int Ndim = CommonParameters::Ndim();
99  const int Ndim_spc = Ndim - 1;
100 
101  const int Nvol = CommonParameters::Nvol();
102  const int NPE = CommonParameters::NPE();
103 
104  const int mu = Ndim_spc;
105 
106  Field_G Umu;
107 
108  Umu.setpart_ex(0, U, mu);
109 
110  double plaq = 0.0;
111  for (int nu = 0; nu < Ndim_spc; ++nu) {
112  upper(m_staple, U, mu, nu);
113 
114  // #pragma omp parallel
115  {
116  double plaq1 = real(dotc(m_staple, Umu));
117 
118 #pragma omp master
119  plaq += plaq1;
120  }
121  }
122 
123  return plaq / Nvol / NPE / Nc / Ndim_spc;
124 }
125 
126 
127 //====================================================================
128 void Staple_lex::staple(Field_G& W, const Field_G& U, const int mu)
129 {
130  const int Ndim = CommonParameters::Ndim();
131 
132  W.set(0.0);
133 
134  for (int nu = 0; nu < Ndim; ++nu) {
135  if (nu != mu) {
136  //W += upper(U, mu, nu);
137  //W += lower(U, mu, nu);
138  Field_G Vud(W.nvol(), 1);
139 
140  upper(Vud, U, mu, nu);
141  axpy(W, 1.0, Vud);
142 
143  lower(Vud, U, mu, nu);
144  axpy(W, 1.0, Vud);
145  }
146  }
147 }
148 
149 
150 //====================================================================
152  const int mu, const int nu)
153 {
154  // (1) mu (2)
155  // +-->--+
156  // nu | |
157  // i+ +
158 
159  //#pragma omp parallel
160  {
161  Field_G Umu;
162  Umu.setpart_ex(0, U, mu);
163 
164  Field_G Unu;
165  Unu.setpart_ex(0, U, nu);
166 
167  m_shift->backward(m_v, Unu, mu);
168  m_shift->backward(c, Umu, nu);
169 
170  mult_Field_Gnd(m_w, 0, c, 0, m_v, 0);
171  mult_Field_Gnn(c, 0, U, nu, m_w, 0);
172  }
173 }
174 
175 
176 //====================================================================
178  const int mu, const int nu)
179 {
180  // + +
181  // nu | |
182  // i+-->--+
183  // (1) mu (2)
184 
185  //#pragma omp parallel
186  {
187  Field_G Unu;
188  Unu.setpart_ex(0, U, nu);
189  m_shift->backward(m_w, Unu, mu);
190 
191  mult_Field_Gnn(m_v, 0, U, mu, m_w, 0);
192  mult_Field_Gdn(m_w, 0, U, nu, m_v, 0);
193 
194  m_shift->forward(c, m_w, nu);
195  }
196 }
197 
198 
199 //====================================================================
200 //============================================================END=====
Field_G m_staple
Definition: staple_lex.h:48
BridgeIO vout
Definition: bridgeIO.cpp:503
std::string m_filename_output
Definition: staple_lex.h:45
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
void general(const char *format,...)
Definition: bridgeIO.cpp:197
double plaquette(const Field_G &)
calculates plaquette value.
Definition: staple_lex.cpp:38
int nvol() const
Definition: field.h:127
void mult_Field_Gdn(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
double plaq_t(const Field_G &)
calculates temporal plaquette value.
Definition: staple_lex.cpp:95
void init(const std::string &filename)
Definition: bridgeIO.cpp:51
Class for parameters.
Definition: parameters.h:46
void staple(Field_G &, const Field_G &, const int mu)
constructs staple in mu-direction (summing up nu-direction).
Definition: staple_lex.cpp:128
void lower(Field_G &, const Field_G &, const int mu, const int nu)
constructs lower staple in mu-nu plane.
Definition: staple_lex.cpp:177
static const std::string class_name
Definition: staple_lex.h:42
SU(N) gauge field.
Definition: field_G.h:38
dcomplex dotc(const Field &y, const Field &x)
Definition: field.cpp:155
Bridge::VerboseLevel m_vl
Definition: staple.h:36
void backward(Field &, const Field &, const int mu)
void upper(Field_G &, const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane.
Definition: staple_lex.cpp:151
ShiftField_lex * m_shift
Definition: staple_lex.h:47
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:319
void mult_Field_Gnn(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
std::ostream & getStream()
Definition: bridgeIO.cpp:391
double plaq_s(const Field_G &)
calculates spatial plaquette value.
Definition: staple_lex.cpp:62
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:197
string get_string(const string &key) const
Definition: parameters.cpp:221
Field_G m_v
Definition: staple_lex.h:48
Field_G m_w
temporary fields.
Definition: staple_lex.h:48
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
void forward(Field &, const Field &, const int mu)
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 set_parameters(const Parameters &params)
setting parameters.
Definition: staple_lex.cpp:25