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