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