Bridge++  Ver. 1.1.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 //====================================================================
24 //- parameter entries
25 namespace {
26  void append_entry(Parameters& param)
27  {
28  param.Register_double("hopping_parameter", 0.0);
29  param.Register_double("clover_coefficient", 0.0);
30  param.Register_int_vector("boundary_condition", std::valarray<int>());
31 
32  param.Register_string("verbose_level", "NULL");
33  }
34 
35 
36 #ifdef USE_PARAMETERS_FACTORY
37  bool init_param = ParametersFactory::Register("", append_entry);
38 #endif
39 }
40 //- end
41 
42 //- parameters class
44 //- end
45 
46 //====================================================================
48 {
49  const string str_vlevel = params.get_string("verbose_level");
50 
51  m_vl = vout.set_verbose_level(str_vlevel);
52 
53  //- fetch and check input parameters
54  double kappa, cSW;
55  valarray<int> bc;
56 
57  int err = 0;
58  err += params.fetch_double("hopping_parameter", kappa);
59  err += params.fetch_double("clover_coefficient", cSW);
60  err += params.fetch_int_vector("boundary_condition", bc);
61 
62  if (err) {
63  vout.crucial(m_vl, "Fopr_CloverTerm: fetch error, input parameter not found.\n");
64  abort();
65  }
66 
67 
68  set_parameters(kappa, cSW, bc);
69 }
70 
71 
72 //====================================================================
73 void Fopr_CloverTerm::set_parameters(double kappa, double cSW,
74  valarray<int> bc)
75 {
76  //- print input parameters
77  vout.general(m_vl, "Parameters of Fopr_CloverTerm:\n");
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 < m_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() == m_Ndim);
87 
88  //- store values
89  m_kappa = kappa;
90  m_cSW = cSW;
91 
92  // m_boundary.resize(m_Ndim); // already resized in init.
93  for (int mu = 0; mu < m_Ndim; ++mu) {
94  m_boundary[mu] = bc[mu];
95  }
96 }
97 
98 
99 //====================================================================
101 {
102  m_U = (Field_G *)U;
103  set_csw();
104 }
105 
106 
107 //====================================================================
108 void Fopr_CloverTerm::init(string repr)
109 {
111  m_Ndim = CommonParameters::Ndim();
114  m_NinF = 2 * m_Nc * m_Nd;
115 
116  m_U = 0;
117 
118  m_repr = repr;
119 
120  m_boundary.resize(m_Ndim);
121  m_SG.resize(m_Ndim * m_Ndim);
122 
123  GammaMatrixSet *gmset = GammaMatrixSet::New(m_repr);
124 
125  m_GM5 = gmset->get_GM(gmset->GAMMA5);
126 
127  m_SG[sg_index(0, 1)] = gmset->get_GM(gmset->SIGMA12);
128  m_SG[sg_index(1, 2)] = gmset->get_GM(gmset->SIGMA23);
129  m_SG[sg_index(2, 0)] = gmset->get_GM(gmset->SIGMA31);
130  m_SG[sg_index(3, 0)] = gmset->get_GM(gmset->SIGMA41);
131  m_SG[sg_index(3, 1)] = gmset->get_GM(gmset->SIGMA42);
132  m_SG[sg_index(3, 2)] = gmset->get_GM(gmset->SIGMA43);
133 
134  m_SG[sg_index(1, 0)] = m_SG[sg_index(0, 1)].mult(-1);
135  m_SG[sg_index(2, 1)] = m_SG[sg_index(1, 2)].mult(-1);
136  m_SG[sg_index(0, 2)] = m_SG[sg_index(2, 0)].mult(-1);
137  m_SG[sg_index(0, 3)] = m_SG[sg_index(3, 0)].mult(-1);
138  m_SG[sg_index(1, 3)] = m_SG[sg_index(3, 1)].mult(-1);
139  m_SG[sg_index(2, 3)] = m_SG[sg_index(3, 2)].mult(-1);
140 
141  m_SG[sg_index(0, 0)] = gmset->get_GM(gmset->UNITY);
142  m_SG[sg_index(1, 1)] = gmset->get_GM(gmset->UNITY);
143  m_SG[sg_index(2, 2)] = gmset->get_GM(gmset->UNITY);
144  m_SG[sg_index(3, 3)] = gmset->get_GM(gmset->UNITY);
145  // these 4 gamma matrices are actually not used.
146 
147  delete gmset;
148 }
149 
150 
151 //====================================================================
153 {
154  // nothing to do.
155 }
156 
157 
158 //====================================================================
159 void Fopr_CloverTerm::mult_gm5(Field& v, const Field& f)
160 {
161  assert(v.nvol() == f.nvol());
162  assert(v.nex() == f.nex());
163  assert(v.nin() == f.nin());
164 
165  Field_F vt(f.nvol(), f.nex());
166 
167  vt.mult_GM(m_GM5, (Field_F)f);
168  v = (Field)vt;
169 }
170 
171 
172 //====================================================================
174  const int mu, const int nu)
175 {
176  assert(mu != nu);
177  v.mult_iGM(m_SG[sg_index(mu, nu)], w);
178 }
179 
180 
181 //====================================================================
182 void Fopr_CloverTerm::mult_sigmaF(Field& v, const Field& f)
183 {
184  mult_csw(v, f);
185 }
186 
187 
188 //====================================================================
189 void Fopr_CloverTerm::mult_csw(Field& v, const Field& w)
190 {
191  int Nc = CommonParameters::Nc();
192  int Nd = CommonParameters::Nd();
193  int Nvol = w.nvol();
194 
195  Field_F wt(Nvol, 1), vt(Nvol, 1);
196 
197  vt = 0.0;
198 
199  wt.mult_iGM(m_SG[sg_index(1, 2)], (Field_F)w);
200  vt.multadd_Field_Gn(0, m_Bx, 0, wt, 0, 1.0);
201 
202  wt.mult_iGM(m_SG[sg_index(2, 0)], (Field_F)w);
203  vt.multadd_Field_Gn(0, m_By, 0, wt, 0, 1.0);
204 
205  wt.mult_iGM(m_SG[sg_index(0, 1)], (Field_F)w);
206  vt.multadd_Field_Gn(0, m_Bz, 0, wt, 0, 1.0);
207 
208  wt.mult_iGM(m_SG[sg_index(3, 0)], (Field_F)w);
209  vt.multadd_Field_Gn(0, m_Ex, 0, wt, 0, 1.0);
210 
211  wt.mult_iGM(m_SG[sg_index(3, 1)], (Field_F)w);
212  vt.multadd_Field_Gn(0, m_Ey, 0, wt, 0, 1.0);
213 
214  wt.mult_iGM(m_SG[sg_index(3, 2)], (Field_F)w);
215  vt.multadd_Field_Gn(0, m_Ez, 0, wt, 0, 1.0);
216 
217  vt *= m_kappa * m_cSW;
218 
219  v = (Field)vt;
220 }
221 
222 
223 //====================================================================
225 {
226  set_fieldstrength(m_Bx, 1, 2);
227  set_fieldstrength(m_By, 2, 0);
228  set_fieldstrength(m_Bz, 0, 1);
229  set_fieldstrength(m_Ex, 3, 0);
230  set_fieldstrength(m_Ey, 3, 1);
231  set_fieldstrength(m_Ez, 3, 2);
232 }
233 
234 
235 //====================================================================
237  const int mu, const int nu)
238 {
239  int Nvol = CommonParameters::Nvol();
240 
241  Staples staple;
242 
243  Field_G Cup(Nvol, 1), Cdn(Nvol, 1);
244  Field_G Umu(Nvol, 1);
245  Field_G v(Nvol, 1), v2(Nvol, 1);
246 
247  Cup = staple.upper(*m_U, mu, nu);
248  Cdn = staple.lower(*m_U, mu, nu);
249  Umu.setpart_ex(0, *m_U, mu);
250 
251  Fst.mult_Field_Gnd(0, Umu, 0, Cup, 0);
252  Fst.multadd_Field_Gnd(0, Umu, 0, Cdn, 0, -1.0);
253 
254  v.mult_Field_Gdn(0, Cup, 0, Umu, 0);
255  v.multadd_Field_Gdn(0, Cdn, 0, Umu, 0, -1.0);
256 
257  m_shift.forward(v2, v, mu);
258 
259  Fst += v2;
260 
261  Fst.ah_Field_G(0);
262  Fst *= 0.25;
263 }
264 
265 
266 //====================================================================
267 //============================================================END=====