Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fopr_CloverTerm.cpp
Go to the documentation of this file.
1 
14 #include "fopr_CloverTerm.h"
15 
16 #ifdef USE_PARAMETERS_FACTORY
17 #include "parameters_factory.h"
18 #endif
19 
20 using std::valarray;
21 using std::string;
22 
23 const std::string Fopr_CloverTerm::class_name = "Fopr_CloverTerm";
24 
25 //====================================================================
26 //- parameter entries
27 namespace {
28  void append_entry(Parameters& param)
29  {
30  param.Register_double("hopping_parameter", 0.0);
31  param.Register_double("clover_coefficient", 0.0);
32  param.Register_int_vector("boundary_condition", std::valarray<int>());
33 
34  param.Register_string("verbose_level", "NULL");
35  }
36 
37 
38 #ifdef USE_PARAMETERS_FACTORY
39  bool init_param = ParametersFactory::Register("", append_entry);
40 #endif
41 }
42 //- end
43 
44 //- parameters class
46 //- end
47 
48 //====================================================================
50 {
51  const string str_vlevel = params.get_string("verbose_level");
52 
53  m_vl = vout.set_verbose_level(str_vlevel);
54 
55  //- fetch and check input parameters
56  double kappa, cSW;
57  valarray<int> bc;
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 
64  if (err) {
65  vout.crucial(m_vl, "%s: fetch error, input parameter not found.\n", class_name.c_str());
66  abort();
67  }
68 
69 
70  set_parameters(kappa, cSW, bc);
71 }
72 
73 
74 //====================================================================
75 void Fopr_CloverTerm::set_parameters(double kappa, double cSW,
76  valarray<int> bc)
77 {
78  //- print input parameters
79  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
80  vout.general(m_vl, " kappa = %8.4f\n", kappa);
81  vout.general(m_vl, " cSW = %8.4f\n", cSW);
82  for (int mu = 0; mu < m_Ndim; ++mu) {
83  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
84  }
85 
86  //- range check
87  // NB. kappa,cSW == 0 is allowed.
88  assert(bc.size() == m_Ndim);
89 
90  //- store values
91  m_kappa = kappa;
92  m_cSW = cSW;
93 
94  // m_boundary.resize(m_Ndim); // already resized in init.
95  for (int mu = 0; mu < m_Ndim; ++mu) {
96  m_boundary[mu] = bc[mu];
97  }
98 }
99 
100 
101 //====================================================================
103 {
104  m_U = (Field_G *)U;
105  set_csw();
106 }
107 
108 
109 //====================================================================
110 void Fopr_CloverTerm::init(string repr)
111 {
113  m_Ndim = CommonParameters::Ndim();
116  m_NinF = 2 * m_Nc * m_Nd;
117 
118  m_U = 0;
119 
120  m_repr = repr;
121 
122  m_boundary.resize(m_Ndim);
123  m_SG.resize(m_Ndim * m_Ndim);
124 
125  GammaMatrixSet *gmset = GammaMatrixSet::New(m_repr);
126 
127  m_GM5 = gmset->get_GM(gmset->GAMMA5);
128 
129  m_SG[sg_index(0, 1)] = gmset->get_GM(gmset->SIGMA12);
130  m_SG[sg_index(1, 2)] = gmset->get_GM(gmset->SIGMA23);
131  m_SG[sg_index(2, 0)] = gmset->get_GM(gmset->SIGMA31);
132  m_SG[sg_index(3, 0)] = gmset->get_GM(gmset->SIGMA41);
133  m_SG[sg_index(3, 1)] = gmset->get_GM(gmset->SIGMA42);
134  m_SG[sg_index(3, 2)] = gmset->get_GM(gmset->SIGMA43);
135 
136  m_SG[sg_index(1, 0)] = m_SG[sg_index(0, 1)].mult(-1);
137  m_SG[sg_index(2, 1)] = m_SG[sg_index(1, 2)].mult(-1);
138  m_SG[sg_index(0, 2)] = m_SG[sg_index(2, 0)].mult(-1);
139  m_SG[sg_index(0, 3)] = m_SG[sg_index(3, 0)].mult(-1);
140  m_SG[sg_index(1, 3)] = m_SG[sg_index(3, 1)].mult(-1);
141  m_SG[sg_index(2, 3)] = m_SG[sg_index(3, 2)].mult(-1);
142 
143  m_SG[sg_index(0, 0)] = gmset->get_GM(gmset->UNITY);
144  m_SG[sg_index(1, 1)] = gmset->get_GM(gmset->UNITY);
145  m_SG[sg_index(2, 2)] = gmset->get_GM(gmset->UNITY);
146  m_SG[sg_index(3, 3)] = gmset->get_GM(gmset->UNITY);
147  // these 4 gamma matrices are actually not used.
148 
149  delete gmset;
150 }
151 
152 
153 //====================================================================
155 {
156  // nothing to do.
157 }
158 
159 
160 //====================================================================
161 void Fopr_CloverTerm::mult_gm5(Field& v, const Field& f)
162 {
163  assert(v.nvol() == f.nvol());
164  assert(v.nex() == f.nex());
165  assert(v.nin() == f.nin());
166 
167  Field_F vt(f.nvol(), f.nex());
168 
169  mult_GM(vt, m_GM5, (Field_F)f);
170  v = (Field)vt;
171 }
172 
173 
174 //====================================================================
176  const int mu, const int nu)
177 {
178  assert(mu != nu);
179  mult_iGM(v, m_SG[sg_index(mu, nu)], w);
180 }
181 
182 
183 //====================================================================
184 void Fopr_CloverTerm::mult_sigmaF(Field& v, const Field& f)
185 {
186  mult_csw(v, f);
187 }
188 
189 
190 //====================================================================
191 void Fopr_CloverTerm::mult_csw(Field& v, const Field& w)
192 {
193  int Nc = CommonParameters::Nc();
194  int Nd = CommonParameters::Nd();
195  int Nvol = w.nvol();
196 
197  Field_F wt(Nvol, 1), vt(Nvol, 1);
198 
199  vt = 0.0;
200 
201  mult_iGM(wt, m_SG[sg_index(1, 2)], (Field_F)w);
202  multadd_Field_Gn(vt, 0, m_Bx, 0, wt, 0, 1.0);
203 
204  mult_iGM(wt, m_SG[sg_index(2, 0)], (Field_F)w);
205  multadd_Field_Gn(vt, 0, m_By, 0, wt, 0, 1.0);
206 
207  mult_iGM(wt, m_SG[sg_index(0, 1)], (Field_F)w);
208  multadd_Field_Gn(vt, 0, m_Bz, 0, wt, 0, 1.0);
209 
210  mult_iGM(wt, m_SG[sg_index(3, 0)], (Field_F)w);
211  multadd_Field_Gn(vt, 0, m_Ex, 0, wt, 0, 1.0);
212 
213  mult_iGM(wt, m_SG[sg_index(3, 1)], (Field_F)w);
214  multadd_Field_Gn(vt, 0, m_Ey, 0, wt, 0, 1.0);
215 
216  mult_iGM(wt, m_SG[sg_index(3, 2)], (Field_F)w);
217  multadd_Field_Gn(vt, 0, m_Ez, 0, wt, 0, 1.0);
218 
219  vt *= m_kappa * m_cSW;
220 
221  v = (Field)vt;
222 }
223 
224 
225 //====================================================================
227 {
228  set_fieldstrength(m_Bx, 1, 2);
229  set_fieldstrength(m_By, 2, 0);
230  set_fieldstrength(m_Bz, 0, 1);
231  set_fieldstrength(m_Ex, 3, 0);
232  set_fieldstrength(m_Ey, 3, 1);
233  set_fieldstrength(m_Ez, 3, 2);
234 }
235 
236 
237 //====================================================================
239  const int mu, const int nu)
240 {
241  int Nvol = CommonParameters::Nvol();
242 
243  Staples staple;
244 
245  Field_G Cup(Nvol, 1), Cdn(Nvol, 1);
246  Field_G Umu(Nvol, 1);
247  Field_G v(Nvol, 1), v2(Nvol, 1);
248 
249  Cup = staple.upper(*m_U, mu, nu);
250  Cdn = staple.lower(*m_U, mu, nu);
251  Umu.setpart_ex(0, *m_U, mu);
252 
253  mult_Field_Gnd(Fst, 0, Umu, 0, Cup, 0);
254  multadd_Field_Gnd(Fst, 0, Umu, 0, Cdn, 0, -1.0);
255 
256  mult_Field_Gdn(v, 0, Cup, 0, Umu, 0);
257  multadd_Field_Gdn(v, 0, Cdn, 0, Umu, 0, -1.0);
258 
259  m_shift.forward(v2, v, mu);
260 
261  Fst += v2;
262 
263  ah_Field_G(Fst, 0);
264  Fst *= 0.25;
265 }
266 
267 
268 //====================================================================
270 {
271  // The following counting explicitly depends on the implementation
272  // and to be recalculated when the code is modified.
273  // Present counting is based on rev.1131. [10 Sep 2014 H.Matsufuru]
274 
275  int Lvol = CommonParameters::Lvol();
276 
277  double flop_site
278  = static_cast<double>(m_Nc * m_Nd * (2 + 12 + 48 * m_Nc));
279  double flop = flop_site * static_cast<double>(Lvol);
280 
281  return flop;
282 }
283 
284 
285 //====================================================================
286 //============================================================END=====
void set_config(Field *U)
setting pointer to the gauge configuration.
BridgeIO vout
Definition: bridgeIO.cpp:207
void Register_string(const string &, const string &)
Definition: parameters.cpp:352
Staple construction.
Definition: staples.h:40
void mult_sigmaF(Field &, const Field &)
Field_G m_Ez
field strength.
GammaMatrix m_GM5
void mult_Field_Gdn(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2)
const Field mult_gm5(const Field &f)
Field_G upper(const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane (wrapping void version).
Definition: staples.cpp:118
void general(const char *format,...)
Definition: bridgeIO.cpp:38
GammaMatrix get_GM(GMspecies spec)
Container of Field-type object.
Definition: field.h:37
void set_parameters(const Parameters &params)
int nvol() const
Definition: field.h:101
void set_fieldstrength(Field_G &, const int, const int)
Class for parameters.
Definition: parameters.h:40
static int Lvol()
int fetch_int_vector(const string &key, std::valarray< int > &val) const
Definition: parameters.cpp:176
void multadd_Field_Gn(Field_F &y, const int ex, const Field_G &u, int ex1, const Field_F &x, int ex2, const double a)
Wilson-type fermion field.
Definition: field_F.h:37
int nin() const
Definition: field.h:100
void ah_Field_G(Field_G &w, const int ex)
SU(N) gauge field.
Definition: field_G.h:36
void multadd_Field_Gdn(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2, const double ff)
void mult_Field_Gnd(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2)
void mult_iGM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication (i is multiplied)
Definition: field_F_imp.cpp:94
Bridge::VerboseLevel m_vl
Definition: fopr.h:99
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
Set of Gamma Matrices: basis class.
int nex() const
Definition: field.h:102
void init(std::string repr)
void multadd_Field_Gnd(Field_G &w, const int ex, const Field_G &u1, const int ex1, const Field_G &u2, const int ex2, const double ff)
std::string m_repr
void crucial(const char *format,...)
Definition: bridgeIO.cpp:26
double flop_count()
this returns the number of floating point operations.
void mult_GM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication
Definition: field_F_imp.cpp:39
ShiftField_lex m_shift
void mult_csw(Field &, const Field &)
static bool Register(const std::string &realm, const creator_callback &cb)
const Field_G * m_U
pointer to gauge configuration.
static const std::string class_name
Field_G lower(const Field_G &, const int mu, const int nu)
constructs lower staple in mu-nu plane (wrapping void version).
Definition: staples.cpp:128
int sg_index(int mu, int nu)
void Register_double(const string &, const double)
Definition: parameters.cpp:324
void Register_int_vector(const string &, const std::valarray< int > &)
Definition: parameters.cpp:345
std::valarray< GammaMatrix > m_SG
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:150
int fetch_double(const string &key, double &val) const
Definition: parameters.cpp:124
string get_string(const string &key) const
Definition: parameters.cpp:85
std::valarray< int > m_boundary
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:191
void forward(Field &, const Field &, const int mu)