Bridge++  Version 1.4.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 
17 #ifdef USE_FACTORY
18 namespace {
19  Force_G *create_object()
20  {
21  return new Force_G_Rectangle_SF();
22  }
23 
24 
25  bool init = Force_G::Factory::Register("Force_G_Rectangle_SF", create_object);
26 }
27 #endif
28 
29 
30 const std::string Force_G_Rectangle_SF::class_name = "Force_G_Rectangle_SF";
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  double ct0, ct1, ct2, ctr0, ctr1, ctr2;
42  std::vector<double> phi, phipr;
43 
44  int err = 0;
45  err += params.fetch_double("beta", beta);
46  err += params.fetch_double("c_plaq", c_plaq);
47  err += params.fetch_double("c_rect", c_rect);
48 
49  err += params.fetch_double("ct0", ct0);
50  err += params.fetch_double("ct1", ct1);
51  err += params.fetch_double("ct2", ct2);
52 
53  err += params.fetch_double("ctr0", ctr0);
54  err += params.fetch_double("ctr1", ctr1);
55  err += params.fetch_double("ctr2", ctr2);
56 
57  err += params.fetch_double_vector("phi", phi);
58  err += params.fetch_double_vector("phipr", phipr);
59 
60  if (err) {
61  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
62  exit(EXIT_FAILURE);
63  }
64 
65 
66  double gg = 6.0 / beta;
67 
68  double ct = ct0 + ct1 * gg + ct2 * gg * gg;
69  double ctr = ctr0 + ctr1 * gg + ctr2 * gg * gg;
70 
71  set_parameters(beta, c_plaq, c_rect, &phi[0], &phipr[0], ct, ctr);
72 }
73 
74 
75 //====================================================================
76 
90 void Force_G_Rectangle_SF::set_parameters(double beta, double c_plaq, double c_rect,
91  double *phi, double *phipr, double ct, double ctr)
92 {
93  //- print input parameters
94  vout.general(m_vl, "%s:\n", class_name.c_str());
95  vout.general(m_vl, " beta = %12.6f\n", beta);
96  vout.general(m_vl, " c_plaq = %12.6f\n", c_plaq);
97  vout.general(m_vl, " c_rect = %12.6f\n", c_rect);
98  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
99  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
100  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
101  vout.general(m_vl, " phipr1 = %12.6f\n", phipr[0]);
102  vout.general(m_vl, " phipr2 = %12.6f\n", phipr[1]);
103  vout.general(m_vl, " phipr3 = %12.6f\n", phipr[2]);
104  vout.general(m_vl, " ct = %12.6f\n", ct);
105  vout.general(m_vl, " ctr = %12.6f\n", ctr);
106 
107  //- range check
108  // NB. beta,c_plaq,c_rect,phi,phipr,ct,ctr = 0 is allowed.
109 
110  //- store values
111  m_beta = beta;
112  m_c_plaq = c_plaq;
113  m_c_rect = c_rect;
114 
115  m_ct = ct;
116  m_ctr = ctr;
117  // m_phi = phi ;
118  // m_phipr = phipr;
119 
120  //- post-process
121  m_staple.set_parameters(phi, phipr);
122 
123  int Lx = CommonParameters::Lx();
124  double c0r, c0i, c1r, c1i, c2r, c2i;
125  c0r = cos(phi[0] / Lx);
126  c0i = sin(phi[0] / Lx);
127  c1r = cos(phi[1] / Lx);
128  c1i = sin(phi[1] / Lx);
129  c2r = cos(phi[2] / Lx);
130  c2i = sin(phi[2] / Lx);
131  m_wk.zero();
132  m_wk.set(0, 0, c0r, c0i);
133  m_wk.set(1, 1, c1r, c1i);
134  m_wk.set(2, 2, c2r, c2i);
135 
136  c0r = cos(phipr[0] / Lx);
137  c0i = sin(phipr[0] / Lx);
138  c1r = cos(phipr[1] / Lx);
139  c1i = sin(phipr[1] / Lx);
140  c2r = cos(phipr[2] / Lx);
141  c2i = sin(phipr[2] / Lx);
142  m_wkpr.zero();
143  m_wkpr.set(0, 0, c0r, c0i);
144  m_wkpr.set(1, 1, c1r, c1i);
145  m_wkpr.set(2, 2, c2r, c2i);
146 }
147 
148 
149 //====================================================================
150 
206 {
207  int Nvol = CommonParameters::Nvol();
208  int Ndim = CommonParameters::Ndim();
209 
210  int Nt = CommonParameters::Nt();
211  int NPEt = CommonParameters::NPEt();
212 
213  assert(m_U->nin() == m_Nc * m_Nc * 2);
214  assert(m_U->nvol() == Nvol);
215  assert(m_U->nex() == Ndim);
216 
217  assert(force.nin() == m_Nc * m_Nc * 2);
218  assert(force.nvol() == Nvol);
219  assert(force.nex() == Ndim);
220 
221  Mat_SU_N ut(m_Nc);
222 
223  Field_G force1(Nvol, 1);
224  Field_G force2(Nvol, 1);
225 
226  Field_G_SF Cup1, Cup2;
227  Field_G_SF Cdn1, Cdn2;
228  Field_G_SF Umu, Unu;
229  Field_G_SF v, w, c;
230 
231  Mat_SU_N vmat(m_Nc), wmat(m_Nc), cmat(m_Nc);
232  Mat_SU_N wzero(m_Nc);
233  wzero.zero();
234 
235 
236  for (int mu = 0; mu < Ndim; ++mu) {
237  force1.set(0.0);
238  for (int nu = 0; nu < Ndim; ++nu) {
239  if (nu == mu) continue;
240 
241  m_staple.upper(Cup1, *m_U, mu, nu);
242  m_staple.upper(Cup2, *m_U, nu, mu);
243  m_staple.lower(Cdn1, *m_U, mu, nu);
244  m_staple.lower(Cdn2, *m_U, nu, mu);
245 
246  // plaquette term
247  Umu = Cup1;
248  Unu = Cdn1;
249  if (Communicator::ipe(3) == 0) {
250  if (mu == 3) {
251  Umu.mult_ct_boundary(0, m_ct);
252  Unu.mult_ct_boundary(0, m_ct);
253  }
254  if (nu == 3) {
255  Unu.mult_ct_boundary(1, m_ct);
256  }
257  }
258  if (Communicator::ipe(3) == NPEt - 1) {
259  if (mu == 3) {
260  Umu.mult_ct_boundary(Nt - 1, m_ct);
261  Unu.mult_ct_boundary(Nt - 1, m_ct);
262  }
263  if (nu == 3) {
264  Umu.mult_ct_boundary(Nt - 1, m_ct);
265  }
266  }
267  force1.addpart_ex(0, Umu, 0, m_c_plaq);
268  force1.addpart_ex(0, Unu, 0, m_c_plaq);
269 
270  // rectangular term
271  Umu.setpart_ex(0, *m_U, mu);
272  Unu.setpart_ex(0, *m_U, nu);
273  // For the boundary spatial link, use Wk.
274  if ((Communicator::ipe(3) == 0) && (nu == 3)) Umu.set_boundary_wk(m_wk);
275  if ((Communicator::ipe(3) == 0) && (mu == 3)) Unu.set_boundary_wk(m_wk);
276 
277  // +---+---+
278  // | | term
279  // x <---+
280 
281  m_shift.backward(v, Cup2, mu);
282  m_shift.backward(c, Umu, nu);
283  // The force for the spatial link near the boundary. Multiplied with ctr.
284  if ((Communicator::ipe(3) == NPEt - 1) && (nu == 3)) {
286  c.mult_ct_boundary(Nt - 1, m_ctr);
287  }
288  mult_Field_Gnd(w, 0, c, 0, v, 0);
289  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
290  // The force for the boundary spatial link is set to zero.
291  if ((Communicator::ipe(3) == 0) && (nu == 3)) c.set_boundary_zero();
292  force1.addpart_ex(0, c, 0, m_c_rect);
293 
294  // +---+
295  // | |
296  // + + term
297  // | |
298  // x v
299 
300  m_shift.backward(v, Unu, mu);
301  m_shift.backward(c, Cup1, nu);
302  // The force for the temporal link near the boundary. Multiplied with ctr.
303  if ((Communicator::ipe(3) == NPEt - 1) && (mu == 3)) {
305  v.mult_ct_boundary(Nt - 1, m_ctr);
306  }
307  mult_Field_Gnd(w, 0, c, 0, v, 0);
308  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
309  // The force for the boundary spatial link is set to zero.
310  if ((Communicator::ipe(3) == 0) && (nu == 3)) c.set_boundary_zero();
311  // The force for the boundary temporal link.
312  if ((Communicator::ipe(3) == 0) && (mu == 3)) c.mult_ct_boundary(0, m_ctr);
313  force1.addpart_ex(0, c, 0, m_c_rect);
314 
315  // +---+---+
316  // | | term
317  // +---x v
318 
319  m_shift.backward(v, Unu, mu);
320  m_shift.backward(c, Umu, nu);
321  if ((Communicator::ipe(3) == NPEt - 1) && (nu == 3)) {
323  c.mult_ct_boundary(Nt - 1, m_ctr);
324  }
325  if ((Communicator::ipe(3) == NPEt - 1) && (mu == 3)) v.set_boundary_wkpr(m_wkpr);
326  mult_Field_Gnd(w, 0, c, 0, v, 0);
327  mult_Field_Gnn(c, 0, Cdn2, 0, w, 0);
328  if ((Communicator::ipe(3) == 0) && (nu == 3)) c.set_boundary_zero();
329  force1.addpart_ex(0, c, 0, m_c_rect);
330 
331  // x <---+
332  // | | term
333  // +---+---+
334 
335  m_shift.backward(v, Cup2, mu);
336  mult_Field_Gnn(w, 0, Umu, 0, v, 0);
337  mult_Field_Gdn(v, 0, Unu, 0, w, 0);
338  if ((Communicator::ipe(3) == 0) && (nu == 3)) v.mult_ct_boundary(0, m_ctr);
339  m_shift.forward(c, v, nu);
340  if ((Communicator::ipe(3) == 0) && (nu == 3)) c.set_boundary_zero();
341  force1.addpart_ex(0, c, 0, m_c_rect);
342 
343  // x ^
344  // | |
345  // + + term
346  // | |
347  // +---+
348 
349  m_shift.backward(v, Unu, mu);
350  if ((Communicator::ipe(3) == NPEt - 1) && (mu == 3)) {
352  v.mult_ct_boundary(Nt - 1, m_ctr);
353  }
354  mult_Field_Gnn(w, 0, Cdn1, 0, v, 0);
355  mult_Field_Gdn(v, 0, Unu, 0, w, 0);
356  if ((Communicator::ipe(3) == 0) && (mu == 3)) v.mult_ct_boundary(0, m_ctr);
357  m_shift.forward(c, v, nu);
358  if ((Communicator::ipe(3) == 0) && (nu == 3)) c.set_boundary_zero();
359  force1.addpart_ex(0, c, 0, m_c_rect);
360 
361  // +---x ^
362  // | | term
363  // +---+---+
364 
365  m_shift.backward(v, Unu, mu);
366  if ((Communicator::ipe(3) == NPEt - 1) && (mu == 3)) v.set_boundary_wkpr(m_wkpr);
367  mult_Field_Gnn(w, 0, Umu, 0, v, 0);
368  mult_Field_Gdn(v, 0, Cdn2, 0, w, 0);
369  if ((Communicator::ipe(3) == 0) && (nu == 3)) v.mult_ct_boundary(0, m_ctr);
370  m_shift.forward(c, v, nu);
371  if ((Communicator::ipe(3) == 0) && (nu == 3)) c.set_boundary_zero();
372  force1.addpart_ex(0, c, 0, m_c_rect);
373  }
374 
375  mult_Field_Gnd(force2, 0, *m_U, mu, force1, 0);
376  at_Field_G(force2, 0);
377 
378  axpy(force, mu, -(m_beta / m_Nc), force2, 0);
379  }
380 
381  double Fave, Fmax, Fdev;
382  force.stat(Fave, Fmax, Fdev);
383  vout.general(m_vl, " Fave = %12.6f Fmax = %12.6f Fdev = %12.6f\n",
384  Fave, Fmax, Fdev);
385 }
386 
387 
388 //====================================================================
389 //============================================================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:80
BridgeIO vout
Definition: bridgeIO.cpp:495
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:55
static int NPEt()
int fetch_double_vector(const string &key, vector< double > &value) const
Definition: parameters.cpp:275
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:164
static const std::string class_name
Field_G * m_U
Definition: force_G.h:34
void general(const char *format,...)
Definition: bridgeIO.cpp:195
Mat_SU_N & zero()
Definition: mat_SU_N.h:383
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 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:193
double m_ct
SF boundary improvement coefficient for the plaquatte action.
void set_parameters(const Parameters &params)
Definition: staple_SF.cpp:39
int nin() const
Definition: field.h:115
void mult_ct_boundary(int t, 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:130
void upper(Field_G_SF &, const Field_G &, const int, const int)
Definition: staple_SF.cpp:818
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 set_boundary_wk(const Mat_SU_N &U)
Set the boundary spatial link at t=0 for SF bc.
Definition: field_G_SF.cpp:29
void backward(Field &, const Field &, const int mu)
int nex() const
Definition: field.h:117
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: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)
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
HMC force class for rectangular gauge action with the SF BC.
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:846
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)