Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
force_G_Rectangle_SF.cpp
Go to the documentation of this file.
1 
14 #include "force_G_Rectangle_SF.h"
15 
16 #ifdef USE_FACTORY_AUTOREGISTER
17 namespace {
18  bool init = Force_G_Rectangle_SF::register_factory();
19 }
20 #endif
21 
22 const std::string Force_G_Rectangle_SF::class_name = "Force_G_Rectangle_SF";
23 
24 //====================================================================
26 {
27  const string str_vlevel = params.get_string("verbose_level");
28 
29  m_vl = vout.set_verbose_level(str_vlevel);
30 
31  //- fetch and check input parameters
32  double beta, c_plaq, c_rect;
33  double ct0, ct1, ct2, ctr0, ctr1, ctr2;
34  std::vector<double> phi, phipr;
35 
36  int err = 0;
37  err += params.fetch_double("beta", beta);
38  err += params.fetch_double("c_plaq", c_plaq);
39  err += params.fetch_double("c_rect", c_rect);
40 
41  err += params.fetch_double("ct0", ct0);
42  err += params.fetch_double("ct1", ct1);
43  err += params.fetch_double("ct2", ct2);
44 
45  err += params.fetch_double("ctr0", ctr0);
46  err += params.fetch_double("ctr1", ctr1);
47  err += params.fetch_double("ctr2", ctr2);
48 
49  err += params.fetch_double_vector("phi", phi);
50  err += params.fetch_double_vector("phipr", phipr);
51 
52  if (err) {
53  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
54  exit(EXIT_FAILURE);
55  }
56 
57 
58  const double gg = 6.0 / beta;
59 
60  const double ct = ct0 + ct1 * gg + ct2 * gg * gg;
61  const double ctr = ctr0 + ctr1 * gg + ctr2 * gg * gg;
62 
63  set_parameters(beta, c_plaq, c_rect, &phi[0], &phipr[0], ct, ctr);
64 }
65 
66 
67 //====================================================================
68 
82 void Force_G_Rectangle_SF::set_parameters(const double beta, const double c_plaq, const double c_rect,
83  double *phi, double *phipr, const double ct, const double ctr)
84 {
85  //- print input parameters
86  vout.general(m_vl, "%s:\n", class_name.c_str());
87  vout.general(m_vl, " beta = %12.6f\n", beta);
88  vout.general(m_vl, " c_plaq = %12.6f\n", c_plaq);
89  vout.general(m_vl, " c_rect = %12.6f\n", c_rect);
90  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
91  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
92  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
93  vout.general(m_vl, " phipr1 = %12.6f\n", phipr[0]);
94  vout.general(m_vl, " phipr2 = %12.6f\n", phipr[1]);
95  vout.general(m_vl, " phipr3 = %12.6f\n", phipr[2]);
96  vout.general(m_vl, " ct = %12.6f\n", ct);
97  vout.general(m_vl, " ctr = %12.6f\n", ctr);
98 
99  //- range check
100  // NB. beta,c_plaq,c_rect,phi,phipr,ct,ctr = 0 is allowed.
101 
102  //- store values
103  m_beta = beta;
104  m_c_plaq = c_plaq;
105  m_c_rect = c_rect;
106 
107  m_ct = ct;
108  m_ctr = ctr;
109  // m_phi = phi ;
110  // m_phipr = phipr;
111 
112  //- post-process
113  m_staple.set_parameters(phi, phipr);
114 
115  const int Lx = CommonParameters::Lx();
116 
117  double c0r = cos(phi[0] / Lx);
118  double c0i = sin(phi[0] / Lx);
119  double c1r = cos(phi[1] / Lx);
120  double c1i = sin(phi[1] / Lx);
121  double c2r = cos(phi[2] / Lx);
122  double c2i = sin(phi[2] / Lx);
123  m_wk.zero();
124  m_wk.set(0, 0, c0r, c0i);
125  m_wk.set(1, 1, c1r, c1i);
126  m_wk.set(2, 2, c2r, c2i);
127 
128  c0r = cos(phipr[0] / Lx);
129  c0i = sin(phipr[0] / Lx);
130  c1r = cos(phipr[1] / Lx);
131  c1i = sin(phipr[1] / Lx);
132  c2r = cos(phipr[2] / Lx);
133  c2i = sin(phipr[2] / Lx);
134  m_wkpr.zero();
135  m_wkpr.set(0, 0, c0r, c0i);
136  m_wkpr.set(1, 1, c1r, c1i);
137  m_wkpr.set(2, 2, c2r, c2i);
138 }
139 
140 
141 //====================================================================
142 
198 {
199  const int Nvol = CommonParameters::Nvol();
200  const int Ndim = CommonParameters::Ndim();
201 
202  const int Nt = CommonParameters::Nt();
203  const int NPEt = CommonParameters::NPEt();
204 
205  assert(m_U->nin() == m_Nc * m_Nc * 2);
206  assert(m_U->nvol() == Nvol);
207  assert(m_U->nex() == Ndim);
208 
209  assert(force.nin() == m_Nc * m_Nc * 2);
210  assert(force.nvol() == Nvol);
211  assert(force.nex() == Ndim);
212 
213  Mat_SU_N wzero(m_Nc);
214  wzero.zero();
215 
216  for (int mu = 0; mu < Ndim; ++mu) {
217  Field_G force1;
218  force1.set(0.0);
219 
220  for (int nu = 0; nu < Ndim; ++nu) {
221  if (nu == mu) continue;
222 
223  Field_G_SF Cup1;
224  m_staple.upper(Cup1, *m_U, mu, nu);
225 
226  Field_G_SF Cup2;
227  m_staple.upper(Cup2, *m_U, nu, mu);
228 
229  Field_G_SF Cdn1;
230  m_staple.lower(Cdn1, *m_U, mu, nu);
231 
232  Field_G_SF Cdn2;
233  m_staple.lower(Cdn2, *m_U, nu, mu);
234 
235  // plaquette term
236  Field_G_SF Umu = Cup1;
237  Field_G_SF Unu = Cdn1;
238  if (Communicator::ipe(3) == 0) {
239  if (mu == 3) {
240  Umu.mult_ct_boundary(0, m_ct);
241  Unu.mult_ct_boundary(0, m_ct);
242  }
243  if (nu == 3) {
244  Unu.mult_ct_boundary(1, m_ct);
245  }
246  }
247  if (Communicator::ipe(3) == NPEt - 1) {
248  if (mu == 3) {
249  Umu.mult_ct_boundary(Nt - 1, m_ct);
250  Unu.mult_ct_boundary(Nt - 1, m_ct);
251  }
252  if (nu == 3) {
253  Umu.mult_ct_boundary(Nt - 1, m_ct);
254  }
255  }
256  force1.addpart_ex(0, Umu, 0, m_c_plaq);
257  force1.addpart_ex(0, Unu, 0, m_c_plaq);
258 
259  // rectangular term
260  Umu.setpart_ex(0, *m_U, mu);
261  Unu.setpart_ex(0, *m_U, nu);
262  // For the boundary spatial link, use Wk.
263  if ((Communicator::ipe(3) == 0) && (nu == 3)) Umu.set_boundary_wk(m_wk);
264  if ((Communicator::ipe(3) == 0) && (mu == 3)) Unu.set_boundary_wk(m_wk);
265 
266  // +---+---+
267  // | | term
268  // x <---+
269  Field_G_SF v;
270  m_shift.backward(v, Cup2, mu);
271 
272  Field_G_SF c;
273  m_shift.backward(c, Umu, nu);
274  // The force for the spatial link near the boundary. Multiplied with ctr.
275  if ((Communicator::ipe(3) == NPEt - 1) && (nu == 3)) {
277  c.mult_ct_boundary(Nt - 1, m_ctr);
278  }
279 
280  Field_G_SF w;
281  mult_Field_Gnd(w, 0, c, 0, v, 0);
282  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
283  // The force for the boundary spatial link is set to zero.
284  if ((Communicator::ipe(3) == 0) && (nu == 3)) c.set_boundary_zero();
285  force1.addpart_ex(0, c, 0, m_c_rect);
286 
287  // +---+
288  // | |
289  // + + term
290  // | |
291  // x v
292 
293  m_shift.backward(v, Unu, mu);
294  m_shift.backward(c, Cup1, nu);
295  // The force for the temporal link near the boundary. Multiplied with ctr.
296  if ((Communicator::ipe(3) == NPEt - 1) && (mu == 3)) {
298  v.mult_ct_boundary(Nt - 1, m_ctr);
299  }
300  mult_Field_Gnd(w, 0, c, 0, v, 0);
301  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
302  // The force for the boundary spatial link is set to zero.
303  if ((Communicator::ipe(3) == 0) && (nu == 3)) c.set_boundary_zero();
304  // The force for the boundary temporal link.
305  if ((Communicator::ipe(3) == 0) && (mu == 3)) c.mult_ct_boundary(0, m_ctr);
306  force1.addpart_ex(0, c, 0, m_c_rect);
307 
308  // +---+---+
309  // | | term
310  // +---x v
311 
312  m_shift.backward(v, Unu, mu);
313  m_shift.backward(c, Umu, nu);
314  if ((Communicator::ipe(3) == NPEt - 1) && (nu == 3)) {
316  c.mult_ct_boundary(Nt - 1, m_ctr);
317  }
318  if ((Communicator::ipe(3) == NPEt - 1) && (mu == 3)) v.set_boundary_wkpr(m_wkpr);
319  mult_Field_Gnd(w, 0, c, 0, v, 0);
320  mult_Field_Gnn(c, 0, Cdn2, 0, w, 0);
321  if ((Communicator::ipe(3) == 0) && (nu == 3)) c.set_boundary_zero();
322  force1.addpart_ex(0, c, 0, m_c_rect);
323 
324  // x <---+
325  // | | term
326  // +---+---+
327 
328  m_shift.backward(v, Cup2, mu);
329  mult_Field_Gnn(w, 0, Umu, 0, v, 0);
330  mult_Field_Gdn(v, 0, Unu, 0, w, 0);
331  if ((Communicator::ipe(3) == 0) && (nu == 3)) v.mult_ct_boundary(0, m_ctr);
332  m_shift.forward(c, v, nu);
333  if ((Communicator::ipe(3) == 0) && (nu == 3)) c.set_boundary_zero();
334  force1.addpart_ex(0, c, 0, m_c_rect);
335 
336  // x ^
337  // | |
338  // + + term
339  // | |
340  // +---+
341 
342  m_shift.backward(v, Unu, mu);
343  if ((Communicator::ipe(3) == NPEt - 1) && (mu == 3)) {
345  v.mult_ct_boundary(Nt - 1, m_ctr);
346  }
347  mult_Field_Gnn(w, 0, Cdn1, 0, v, 0);
348  mult_Field_Gdn(v, 0, Unu, 0, w, 0);
349  if ((Communicator::ipe(3) == 0) && (mu == 3)) v.mult_ct_boundary(0, m_ctr);
350  m_shift.forward(c, v, nu);
351  if ((Communicator::ipe(3) == 0) && (nu == 3)) c.set_boundary_zero();
352  force1.addpart_ex(0, c, 0, m_c_rect);
353 
354  // +---x ^
355  // | | term
356  // +---+---+
357 
358  m_shift.backward(v, Unu, mu);
359  if ((Communicator::ipe(3) == NPEt - 1) && (mu == 3)) v.set_boundary_wkpr(m_wkpr);
360  mult_Field_Gnn(w, 0, Umu, 0, v, 0);
361  mult_Field_Gdn(v, 0, Cdn2, 0, w, 0);
362  if ((Communicator::ipe(3) == 0) && (nu == 3)) v.mult_ct_boundary(0, m_ctr);
363  m_shift.forward(c, v, nu);
364  if ((Communicator::ipe(3) == 0) && (nu == 3)) c.set_boundary_zero();
365  force1.addpart_ex(0, c, 0, m_c_rect);
366  }
367 
368  Field_G force2;
369  mult_Field_Gnd(force2, 0, *m_U, mu, force1, 0);
370  at_Field_G(force2, 0);
371 
372  axpy(force, mu, -(m_beta / m_Nc), force2, 0);
373  }
374 
375  double Fave, Fmax, Fdev;
376  force.stat(Fave, Fmax, Fdev);
377  vout.general(m_vl, " Fave = %12.6f Fmax = %12.6f Fdev = %12.6f\n",
378  Fave, Fmax, Fdev);
379 }
380 
381 
382 //====================================================================
383 //============================================================END=====
SU(N) gauge field class in which a few functions are added for the SF.
Definition: field_G_SF.h:33
void set_boundary_zero()
Set the boundary matrix to 0 for SF bc.
Definition: field_G_SF.cpp:78
BridgeIO vout
Definition: bridgeIO.cpp:503
void set_boundary_wkpr(const Mat_SU_N &U)
Set the boundary spatial link at t=Nt-1 for SF bc.
Definition: field_G_SF.cpp:53
int fetch_double_vector(const string &key, vector< double > &value) const
Definition: parameters.cpp:410
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
static const std::string class_name
Field_G * m_U
Definition: force_G.h:34
void general(const char *format,...)
Definition: bridgeIO.cpp:197
Mat_SU_N & zero()
Definition: mat_SU_N.h:383
Container of Field-type object.
Definition: field.h:45
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
int nvol() const
Definition: field.h:127
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)
void set_parameters(const Parameters &params)
Class for parameters.
Definition: parameters.h:46
static int ipe(const int dir)
logical coordinate of current proc.
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:204
double m_ct
SF boundary improvement coefficient for the plaquatte action.
void set_parameters(const Parameters &params)
Definition: staple_SF.cpp:35
int nin() const
Definition: field.h:126
void upper(Field_G_SF &, const Field_G &, const int, const int)
Definition: staple_SF.cpp:886
SU(N) gauge field.
Definition: field_G.h:38
Bridge::VerboseLevel m_vl
Definition: force_G.h:35
void mult_ct_boundary(const int t, const double ct)
Multiply the boundary improvement factor ct or ctr to an SU(N) matrix object which belongs to a site ...
Definition: field_G_SF.cpp:128
void set_boundary_wk(const Mat_SU_N &U)
Set the boundary spatial link at t=0 for SF bc.
Definition: field_G_SF.cpp:27
void backward(Field &, const Field &, const int mu)
int nex() const
Definition: field.h:128
Mat_SU_N m_wk
SF boundary condition.
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)
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:667
double m_ctr
SF boundary improvement coefficient for the rectangle action.
void set(int c, double re, const double &im)
Definition: mat_SU_N.h:133
void lower(Field_G_SF &, const Field_G &, const int, const int)
Definition: staple_SF.cpp:921
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
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)