Bridge++  Ver. 2.0.2
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  std::string vlevel;
28  if (!params.fetch_string("verbose_level", vlevel)) {
29  m_vl = vout.set_verbose_level(vlevel);
30  }
31 
32  //- fetch and check input parameters
33  double rho1;
34  std::vector<double> phi, phipr;
35 
36  int err = 0;
37  err += params.fetch_double("rho_uniform", rho1);
38  err += params.fetch_double_vector("phi", phi);
39  err += params.fetch_double_vector("phipr", phipr);
40 
41  if (err) {
42  vout.crucial(m_vl, "Error at %s: input parameter not found.\n",
43  class_name.c_str());
44  exit(EXIT_FAILURE);
45  }
46 
47 
48  set_parameters(rho1, phi, phipr);
49 }
50 
51 
52 //====================================================================
54 {
55  params.set_double_vector("rho", m_rho);
56  params.set_double_vector("phi", m_phi);
57  params.set_double_vector("phipr", m_phipr);
58 
59  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
60 }
61 
62 
63 //====================================================================
64 void ForceSmear_APE_SF::set_parameters(const double rho1,
65  const std::vector<double>& phi,
66  const std::vector<double>& phipr)
67 {
68  //- print input parameters
69  vout.general(m_vl, "%s:\n", class_name.c_str());
70  vout.general(m_vl, " rho = %8.4f\n", rho1);
71 
72  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
73  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
74  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
75  vout.general(m_vl, " phipr1= %12.6f\n", phipr[0]);
76  vout.general(m_vl, " phipr2= %12.6f\n", phipr[1]);
77  vout.general(m_vl, " phipr3= %12.6f\n", phipr[2]);
78 
79  //- range check
80  // NB. rho == 0 is allowed.
81  // NB. phi,phipr == 0 is allowed.
82 
83  //- store values
84  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
85  for (int mu = 0; mu < m_Ndim; ++mu) {
86  for (int nu = 0; nu < m_Ndim; ++nu) {
87  m_rho[mu + nu * m_Ndim] = rho1;
88  }
89  }
90 
91  m_phi.resize(3);
92  m_phipr.resize(3);
93  for (int i = 0; i < 3; ++i) {
94  m_phi[i] = phi[i];
95  m_phipr[i] = phipr[i];
96  }
97 
98  //- propagate parameters
99  // set_wk.set_parameters(m_phi, m_phipr);
100 
101  const int Lx = CommonParameters::Lx();
102  double Lx_inv = 1.0 / double(Lx);
103  double c0r = cos(phi[0] * Lx_inv);
104  double c0i = sin(phi[0] * Lx_inv);
105  double c1r = cos(phi[1] * Lx_inv);
106  double c1i = sin(phi[1] * Lx_inv);
107  double c2r = cos(phi[2] * Lx_inv);
108  double c2i = sin(phi[2] * Lx_inv);
109  m_wk.zero();
110  m_wk.set(0, 0, c0r, c0i);
111  m_wk.set(1, 1, c1r, c1i);
112  m_wk.set(2, 2, c2r, c2i);
113 
114  c0r = cos(phipr[0] * Lx_inv);
115  c0i = sin(phipr[0] * Lx_inv);
116  c1r = cos(phipr[1] * Lx_inv);
117  c1i = sin(phipr[1] * Lx_inv);
118  c2r = cos(phipr[2] * Lx_inv);
119  c2i = sin(phipr[2] * Lx_inv);
120 
121  m_wkpr.zero();
122  m_wkpr.set(0, 0, c0r, c0i);
123  m_wkpr.set(1, 1, c1r, c1i);
124  m_wkpr.set(2, 2, c2r, c2i);
125 }
126 
127 
128 //====================================================================
129 void ForceSmear_APE_SF::set_parameters(const std::vector<double>& rho,
130  const std::vector<double>& phi,
131  const std::vector<double>& phipr)
132 {
133  //- print input parameters
134  vout.general(m_vl, "%s:\n", class_name.c_str());
135  for (int mu = 0; mu < m_Ndim; ++mu) {
136  vout.general(m_vl, " rho[%d] = %8.4f\n", mu, rho[mu]);
137  }
138 
139  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
140  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
141  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
142  vout.general(m_vl, " phipr1= %12.6f\n", phipr[0]);
143  vout.general(m_vl, " phipr2= %12.6f\n", phipr[1]);
144  vout.general(m_vl, " phipr3= %12.6f\n", phipr[2]);
145 
146  //- range check
147  // NB. rho == 0 is allowed.
148  // NB. phi,phipr == 0 is allowed.
149  assert(rho.size() == m_Ndim * m_Ndim);
150 
151  // store values
152  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
153  for (int mu = 0; mu < m_Ndim; ++mu) {
154  for (int nu = 0; nu < m_Ndim; ++nu) {
155  m_rho[mu + nu * m_Ndim] = rho[mu + nu * m_Ndim];
156  }
157  }
158 
159  m_phi.resize(3);
160  m_phipr.resize(3);
161  for (int i = 0; i < 3; ++i) {
162  m_phi[i] = phi[i];
163  m_phipr[i] = phipr[i];
164  }
165 
166  // propagate parameters
167  // set_wk.set_parameters(m_phi, m_phipr);
168 
169  const int Lx = CommonParameters::Lx();
170  double Lx_inv = 1.0 / double(Lx);
171  double c0r = cos(phi[0] * Lx_inv);
172  double c0i = sin(phi[0] * Lx_inv);
173  double c1r = cos(phi[1] * Lx_inv);
174  double c1i = sin(phi[1] * Lx_inv);
175  double c2r = cos(phi[2] * Lx_inv);
176  double c2i = sin(phi[2] * Lx_inv);
177  m_wk.zero();
178  m_wk.set(0, 0, c0r, c0i);
179  m_wk.set(1, 1, c1r, c1i);
180  m_wk.set(2, 2, c2r, c2i);
181 
182  c0r = cos(phipr[0] * Lx_inv);
183  c0i = sin(phipr[0] * Lx_inv);
184  c1r = cos(phipr[1] * Lx_inv);
185  c1i = sin(phipr[1] * Lx_inv);
186  c2r = cos(phipr[2] * Lx_inv);
187  c2i = sin(phipr[2] * Lx_inv);
188 
189  m_wkpr.zero();
190  m_wkpr.set(0, 0, c0r, c0i);
191  m_wkpr.set(1, 1, c1r, c1i);
192  m_wkpr.set(2, 2, c2r, c2i);
193 }
194 
195 
196 //====================================================================
198 {
201 
202  m_rho.resize(m_Ndim * m_Ndim);
203  m_U.resize(m_Ndim);
204  m_iTheta.resize(m_Ndim);
205 
206  for (int mu = 0; mu < m_Ndim; ++mu) {
207  for (int nu = 0; nu < m_Ndim; ++nu) {
208  m_rho[mu + nu * m_Ndim] = 0.0;
209  }
210  }
211 }
212 
213 
214 //====================================================================
215 
228 /*
229 Field ForceSmear_APE_SF::force_udiv(const Field_G& Sigmap, const Field_G& U)
230 {
231  Field_G Sigma(Sigmap.nvol(), Sigmap.nex());
232 
233  force_udiv(Sigma, Sigmap, U);
234 
235  return Sigma;
236 }
237 */
238 
239 //====================================================================
240 void ForceSmear_APE_SF::force_udiv(Field_G& Sigma, const Field_G& Sigmap, const Field_G& U)
241 {
242  const int Nc = CommonParameters::Nc();
243 
244  assert(Sigmap.nin() == (2 * Nc * Nc));
245  assert(Sigmap.nvol() == m_Nvol);
246  assert(Sigmap.nex() == m_Ndim);
247 
248  for (int mu = 0; mu < m_Ndim; ++mu) {
249  copy(m_U[mu], 0, U, mu);
250  if (mu != 3) Field_SF::set_boundary_wk(m_U[mu], m_wk);
251  }
252 
253  for (int mu = 0; mu < m_Ndim; ++mu) {
254  Field_G C;
255  C.set(0.0);
256 
257  for (int nu = 0; nu < m_Ndim; ++nu) {
258  if (nu == mu) continue;
259  double rho = m_rho[mu + m_Ndim * nu];
260 
261  Field_G c_tmp;
262  staple(c_tmp, m_U[mu], m_U[nu], mu, nu);
263  axpy(C, 0, rho, c_tmp, 0);
264  }
265 
266  Field_G sigmap_tmp;
267  copy(sigmap_tmp, 0, Sigmap, mu);
268 
269  double alpha = m_rho[mu + m_Ndim * mu];
270 
271  Field_G Xi;
273  alpha, sigmap_tmp, C, m_U[mu]);
274  copy(Sigma, mu, Xi, 0);
275  }
276 
277  for (int mu = 0; mu < m_Ndim; ++mu) {
278  for (int nu = 0; nu < m_Ndim; ++nu) {
279  if (nu == mu) continue;
280 
281  double rho = m_rho[mu + m_Ndim * nu];
282 
283  Field_G sigma_tmp;
284  force_each(sigma_tmp, m_U[mu], m_U[nu],
285  m_iTheta[mu], m_iTheta[nu], mu, nu);
286  axpy(Sigma, mu, rho, sigma_tmp, 0);
287  }
288  }
290 }
291 
292 
293 //====================================================================
294 
308  const Field_G& V_mu, const Field_G& V_nu,
309  const Field_G& iTheta_mu,
310  const Field_G& iTheta_nu,
311  const int mu, const int nu)
312 {
313  Sigma_mu.set(0.0);
314 
315  //- The 1st block
316  Field_G vt1;
317  m_shift.backward(vt1, V_nu, mu);
318  if (mu == 3) Field_SF::set_boundary_wkpr(vt1, m_wkpr);
319 
320  Field_G vt2;
321  m_shift.backward(vt2, V_mu, nu);
322  if (nu == 3) Field_SF::set_boundary_wkpr(vt2, m_wkpr);
323 
324  Field_G vt3;
325  mult_Field_Gnd(vt3, 0, vt1, 0, vt2, 0);
326  multadd_Field_Gnd(Sigma_mu, 0, vt3, 0, iTheta_nu, 0, 1.0);
327 
328  //- The 2nd block
329  mult_Field_Gdn(vt3, 0, iTheta_mu, 0, V_nu, 0);
330  mult_Field_Gdn(vt2, 0, vt1, 0, vt3, 0);
331  m_shift.forward(vt3, vt2, nu);
332  axpy(Sigma_mu, 1.0, vt3); // Sigma_mu += vt3;
333 
334  //- The 3rd block
335  mult_Field_Gdn(vt3, 0, V_mu, 0, iTheta_nu, 0);
336  mult_Field_Gdn(vt2, 0, vt1, 0, vt3, 0);
337  m_shift.forward(vt3, vt2, nu);
338  axpy(Sigma_mu, 1.0, vt3); // Sigma_mu += vt3;
339 
340  //- The 4th block
341  m_shift.backward(vt1, iTheta_nu, mu);
342  m_shift.backward(vt2, V_mu, nu);
343  if (nu == 3) Field_SF::set_boundary_wkpr(vt2, m_wkpr);
344  mult_Field_Gnd(vt3, 0, vt1, 0, vt2, 0);
345  multadd_Field_Gnd(Sigma_mu, 0, vt3, 0, V_nu, 0, 1.0);
346 
347  //- The 5th block
348  mult_Field_Gdd(vt2, 0, vt1, 0, V_mu, 0);
349  mult_Field_Gnn(vt3, 0, vt2, 0, V_nu, 0);
350  m_shift.forward(vt2, vt3, nu);
351  axpy(Sigma_mu, 1.0, vt2); // Sigma_mu += vt2;
352 
353  //- The 6th block
354  m_shift.backward(vt1, V_nu, mu);
355  if (mu == 3) Field_SF::set_boundary_wkpr(vt1, m_wkpr);
356  m_shift.backward(vt2, iTheta_mu, nu);
357  mult_Field_Gnd(vt3, 0, vt1, 0, vt2, 0);
358  multadd_Field_Gnd(Sigma_mu, 0, vt3, 0, V_nu, 0, 1.0);
359 }
360 
361 
362 //====================================================================
364  const Field_G& u_mu, const Field_G& u_nu,
365  const int mu, const int nu)
366 {
367  //- upper direction
368  Field_G v1;
369 
370  m_shift.backward(v1, u_mu, nu);
371  if (nu == 3) Field_SF::set_boundary_wkpr(v1, m_wkpr);
372 
373  Field_G v2;
374  mult_Field_Gnn(v2, 0, u_nu, 0, v1, 0);
375 
376  m_shift.backward(v1, u_nu, mu);
377  if (mu == 3) Field_SF::set_boundary_wkpr(v1, m_wkpr);
378 
379  mult_Field_Gnd(c, 0, v2, 0, v1, 0);
380 
381  //- lower direction
382  m_shift.backward(v2, u_nu, mu);
383  if (mu == 3) Field_SF::set_boundary_wkpr(v2, m_wkpr);
384 
385  mult_Field_Gnn(v1, 0, u_mu, 0, v2, 0);
386  mult_Field_Gdn(v2, 0, u_nu, 0, v1, 0);
387  m_shift.forward(v1, v2, nu);
388  axpy(c, 0, 1.0, v1, 0);
389 }
390 
391 
392 //============================================================END=====
Field_SF::set_boundary_wkpr
void set_boundary_wkpr(Field_G &u, const Mat_SU_N &wkpr)
Definition: field_SF.cpp:63
ForceSmear_APE_SF::m_U
std::vector< Field_G > m_U
Definition: forceSmear_APE_SF.h:51
mult_Field_Gdn
void mult_Field_Gdn(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
Definition: field_G_imp.cpp:134
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
ForceSmear_APE_SF::m_phi
std::vector< double > m_phi
SF boundary condition at t=0.
Definition: forceSmear_APE_SF.h:55
ShiftField_lex::forward
void forward(Field &, const Field &, const int mu)
Definition: shiftField_lex.cpp:79
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Field::set
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
Parameters
Class for parameters.
Definition: parameters.h:46
Field::nex
int nex() const
Definition: field.h:128
ForceSmear_APE_SF::m_wk
Mat_SU_N m_wk
SF boundary condition at t=0.
Definition: forceSmear_APE_SF.h:59
ForceSmear_APE_SF::force_udiv
void force_udiv(Field_G &Sigma, const Field_G &Sigma_p, const Field_G &U)
Definition: forceSmear_APE_SF.cpp:240
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Field_SF::set_boundary_wk
void set_boundary_wk(Field_G &u, const Mat_SU_N &wk)
Definition: field_SF.cpp:32
ForceSmear_APE_SF::get_parameters
void get_parameters(Parameters &params) const
Definition: forceSmear_APE_SF.cpp:53
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
ForceSmear_APE_SF::set_parameters
void set_parameters(const Parameters &params)
Definition: forceSmear_APE_SF.cpp:25
Parameters::set_double_vector
void set_double_vector(const string &key, const vector< double > &value)
Definition: parameters.cpp:42
ForceSmear_APE_SF::rho
double rho(const int mu, const int nu)
Definition: forceSmear_APE_SF.h:103
Field::nin
int nin() const
Definition: field.h:126
ForceSmear_APE_SF::m_rho
std::vector< double > m_rho
Definition: forceSmear_APE_SF.h:48
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
SU_N::Mat_SU_N::set
void set(int c, const double &re, const double &im)
Definition: mat_SU_N.h:137
ForceSmear_APE_SF::m_shift
ShiftField_lex m_shift
Definition: forceSmear_APE_SF.h:50
ForceSmear_APE_SF::m_Nvol
int m_Nvol
Definition: forceSmear_APE_SF.h:47
CommonParameters::Lx
static int Lx()
Definition: commonParameters.h:91
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
ForceSmear_APE_SF::class_name
static const std::string class_name
Definition: forceSmear_APE_SF.h:42
SU_N::Mat_SU_N::zero
Mat_SU_N & zero()
Definition: mat_SU_N.h:429
ForceSmear_APE_SF::m_iTheta
std::vector< Field_G > m_iTheta
Definition: forceSmear_APE_SF.h:52
ForceSmear_APE_SF::m_wkpr
Mat_SU_N m_wkpr
SF boundary condition at t=Nt.
Definition: forceSmear_APE_SF.h:60
ForceSmear_APE_SF::m_proj
Projection * m_proj
Definition: forceSmear_APE_SF.h:49
Field::nvol
int nvol() const
Definition: field.h:127
multadd_Field_Gnd
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)
Definition: field_G_imp.cpp:335
Field_SF::set_boundary_spatial_link_zero
void set_boundary_spatial_link_zero(Field_G &u)
Definition: field_SF.cpp:151
ForceSmear_APE_SF::m_Ndim
int m_Ndim
Definition: forceSmear_APE_SF.h:47
Projection::force_recursive
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
forceSmear_APE_SF.h
ForceSmear_APE_SF::m_phipr
std::vector< double > m_phipr
SF boundary condition at t=Nt.
Definition: forceSmear_APE_SF.h:57
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
mult_Field_Gnn
void mult_Field_Gnn(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
Definition: field_G_imp.cpp:95
ShiftField_lex::backward
void backward(Field &, const Field &, const int mu)
Definition: shiftField_lex.cpp:59
ForceSmear_APE_SF::m_vl
Bridge::VerboseLevel m_vl
Definition: forceSmear_APE_SF.h:45
mult_Field_Gdd
void mult_Field_Gdd(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
Definition: field_G_imp.cpp:212
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Parameters::fetch_double
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Parameters::fetch_double_vector
int fetch_double_vector(const string &key, vector< double > &value) const
Definition: parameters.cpp:410
ForceSmear_APE_SF::init
void init()
Definition: forceSmear_APE_SF.cpp:197
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
mult_Field_Gnd
void mult_Field_Gnd(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
Definition: field_G_imp.cpp:173
ForceSmear_APE_SF::force_each
void force_each(Field_G &, const Field_G &, const Field_G &, const Field_G &, const Field_G &, const int mu, const int nu)
Definition: forceSmear_APE_SF.cpp:307
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
ForceSmear_APE_SF::staple
void staple(Field_G &, const Field_G &, const Field_G &, const int mu, const int nu)
Definition: forceSmear_APE_SF.cpp:363
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:154