Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
forceSmear_APE_SF.cpp
Go to the documentation of this file.
1 
14 #include "forceSmear_APE_SF.h"
15 
16 #ifdef USE_FACTORY_AUTOREGISTER
17 namespace {
18  bool init = ForceSmear_APE_SF::register_factory();
19 }
20 #endif
21 
22 const std::string ForceSmear_APE_SF::class_name = "ForceSmear_APE_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 rho1;
33  std::vector<double> phi, phipr;
34 
35  int err = 0;
36  err += params.fetch_double("rho_uniform", rho1);
37  err += params.fetch_double_vector("phi", phi);
38  err += params.fetch_double_vector("phipr", phipr);
39 
40  if (err) {
41  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
42  exit(EXIT_FAILURE);
43  }
44 
45 
46  set_parameters(rho1, &phi[0], &phipr[0]);
47 }
48 
49 
50 //====================================================================
51 void ForceSmear_APE_SF::set_parameters(const double rho1, double *phi, double *phipr)
52 {
53  //- print input parameters
54  vout.general(m_vl, "%s:\n", class_name.c_str());
55  vout.general(m_vl, " rho = %8.4f\n", rho1);
56 
57  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
58  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
59  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
60  vout.general(m_vl, " phipr1= %12.6f\n", phipr[0]);
61  vout.general(m_vl, " phipr2= %12.6f\n", phipr[1]);
62  vout.general(m_vl, " phipr3= %12.6f\n", phipr[2]);
63 
64  //- range check
65  // NB. rho == 0 is allowed.
66  // NB. phi,phipr == 0 is allowed.
67 
68  //- store values
69  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
70  for (int mu = 0; mu < m_Ndim; ++mu) {
71  for (int nu = 0; nu < m_Ndim; ++nu) {
72  m_rho[mu + nu * m_Ndim] = rho1;
73  }
74  }
75 
76  for (int i = 0; i < 3; ++i) {
77  m_phi[i] = phi[i];
78  m_phipr[i] = phipr[i];
79  }
80 
81  //- propagate parameters
83 }
84 
85 
86 //====================================================================
87 void ForceSmear_APE_SF::set_parameters(const std::vector<double>& rho, double *phi, double *phipr)
88 {
89  //- print input parameters
90  vout.general(m_vl, "%s:\n", class_name.c_str());
91  for (int mu = 0; mu < m_Ndim; ++mu) {
92  vout.general(m_vl, " rho[%d] = %8.4f\n", mu, rho[mu]);
93  }
94 
95  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
96  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
97  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
98  vout.general(m_vl, " phipr1= %12.6f\n", phipr[0]);
99  vout.general(m_vl, " phipr2= %12.6f\n", phipr[1]);
100  vout.general(m_vl, " phipr3= %12.6f\n", phipr[2]);
101 
102  //- range check
103  // NB. rho == 0 is allowed.
104  // NB. phi,phipr == 0 is allowed.
105  assert(rho.size() == m_Ndim * m_Ndim);
106 
107  // store values
108  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
109  for (int mu = 0; mu < m_Ndim; ++mu) {
110  for (int nu = 0; nu < m_Ndim; ++nu) {
111  m_rho[mu + nu * m_Ndim] = rho[mu + nu * m_Ndim];
112  }
113  }
114 
115  for (int i = 0; i < 3; ++i) {
116  m_phi[i] = phi[i];
117  m_phipr[i] = phipr[i];
118  }
119 
120  // propagate parameters
122 }
123 
124 
125 //====================================================================
127 {
130 
131  m_rho.resize(m_Ndim * m_Ndim);
132  m_U.resize(m_Ndim);
133  m_iTheta.resize(m_Ndim);
134 
135  for (int mu = 0; mu < m_Ndim; ++mu) {
136  for (int nu = 0; nu < m_Ndim; ++nu) {
137  m_rho[mu + nu * m_Ndim] = 0.0;
138  }
139  }
140 }
141 
142 
143 //====================================================================
144 
157 /*
158 Field ForceSmear_APE_SF::force_udiv(const Field_G& Sigmap, const Field_G& U)
159 {
160  Field_G Sigma(Sigmap.nvol(), Sigmap.nex());
161 
162  force_udiv(Sigma, Sigmap, U);
163 
164  return Sigma;
165 }
166 */
167 
168 //====================================================================
169 void ForceSmear_APE_SF::force_udiv(Field_G& Sigma, const Field_G& Sigmap, const Field_G& U)
170 {
171  const int Nc = CommonParameters::Nc();
172  const int NinG = 2 * Nc * Nc;
173 
174  assert(Sigmap.nin() == NinG);
175  assert(Sigmap.nvol() == m_Nvol);
176  assert(Sigmap.nex() == m_Ndim);
177 
178  for (int mu = 0; mu < m_Ndim; ++mu) {
179  m_U[mu].setpart_ex(0, U, mu);
180  if (mu != 3) set_wk.set_boundary_wk(m_U[mu]);
181  }
182 
183  for (int mu = 0; mu < m_Ndim; ++mu) {
184  Field_G C;
185  C.set(0.0);
186 
187  for (int nu = 0; nu < m_Ndim; ++nu) {
188  if (nu == mu) continue;
189  double rho = m_rho[mu + m_Ndim * nu];
190 
191  Field_G c_tmp;
192  staple(c_tmp, m_U[mu], m_U[nu], mu, nu);
193  C.addpart_ex(0, c_tmp, 0, rho);
194  }
195 
196  Field_G sigmap_tmp;
197  sigmap_tmp.setpart_ex(0, Sigmap, mu);
198 
199  double alpha = m_rho[mu + m_Ndim * mu];
200 
201  Field_G Xi;
203  alpha, sigmap_tmp, C, m_U[mu]);
204  Sigma.setpart_ex(mu, Xi, 0);
205  }
206 
207  for (int mu = 0; mu < m_Ndim; ++mu) {
208  for (int nu = 0; nu < m_Ndim; ++nu) {
209  if (nu == mu) continue;
210 
211  double rho = m_rho[mu + m_Ndim * nu];
212 
213  Field_G sigma_tmp;
214  force_each(sigma_tmp, m_U[mu], m_U[nu],
215  m_iTheta[mu], m_iTheta[nu], mu, nu);
216  Sigma.addpart_ex(mu, sigma_tmp, 0, rho);
217  }
218  }
220 }
221 
222 
223 //====================================================================
224 
238  const Field_G& V_mu, const Field_G& V_nu,
239  const Field_G& iTheta_mu,
240  const Field_G& iTheta_nu,
241  const int mu, const int nu)
242 {
243  Sigma_mu.set(0.0);
244 
245  //- The 1st block
246  Field_G vt1;
247  m_shift.backward(vt1, V_nu, mu);
248  if (mu == 3) set_wk.set_boundary_wkpr(vt1);
249 
250  Field_G vt2;
251  m_shift.backward(vt2, V_mu, nu);
252  if (nu == 3) set_wk.set_boundary_wkpr(vt2);
253 
254  Field_G vt3;
255  mult_Field_Gnd(vt3, 0, vt1, 0, vt2, 0);
256  multadd_Field_Gnd(Sigma_mu, 0, vt3, 0, iTheta_nu, 0, 1.0);
257 
258  //- The 2nd block
259  mult_Field_Gdn(vt3, 0, iTheta_mu, 0, V_nu, 0);
260  mult_Field_Gdn(vt2, 0, vt1, 0, vt3, 0);
261  m_shift.forward(vt3, vt2, nu);
262  axpy(Sigma_mu, 1.0, vt3); // Sigma_mu += vt3;
263 
264  //- The 3rd block
265  mult_Field_Gdn(vt3, 0, V_mu, 0, iTheta_nu, 0);
266  mult_Field_Gdn(vt2, 0, vt1, 0, vt3, 0);
267  m_shift.forward(vt3, vt2, nu);
268  axpy(Sigma_mu, 1.0, vt3); // Sigma_mu += vt3;
269 
270  //- The 4th block
271  m_shift.backward(vt1, iTheta_nu, mu);
272  m_shift.backward(vt2, V_mu, nu);
273  if (nu == 3) set_wk.set_boundary_wkpr(vt2);
274  mult_Field_Gnd(vt3, 0, vt1, 0, vt2, 0);
275  multadd_Field_Gnd(Sigma_mu, 0, vt3, 0, V_nu, 0, 1.0);
276 
277  //- The 5th block
278  mult_Field_Gdd(vt2, 0, vt1, 0, V_mu, 0);
279  mult_Field_Gnn(vt3, 0, vt2, 0, V_nu, 0);
280  m_shift.forward(vt2, vt3, nu);
281  axpy(Sigma_mu, 1.0, vt2); // Sigma_mu += vt2;
282 
283  //- The 6th block
284  m_shift.backward(vt1, V_nu, mu);
285  if (mu == 3) set_wk.set_boundary_wkpr(vt1);
286  m_shift.backward(vt2, iTheta_mu, nu);
287  mult_Field_Gnd(vt3, 0, vt1, 0, vt2, 0);
288  multadd_Field_Gnd(Sigma_mu, 0, vt3, 0, V_nu, 0, 1.0);
289 }
290 
291 
292 //====================================================================
294  const Field_G& u_mu, const Field_G& u_nu,
295  const int mu, const int nu)
296 {
297  //- upper direction
298  Field_G v1;
299 
300  m_shift.backward(v1, u_mu, nu);
301  if (nu == 3) set_wk.set_boundary_wkpr(v1);
302 
303  Field_G v2;
304  mult_Field_Gnn(v2, 0, u_nu, 0, v1, 0);
305 
306  m_shift.backward(v1, u_nu, mu);
307  if (mu == 3) set_wk.set_boundary_wkpr(v1);
308 
309  mult_Field_Gnd(c, 0, v2, 0, v1, 0);
310 
311  //- lower direction
312  m_shift.backward(v2, u_nu, mu);
313  if (mu == 3) set_wk.set_boundary_wkpr(v2);
314 
315  mult_Field_Gnn(v1, 0, u_mu, 0, v2, 0);
316  mult_Field_Gdn(v2, 0, u_nu, 0, v1, 0);
317  m_shift.forward(v1, v2, nu);
318  c.addpart_ex(0, v1, 0);
319 }
320 
321 
322 //====================================================================
323 //============================================================END=====
Bridge::VerboseLevel m_vl
Definition: forceSmear.h:56
BridgeIO vout
Definition: bridgeIO.cpp:503
void force_each(Field_G &, const Field_G &, const Field_G &, const Field_G &, const Field_G &, const int mu, const int nu)
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
void force_udiv(Field_G &Sigma, const Field_G &Sigma_p, const Field_G &U)
void general(const char *format,...)
Definition: bridgeIO.cpp:197
static const std::string class_name
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 set_parameters(const Parameters &params)
double rho(const int mu, const int nu)
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
int nvol() const
Definition: field.h:127
void mult_Field_Gdn(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
std::vector< Field_G > m_iTheta
virtual void force_recursive(Field_G &Xi, Field_G &iTheta, const double alpha, const Field_G &Sigmap, const Field_G &C, const Field_G &U)=0
determination of fields for force calculation
Class for parameters.
Definition: parameters.h:46
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:204
int nin() const
Definition: field.h:126
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:102
SU(N) gauge field.
Definition: field_G.h:38
void set_parameters(const std::vector< double > &phi, const std::vector< double > &phipr)
Set the parameter by giving vector objects.
Definition: field_G_SF.cpp:245
double m_phi[3]
SF boundary condition at t=0.
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 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
ShiftField_lex m_shift
void backward(Field &, const Field &, const int mu)
int nex() const
Definition: field.h:128
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 staple(Field_G &, const Field_G &, const Field_G &, const int mu, const int nu)
std::vector< Field_G > m_U
double m_phipr[3]
SF boundary condition at t=Nt.
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)