Bridge++  Ver. 1.3.x
force_F_CloverTerm.cpp
Go to the documentation of this file.
1 
14 #include "force_F_CloverTerm.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 
29  param.Register_string("verbose_level", "NULL");
30  }
31 
32 
33 #ifdef USE_PARAMETERS_FACTORY
34  bool init_param = ParametersFactory::Register("Force.F_CloverTerm", append_entry);
35 #endif
36 }
37 //- end
38 
39 //- parameters class
41 //- end
42 
43 const std::string Force_F_CloverTerm::class_name = "Force_F_CloverTerm";
44 
45 //====================================================================
47 {
48  const string str_vlevel = params.get_string("verbose_level");
49 
50  m_vl = vout.set_verbose_level(str_vlevel);
51 
52  //- fetch and check input parameters
53  double kappa, cSW;
54  std::vector<int> bc;
55 
56  int err = 0;
57  err += params.fetch_double("hopping_parameter", kappa);
58  err += params.fetch_double("clover_coefficient", cSW);
59  err += params.fetch_int_vector("boundary_condition", bc);
60 
61  if (err) {
62  vout.crucial(m_vl, "%s: fetch error, input parameter not found.\n", class_name.c_str());
63  exit(EXIT_FAILURE);
64  }
65 
66 
67  set_parameters(kappa, cSW, bc);
68 }
69 
70 
71 //====================================================================
72 void Force_F_CloverTerm::set_parameters(double kappa, double cSW, const std::vector<int> bc)
73 {
74  int Ndim = CommonParameters::Ndim();
75 
76  //- print input parameters
77  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
78  vout.general(m_vl, " kappa = %8.4f\n", kappa);
79  vout.general(m_vl, " cSW = %8.4f\n", cSW);
80  for (int mu = 0; mu < Ndim; ++mu) {
81  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
82  }
83 
84  //- range check
85  // NB. kappa,cSW == 0 is allowed.
86  assert(bc.size() == Ndim);
87 
88  //- store values
89  m_kappa = kappa;
90  m_cSW = cSW;
91 
92  m_boundary.resize(Ndim);
93  for (int mu = 0; mu < Ndim; ++mu) {
94  m_boundary[mu] = bc[mu];
95  }
96 }
97 
98 
99 //====================================================================
100 void Force_F_CloverTerm::init(std::string repr)
101 {
102  m_repr = repr;
103 
105  int Nvol = CommonParameters::Nvol();
106 
108  m_Cud = new Field_G(Nvol, m_Ndim * m_Ndim);
109 
111 }
112 
113 
114 //====================================================================
116 {
117  delete m_Cud;
118  delete m_fopr_csw;
119 }
120 
121 
122 // override default force_core()
123 //====================================================================
125 {
126  vout.crucial(m_vl, "%s: force_core() is not available.\n", class_name.c_str());
127  exit(EXIT_FAILURE);
128 }
129 
130 
131 //====================================================================
133 {
134  vout.crucial(m_vl, "%s: force_udiv() is not available.\n", class_name.c_str());
135  exit(EXIT_FAILURE);
136 }
137 
138 
139 //====================================================================
140 void Force_F_CloverTerm::force_udiv1(Field& force_, const Field& zeta_, const Field& eta_)
141 {
142  int Nvol = CommonParameters::Nvol();
143  int Ndim = CommonParameters::Ndim();
144 
145  Field_G force(Nvol, Ndim);
146  Field_F zeta(zeta_);
147  Field_F eta(eta_);
148 
149  force_udiv1_impl(force, zeta, eta);
150 
151  copy(force_, force); // force_ = force;
152 }
153 
154 
155 //====================================================================
156 void Force_F_CloverTerm::force_udiv1_impl(Field_G& force, const Field_F& zeta, const Field_F& eta)
157 {
158  int Nc = CommonParameters::Nc();
159  int Nd = CommonParameters::Nd();
160  int Nvol = CommonParameters::Nvol();
161  int Ndim = CommonParameters::Ndim();
162 
164 
165  Field_G force1(Nvol, 1), force2(Nvol, 1);
166  Field_G Umu(Nvol, 1), Unu(Nvol, 1), Utmp(Nvol, 1), Utmp2(Nvol, 1);
167  Field_F vt1(Nvol, 1), vt2(Nvol, 1), vt3(Nvol, 1), vt4(Nvol, 1);
168  Field_F zeta_mu(Nvol, 1);
169 
170  Mat_SU_N ut(Nc);
171  Vec_SU_N vec1(Nc), vec2(Nc);
172 
173  Field_F eta2(Nvol, 1), eta3(Nvol, 1);
174 
175  force.set(0.0);
176 
177  m_fopr_csw->mult_gm5(eta2, eta);
178 
179  for (int mu = 0; mu < Ndim; ++mu) {
180  for (int nu = 0; nu < Ndim; ++nu) {
181  if (nu == mu) continue;
182 
183  m_fopr_csw->mult_isigma(eta3, eta2, mu, nu);
184 
185  Umu.setpart_ex(0, *m_U, mu);
186  Unu.setpart_ex(0, *m_U, nu);
187 
188  int ex = 0;
189 
190  // R(1) and R(5)
191  mult_Field_Gd(vt1, 0, *m_Cud, index_dir(mu, nu), eta3, ex);
192  tensorProd_Field_F(force1, zeta, vt1);
193  copy(force2, force1); // force2 = force1;
194 
195  // R(2)
196  mult_Field_Gd(vt3, 0, Umu, 0, eta3, ex);
197  shift.backward(vt1, vt3, nu);
198  shift.backward(vt2, zeta, nu);
199  shift.backward(Utmp, Unu, mu);
200  mult_Field_Gn(vt3, 0, Utmp, 0, vt1, ex);
201  mult_Field_Gn(vt4, 0, Unu, 0, vt2, ex);
202  tensorProd_Field_F(force1, vt4, vt3);
203  axpy(force2, 1.0, force1); // force2 += force1;
204 
205  // R(4) and R(8)
206  shift.backward(vt1, eta3, mu);
207  shift.backward(zeta_mu, zeta, mu);
208  mult_Field_Gn(vt4, 0, *m_Cud, index_dir(mu, nu), zeta_mu, ex);
209  tensorProd_Field_F(force1, vt4, vt1);
210  axpy(force2, 1.0, force1); // force2 += force1;
211 
212  // R(3)
213  shift.backward(vt1, eta3, nu);
214  mult_Field_Gn(vt3, 0, Unu, 0, vt1, ex);
215  mult_Field_Gn(vt4, 0, Umu, 0, zeta_mu, ex);
216  shift.backward(vt1, vt3, mu);
217  shift.backward(vt2, vt4, nu);
218  mult_Field_Gn(vt4, 0, Unu, 0, vt2, ex);
219  tensorProd_Field_F(force1, vt4, vt1);
220  axpy(force2, 1.0, force1); // force2 += force1;
221 
222  // R(6)
223  shift.backward(Utmp, Unu, mu);
224  mult_Field_Gdd(Utmp2, 0, Utmp, 0, Umu, 0);
225  mult_Field_Gn(vt1, 0, Utmp2, 0, eta3, ex);
226  mult_Field_Gd(vt2, 0, Unu, 0, zeta, ex);
227  shift.forward(vt3, vt1, nu);
228  shift.forward(vt4, vt2, nu);
229  tensorProd_Field_F(force1, vt4, vt3);
230  axpy(force2, -1.0, force1); // force2 -= force1;
231 
232  // R(7)
233  mult_Field_Gd(vt1, 0, Unu, 0, eta3, ex);
234  mult_Field_Gn(vt2, 0, Umu, 0, zeta_mu, ex);
235  shift.backward(vt3, vt1, mu);
236  shift.forward(vt1, vt3, nu);
237  mult_Field_Gd(vt4, 0, Unu, 0, vt2, ex);
238  shift.forward(vt2, vt4, nu);
239  tensorProd_Field_F(force1, vt2, vt1);
240  axpy(force2, -1.0, force1); // force2 -= force1;
241 
242  scal(force2, -m_kappa * m_cSW / 8.0); // force2 *= -m_kappa * m_cSW / 8.0;
243  force.addpart_ex(mu, force2, 0);
244  }
245  }
246 }
247 
248 
249 //====================================================================
251 {
252  int Nc = CommonParameters::Nc();
253  int Nd = CommonParameters::Nd();
254  int Nvol = CommonParameters::Nvol();
255 
256  Field_G Cmu_ud1(Nvol, 1);
257  Field_G Cmu_ud2(Nvol, 1);
258  Staples staple;
259 
260  for (int mu = 0; mu < m_Ndim; ++mu) {
261  for (int nu = 0; nu < m_Ndim; ++nu) {
262  if (nu == mu) continue;
263 
264  staple.upper(Cmu_ud1, *m_U, mu, nu);
265  staple.lower(Cmu_ud2, *m_U, mu, nu);
266  axpy(Cmu_ud1, -1.0, Cmu_ud2);
267  m_Cud->setpart_ex(index_dir(mu, nu), Cmu_ud1, 0);
268  }
269  }
270 }
271 
272 
273 //====================================================================
274 //============================================================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
BridgeIO vout
Definition: bridgeIO.cpp:278
void Register_string(const string &, const string &)
Definition: parameters.cpp:351
Staple construction.
Definition: staples.h:40
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:155
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_udiv1(Field &force, const Field &zeta, const Field &eta)
For recursive calculation of smeared force.
Class for parameters.
Definition: parameters.h:38
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:381
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)
Wilson-type fermion field.
Definition: field_F.h:37
int index_dir(int mu, int nu)
double m_kappa
hopping parameter
SU(N) gauge field.
Definition: field_G.h:38
void mult_gm5(Field &v, const Field &w)
std::vector< int > m_boundary
boundary conditions
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
void force_core(Field &force, const Field &eta)
Force determination for clover fermion.
void set_parameters(const Parameters &params)
Setting parameters of clover fermion force.
void backward(Field &, const Field &, const int mu)
void force_udiv(Field &force, const Field &eta)
For recursive calculation of smeared force.
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
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:168
void set_component()
Set building components for force calculation.
int m_Ndim
spacetime dimension
void crucial(const char *format,...)
Definition: bridgeIO.cpp:48
std::string m_repr
gamma matrix representation
void tensorProd_Field_F(Field_G &u, const Field_F &v1, const Field_F &v2)
Definition: tensorProd.cpp:22
void lower(Field_G &, const Field_G &, const int mu, const int nu)
constructs lower staple in mu-nu plane.
Definition: staples.cpp:152
static bool Register(const std::string &realm, const creator_callback &cb)
Fopr_CloverTerm * m_fopr_csw
fermion operator
void force_udiv1_impl(Field_G &force, const Field_F &zeta, const Field_F &eta)
Core implemetation of clover force calculation.
void Register_double(const string &, const double)
Definition: parameters.cpp:323
Methods to shift a field in the lexical site index.
double m_cSW
clover coefficient
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
Field_G * m_Cud
for force calculation
void upper(Field_G &, const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane.
Definition: staples.cpp:128
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:28
int fetch_int_vector(const string &key, std::vector< int > &val) const
Definition: parameters.cpp:176
void forward(Field &, const Field &, const int mu)
void init(std::string)
static const std::string class_name