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