Bridge++  Ver. 1.3.x
forceSmear_APE_SF.cpp
Go to the documentation of this file.
1 
14 #include "forceSmear_APE_SF.h"
15 
16 #ifdef USE_PARAMETERS_FACTORY
17 #include "parameters_factory.h"
18 #endif
19 
20 
21 #ifdef USE_FACTORY
22 namespace {
23  ForceSmear *create_object(Projection *proj)
24  {
25  return new ForceSmear_APE_SF(proj);
26  }
27 
28 
29  bool init = ForceSmear::Factory::Register("APE_SF", create_object);
30 }
31 #endif
32 
33 //- parameter entries
34 namespace {
35  void append_entry(Parameters& param)
36  {
37  param.Register_double("rho_uniform", 0.0);
38  param.Register_double_vector("phi", std::vector<double>());
39  param.Register_double_vector("phipr", std::vector<double>());
40 
41  param.Register_string("verbose_level", "NULL");
42  }
43 
44 
45 #ifdef USE_PARAMETERS_FACTORY
46  bool init_param = ParametersFactory::Register("ForceSmear.APE_SF", append_entry);
47 #endif
48 }
49 //- end
50 
51 //- parameters class
53 //- end
54 
55 const std::string ForceSmear_APE_SF::class_name = "ForceSmear_APE_SF";
56 
57 //====================================================================
59 {
60  const string str_vlevel = params.get_string("verbose_level");
61 
62  m_vl = vout.set_verbose_level(str_vlevel);
63 
64  //- fetch and check input parameters
65  double rho1;
66  std::vector<double> phi, phipr;
67 
68  int err = 0;
69  err += params.fetch_double("rho_uniform", rho1);
70  err += params.fetch_double_vector("phi", phi);
71  err += params.fetch_double_vector("phipr", phipr);
72 
73  if (err) {
74  vout.crucial(m_vl, "%s: fetch error, input parameter not found.\n", class_name.c_str());
75  exit(EXIT_FAILURE);
76  }
77 
78 
79  set_parameters(rho1, &phi[0], &phipr[0]);
80 }
81 
82 
83 //====================================================================
84 void ForceSmear_APE_SF::set_parameters(const double rho1, double *phi, double *phipr)
85 {
86  //- print input parameters
87  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
88  vout.general(m_vl, " rho = %8.4f\n", rho1);
89 
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 
97  //- range check
98  // NB. rho == 0 is allowed.
99  // NB. phi,phipr == 0 is allowed.
100 
101  //- store values
102  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
103  for (int mu = 0; mu < m_Ndim; ++mu) {
104  for (int nu = 0; nu < m_Ndim; ++nu) {
105  m_rho[mu + nu * m_Ndim] = rho1;
106  }
107  }
108 
109  for (int i = 0; i < 3; ++i) {
110  m_phi[i] = phi[i];
111  m_phipr[i] = phipr[i];
112  }
113 
114  //- propagate parameters
116 }
117 
118 
119 //====================================================================
120 void ForceSmear_APE_SF::set_parameters(const std::vector<double>& rho, double *phi, double *phipr)
121 {
122  //- print input parameters
123  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
124  for (int mu = 0; mu < m_Ndim; ++mu) {
125  vout.general(m_vl, " rho[%d] = %8.4f\n", mu, rho[mu]);
126  }
127 
128  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
129  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
130  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
131  vout.general(m_vl, " phipr1= %12.6f\n", phipr[0]);
132  vout.general(m_vl, " phipr2= %12.6f\n", phipr[1]);
133  vout.general(m_vl, " phipr3= %12.6f\n", phipr[2]);
134 
135  //- range check
136  // NB. rho == 0 is allowed.
137  // NB. phi,phipr == 0 is allowed.
138  assert(rho.size() == m_Ndim * m_Ndim);
139 
140  // store values
141  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
142  for (int mu = 0; mu < m_Ndim; ++mu) {
143  for (int nu = 0; nu < m_Ndim; ++nu) {
144  m_rho[mu + nu * m_Ndim] = rho[mu + nu * m_Ndim];
145  }
146  }
147 
148  for (int i = 0; i < 3; ++i) {
149  m_phi[i] = phi[i];
150  m_phipr[i] = phipr[i];
151  }
152 
153  // propagate parameters
155 }
156 
157 
158 //====================================================================
160 {
163 
164  m_rho.resize(m_Ndim * m_Ndim);
165  m_U.resize(m_Ndim);
166  m_iTheta.resize(m_Ndim);
167 
168  for (int mu = 0; mu < m_Ndim; ++mu) {
169  for (int nu = 0; nu < m_Ndim; ++nu) {
170  m_rho[mu + nu * m_Ndim] = 0.0;
171  }
172  }
173 }
174 
175 
176 //====================================================================
177 
190 /*
191 Field ForceSmear_APE_SF::force_udiv(const Field_G& Sigmap, const Field_G& U)
192 {
193  Field_G Sigma(Sigmap.nvol(), Sigmap.nex());
194 
195  force_udiv(Sigma, Sigmap, U);
196 
197  return Sigma;
198 }
199 */
200 
201 //====================================================================
202 void ForceSmear_APE_SF::force_udiv(Field_G& Sigma, const Field_G& Sigmap, const Field_G& U)
203 {
204  int Nc = CommonParameters::Nc();
205  int NinG = 2 * Nc * Nc;
206 
207  assert(Sigmap.nin() == NinG);
208  assert(Sigmap.nvol() == m_Nvol);
209  assert(Sigmap.nex() == m_Ndim);
210 
211  Field_G C(m_Nvol, 1);
212  Field_G sigmap_tmp(m_Nvol, 1), Xi(m_Nvol, 1);
213 
214  for (int mu = 0; mu < m_Ndim; ++mu) {
215  m_U[mu].setpart_ex(0, U, mu);
216  if (mu != 3) set_wk.set_boundary_wk(m_U[mu]);
217  }
218 
219  Field_G c_tmp(m_Nvol, 1);
220  for (int mu = 0; mu < m_Ndim; ++mu) {
221  C.set(0.0);
222  for (int nu = 0; nu < m_Ndim; ++nu) {
223  if (nu == mu) continue;
224  double rho = m_rho[mu + m_Ndim * nu];
225  staple(c_tmp, m_U[mu], m_U[nu], mu, nu);
226  C.addpart_ex(0, c_tmp, 0, rho);
227  }
228 
229  sigmap_tmp.setpart_ex(0, Sigmap, mu);
230 
231  double alpha = m_rho[mu + m_Ndim * mu];
233  alpha, sigmap_tmp, C, m_U[mu]);
234  Sigma.setpart_ex(mu, Xi, 0);
235  }
236 
237  Field_G sigma_tmp(m_Nvol, 1);
238  for (int mu = 0; mu < m_Ndim; ++mu) {
239  for (int nu = 0; nu < m_Ndim; ++nu) {
240  if (nu == mu) continue;
241  double rho = m_rho[mu + m_Ndim * nu];
242  force_each(sigma_tmp, m_U[mu], m_U[nu],
243  m_iTheta[mu], m_iTheta[nu], mu, nu);
244  Sigma.addpart_ex(mu, sigma_tmp, 0, rho);
245  }
246  }
248 }
249 
250 
251 //====================================================================
252 
266  const Field_G& V_mu, const Field_G& V_nu,
267  const Field_G& iTheta_mu,
268  const Field_G& iTheta_nu,
269  int mu, int nu)
270 {
271  Field_G vt1(m_Nvol, 1), vt2(m_Nvol, 1), vt3(m_Nvol, 1);
272 
273  Sigma_mu.set(0.0);
274  //- The 1st block
275  m_shift.backward(vt1, V_nu, mu);
276  if (mu == 3) set_wk.set_boundary_wkpr(vt1);
277  m_shift.backward(vt2, V_mu, nu);
278  if (nu == 3) set_wk.set_boundary_wkpr(vt2);
279  mult_Field_Gnd(vt3, 0, vt1, 0, vt2, 0);
280  multadd_Field_Gnd(Sigma_mu, 0, vt3, 0, iTheta_nu, 0, 1.0);
281 
282  //- The 2nd block
283  mult_Field_Gdn(vt3, 0, iTheta_mu, 0, V_nu, 0);
284  mult_Field_Gdn(vt2, 0, vt1, 0, vt3, 0);
285  m_shift.forward(vt3, vt2, nu);
286  axpy(Sigma_mu, 1.0, vt3); // Sigma_mu += vt3;
287 
288  //- The 3rd block
289  mult_Field_Gdn(vt3, 0, V_mu, 0, iTheta_nu, 0);
290  mult_Field_Gdn(vt2, 0, vt1, 0, vt3, 0);
291  m_shift.forward(vt3, vt2, nu);
292  axpy(Sigma_mu, 1.0, vt3); // Sigma_mu += vt3;
293 
294  //- The 4th block
295  m_shift.backward(vt1, iTheta_nu, mu);
296  m_shift.backward(vt2, V_mu, nu);
297  if (nu == 3) set_wk.set_boundary_wkpr(vt2);
298  mult_Field_Gnd(vt3, 0, vt1, 0, vt2, 0);
299  multadd_Field_Gnd(Sigma_mu, 0, vt3, 0, V_nu, 0, 1.0);
300 
301  //- The 5th block
302  mult_Field_Gdd(vt2, 0, vt1, 0, V_mu, 0);
303  mult_Field_Gnn(vt3, 0, vt2, 0, V_nu, 0);
304  m_shift.forward(vt2, vt3, nu);
305  axpy(Sigma_mu, 1.0, vt2); // Sigma_mu += vt2;
306 
307  //- The 6th block
308  m_shift.backward(vt1, V_nu, mu);
309  if (mu == 3) set_wk.set_boundary_wkpr(vt1);
310  m_shift.backward(vt2, iTheta_mu, nu);
311  mult_Field_Gnd(vt3, 0, vt1, 0, vt2, 0);
312  multadd_Field_Gnd(Sigma_mu, 0, vt3, 0, V_nu, 0, 1.0);
313 }
314 
315 
316 //====================================================================
318  const Field_G& u_mu, const Field_G& u_nu,
319  int mu, int nu)
320 {
321  Field_G v1(m_Nvol, 1), v2(m_Nvol, 1);
322 
323  //- upper direction
324  m_shift.backward(v1, u_mu, nu);
325  if (nu == 3) set_wk.set_boundary_wkpr(v1);
326  mult_Field_Gnn(v2, 0, u_nu, 0, v1, 0);
327 
328  m_shift.backward(v1, u_nu, mu);
329  if (mu == 3) set_wk.set_boundary_wkpr(v1);
330  mult_Field_Gnd(c, 0, v2, 0, v1, 0);
331 
332  //- lower direction
333  m_shift.backward(v2, u_nu, mu);
334  if (mu == 3) set_wk.set_boundary_wkpr(v2);
335  mult_Field_Gnn(v1, 0, u_mu, 0, v2, 0);
336  mult_Field_Gdn(v2, 0, u_nu, 0, v1, 0);
337  m_shift.forward(v1, v2, nu);
338  c.addpart_ex(0, v1, 0);
339 }
340 
341 
342 //====================================================================
343 //============================================================END=====
Bridge::VerboseLevel m_vl
Definition: forceSmear.h:56
BridgeIO vout
Definition: bridgeIO.cpp:278
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:76
void Register_string(const string &, const string &)
Definition: parameters.cpp:351
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:155
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 force_udiv(Field_G &Sigma, const Field_G &Sigma_p, const Field_G &U)
void general(const char *format,...)
Definition: bridgeIO.cpp:65
static const std::string class_name
void set_parameters(const Parameters &params)
int nvol() const
Definition: field.h:116
std::vector< Field_G > m_iTheta
Class for parameters.
Definition: parameters.h:38
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:189
void mult_Field_Gdd(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2)
void force_each(Field_G &, const Field_G &, const Field_G &, const Field_G &, const Field_G &, int mu, int nu)
int nin() const
Definition: field.h:115
Base class for force calculation of smeared operators.
Definition: forceSmear.h:34
std::vector< double > m_rho
void set_boundary_spatial_link_zero()
Set the boundary spatial link to 0 for SF bc.
Definition: field_G_SF.cpp:125
SU(N) gauge field.
Definition: field_G.h:38
virtual void force_recursive(Field_G &Xi, Field_G &iTheta, double alpha, const Field_G &Sigmap, const Field_G &C, const Field_G &U)=0
determination of fields for force calculation
void mult_Field_Gnd(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2)
double m_phi[3]
SF boundary condition at t=0.
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:50
void mult_Field_Gnn(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2)
ShiftField_lex m_shift
void backward(Field &, const Field &, const int mu)
int nex() const
Definition: field.h:117
void multadd_Field_Gnd(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2, const double ff)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:168
void crucial(const char *format,...)
Definition: bridgeIO.cpp:48
base class for projection operator into gauge group.
Definition: projection.h:31
void set_parameters(const Parameters_Field_G_SF &params)
Set the parameter with Parameters_Field_G_SF class.
Definition: field_G_SF.cpp:268
std::vector< Field_G > m_U
static bool Register(const std::string &realm, const creator_callback &cb)
double m_phipr[3]
SF boundary condition at t=Nt.
void Register_double_vector(const string &, const std::vector< double > &)
Definition: parameters.cpp:337
void staple(Field_G &, const Field_G &, const Field_G &, int mu, int nu)
int fetch_double_vector(const string &key, std::vector< double > &val) const
Definition: parameters.cpp:158
void Register_double(const string &, const double)
Definition: parameters.cpp:323
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:177
int fetch_double(const string &key, double &val) const
Definition: parameters.cpp:124
string get_string(const string &key) const
Definition: parameters.cpp:87
double rho(int mu, int nu)
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:28
void forward(Field &, const Field &, const int mu)