Bridge++  Ver. 1.3.x
action_G_Rectangle.cpp
Go to the documentation of this file.
1 
14 #include "action_G_Rectangle.h"
15 
16 
17 #ifdef USE_FACTORY
18 namespace {
19  Action *create_object()
20  {
21  return new Action_G_Rectangle();
22  }
23 
24 
25  bool init = Action::Factory::Register("Action_G_Rectangle", create_object);
26 }
27 #endif
28 
29 
30 //- parameter entries
31 namespace {
32  void append_entry(Parameters& param)
33  {
34  param.Register_double("beta", 0.0);
35  param.Register_double("c_plaq", 0.0);
36  param.Register_double("c_rect", 0.0);
37 
38  param.Register_string("verbose_level", "NULL");
39  }
40 
41 
42 #ifdef USE_PARAMETERS_FACTORY
43  bool init_param = ParametersFactory::Register("Action.G_Rectangle", append_entry);
44 #endif
45 }
46 //- end
47 
48 //- parameters class
50 //- end
51 
52 const std::string Action_G_Rectangle::class_name = "Action_G_Rectangle";
53 
54 //====================================================================
56 {
57  const string str_vlevel = params.get_string("verbose_level");
58 
59  m_vl = vout.set_verbose_level(str_vlevel);
60 
61  //- fetch and check input parameters
62  double beta, c_plaq, c_rect;
63 
64  int err = 0;
65  err += params.fetch_double("beta", beta);
66  err += params.fetch_double("c_plaq", c_plaq);
67  err += params.fetch_double("c_rect", c_rect);
68 
69  if (err) {
70  vout.crucial(m_vl, "%s: fetch error, input parameter not found.\n", class_name.c_str());
71  exit(EXIT_FAILURE);
72  }
73 
74 
75  set_parameters(beta, c_plaq, c_rect);
76 }
77 
78 
79 //====================================================================
81  double c_plaq, double c_rect)
82 {
83  //- print input parameters
84  vout.general(m_vl, "%s:\n", class_name.c_str());
85  vout.general(m_vl, " beta = %12.6f\n", beta);
86  vout.general(m_vl, " c_plaq = %12.6f\n", c_plaq);
87  vout.general(m_vl, " c_rect = %12.6f\n", c_rect);
88 
89  //- range check
90  // NB. beta,c_plaq,c_rect == 0 is allowed.
91 
92  //- store values
93  m_beta = beta;
94  m_c_plaq = c_plaq;
95  m_c_rect = c_rect;
96 
97  //- post-process
98  int Nc = CommonParameters::Nc();
99  int Nvol = CommonParameters::Nvol();
100  int Ndim = CommonParameters::Ndim();
101  int NinG = 2 * Nc * Nc;
102 }
103 
104 
105 //====================================================================
107 {
108  double H_U = calcH();
109 
110  return H_U;
111 }
112 
113 
114 //====================================================================
116 {
117  int Nc = CommonParameters::Nc();
118  int Ndim = CommonParameters::Ndim();
119  int Nvol = CommonParameters::Nvol();
120  int Lvol = CommonParameters::Lvol();
121 
122  int Ndim2 = Ndim * (Ndim - 1) / 2;
123  int size_U = Lvol * Ndim2;
124 
125  Field_G Cup1(Nvol, 1), Cup2(Nvol, 1);
126  Field_G Cdn1(Nvol, 1), Cdn2(Nvol, 1);
127  Field_G Umu(Nvol, 1), Unu(Nvol, 1);
128  Field_G v(Nvol, 1), w(Nvol, 1), c(Nvol, 1);
129 
130  double plaqF = 0.0;
131  double rectF = 0.0;
132 
133  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
134 
135  for (int mu = 0; mu < Ndim; ++mu) {
136  for (int nu = mu + 1; nu < Ndim; ++nu) {
137  m_staple.upper(Cup1, *m_U, mu, nu);
138  m_staple.upper(Cup2, *m_U, nu, mu);
139 
140  // plaquette term
141  for (int site = 0; site < Nvol; ++site) {
142  plaqF += ReTr(m_U->mat(site, mu) * Cup1.mat_dag(site));
143  }
144 
145  // rectangular terms
146 
147  // +---+---+
148  // | | term
149  // x <---+
150 
151  Umu.setpart_ex(0, *m_U, mu);
152  Unu.setpart_ex(0, *m_U, nu);
153 
154  m_shift.backward(v, Cup2, mu);
155  m_shift.backward(c, Umu, nu);
156 
157  mult_Field_Gnd(w, 0, c, 0, v, 0);
158  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
159  for (int site = 0; site < Nvol; ++site) {
160  rectF += ReTr(m_U->mat(site, mu) * c.mat_dag(site));
161  }
162 
163  // +---+
164  // | |
165  // + + term
166  // | |
167  // x v
168 
169  m_shift.backward(v, Unu, mu);
170  m_shift.backward(c, Cup1, nu);
171 
172  mult_Field_Gnd(w, 0, c, 0, v, 0);
173  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
174  for (int site = 0; site < Nvol; ++site) {
175  rectF += ReTr(m_U->mat(site, mu) * c.mat_dag(site));
176  }
177  }
178  }
179 
180  plaqF = Communicator::reduce_sum(plaqF);
181  rectF = Communicator::reduce_sum(rectF);
182 
183  double plaq = plaqF / Nc;
184  vout.general(m_vl, " Plaquette = %18.8f\n", plaq / size_U);
185 
186  double H_U = m_c_plaq * (Ndim2 * Lvol - plaqF / Nc)
187  + m_c_rect * (Ndim2 * Lvol * 2 - rectF / Nc);
188 
189  H_U = m_beta * H_U;
190 
191  vout.general(m_vl, " H_Grectangle = %18.8f\n", H_U);
192  vout.general(m_vl, " H_G/dof = %18.8f\n", H_U / size_U);
193 
194  return H_U;
195 }
196 
197 
198 //====================================================================
200 {
201  int Nc = CommonParameters::Nc();
202  int Nvol = CommonParameters::Nvol();
203  int Ndim = CommonParameters::Ndim();
204 
205  assert(m_U->nin() == Nc * Nc * 2);
206  assert(m_U->nvol() == Nvol);
207  assert(m_U->nex() == Ndim);
208 
209  assert(force.nin() == Nc * Nc * 2);
210  assert(force.nvol() == Nvol);
211  assert(force.nex() == Ndim);
212 
213  force.set(0.0);
214 
215  double betaNc = m_beta / Nc;
216  Mat_SU_N ut(Nc);
217 
218  Field_G force1(Nvol, 1), force2(Nvol, 1);
219 
220  Field_G Cup1(Nvol, 1), Cup2(Nvol, 1);
221  Field_G Cdn1(Nvol, 1), Cdn2(Nvol, 1);
222  Field_G Umu(Nvol, 1), Unu(Nvol, 1);
223  Field_G v(Nvol, 1), w(Nvol, 1), c(Nvol, 1);
224 
225  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
226 
227  for (int mu = 0; mu < Ndim; ++mu) {
228  force1.set(0.0);
229  for (int nu = 0; nu < Ndim; ++nu) {
230  if (nu == mu) continue;
231 
232  m_staple.upper(Cup1, *m_U, mu, nu);
233  m_staple.upper(Cup2, *m_U, nu, mu);
234  m_staple.lower(Cdn1, *m_U, mu, nu);
235  m_staple.lower(Cdn2, *m_U, nu, mu);
236 
237  // plaquette term
238  force1.addpart_ex(0, Cup1, 0, m_c_plaq);
239  force1.addpart_ex(0, Cdn1, 0, m_c_plaq);
240 
241  // rectangular term
242 
243  Umu.setpart_ex(0, *m_U, mu);
244  Unu.setpart_ex(0, *m_U, nu);
245 
246  // +---+---+
247  // | | term
248  // x <---+
249 
250  m_shift.backward(v, Cup2, mu);
251  m_shift.backward(c, Umu, nu);
252 
253  mult_Field_Gnd(w, 0, c, 0, v, 0);
254  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
255 
256  force1.addpart_ex(0, c, 0, m_c_rect);
257 
258  // +---+
259  // | |
260  // + + term
261  // | |
262  // x v
263 
264  m_shift.backward(v, Unu, mu);
265  m_shift.backward(c, Cup1, nu);
266 
267  mult_Field_Gnd(w, 0, c, 0, v, 0);
268  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
269 
270  force1.addpart_ex(0, c, 0, m_c_rect);
271 
272  // +---+---+
273  // | | term
274  // +---x v
275 
276  m_shift.backward(v, Unu, mu);
277  m_shift.backward(c, Umu, nu);
278 
279  mult_Field_Gnd(w, 0, c, 0, v, 0);
280  mult_Field_Gnn(c, 0, Cdn2, 0, w, 0);
281 
282  force1.addpart_ex(0, c, 0, m_c_rect);
283 
284  // x <---+
285  // | | term
286  // +---+---+
287 
288  m_shift.backward(v, Cup2, mu);
289 
290  mult_Field_Gnn(w, 0, Umu, 0, v, 0);
291  mult_Field_Gdn(v, 0, Unu, 0, w, 0);
292 
293  m_shift.forward(c, v, nu);
294 
295  force1.addpart_ex(0, c, 0, m_c_rect);
296 
297  // x ^
298  // | |
299  // + + term
300  // | |
301  // +---+
302 
303  m_shift.backward(v, Unu, mu);
304 
305  mult_Field_Gnn(w, 0, Cdn1, 0, v, 0);
306  mult_Field_Gdn(v, 0, Unu, 0, w, 0);
307 
308  m_shift.forward(c, v, nu);
309 
310  force1.addpart_ex(0, c, 0, m_c_rect);
311 
312  // +---x ^
313  // | | term
314  // +---+---+
315 
316  m_shift.backward(v, Unu, mu);
317 
318  mult_Field_Gnn(w, 0, Umu, 0, v, 0);
319  mult_Field_Gdn(v, 0, Cdn2, 0, w, 0);
320 
321  m_shift.forward(c, v, nu);
322 
323  force1.addpart_ex(0, c, 0, m_c_rect);
324  }
325 
326  mult_Field_Gnd(force2, 0, *m_U, mu, force1, 0);
327  at_Field_G(force2, 0);
328  axpy(force, mu, -betaNc, force2, 0);
329  }
330 
331  double Fave, Fmax, Fdev;
332  force.stat(Fave, Fmax, Fdev);
333  vout.general(m_vl, " Frectangle_ave = %12.6f Frectangle_max = %12.6f Frectangle_dev = %12.6f\n",
334  Fave, Fmax, Fdev);
335 }
336 
337 
338 //====================================================================
339 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:278
double langevin(RandomNumbers *)
Langevis step.
void Register_string(const string &, const string &)
Definition: parameters.cpp:351
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:155
void mult_Field_Gdn(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2)
void general(const char *format,...)
Definition: bridgeIO.cpp:65
Container of Field-type object.
Definition: field.h:39
ShiftField_lex m_shift
int nvol() const
Definition: field.h:116
Class for parameters.
Definition: parameters.h:38
static int Lvol()
Base class of HMC action class family.
Definition: action.h:42
double calcH()
calculate Hamiltonian of this action term.
int nin() const
Definition: field.h:115
SU(N) gauge field.
Definition: field_G.h:38
static const std::string class_name
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 mult_Field_Gnn(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2)
void backward(Field &, const Field &, const int mu)
int nex() const
Definition: field.h:117
void set_parameters(const Parameters &params)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:168
void at_Field_G(Field_G &w, const int ex)
void crucial(const char *format,...)
Definition: bridgeIO.cpp:48
void lower(Field_G &, const Field_G &, const int mu, const int nu)
constructs lower staple in mu-nu plane.
Definition: staples.cpp:152
static bool Register(const std::string &realm, const creator_callback &cb)
Bridge::VerboseLevel m_vl
Definition: action.h:81
Base class of random number generators.
Definition: randomNumbers.h:39
void stat(double &Fave, double &Fmax, double &Fdev) const
determines the statistics of the field. average, maximum value, and deviation is determined over glob...
Definition: field.cpp:516
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:126
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...
void Register_double(const string &, const double)
Definition: parameters.cpp:323
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:177
int fetch_double(const string &key, double &val) const
Definition: parameters.cpp:124
string get_string(const string &key) const
Definition: parameters.cpp:87
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:113
void upper(Field_G &, const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane.
Definition: staples.cpp:128
void force(Field &)
returns force for molcular dynamical update of conjugate momenta.
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:28
double ReTr(const Mat_SU_N &m)
Definition: mat_SU_N.h:488
void forward(Field &, const Field &, const int mu)