Bridge++  Ver. 1.3.x
force_F_Clover_Nf2.cpp
Go to the documentation of this file.
1 
14 #include "force_F_Clover_Nf2.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_Clover_Nf2", append_entry);
35 #endif
36 }
37 //- end
38 
39 //- parameters class
41 //- end
42 
43 const std::string Force_F_Clover_Nf2::class_name = "Force_F_Clover_Nf2";
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_Clover_Nf2::set_parameters(const double kappa, const double cSW,
73  const std::vector<int> bc)
74 {
75  int Ndim = CommonParameters::Ndim();
76 
77  //- print input parameters
78  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
79  vout.general(m_vl, " kappa = %8.4f\n", kappa);
80  vout.general(m_vl, " cSW = %8.4f\n", cSW);
81  for (int mu = 0; mu < Ndim; ++mu) {
82  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
83  }
84 
85  //- range check
86  // NB. kappa,cSW == 0 is allowed.
87  assert(bc.size() == Ndim);
88 
89  //- store values
90  m_kappa = kappa;
91  m_cSW = cSW;
92 
93  m_boundary.resize(Ndim);
94  for (int mu = 0; mu < Ndim; ++mu) {
95  m_boundary[mu] = bc[mu];
96  }
97 
98  //- propagate parameters
100 
103 }
104 
105 
106 //====================================================================
107 void Force_F_Clover_Nf2::init(std::string repr)
108 {
109  m_repr = repr;
110 
111  m_fopr_c = new Fopr_Clover(repr);
112  m_force_w = new Force_F_Wilson_Nf2(repr);
113  m_force_csw = new Force_F_CloverTerm(repr);
114 
116 
117  int Nvol = CommonParameters::Nvol();
119 
120  m_Cud = new Field_G(Nvol, m_Ndim * m_Ndim);
121 }
122 
123 
124 //====================================================================
126 {
127  delete m_Cud;
128  delete m_force_csw;
129  delete m_force_w;
130  delete m_fopr_c;
131 }
132 
133 
134 //====================================================================
135 void Force_F_Clover_Nf2::force_udiv(Field& force_, const Field& eta_)
136 {
137  int Nc = CommonParameters::Nc();
138  int Nvol = CommonParameters::Nvol();
139  int Ndim = CommonParameters::Ndim();
140 
141  Field_G force1(Nvol, Ndim);
142 
143  Field_F zeta(Nvol, 1);
144  Field_F eta(eta_);
145 
146  m_fopr_c->H(zeta, eta);
147 
148  force_udiv1(force1, eta, zeta);
149  copy(force_, force1); // force_ = force1;
150 
151  force_udiv1(force1, zeta, eta);
152  axpy(force_, 1.0, force1); // force_ += force1;
153 }
154 
155 
156 //====================================================================
157 void Force_F_Clover_Nf2::force_udiv1(Field& force_, const Field& zeta_, const Field& eta_)
158 {
159  int Nc = CommonParameters::Nc();
160  int Nvol = CommonParameters::Nvol();
161  int Ndim = CommonParameters::Ndim();
162 
163  Field_G force(Nvol, Ndim);
164  Field_F zeta(zeta_);
165  Field_F eta(eta_);
166 
167  force_udiv1_impl(force, zeta, eta);
168 
169  copy(force_, force); // force_ = force;
170 }
171 
172 
173 //====================================================================
174 void Force_F_Clover_Nf2::force_udiv1_impl(Field_G& force, const Field_F& zeta, const Field_F& eta)
175 {
176  int Nc = CommonParameters::Nc();
177  int Nd = CommonParameters::Nd();
178  int Nvol = CommonParameters::Nvol();
179  int Ndim = CommonParameters::Ndim();
180 
182  Field_G force2(Nvol, Ndim);
183 
184  force.set(0.0);
185 
186  m_force_w->force_udiv1(force, zeta, eta);
187  m_force_csw->force_udiv1(force2, zeta, eta);
188 
189  axpy(force, 1.0, force2); // force += force2;
190 }
191 
192 
193 //====================================================================
195 {
196  int Nc = CommonParameters::Nc();
197  int Nd = CommonParameters::Nd();
198  int Nvol = CommonParameters::Nvol();
199 
200  Staples staple;
201  Field_G Cmu_ud1(Nvol, 1);
202  Field_G Cmu_ud2(Nvol, 1);
203 
204  for (int mu = 0; mu < m_Ndim; ++mu) {
205  for (int nu = 0; nu < m_Ndim; ++nu) {
206  if (nu == mu) continue;
207 
208  staple.upper(Cmu_ud1, *m_U, mu, nu);
209  staple.lower(Cmu_ud2, *m_U, mu, nu);
210  //Cmu_ud -= staple.lower(*m_U, mu, nu);
211  axpy(Cmu_ud1, -1.0, Cmu_ud2);
212  m_Cud->setpart_ex(index_dir(mu, nu), Cmu_ud1, 0);
213  }
214  }
215 }
216 
217 
218 //====================================================================
219 //============================================================END=====
void Register_int_vector(const string &, const std::vector< int > &)
Definition: parameters.cpp:344
double m_kappa
hopping parameter
BridgeIO vout
Definition: bridgeIO.cpp:278
void init(std::string)
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 index_dir(int mu, int nu)
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.
double m_cSW
clover coefficient
Class for parameters.
Definition: parameters.h:38
int m_Ndim
spacetime dimension
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:381
void H(Field &, const Field &)
Wilson-type fermion field.
Definition: field_F.h:37
void set_parameters(const Parameters &params)
Setting parameters of clover fermion force.
std::vector< int > m_boundary
boundary conditions
void force_udiv1_impl(Field_G &force, const Field_F &zeta, const Field_F &eta)
Core implemetation of clover force calculation.
SU(N) gauge field.
Definition: field_G.h:38
void set_parameters(const Parameters &params)
Setting parameters of clover fermion force.
Force_F_CloverTerm * m_force_csw
Clover term force.
void force_udiv1(Field &force, const Field &zeta, const Field &eta)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:168
void force_udiv(Field &force, const Field &eta)
For recursive calculation of smeared force.
void crucial(const char *format,...)
Definition: bridgeIO.cpp:48
void set_parameters(const Parameters &params)
Field_G * m_Cud
for force calculation
void lower(Field_G &, const Field_G &, const int mu, const int nu)
constructs lower staple in mu-nu plane.
Definition: staples.cpp:152
void force_udiv1(Field &force, const Field &zeta, const Field &eta)
For recursive calculation of smeared force.
static bool Register(const std::string &realm, const creator_callback &cb)
void set_component()
Set building components for force calculation.
Force_F_Wilson_Nf2 * m_force_w
Wilson fermion force.
void Register_double(const string &, const double)
Definition: parameters.cpp:323
std::string m_repr
gamma matrix representation
Methods to shift a field in the lexical site index.
static const std::string class_name
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
Fopr_Clover * m_fopr_c
fermion operator
string get_string(const string &key) const
Definition: parameters.cpp:87
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
void set_parameters(const Parameters &params)
Definition: fopr_Clover.cpp:99
int fetch_int_vector(const string &key, std::vector< int > &val) const
Definition: parameters.cpp:176