Bridge++  Ver. 1.3.x
force_F_Clover_SF.cpp
Go to the documentation of this file.
1 
14 #include "force_F_Clover_SF.h"
15 
16 #ifdef USE_PARAMETERS_FACTORY
17 #include "parameters_factory.h"
18 #endif
19 
20 
21 //- parameter entries
22 namespace {
23  void append_entry(Parameters& param)
24  {
25  param.Register_double("hopping_parameter", 0.0);
26  param.Register_double("clover_coefficient", 0.0);
27  param.Register_int_vector("boundary_condition", std::vector<int>());
28  param.Register_double_vector("phi", std::vector<double>());
29  param.Register_double_vector("phipr", std::vector<double>());
30 
31  param.Register_string("verbose_level", "NULL");
32  }
33 
34 
35 #ifdef USE_PARAMETERS_FACTORY
36  bool init_param = ParametersFactory::Register("Force.F_Clover_SF", append_entry);
37 #endif
38 }
39 //- end
40 
41 //- parameters class
43 //- end
44 
45 const std::string Force_F_Clover_SF::class_name = "Force_F_Clover_SF";
46 
47 //====================================================================
49 {
50  const string str_vlevel = params.get_string("verbose_level");
51 
52  m_vl = vout.set_verbose_level(str_vlevel);
53 
54  //- fetch and check input parameters
55  double kappa, cSW;
56  std::vector<int> bc;
57  std::vector<double> phi, phipr;
58 
59  int err = 0;
60  err += params.fetch_double("hopping_parameter", kappa);
61  err += params.fetch_double("clover_coefficient", cSW);
62  err += params.fetch_int_vector("boundary_condition", bc);
63  err += params.fetch_double_vector("phi", phi);
64  err += params.fetch_double_vector("phipr", phipr);
65 
66  if (err) {
67  vout.crucial(m_vl, "%s: fetch error, input parameter not found.\n", class_name.c_str());
68  exit(EXIT_FAILURE);
69  }
70 
71 
72  set_parameters(kappa, cSW, bc, &phi[0], &phipr[0]);
73 }
74 
75 
76 //====================================================================
77 void Force_F_Clover_SF::set_parameters(double kappa, double cSW, const std::vector<int> bc,
78  double *phi, double *phipr)
79 {
80  int Ndim = CommonParameters::Ndim();
81 
82  //- print input parameters
83  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
84  vout.general(m_vl, " kappa = %8.4f\n", kappa);
85  vout.general(m_vl, " cSW = %8.4f\n", cSW);
86  for (int mu = 0; mu < Ndim; ++mu) {
87  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
88  }
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. kappa,cSW == 0 is allowed.
99  assert(bc.size() == Ndim);
100  // NB. phi,phipr == 0 is allowed.
101 
102  //- store values
103  m_kappa = kappa;
104  m_cSW = cSW;
105 
106  for (int i = 0; i < 3; ++i) {
107  m_phi[i] = phi[i];
108  m_phipr[i] = phipr[i];
109  }
110 
111  m_boundary.resize(Ndim);
112  for (int mu = 0; mu < Ndim; ++mu) {
113  m_boundary[mu] = bc[mu];
114  }
115 
116  //- propagate parameters
119 
121 }
122 
123 
124 //====================================================================
125 void Force_F_Clover_SF::force_udiv(Field& force_, const Field& eta_)
126 {
127  int Nc = CommonParameters::Nc();
128  int Nvol = CommonParameters::Nvol();
129  int Ndim = CommonParameters::Ndim();
130 
131  Field_G force(Nvol, Ndim);
132  Field_G force1(Nvol, Ndim);
133  Field_F zeta(Nvol, 1);
134  Field_F eta(eta_);
135 
136  m_fopr_c->set_mode("H");
137  m_fopr_c->mult(zeta, eta);
138 
139  force_udiv1_impl(force, eta, zeta);
140  force_udiv1_impl(force1, zeta, eta);
141  axpy(force, 1.0, force1); // force += force1;
142 
144 
145  copy(force_, force); // force_ = force;
146 }
147 
148 
149 //====================================================================
150 void Force_F_Clover_SF::force_udiv1(Field& force_, const Field& zeta_, const Field& eta_)
151 {
152  int Nc = CommonParameters::Nc();
153  int Nvol = CommonParameters::Nvol();
154  int Ndim = CommonParameters::Ndim();
155 
156  Field_G force(Nvol, Ndim);
157  Field_F zeta(zeta_);
158  Field_F eta(eta_);
159 
160  force_udiv1_impl(force, zeta, eta);
161 
162  copy(force_, force); // force_ = force;
163 }
164 
165 
166 //====================================================================
167 void Force_F_Clover_SF::force_udiv1_impl(Field_G& force, const Field_F& zeta, const Field_F& eta)
168 {
169  int Nc = CommonParameters::Nc();
170  int Nd = CommonParameters::Nd();
171  int Nvol = CommonParameters::Nvol();
172  int Ndim = CommonParameters::Ndim();
173 
175 
176  Field_G force1(Nvol, 1), force2(Nvol, 1);
177  Field_G Umu(Nvol, 1), Unu(Nvol, 1), Utmp(Nvol, 1), Utmp2(Nvol, 1);
178  Field_F vt1(Nvol, 1), vt2(Nvol, 1), vt3(Nvol, 1), vt4(Nvol, 1);
179  Field_F zeta_mu(Nvol, 1);
180 
181  Mat_SU_N ut(Nc);
182  Vec_SU_N vec1(Nc), vec2(Nc);
183 
184  Field_F zeta1(zeta);
185  Field_F eta2(Nvol, 1), eta3(Nvol, 1);
186 
187  force.set(0.0);
188 
190 
191  m_force_w->force_udiv1(force, zeta, eta);
192 
193  m_fopr_c->mult_gm5(eta2, eta);
195 
196  for (int mu = 0; mu < Ndim; ++mu) {
197  for (int nu = 0; nu < Ndim; ++nu) {
198  if (nu == mu) continue;
199 
200  m_fopr_c->mult_isigma(eta3, eta2, mu, nu);
201 
202  Umu.setpart_ex(0, *m_U, mu);
203  Unu.setpart_ex(0, *m_U, nu);
204  if (mu != 3) set_wk.set_boundary_wk(Umu);
205  if (nu != 3) set_wk.set_boundary_wk(Unu);
206 
207  int ex = 0;
208 
209  // R(1) and R(5)
210  mult_Field_Gd(vt1, 0, *m_Cud, index_dir(mu, nu), eta3, ex);
211  tensorProd_Field_F(force1, zeta1, vt1);
212  copy(force2, force1); // force2 = force1;
213 
214  // R(2)
215  mult_Field_Gd(vt3, 0, Umu, 0, eta3, ex);
216  shift.backward(vt1, vt3, nu);
217  shift.backward(vt2, zeta1, nu);
218  shift.backward(Utmp, Unu, mu);
219  if (mu == 3) set_wk.set_boundary_wkpr(Utmp);
220  mult_Field_Gn(vt3, 0, Utmp, 0, vt1, ex);
221  mult_Field_Gn(vt4, 0, Unu, 0, vt2, ex);
222  tensorProd_Field_F(force1, vt4, vt3);
223  axpy(force2, 1.0, force1); // force2 += force1;
224 
225  // R(4) and R(8)
226  shift.backward(vt1, eta3, mu);
227  shift.backward(zeta_mu, zeta1, mu);
228  mult_Field_Gn(vt4, 0, *m_Cud, index_dir(mu, nu), zeta_mu, ex);
229  tensorProd_Field_F(force1, vt4, vt1);
230  axpy(force2, 1.0, force1); // force2 += force1;
231 
232  // R(3)
233  shift.backward(vt1, eta3, nu);
234  mult_Field_Gn(vt3, 0, Unu, 0, vt1, ex);
235  mult_Field_Gn(vt4, 0, Umu, 0, zeta_mu, ex);
236  shift.backward(vt1, vt3, mu);
237  shift.backward(vt2, vt4, nu);
238  mult_Field_Gn(vt4, 0, Unu, 0, vt2, ex);
239  tensorProd_Field_F(force1, vt4, vt1);
240  axpy(force2, 1.0, force1); // force2 += force1;
241 
242  // R(6)
243  shift.backward(Utmp, Unu, mu);
244  if (mu == 3) set_wk.set_boundary_wkpr(Utmp);
245  mult_Field_Gdd(Utmp2, 0, Utmp, 0, Umu, 0);
246  mult_Field_Gn(vt1, 0, Utmp2, 0, eta3, ex);
247  mult_Field_Gd(vt2, 0, Unu, 0, zeta1, ex);
248  shift.forward(vt3, vt1, nu);
249  shift.forward(vt4, vt2, nu);
250  tensorProd_Field_F(force1, vt4, vt3);
251  axpy(force2, -1.0, force1); // force2 -= force1;
252 
253  // R(7)
254  mult_Field_Gd(vt1, 0, Unu, 0, eta3, ex);
255  mult_Field_Gn(vt2, 0, Umu, 0, zeta_mu, ex);
256  shift.backward(vt3, vt1, mu);
257  shift.forward(vt1, vt3, nu);
258  mult_Field_Gd(vt4, 0, Unu, 0, vt2, ex);
259  shift.forward(vt2, vt4, nu);
260  tensorProd_Field_F(force1, vt2, vt1);
261  axpy(force2, -1.0, force1); // force2 -= force1;
262 
263  scal(force2, -m_kappa * m_cSW / 8.0); // force2 *= -m_kappa * m_cSW / 8.0;
264  force.addpart_ex(mu, force2, 0);
265  }
266  }
267 }
268 
269 
270 //====================================================================
272 {
273  int Nc = CommonParameters::Nc();
274  int Nd = CommonParameters::Nd();
275  int Nvol = CommonParameters::Nvol();
276 
277  Field_G_SF Cmu_ud1(Nvol, 1);
278  Field_G_SF Cmu_ud2(Nvol, 1);
279 
280  Staples_SF staple;
281 
282  staple.set_parameters(m_phi, m_phipr);
283 
284  for (int mu = 0; mu < m_Ndim; ++mu) {
285  for (int nu = 0; nu < m_Ndim; ++nu) {
286  if (nu == mu) continue;
287 
288  staple.upper(Cmu_ud1, *m_U, mu, nu);
289  staple.lower(Cmu_ud2, *m_U, mu, nu);
290  axpy(Cmu_ud1, -1.0, Cmu_ud2);
291  m_Cud->setpart_ex(index_dir(mu, nu), Cmu_ud1, 0);
292  }
293  }
294 }
295 
296 
297 //====================================================================
298 //============================================================END=====
void Register_int_vector(const string &, const std::vector< int > &)
Definition: parameters.cpp:344
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:282
void mult_Field_Gd(Field_F &y, const int ex, const Field_G &u, int ex1, const Field_F &x, int ex2)
Definition: field_F_imp.cpp:83
double m_phi[3]
SF boundary condition at t=0.
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
std::vector< int > m_boundary
boundary conditions
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:155
void upper(Field_G_SF &, const Field_G &, const int, const int)
Definition: staples_SF.cpp:860
double m_cSW
clover coefficient
void set_parameters(const Parameters &params)
Definition: staples_SF.cpp:62
void force_udiv1_impl(Field_G &force, const Field_F &zeta, const Field_F &eta)
Core implemetation of clover force calculation.
Field_F_SF set_zero
In order to set the boundary field.
void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
void general(const char *format,...)
Definition: bridgeIO.cpp:65
Bridge::VerboseLevel m_vl
Definition: force.h:72
int shift(void)
Container of Field-type object.
Definition: field.h:39
Field_G * m_U
Definition: force.h:70
void force_udiv(Field &force, const Field &eta)
For recursive calculation of smeared force.
Class for parameters.
Definition: parameters.h:38
Fopr_Clover_SF * m_fopr_c
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:381
void force_udiv1(Field &force, const Field &zeta, const Field &eta)
For recursive calculation of smeared force.
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 mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
double m_phipr[3]
SF boundary condition at t=Nt.
Wilson-type fermion field.
Definition: field_F.h:37
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
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 backward(Field &, const Field &, const int mu)
void mult_gm5(Field &v, const Field &w)
static const std::string class_name
int index_dir(int mu, int nu)
void mult_Field_Gn(Field_F &y, const int ex, const Field_G &u, int ex1, const Field_F &x, int ex2)
Definition: field_F_imp.cpp:39
double m_kappa
hopping parameter
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
void set_parameters(const Parameters_Field_G_SF &params)
Set the parameter with Parameters_Field_G_SF class.
Definition: field_G_SF.cpp:268
void mult(Field &v, const Field &f)
multiplies fermion operator to a given field (2nd argument)
void tensorProd_Field_F(Field_G &u, const Field_F &v1, const Field_F &v2)
Definition: tensorProd.cpp:22
void set_parameters(const Parameters &params)
Field_G * m_Cud
for force calculation
static bool Register(const std::string &realm, const creator_callback &cb)
void set_boundary_zero(Field &f)
Definition: field_F_SF.h:56
void force_udiv1(Field &force, const Field &zeta, const Field &eta)
void Register_double_vector(const string &, const std::vector< double > &)
Definition: parameters.cpp:337
void set_parameters(const Parameters &params)
void lower(Field_G_SF &, const Field_G &, const int, const int)
Definition: staples_SF.cpp:903
int fetch_double_vector(const string &key, std::vector< double > &val) const
Definition: parameters.cpp:158
Force_F_Wilson_SF * m_force_w
void Register_double(const string &, const double)
Definition: parameters.cpp:323
Methods to shift a field in the lexical site index.
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
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:28
void set_parameters(const Parameters &params)
int fetch_int_vector(const string &key, std::vector< int > &val) const
Definition: parameters.cpp:176
void set_component()
Set building components for force calculation.
void forward(Field &, const Field &, const int mu)