Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
forceSmear_APE.cpp
Go to the documentation of this file.
1 
14 #include "forceSmear_APE.h"
15 
16 #ifdef USE_FACTORY_AUTOREGISTER
17 namespace {
18  bool init = ForceSmear_APE::register_factory();
19 }
20 #endif
21 
22 const std::string ForceSmear_APE::class_name = "ForceSmear_APE";
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 
34  int err = 0;
35  err += params.fetch_double("rho_uniform", rho1);
36 
37  if (err) {
38  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
39  exit(EXIT_FAILURE);
40  }
41 
42 
43  set_parameters(rho1);
44 }
45 
46 
47 //====================================================================
48 void ForceSmear_APE::set_parameters(const double rho1)
49 {
50  //- print input parameters
51  vout.general(m_vl, "%s:\n", class_name.c_str());
52  vout.general(m_vl, " rho = %8.4f\n", rho1);
53 
54  //- range check
55  // NB. rho == 0 is allowed.
56 
57  //- store values
58  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
59  for (int mu = 0; mu < m_Ndim; ++mu) {
60  for (int nu = 0; nu < m_Ndim; ++nu) {
61  m_rho[mu + nu * m_Ndim] = rho1;
62  }
63  }
64 }
65 
66 
67 //====================================================================
68 void ForceSmear_APE::set_parameters(const std::vector<double>& rho)
69 {
70  //- print input parameters
71  vout.general(m_vl, "%s:\n", class_name.c_str());
72  for (int mu = 0; mu < m_Ndim; ++mu) {
73  vout.general(m_vl, " rho[%d] = %8.4f\n", mu, rho[mu]);
74  }
75 
76  //- range check
77  // NB. rho == 0 is allowed.
78  assert(rho.size() == m_Ndim * m_Ndim);
79 
80  //- store values
81  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
82  for (int mu = 0; mu < m_Ndim; ++mu) {
83  for (int nu = 0; nu < m_Ndim; ++nu) {
84  m_rho[mu + nu * m_Ndim] = rho[mu + nu * m_Ndim];
85  }
86  }
87 }
88 
89 
90 //====================================================================
92 {
95 
96  m_rho.resize(m_Ndim * m_Ndim);
97  m_U.resize(m_Ndim);
98  m_iTheta.resize(m_Ndim);
99 
100  for (int mu = 0; mu < m_Ndim; ++mu) {
101  for (int nu = 0; nu < m_Ndim; ++nu) {
102  m_rho[mu + nu * m_Ndim] = 0.0;
103  }
104  }
105 }
106 
107 
108 //====================================================================
109 void ForceSmear_APE::force_udiv(Field_G& Sigma, const Field_G& Sigmap, const Field_G& U)
110 {
111  const int Nc = CommonParameters::Nc();
112  const int NinG = 2 * Nc * Nc;
113 
114  assert(Sigmap.nin() == NinG);
115  assert(Sigmap.nvol() == m_Nvol);
116  assert(Sigmap.nex() == m_Ndim);
117 
118  for (int mu = 0; mu < m_Ndim; ++mu) {
119  m_U[mu].setpart_ex(0, U, mu);
120  }
121 
122  for (int mu = 0; mu < m_Ndim; ++mu) {
123  Field_G C;
124  C.set(0.0);
125 
126  for (int nu = 0; nu < m_Ndim; ++nu) {
127  if (nu == mu) continue;
128  double rho = m_rho[mu + m_Ndim * nu];
129 
130  Field_G c_tmp;
131  staple(c_tmp, m_U[mu], m_U[nu], mu, nu);
132  C.addpart_ex(0, c_tmp, 0, rho);
133  }
134 
135  Field_G sigmap_tmp;
136  sigmap_tmp.setpart_ex(0, Sigmap, mu);
137 
138  double alpha = m_rho[mu + m_Ndim * mu];
139 
140  Field_G Xi;
142  alpha, sigmap_tmp, C, m_U[mu]);
143  Sigma.setpart_ex(mu, Xi, 0);
144  }
145 
146  for (int mu = 0; mu < m_Ndim; ++mu) {
147  for (int nu = 0; nu < m_Ndim; ++nu) {
148  if (nu == mu) continue;
149  double rho = m_rho[mu + m_Ndim * nu];
150 
151  Field_G sigma_tmp;
152  force_each(sigma_tmp, m_U[mu], m_U[nu],
153  m_iTheta[mu], m_iTheta[nu], mu, nu);
154  Sigma.addpart_ex(mu, sigma_tmp, 0, rho);
155  }
156  }
157 }
158 
159 
160 //====================================================================
162  const Field_G& V_mu, const Field_G& V_nu,
163  const Field_G& iTheta_mu,
164  const Field_G& iTheta_nu,
165  const int mu, const int nu)
166 {
167  Sigma_mu.set(0.0);
168 
169  Field_G vt1;
170  m_shift.backward(vt1, V_nu, mu);
171 
172  Field_G vt2;
173  m_shift.backward(vt2, V_mu, nu);
174 
175  Field_G vt3;
176  mult_Field_Gnd(vt3, 0, vt1, 0, vt2, 0);
177  multadd_Field_Gnd(Sigma_mu, 0, vt3, 0, iTheta_nu, 0, 1.0);
178 
179  mult_Field_Gdn(vt3, 0, iTheta_mu, 0, V_nu, 0);
180  mult_Field_Gdn(vt2, 0, vt1, 0, vt3, 0);
181  m_shift.forward(vt3, vt2, nu);
182  axpy(Sigma_mu, 1.0, vt3); // Sigma_mu += vt3;
183 
184  mult_Field_Gdn(vt3, 0, V_mu, 0, iTheta_nu, 0);
185  mult_Field_Gdn(vt2, 0, vt1, 0, vt3, 0);
186  m_shift.forward(vt3, vt2, nu);
187  axpy(Sigma_mu, 1.0, vt3); // Sigma_mu += vt3;
188 
189  m_shift.backward(vt1, iTheta_nu, mu);
190  m_shift.backward(vt2, V_mu, nu);
191  mult_Field_Gnd(vt3, 0, vt1, 0, vt2, 0);
192  multadd_Field_Gnd(Sigma_mu, 0, vt3, 0, V_nu, 0, 1.0);
193 
194  mult_Field_Gdd(vt2, 0, vt1, 0, V_mu, 0);
195  mult_Field_Gnn(vt3, 0, vt2, 0, V_nu, 0);
196  m_shift.forward(vt2, vt3, nu);
197  axpy(Sigma_mu, 1.0, vt2); // Sigma_mu += vt2;
198 
199  m_shift.backward(vt1, V_nu, mu);
200  m_shift.backward(vt2, iTheta_mu, nu);
201  mult_Field_Gnd(vt3, 0, vt1, 0, vt2, 0);
202  multadd_Field_Gnd(Sigma_mu, 0, vt3, 0, V_nu, 0, 1.0);
203 }
204 
205 
206 //====================================================================
208  const Field_G& u_mu, const Field_G& u_nu,
209  const int mu, const int nu)
210 {
211  //- upper direction
212  Field_G v1;
213 
214  m_shift.backward(v1, u_mu, nu);
215 
216  Field_G v2;
217  mult_Field_Gnn(v2, 0, u_nu, 0, v1, 0);
218 
219  m_shift.backward(v1, u_nu, mu);
220  mult_Field_Gnd(c, 0, v2, 0, v1, 0);
221 
222  //- lower direction
223  m_shift.backward(v2, u_nu, mu);
224  mult_Field_Gnn(v1, 0, u_mu, 0, v2, 0);
225  mult_Field_Gdn(v2, 0, u_nu, 0, v1, 0);
226  m_shift.forward(v1, v2, nu);
227  c.addpart_ex(0, v1, 0);
228 }
229 
230 
231 //====================================================================
232 //============================================================END=====
Bridge::VerboseLevel m_vl
Definition: forceSmear.h:56
BridgeIO vout
Definition: bridgeIO.cpp:503
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
void general(const char *format,...)
Definition: bridgeIO.cpp:197
std::vector< Field_G > m_iTheta
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)
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)
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
void force_each(Field_G &, const Field_G &, const Field_G &, const Field_G &, const Field_G &, const int mu, const int nu)
double rho(const int mu, const int nu)
SU(N) gauge field.
Definition: field_G.h:38
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_parameters(const Parameters &params)
void backward(Field &, const Field &, const int mu)
int nex() const
Definition: field.h:128
void staple(Field_G &, const Field_G &, const Field_G &, const int mu, const int nu)
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 force_udiv(Field_G &Sigma, const Field_G &Sigma_p, const Field_G &U)
ShiftField_lex m_shift
std::vector< Field_G > m_U
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
std::vector< double > m_rho
static const std::string class_name
Projection * m_proj
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)