Bridge++  Version 1.4.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
action_G_Rectangle_SF.cpp
Go to the documentation of this file.
1 
14 #include "action_G_Rectangle_SF.h"
15 
16 
17 #ifdef USE_FACTORY
18 namespace {
19  Action *create_object()
20  {
21  return new Action_G_Rectangle_SF();
22  }
23 
24 
25  bool init = Action::Factory::Register("Action_G_Rectangle_SF", create_object);
26 }
27 #endif
28 
29 
30 
31 const std::string Action_G_Rectangle_SF::class_name = "Action_G_Rectangle_SF";
32 
33 //====================================================================
35 {
36  const string str_vlevel = params.get_string("verbose_level");
37 
38  m_vl = vout.set_verbose_level(str_vlevel);
39 
40  //- fetch and check input parameters
41  double beta, c_plaq, c_rect;
42  double ct0, ct1, ct2, ctr0, ctr1, ctr2;
43  std::vector<double> phi, phipr;
44 
45  int err = 0;
46  err += params.fetch_double("beta", beta);
47  err += params.fetch_double("c_plaq", c_plaq);
48  err += params.fetch_double("c_rect", c_rect);
49 
50  err += params.fetch_double("ct0", ct0);
51  err += params.fetch_double("ct1", ct1);
52  err += params.fetch_double("ct2", ct2);
53 
54  err += params.fetch_double("ctr0", ctr0);
55  err += params.fetch_double("ctr1", ctr1);
56  err += params.fetch_double("ctr2", ctr2);
57 
58  err += params.fetch_double_vector("phi", phi);
59  err += params.fetch_double_vector("phipr", phipr);
60 
61  if (err) {
62  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
63  exit(EXIT_FAILURE);
64  }
65 
66 
67  double gg = 6.0 / beta;
68 
69  double ct = ct0 + ct1 * gg + ct2 * gg * gg;
70  double ctr = ctr0 + ctr1 * gg + ctr2 * gg * gg;
71 
72  set_parameters(beta, c_plaq, c_rect, &phi[0], &phipr[0], ct, ctr);
73 
74  //- post-process
75  m_force_G->set_parameters(params);
76 }
77 
78 
79 //====================================================================
80 
94 void Action_G_Rectangle_SF::set_parameters(double beta, double c_plaq, double c_rect,
95  double *phi, double *phipr, double ct, double ctr)
96 {
97  //- print input parameters
98  vout.general(m_vl, "%s:\n", class_name.c_str());
99  vout.general(m_vl, " beta = %12.6f\n", beta);
100  vout.general(m_vl, " c_plaq = %12.6f\n", c_plaq);
101  vout.general(m_vl, " c_rect = %12.6f\n", c_rect);
102  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
103  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
104  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
105  vout.general(m_vl, " phipr1 = %12.6f\n", phipr[0]);
106  vout.general(m_vl, " phipr2 = %12.6f\n", phipr[1]);
107  vout.general(m_vl, " phipr3 = %12.6f\n", phipr[2]);
108  vout.general(m_vl, " ct = %12.6f\n", ct);
109  vout.general(m_vl, " ctr = %12.6f\n", ctr);
110 
111  //- range check
112  // NB. beta,c_plaq,c_rect,phi,phipr,ct,ctr = 0 is allowed.
113 
114  //- store values
115  m_beta = beta;
116  m_c_plaq = c_plaq;
117  m_c_rect = c_rect;
118 
119  m_ct = ct;
120  m_ctr = ctr;
121  // m_phi = phi ;
122  // m_phipr = phipr;
123 
124  //- post-process
125  m_staple.set_parameters(phi, phipr);
126 
127  int Lx = CommonParameters::Lx();
128  double c0r, c0i, c1r, c1i, c2r, c2i;
129  c0r = cos(phi[0] / Lx);
130  c0i = sin(phi[0] / Lx);
131  c1r = cos(phi[1] / Lx);
132  c1i = sin(phi[1] / Lx);
133  c2r = cos(phi[2] / Lx);
134  c2i = sin(phi[2] / Lx);
135  m_wk.zero();
136  m_wk.set(0, 0, c0r, c0i);
137  m_wk.set(1, 1, c1r, c1i);
138  m_wk.set(2, 2, c2r, c2i);
139 
140  c0r = cos(phipr[0] / Lx);
141  c0i = sin(phipr[0] / Lx);
142  c1r = cos(phipr[1] / Lx);
143  c1i = sin(phipr[1] / Lx);
144  c2r = cos(phipr[2] / Lx);
145  c2i = sin(phipr[2] / Lx);
146  m_wkpr.zero();
147  m_wkpr.set(0, 0, c0r, c0i);
148  m_wkpr.set(1, 1, c1r, c1i);
149  m_wkpr.set(2, 2, c2r, c2i);
150 }
151 
152 
153 //====================================================================
155 {
156  double H_U = calcH();
157 
158  return H_U;
159 }
160 
161 
162 //====================================================================
163 
206 {
207  int Ndim = CommonParameters::Ndim();
208  int Nvol = CommonParameters::Nvol();
209 
210  int Nt = CommonParameters::Nt();
211  int NPEt = CommonParameters::NPEt();
212 
213  // int Ndim2 = Ndim * (Ndim - 1) / 2;
214  // int size_U = Lvol * Ndim2;
215 
216  //Field_G Cup1(Nvol,1), Cup2(Nvol,1);
217  //Field_G Cdn1(Nvol,1), Cdn2(Nvol,1);
218  // Field_G Umu(Nvol,1), Unu(Nvol,1);
219  // Field_G v(Nvol,1), w(Nvol,1), c(Nvol,1);
220  Field_G_SF Cup1, Cup2;
221  Field_G_SF Cdn1, Cdn2;
222  Field_G_SF Umu, Unu;
223  Field_G_SF v, w, c;
224 
225  Mat_SU_N vmat(m_Nc), wmat(m_Nc), cmat(m_Nc);
226 
227  double plaqF = 0.0;
228  double rectF = 0.0;
229 
230  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
231 
232  for (int mu = 0; mu < Ndim; ++mu) {
233  for (int nu = mu + 1; nu < Ndim; ++nu) {
234  m_staple.upper(Cup1, *m_U, mu, nu);
235  m_staple.upper(Cup2, *m_U, nu, mu);
236 
237  // plaquette term
238  Unu = Cup2;
239  // If the node is at the boundary the temporal plaquette is multiplied with ct.
240  if ((nu == 3) && (Communicator::ipe(3) == 0)) {
241  Unu.mult_ct_boundary(0, m_ct);
242  }
243  if ((nu == 3) && (Communicator::ipe(3) == NPEt - 1)) {
244  Unu.mult_ct_boundary(Nt - 1, m_ct);
245  }
246  for (int site = 0; site < Nvol; ++site) {
247  plaqF += ReTr(m_U->mat(site, nu) * Unu.mat_dag(site));
248  }
249 
250  // rectangular terms
251 
252  // +---+---+
253  // | | term
254  // x <---+
255 
256  Umu.setpart_ex(0, *m_U, mu);
257  Unu.setpart_ex(0, *m_U, nu);
258  if ((Communicator::ipe(3) == 0) && (nu == 3)) {
259  Umu.set_boundary_wk(m_wk);
260  }
261 
262  m_shift.backward(v, Cup2, mu);
263  m_shift.backward(c, Umu, nu);
264 
265  if ((Communicator::ipe(3) == 0) && (nu == 3)) {
266  c.mult_ct_boundary(0, m_ctr);
267  }
268  if ((Communicator::ipe(3) == NPEt - 1) && (nu == 3)) {
270  c.mult_ct_boundary(Nt - 1, m_ctr);
271  }
272 
273  mult_Field_Gnd(w, 0, c, 0, v, 0);
274  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
275  for (int site = 0; site < Nvol; ++site) {
276  rectF += ReTr(Umu.mat(site) * c.mat_dag(site));
277  }
278 
279  // +---+
280  // | |
281  // + + term
282  // | |
283  // x v
284 
285  m_shift.backward(v, Unu, mu);
286  m_shift.backward(c, Cup1, nu);
287 
288  mult_Field_Gnd(w, 0, c, 0, v, 0);
289  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
290  for (int site = 0; site < Nvol; ++site) {
291  rectF += ReTr(Umu.mat(site) * c.mat_dag(site));
292  }
293  }
294  }
295 
296  plaqF = Communicator::reduce_sum(plaqF);
297  rectF = Communicator::reduce_sum(rectF);
298 
299  // double plaq = plaqF/Nc;
300  // vout.general(m_vl," Plaquette = %18.8f\n",plaq/size_U);
301 
302  // double H_U = m_c_plaq * (Ndim2*Lvol - plaqF/Nc)
303  // + m_c_rect * (Ndim2*Lvol*2 - rectF/Nc);
304  double H_U = m_c_plaq * (-plaqF / m_Nc)
305  + m_c_rect * (-rectF / m_Nc);
306 
307  H_U = m_beta * H_U;
308 
309  vout.general(m_vl, " H_Grectangle = %18.8f\n", H_U);
310  // vout.general(m_vl," H_G/dof = %18.8f\n",H_U/size_U);
311 
312  return H_U;
313 }
314 
315 
316 //====================================================================
317 
373 {
374  //- check of argument type
375  assert(force.nin() == m_U->nin());
376  assert(force.nvol() == m_U->nvol());
377  assert(force.nex() == m_U->nex());
378 
379  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
380 
381  force.set(0.0);
382 
383  m_force_G->force_core(force, m_U);
384 }
385 
386 
387 //====================================================================
388 //============================================================END=====
SU(N) gauge field class in which a few functions are added for the SF.
Definition: field_G_SF.h:33
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
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
Class for parameters.
Definition: parameters.h:46
static int ipe(const int dir)
logical coordinate of current proc.
virtual void force_core(Field &)=0
Base class of HMC action class family.
Definition: action.h:36
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 set_parameters(const Parameters &params)
void upper(Field_G_SF &, const Field_G &, const int, const int)
Definition: staple_SF.cpp:818
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
double m_ct
SF boundary improvement coefficient for the plaquatte action.
void backward(Field &, const Field &, const int mu)
int nex() const
Definition: field.h:117
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
HMC action class for rectangular gauge action with the SF BC.
Bridge::VerboseLevel m_vl
Definition: action.h:75
Base class of random number generators.
Definition: randomNumbers.h:36
double m_ctr
SF boundary improvement coefficient for the rectangle action.
static const std::string class_name
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:126
double langevin(RandomNumbers *)
Langevis step.
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...
Mat_SU_N m_wk
SF boundary condition.
virtual void set_parameters(const Parameters &)=0
void set(int c, double re, const double &im)
Definition: mat_SU_N.h:133
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
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:113
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
double ReTr(const Mat_SU_N &m)
Definition: mat_SU_N.h:488
void mult_Field_Gnd(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)