Bridge++  Version 1.4.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
force_G_Rectangle.cpp
Go to the documentation of this file.
1 
14 #include "force_G_Rectangle.h"
15 
16 
17 #ifdef USE_FACTORY
18 namespace {
19  Force_G *create_object()
20  {
21  return new Force_G_Rectangle();
22  }
23 
24 
25  bool init = Force_G::Factory::Register("Force_G_Rectangle", create_object);
26 }
27 #endif
28 
29 
30 const std::string Force_G_Rectangle::class_name = "Force_G_Rectangle";
31 
32 //====================================================================
34 {
35  const string str_vlevel = params.get_string("verbose_level");
36 
37  m_vl = vout.set_verbose_level(str_vlevel);
38 
39  //- fetch and check input parameters
40  double beta, c_plaq, c_rect;
41 
42  int err = 0;
43  err += params.fetch_double("beta", beta);
44  err += params.fetch_double("c_plaq", c_plaq);
45  err += params.fetch_double("c_rect", c_rect);
46 
47  if (err) {
48  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
49  exit(EXIT_FAILURE);
50  }
51 
52 
53  set_parameters(beta, c_plaq, c_rect);
54 }
55 
56 
57 //====================================================================
58 void Force_G_Rectangle::set_parameters(double beta, double c_plaq, double c_rect)
59 {
60  //- print input parameters
61  vout.general(m_vl, "%s:\n", class_name.c_str());
62  vout.general(m_vl, " beta = %12.6f\n", beta);
63  vout.general(m_vl, " c_plaq = %12.6f\n", c_plaq);
64  vout.general(m_vl, " c_rect = %12.6f\n", c_rect);
65 
66  //- range check
67  // NB. beta,c_plaq,c_rect == 0 is allowed.
68 
69  //- store values
70  m_beta = beta;
71  m_c_plaq = c_plaq;
72  m_c_rect = c_rect;
73 
74  //- post-process
75 }
76 
77 
78 //====================================================================
80 {
81  int Nc = CommonParameters::Nc();
82  int Nvol = CommonParameters::Nvol();
83  int Ndim = CommonParameters::Ndim();
84  const double eps = CommonParameters::epsilon_criterion();
85 
86  assert(m_U->nin() == Nc * Nc * 2);
87  assert(m_U->nvol() == Nvol);
88  assert(m_U->nex() == Ndim);
89 
90  assert(force.nin() == Nc * Nc * 2);
91  assert(force.nvol() == Nvol);
92  assert(force.nex() == Ndim);
93 
94  Mat_SU_N ut(Nc);
95 
96  Field_G force1(Nvol, 1), force2(Nvol, 1);
97 
98  Field_G Cup1(Nvol, 1), Cup2(Nvol, 1);
99  Field_G Cdn1(Nvol, 1), Cdn2(Nvol, 1);
100  Field_G Umu(Nvol, 1), Unu(Nvol, 1);
101  Field_G v(Nvol, 1), w(Nvol, 1), c(Nvol, 1);
102 
103  for (int mu = 0; mu < Ndim; ++mu) {
104  force1.set(0.0);
105  for (int nu = 0; nu < Ndim; ++nu) {
106  if (nu == mu) continue;
107 
108  m_staple.upper(Cup1, *m_U, mu, nu);
109  m_staple.upper(Cup2, *m_U, nu, mu);
110  m_staple.lower(Cdn1, *m_U, mu, nu);
111  m_staple.lower(Cdn2, *m_U, nu, mu);
112 
113  //- plaquette term
114  force1.addpart_ex(0, Cup1, 0, m_c_plaq);
115  force1.addpart_ex(0, Cdn1, 0, m_c_plaq);
116 
117 
118  //- rectangular term
119  // NB. skip this part, if m_c_rect = 0.0
120  if (fabs(m_c_rect) > eps) {
121  Umu.setpart_ex(0, *m_U, mu);
122  Unu.setpart_ex(0, *m_U, nu);
123 
124  // +---+---+
125  // | | term
126  // x <---+
127 
128  m_shift.backward(v, Cup2, mu);
129  m_shift.backward(c, Umu, nu);
130 
131  mult_Field_Gnd(w, 0, c, 0, v, 0);
132  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
133 
134  force1.addpart_ex(0, c, 0, m_c_rect);
135 
136  // +---+
137  // | |
138  // + + term
139  // | |
140  // x v
141 
142  m_shift.backward(v, Unu, mu);
143  m_shift.backward(c, Cup1, nu);
144 
145  mult_Field_Gnd(w, 0, c, 0, v, 0);
146  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
147 
148  force1.addpart_ex(0, c, 0, m_c_rect);
149 
150  // +---+---+
151  // | | term
152  // +---x v
153 
154  m_shift.backward(v, Unu, 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, Cdn2, 0, w, 0);
159 
160  force1.addpart_ex(0, c, 0, m_c_rect);
161 
162  // x <---+
163  // | | term
164  // +---+---+
165 
166  m_shift.backward(v, Cup2, mu);
167 
168  mult_Field_Gnn(w, 0, Umu, 0, v, 0);
169  mult_Field_Gdn(v, 0, Unu, 0, w, 0);
170 
171  m_shift.forward(c, v, nu);
172 
173  force1.addpart_ex(0, c, 0, m_c_rect);
174 
175  // x ^
176  // | |
177  // + + term
178  // | |
179  // +---+
180 
181  m_shift.backward(v, Unu, mu);
182 
183  mult_Field_Gnn(w, 0, Cdn1, 0, v, 0);
184  mult_Field_Gdn(v, 0, Unu, 0, w, 0);
185 
186  m_shift.forward(c, v, nu);
187 
188  force1.addpart_ex(0, c, 0, m_c_rect);
189 
190  // +---x ^
191  // | | term
192  // +---+---+
193 
194  m_shift.backward(v, Unu, mu);
195 
196  mult_Field_Gnn(w, 0, Umu, 0, v, 0);
197  mult_Field_Gdn(v, 0, Cdn2, 0, w, 0);
198 
199  m_shift.forward(c, v, nu);
200 
201  force1.addpart_ex(0, c, 0, m_c_rect);
202  }
203  }
204 
205  mult_Field_Gnd(force2, 0, *m_U, mu, force1, 0);
206  at_Field_G(force2, 0);
207 
208  axpy(force, mu, -(m_beta / Nc), force2, 0);
209  }
210 
211  double Fave, Fmax, Fdev;
212  force.stat(Fave, Fmax, Fdev);
213  vout.general(m_vl, " Fave = %12.6f Fmax = %12.6f Fdev = %12.6f\n",
214  Fave, Fmax, Fdev);
215 }
216 
217 
218 //====================================================================
219 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:495
static double epsilon_criterion()
Field_G * m_U
Definition: force_G.h:34
ShiftField_lex m_shift
void general(const char *format,...)
Definition: bridgeIO.cpp:195
Container of Field-type object.
Definition: field.h:39
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:211
int nvol() const
Definition: field.h:116
void force_core(Field &)
void at_Field_G(Field_G &W, const int ex)
void mult_Field_Gdn(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
Class for parameters.
Definition: parameters.h:46
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
int nin() const
Definition: field.h:115
SU(N) gauge field.
Definition: field_G.h:38
Base class of gauge force calculation.
Definition: force_G.h:31
Bridge::VerboseLevel m_vl
Definition: force_G.h:35
void backward(Field &, const Field &, const int mu)
int nex() const
Definition: field.h:117
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
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 mult_Field_Gnn(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
HMC force class for rectangular gauge action.
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
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
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
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)