Bridge++  Version 1.4.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
force_F_CloverTerm.cpp
Go to the documentation of this file.
1 
14 #include "force_F_CloverTerm.h"
15 
16 
17 const std::string Force_F_CloverTerm::class_name = "Force_F_CloverTerm";
18 
19 //====================================================================
21 {
22  const string str_vlevel = params.get_string("verbose_level");
23 
24  m_vl = vout.set_verbose_level(str_vlevel);
25 
26  //- fetch and check input parameters
27  double kappa, cSW;
28  std::vector<int> bc;
29 
30  int err = 0;
31  err += params.fetch_double("hopping_parameter", kappa);
32  err += params.fetch_double("clover_coefficient", cSW);
33  err += params.fetch_int_vector("boundary_condition", bc);
34 
35  if (err) {
36  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
37  exit(EXIT_FAILURE);
38  }
39 
40 
41  set_parameters(kappa, cSW, bc);
42 }
43 
44 
45 //====================================================================
46 void Force_F_CloverTerm::set_parameters(double kappa, double cSW, const std::vector<int> bc)
47 {
48  int Ndim = CommonParameters::Ndim();
49 
50  //- print input parameters
51  vout.general(m_vl, "%s:\n", class_name.c_str());
52  vout.general(m_vl, " kappa = %12.8f\n", kappa);
53  vout.general(m_vl, " cSW = %12.8f\n", cSW);
54  for (int mu = 0; mu < Ndim; ++mu) {
55  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
56  }
57 
58  //- range check
59  // NB. kappa,cSW == 0 is allowed.
60  assert(bc.size() == Ndim);
61 
62  //- store values
63  m_kappa = kappa;
64  m_cSW = cSW;
65 
66  m_boundary.resize(Ndim);
67  for (int mu = 0; mu < Ndim; ++mu) {
68  m_boundary[mu] = bc[mu];
69  }
70 }
71 
72 
73 //====================================================================
74 void Force_F_CloverTerm::init(std::string repr)
75 {
76  m_repr = repr;
77 
79  int Nvol = CommonParameters::Nvol();
80 
82  m_Cud = new Field_G(Nvol, m_Ndim * m_Ndim);
83 
85 }
86 
87 
88 //====================================================================
90 {
91  delete m_Cud;
92  delete m_fopr_csw;
93 }
94 
95 
96 // override default force_core()
97 //====================================================================
98 void Force_F_CloverTerm::force_core(Field& force, const Field& eta)
99 {
100  vout.crucial(m_vl, "Error at %s: force_core() is not available.\n", class_name.c_str());
101  exit(EXIT_FAILURE);
102 }
103 
104 
105 //====================================================================
107 {
108  vout.crucial(m_vl, "Error at %s: force_udiv() is not available.\n", class_name.c_str());
109  exit(EXIT_FAILURE);
110 }
111 
112 
113 //====================================================================
114 void Force_F_CloverTerm::force_udiv1(Field& force_, const Field& zeta_, const Field& eta_)
115 {
116  int Nvol = CommonParameters::Nvol();
117  int Ndim = CommonParameters::Ndim();
118 
119  Field_G force(Nvol, Ndim);
120  Field_F zeta(zeta_);
121  Field_F eta(eta_);
122 
123  force_udiv1_impl(force, zeta, eta);
124 
125  copy(force_, force); // force_ = force;
126 }
127 
128 
129 //====================================================================
130 void Force_F_CloverTerm::force_udiv1_impl(Field_G& force, const Field_F& zeta, const Field_F& eta)
131 {
132  int Nc = CommonParameters::Nc();
133  int Nd = CommonParameters::Nd();
134  int Nvol = CommonParameters::Nvol();
135  int Ndim = CommonParameters::Ndim();
136 
138 
139  Field_G force1(Nvol, 1), force2(Nvol, 1);
140  Field_G Umu(Nvol, 1), Unu(Nvol, 1), Utmp(Nvol, 1), Utmp2(Nvol, 1);
141  Field_F vt1(Nvol, 1), vt2(Nvol, 1), vt3(Nvol, 1), vt4(Nvol, 1);
142  Field_F zeta_mu(Nvol, 1);
143 
144  Mat_SU_N ut(Nc);
145  Vec_SU_N vec1(Nc), vec2(Nc);
146 
147  Field_F eta2(Nvol, 1), eta3(Nvol, 1);
148 
149  force.set(0.0);
150 
151  m_fopr_csw->mult_gm5(eta2, eta);
152 
153  for (int mu = 0; mu < Ndim; ++mu) {
154  for (int nu = 0; nu < Ndim; ++nu) {
155  if (nu == mu) continue;
156 
157  m_fopr_csw->mult_isigma(eta3, eta2, mu, nu);
158 
159  Umu.setpart_ex(0, *m_U, mu);
160  Unu.setpart_ex(0, *m_U, nu);
161 
162  int ex = 0;
163 
164  // R(1) and R(5)
165  mult_Field_Gd(vt1, 0, *m_Cud, index_dir(mu, nu), eta3, ex);
166  tensorProd_Field_F(force1, zeta, vt1);
167  copy(force2, force1); // force2 = force1;
168 
169  // R(2)
170  mult_Field_Gd(vt3, 0, Umu, 0, eta3, ex);
171  shift.backward(vt1, vt3, nu);
172  shift.backward(vt2, zeta, nu);
173  shift.backward(Utmp, Unu, mu);
174  mult_Field_Gn(vt3, 0, Utmp, 0, vt1, ex);
175  mult_Field_Gn(vt4, 0, Unu, 0, vt2, ex);
176  tensorProd_Field_F(force1, vt4, vt3);
177  axpy(force2, 1.0, force1); // force2 += force1;
178 
179  // R(4) and R(8)
180  shift.backward(vt1, eta3, mu);
181  shift.backward(zeta_mu, zeta, mu);
182  mult_Field_Gn(vt4, 0, *m_Cud, index_dir(mu, nu), zeta_mu, ex);
183  tensorProd_Field_F(force1, vt4, vt1);
184  axpy(force2, 1.0, force1); // force2 += force1;
185 
186  // R(3)
187  shift.backward(vt1, eta3, nu);
188  mult_Field_Gn(vt3, 0, Unu, 0, vt1, ex);
189  mult_Field_Gn(vt4, 0, Umu, 0, zeta_mu, ex);
190  shift.backward(vt1, vt3, mu);
191  shift.backward(vt2, vt4, nu);
192  mult_Field_Gn(vt4, 0, Unu, 0, vt2, ex);
193  tensorProd_Field_F(force1, vt4, vt1);
194  axpy(force2, 1.0, force1); // force2 += force1;
195 
196  // R(6)
197  shift.backward(Utmp, Unu, mu);
198  mult_Field_Gdd(Utmp2, 0, Utmp, 0, Umu, 0);
199  mult_Field_Gn(vt1, 0, Utmp2, 0, eta3, ex);
200  mult_Field_Gd(vt2, 0, Unu, 0, zeta, ex);
201  shift.forward(vt3, vt1, nu);
202  shift.forward(vt4, vt2, nu);
203  tensorProd_Field_F(force1, vt4, vt3);
204  axpy(force2, -1.0, force1); // force2 -= force1;
205 
206  // R(7)
207  mult_Field_Gd(vt1, 0, Unu, 0, eta3, ex);
208  mult_Field_Gn(vt2, 0, Umu, 0, zeta_mu, ex);
209  shift.backward(vt3, vt1, mu);
210  shift.forward(vt1, vt3, nu);
211  mult_Field_Gd(vt4, 0, Unu, 0, vt2, ex);
212  shift.forward(vt2, vt4, nu);
213  tensorProd_Field_F(force1, vt2, vt1);
214  axpy(force2, -1.0, force1); // force2 -= force1;
215 
216  scal(force2, -m_kappa * m_cSW / 8.0); // force2 *= -m_kappa * m_cSW / 8.0;
217  force.addpart_ex(mu, force2, 0);
218  }
219  }
220 }
221 
222 
223 //====================================================================
225 {
226  int Nc = CommonParameters::Nc();
227  int Nd = CommonParameters::Nd();
228  int Nvol = CommonParameters::Nvol();
229 
230  Field_G Cmu_ud1(Nvol, 1);
231  Field_G Cmu_ud2(Nvol, 1);
232  Staple_lex staple;
233 
234  for (int mu = 0; mu < m_Ndim; ++mu) {
235  for (int nu = 0; nu < m_Ndim; ++nu) {
236  if (nu == mu) continue;
237 
238  staple.upper(Cmu_ud1, *m_U, mu, nu);
239  staple.lower(Cmu_ud2, *m_U, mu, nu);
240  axpy(Cmu_ud1, -1.0, Cmu_ud2);
241  m_Cud->setpart_ex(index_dir(mu, nu), Cmu_ud1, 0);
242  }
243  }
244 }
245 
246 
247 //====================================================================
248 //============================================================END=====
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:495
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:164
void general(const char *format,...)
Definition: bridgeIO.cpp:195
Bridge::VerboseLevel m_vl
Definition: force_F.h:72
int shift(void)
Org::Fopr_CloverTerm Fopr_CloverTerm
Clover term operator.
Container of Field-type object.
Definition: field.h:39
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:211
Field_G * m_U
Definition: force_F.h:70
void force_udiv1(Field &force, const Field &zeta, const Field &eta)
For recursive calculation of smeared force.
void mult_gm5(Field &v, const Field &w)
gamma_5 multiplication. [31 Mar 2017 H.Matsufuru]
Class for parameters.
Definition: parameters.h:46
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:381
void lower(Field_G &, const Field_G &, const int mu, const int nu)
constructs lower staple in mu-nu plane.
Definition: staple_lex.cpp:180
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:193
Wilson-type fermion field.
Definition: field_F.h:37
int index_dir(int mu, int nu)
double m_kappa
hopping parameter
Staple construction.
Definition: staple_lex.h:39
SU(N) gauge field.
Definition: field_G.h:38
std::vector< int > m_boundary
boundary conditions
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 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 upper(Field_G &, const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane.
Definition: staple_lex.cpp:156
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:178
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:32
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.
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:186
string get_string(const string &key) const
Definition: parameters.cpp:116
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:294
Field_G * m_Cud
for force calculation
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
void forward(Field &, const Field &, const int mu)
void init(std::string)
static const std::string class_name