Bridge++  Ver. 2.0.2
force_F_Clover_SF.cpp
Go to the documentation of this file.
1 
14 #include "force_F_Clover_SF.h"
15 
16 const std::string Force_F_Clover_SF::class_name = "Force_F_Clover_SF";
17 
18 //====================================================================
20 {
21  std::string vlevel;
22  if (!params.fetch_string("verbose_level", vlevel)) {
23  m_vl = vout.set_verbose_level(vlevel);
24  }
25 
26  //- fetch and check input parameters
27  double kappa, cSW;
28  std::vector<int> bc;
29  std::vector<double> phi, phipr;
30 
31  int err = 0;
32  err += params.fetch_double("hopping_parameter", kappa);
33  err += params.fetch_double("clover_coefficient", cSW);
34  err += params.fetch_int_vector("boundary_condition", bc);
35  err += params.fetch_double_vector("phi", phi);
36  err += params.fetch_double_vector("phipr", phipr);
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(kappa, cSW, bc, &phi[0], &phipr[0]);
45 }
46 
47 
48 //====================================================================
50 {
51  params.set_double("hopping_parameter", m_kappa);
52  params.set_double("clover_coefficient", m_cSW);
53  params.set_int_vector("boundary_condition", m_boundary);
54  params.set_double_vector("phi", m_phi);
55  params.set_double_vector("phipr", m_phipr);
56 
57  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
58 }
59 
60 
61 //====================================================================
62 void Force_F_Clover_SF::set_parameters(const double kappa, const double cSW, const std::vector<int> bc,
63  double *phi, double *phipr)
64 {
65  const int Ndim = CommonParameters::Ndim();
66 
67  //- print input parameters
68  vout.general(m_vl, "%s:\n", class_name.c_str());
69  vout.general(m_vl, " kappa = %12.8f\n", kappa);
70  vout.general(m_vl, " cSW = %12.8f\n", cSW);
71  for (int mu = 0; mu < Ndim; ++mu) {
72  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
73  }
74 
75  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
76  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
77  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
78  vout.general(m_vl, " phipr1= %12.6f\n", phipr[0]);
79  vout.general(m_vl, " phipr2= %12.6f\n", phipr[1]);
80  vout.general(m_vl, " phipr3= %12.6f\n", phipr[2]);
81 
82  //- range check
83  // NB. kappa,cSW == 0 is allowed.
84  assert(bc.size() == Ndim);
85  // NB. phi,phipr == 0 is allowed.
86 
87  //- store values
88  m_kappa = kappa;
89  m_cSW = cSW;
90 
91  m_boundary.resize(Ndim);
92  m_boundary = bc;
93 
94  m_phi.resize(3);
95  m_phipr.resize(3);
96  for (int i = 0; i < 3; ++i) {
97  m_phi[i] = phi[i];
98  m_phipr[i] = phipr[i];
99  }
100 
101  //- propagate parameters
104 
105  const int Lx = CommonParameters::Lx();
106  double Lx_inv = 1.0 / double(Lx);
107  double c0r = cos(phi[0] * Lx_inv);
108  double c0i = sin(phi[0] * Lx_inv);
109  double c1r = cos(phi[1] * Lx_inv);
110  double c1i = sin(phi[1] * Lx_inv);
111  double c2r = cos(phi[2] * Lx_inv);
112  double c2i = sin(phi[2] * Lx_inv);
113  m_wk.zero();
114  m_wk.set(0, 0, c0r, c0i);
115  m_wk.set(1, 1, c1r, c1i);
116  m_wk.set(2, 2, c2r, c2i);
117 
118  c0r = cos(phipr[0] * Lx_inv);
119  c0i = sin(phipr[0] * Lx_inv);
120  c1r = cos(phipr[1] * Lx_inv);
121  c1i = sin(phipr[1] * Lx_inv);
122  c2r = cos(phipr[2] * Lx_inv);
123  c2i = sin(phipr[2] * Lx_inv);
124 
125  m_wkpr.zero();
126  m_wkpr.set(0, 0, c0r, c0i);
127  m_wkpr.set(1, 1, c1r, c1i);
128  m_wkpr.set(2, 2, c2r, c2i);
129  // set_wk.set_parameters(m_phi, m_phipr);
130 }
131 
132 
133 //====================================================================
134 void Force_F_Clover_SF::force_udiv(Field& force_, const Field& eta_)
135 {
136  const int Nvol = CommonParameters::Nvol();
137  const int Ndim = CommonParameters::Ndim();
138 
139  Field_F zeta;
140  Field_F eta(eta_);
141 
142  m_fopr_c->set_mode("H");
143  m_fopr_c->mult(zeta, eta);
144 
145  Field_G force(Nvol, Ndim);
146  force_udiv1_impl(force, eta, zeta);
147 
148  Field_G force1(Nvol, Ndim);
149  force_udiv1_impl(force1, zeta, eta);
150 
151  axpy(force, 1.0, force1); // force += force1;
152 
154 
155  copy(force_, force); // force_ = force;
156 }
157 
158 
159 //====================================================================
160 void Force_F_Clover_SF::force_udiv1(Field& force_, const Field& zeta_, const Field& eta_)
161 {
162  const int Nvol = CommonParameters::Nvol();
163  const int Ndim = CommonParameters::Ndim();
164 
165  Field_G force(Nvol, Ndim);
166  Field_F zeta(zeta_);
167  Field_F eta(eta_);
168 
169  force_udiv1_impl(force, zeta, eta);
170 
171  copy(force_, force); // force_ = force;
172 }
173 
174 
175 //====================================================================
176 void Force_F_Clover_SF::force_udiv1_impl(Field_G& force, const Field_F& zeta, const Field_F& eta)
177 {
178  const int Nc = CommonParameters::Nc();
179  const int Nd = CommonParameters::Nd();
180  const int Nvol = CommonParameters::Nvol();
181  const int Ndim = CommonParameters::Ndim();
182 
183  force.set(0.0);
184 
185  Field_F zeta1(zeta);
186  set_boundary_zero(zeta1);
187 
188  m_force_w->force_udiv1(force, zeta, eta);
189 
190  Field_F eta2;
191  m_fopr_c->mult_gm5(eta2, eta);
192  set_boundary_zero(eta2);
193 
194  for (int mu = 0; mu < Ndim; ++mu) {
195  for (int nu = 0; nu < Ndim; ++nu) {
196  if (nu == mu) continue;
197 
198  Field_F eta3;
199  m_fopr_c->mult_isigma(eta3, eta2, mu, nu);
200 
201  Field_G Umu;
202  Umu.setpart_ex(0, *m_U, mu);
203 
204  Field_G Unu;
205  Unu.setpart_ex(0, *m_U, nu);
206  if (mu != 3) Field_SF::set_boundary_wk(Umu, m_wk);
207  if (nu != 3) Field_SF::set_boundary_wk(Unu, m_wk);
208 
209  const int ex = 0;
210 
211  // R(1) and R(5)
212  Field_F vt1;
213  mult_Field_Gd(vt1, 0, *m_Cud, index_dir(mu, nu), eta3, ex);
214 
215  Field_G force1;
216  tensorProd_Field_F(force1, zeta1, vt1);
217 
218  Field_G force2;
219  copy(force2, force1); // force2 = force1;
220 
221  // R(2)
222  Field_F vt3;
223  mult_Field_Gd(vt3, 0, Umu, 0, eta3, ex);
224 
226  shift.backward(vt1, vt3, nu);
227 
228  Field_F vt2;
229  shift.backward(vt2, zeta1, nu);
230 
231  Field_G Utmp;
232  shift.backward(Utmp, Unu, mu);
233  if (mu == 3) Field_SF::set_boundary_wkpr(Utmp, m_wkpr);
234 
235  mult_Field_Gn(vt3, 0, Utmp, 0, vt1, ex);
236 
237  Field_F vt4;
238  mult_Field_Gn(vt4, 0, Unu, 0, vt2, ex);
239  tensorProd_Field_F(force1, vt4, vt3);
240  axpy(force2, 1.0, force1); // force2 += force1;
241 
242  // R(4) and R(8)
243  shift.backward(vt1, eta3, mu);
244 
245  Field_F zeta_mu;
246  shift.backward(zeta_mu, zeta1, mu);
247  mult_Field_Gn(vt4, 0, *m_Cud, index_dir(mu, nu), zeta_mu, ex);
248  tensorProd_Field_F(force1, vt4, vt1);
249  axpy(force2, 1.0, force1); // force2 += force1;
250 
251  // R(3)
252  shift.backward(vt1, eta3, nu);
253  mult_Field_Gn(vt3, 0, Unu, 0, vt1, ex);
254  mult_Field_Gn(vt4, 0, Umu, 0, zeta_mu, ex);
255  shift.backward(vt1, vt3, mu);
256  shift.backward(vt2, vt4, nu);
257  mult_Field_Gn(vt4, 0, Unu, 0, vt2, ex);
258  tensorProd_Field_F(force1, vt4, vt1);
259  axpy(force2, 1.0, force1); // force2 += force1;
260 
261  // R(6)
262  shift.backward(Utmp, Unu, mu);
263  if (mu == 3) Field_SF::set_boundary_wkpr(Utmp, m_wkpr);
264 
265  Field_G Utmp2;
266  mult_Field_Gdd(Utmp2, 0, Utmp, 0, Umu, 0);
267  mult_Field_Gn(vt1, 0, Utmp2, 0, eta3, ex);
268  mult_Field_Gd(vt2, 0, Unu, 0, zeta1, ex);
269  shift.forward(vt3, vt1, nu);
270  shift.forward(vt4, vt2, nu);
271  tensorProd_Field_F(force1, vt4, vt3);
272  axpy(force2, -1.0, force1); // force2 -= force1;
273 
274  // R(7)
275  mult_Field_Gd(vt1, 0, Unu, 0, eta3, ex);
276  mult_Field_Gn(vt2, 0, Umu, 0, zeta_mu, ex);
277  shift.backward(vt3, vt1, mu);
278  shift.forward(vt1, vt3, nu);
279  mult_Field_Gd(vt4, 0, Unu, 0, vt2, ex);
280  shift.forward(vt2, vt4, nu);
281  tensorProd_Field_F(force1, vt2, vt1);
282  axpy(force2, -1.0, force1); // force2 -= force1;
283 
284  scal(force2, -m_kappa * m_cSW / 8.0); // force2 *= -m_kappa * m_cSW / 8.0;
285  force.addpart_ex(mu, force2, 0);
286  }
287  }
288 }
289 
290 
291 //====================================================================
293 {
294  for (int mu = 0; mu < m_Ndim; ++mu) {
295  for (int nu = 0; nu < m_Ndim; ++nu) {
296  if (nu == mu) continue;
297 
298  Staple_SF staple;
299  staple.set_parameters(m_phi, m_phipr);
300 
301  Field_G Cmu_ud1;
302  staple.upper(Cmu_ud1, *m_U, mu, nu);
303 
304  Field_G Cmu_ud2;
305  staple.lower(Cmu_ud2, *m_U, mu, nu);
306 
307  axpy(Cmu_ud1, -1.0, Cmu_ud2);
308  m_Cud->setpart_ex(index_dir(mu, nu), Cmu_ud1, 0);
309  }
310  }
311 }
312 
313 
314 //====================================================================
316 {
317 #pragma omp barrier
318 
319  int Nc = CommonParameters::Nc();
320  int Nd = CommonParameters::Nd();
321  int Nvol = CommonParameters::Nvol();
322  int Svol = Nvol / CommonParameters::Nt();
323  int Nc2 = 2 * Nc;
324 
325  if (Communicator::ipe(3) == 0) {
326  for (int site = 0; site < Svol; ++site) {
327  for (int s = 0; s < Nd; ++s) {
328  for (int cc = 0; cc < Nc2; ++cc) {
329  f.set(cc + Nc2 * s, site, 0, 0.0);
330  }
331  }
332  }
333  }
334 
335 #pragma omp barrier
336 }
337 
338 
339 //============================================================END=====
Fopr_Clover_SF::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_Clover_SF.cpp:117
Field_SF::set_boundary_wkpr
void set_boundary_wkpr(Field_G &u, const Mat_SU_N &wkpr)
Definition: field_SF.cpp:63
Field::setpart_ex
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:201
Force_F_Clover_SF::force_udiv
void force_udiv(Field &force, const Field &eta)
For recursive calculation of smeared force.
Definition: force_F_Clover_SF.cpp:134
Force_F_Clover_SF::m_cSW
double m_cSW
clover coefficient
Definition: force_F_Clover_SF.h:47
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
Staple_SF::set_parameters
void set_parameters(const Parameters &params)
Definition: staple_SF.cpp:35
Force_F_Clover_SF::force_udiv1
void force_udiv1(Field &force, const Field &zeta, const Field &eta)
For recursive calculation of smeared force.
Definition: force_F_Clover_SF.cpp:160
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
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Field_SF::set_boundary_wk
void set_boundary_wk(Field_G &u, const Mat_SU_N &wk)
Definition: field_SF.cpp:32
Fopr_Clover_SF::mult_isigma
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
Definition: fopr_Clover_SF.cpp:374
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
mult_Field_Gd
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:76
Staple_SF
Staple construction.
Definition: staple_SF.h:36
Parameters::set_double_vector
void set_double_vector(const string &key, const vector< double > &value)
Definition: parameters.cpp:42
Force_F_Clover_SF::index_dir
int index_dir(const int mu, const int nu)
Definition: force_F_Clover_SF.h:144
Force_F_Clover_SF::m_wkpr
Mat_SU_N m_wkpr
SF boundary condition at t=Nt.
Definition: force_F_Clover_SF.h:67
Staple_SF::upper
void upper(Field_G &, const Field_G &, const int, const int)
Definition: staple_SF.cpp:877
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
tensorProd_Field_F
void tensorProd_Field_F(Field_G &u, const Field_F &v1, const Field_F &v2)
Definition: tensorProd.cpp:32
Force_F_Clover_SF::m_fopr_c
Fopr_Clover_SF * m_fopr_c
Definition: force_F_Clover_SF.h:53
Force::m_U
Field_G * m_U
Definition: force_F.h:66
SU_N::Mat_SU_N::set
void set(int c, const double &re, const double &im)
Definition: mat_SU_N.h:137
Force_F_Wilson_SF::force_udiv1
void force_udiv1(Field &force, const Field &zeta, const Field &eta)
Definition: force_F_Wilson_SF.cpp:107
CommonParameters::Lx
static int Lx()
Definition: commonParameters.h:91
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
SU_N::Mat_SU_N::zero
Mat_SU_N & zero()
Definition: mat_SU_N.h:429
Fopr_Clover_SF::mult_gm5
void mult_gm5(Field &v, const Field &w)
multiplies gamma_5 matrix.
Definition: fopr_Clover_SF.h:124
Force_F_Wilson_SF::set_parameters
void set_parameters(const Parameters &params)
Definition: force_F_Wilson_SF.cpp:19
CommonParameters::Nt
static int Nt()
Definition: commonParameters.h:108
Parameters::fetch_int_vector
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
Fopr_Clover_SF::set_mode
void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: fopr_Clover_SF.cpp:233
Force_F_Clover_SF::class_name
static const std::string class_name
Definition: force_F_Clover_SF.h:41
Fopr_Clover_SF::mult
void mult(Field &v, const Field &f)
multiplies fermion operator to a given field.
Definition: fopr_Clover_SF.cpp:245
Parameters::set_int_vector
void set_int_vector(const string &key, const vector< int > &value)
Definition: parameters.cpp:45
Force_F_Clover_SF::m_Cud
Field_G * m_Cud
for force calculation
Definition: force_F_Clover_SF.h:51
ShiftField_lex
Methods to shift a field in the lexical site index.
Definition: shiftField_lex.h:39
Force_F_Clover_SF::set_parameters
void set_parameters(const Parameters &params)
Definition: force_F_Clover_SF.cpp:19
Field_SF::set_boundary_spatial_link_zero
void set_boundary_spatial_link_zero(Field_G &u)
Definition: field_SF.cpp:151
Force_F_Clover_SF::m_kappa
double m_kappa
hopping parameter
Definition: force_F_Clover_SF.h:46
Force_F_Clover_SF::set_boundary_zero
void set_boundary_zero(Field_F &f)
Definition: force_F_Clover_SF.cpp:315
CommonParameters::Nd
static int Nd()
Definition: commonParameters.h:116
Staple_SF::lower
void lower(Field_G &, const Field_G &, const int, const int)
Definition: staple_SF.cpp:912
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
mult_Field_Gn
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:36
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
scal
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:261
Communicator::ipe
static int ipe(const int dir)
logical coordinate of current proc.
Definition: communicator.cpp:105
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Field_F
Wilson-type fermion field.
Definition: field_F.h:37
Parameters::fetch_double
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
Force_F_Clover_SF::m_force_w
Force_F_Wilson_SF * m_force_w
Definition: force_F_Clover_SF.h:54
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Force_F_Clover_SF::get_parameters
void get_parameters(Parameters &params) const
Definition: force_F_Clover_SF.cpp:49
Force_F_Clover_SF::m_wk
Mat_SU_N m_wk
In order to set the boundary field.
Definition: force_F_Clover_SF.h:66
force_F_Clover_SF.h
Force_F_Clover_SF::m_phi
std::vector< double > m_phi
SF boundary condition at t=0.
Definition: force_F_Clover_SF.h:58
Field
Container of Field-type object.
Definition: field.h:46
Force_F_Clover_SF::force_udiv1_impl
void force_udiv1_impl(Field_G &force, const Field_F &zeta, const Field_F &eta)
Core implemetation of clover force calculation.
Definition: force_F_Clover_SF.cpp:176
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Force_F_Clover_SF::set_component
void set_component()
Set building components for force calculation.
Definition: force_F_Clover_SF.cpp:292
Parameters::fetch_double_vector
int fetch_double_vector(const string &key, vector< double > &value) const
Definition: parameters.cpp:410
Force_F_Clover_SF::m_phipr
std::vector< double > m_phipr
SF boundary condition at t=Nt.
Definition: force_F_Clover_SF.h:60
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Force_F_Clover_SF::m_boundary
std::vector< int > m_boundary
boundary conditions
Definition: force_F_Clover_SF.h:48
Test_Gauge::shift
int shift(void)
Definition: test_Gauge_Shift.cpp:58
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
Force_F_Clover_SF::m_Ndim
int m_Ndim
Definition: force_F_Clover_SF.h:50
Force_F_Clover_SF::m_vl
Bridge::VerboseLevel m_vl
Definition: force_F_Clover_SF.h:44