Bridge++  Ver. 2.0.2
force_F_Overlap_Nf2.cpp
Go to the documentation of this file.
1 
14 #include "force_F_Overlap_Nf2.h"
15 
16 const std::string Force_F_Overlap_Nf2::class_name = "Force_F_Overlap_Nf2";
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 mq, M0;
28  int Np;
29  double x_min, x_max;
30  int Niter_ms;
31  double Stop_cond_ms;
32  std::vector<int> bc;
33 
34  int err = 0;
35  err += params.fetch_double("quark_mass", mq);
36  err += params.fetch_double("domain_wall_height", M0);
37  err += params.fetch_int("number_of_poles", Np);
38  err += params.fetch_double("lower_bound", x_min);
39  err += params.fetch_double("upper_bound", x_max);
40  err += params.fetch_int("maximum_number_of_iteration", Niter_ms);
41  err += params.fetch_double("convergence_criterion_squared", Stop_cond_ms);
42  err += params.fetch_int_vector("boundary_condition", bc);
43 
44  if (err) {
45  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
46  exit(EXIT_FAILURE);
47  }
48 
49 
50  set_parameters(mq, M0, Np, x_min, x_max, Niter_ms, Stop_cond_ms, bc);
51 }
52 
53 
54 //====================================================================
56 {
57  params.set_double("quark_mass", m_mq);
58  params.set_double("domain_wall_height", m_M0);
59  params.set_int("number_of_poles", m_Np);
60  params.set_double("lower_bound", m_x_min);
61  params.set_double("upper_bound", m_x_max);
62  params.set_int("maximum_number_of_iteration", m_Niter_ms);
63  params.set_double("convergence_criterion_squared", m_Stop_cond_ms);
64  params.set_int_vector("boundary_condition", m_boundary);
65 
66  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
67 }
68 
69 
70 //====================================================================
71 void Force_F_Overlap_Nf2::set_parameters(const double mq, const double M0,
72  const int Np, const double x_min, const double x_max,
73  const int Niter_ms, const double Stop_cond_ms,
74  const std::vector<int> bc)
75 {
76  const int Ndim = CommonParameters::Ndim();
77 
78  //- print input parameters
79  vout.general(m_vl, "Paramters of %s:\n", class_name.c_str());
80  vout.general(m_vl, " mq = %12.8f\n", mq);
81  vout.general(m_vl, " M0 = %12.8f\n", M0);
82  vout.general(m_vl, " Np = %4d\n", Np);
83  vout.general(m_vl, " x_min = %12.8f\n", x_min);
84  vout.general(m_vl, " x_max = %12.8f\n", x_max);
85  vout.general(m_vl, " Niter_ms = %6d\n", Niter_ms);
86  vout.general(m_vl, " Stop_cond_ms = %8.2e\n", Stop_cond_ms);
87  for (int mu = 0; mu < Ndim; ++mu) {
88  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
89  }
90 
91  //- range check
92  int err = 0;
93  err += ParameterCheck::non_zero(M0);
94  err += ParameterCheck::non_zero(mq);
95  err += ParameterCheck::non_zero(Np);
96  // NB. x_min,x_max == 0 is allowed.
97  err += ParameterCheck::non_zero(Niter_ms);
98  err += ParameterCheck::square_non_zero(Stop_cond_ms);
99 
100  if (err) {
101  vout.crucial(m_vl, "Error at %s: parameter range check failed.\n", class_name.c_str());
102  exit(EXIT_FAILURE);
103  }
104 
105  assert(bc.size() == Ndim);
106 
107  //- store values
108  m_M0 = M0;
109  m_mq = mq;
110  m_Np = Np;
111  m_x_min = x_min;
112  m_x_max = x_max;
113  m_Niter_ms = Niter_ms;
114  m_Stop_cond_ms = Stop_cond_ms;
115 
116  m_boundary.resize(Ndim);
117  m_boundary = bc;
118 
119  //- post-process
120  m_kappa = 0.5 / (4.0 - m_M0);
121 
122  m_fopr_w = new Fopr_Wilson();
125 
129 
130  //- Zolotarev coefficients
131  m_sigma.resize(m_Np);
132  m_cl.resize(2 * m_Np);
133  m_bl.resize(m_Np);
134 }
135 
136 
137 //====================================================================
138 void Force_F_Overlap_Nf2::force_core(Field& force_, const Field& psi)
139 {
140  //- solving psi = (H^2)^(-1) phi
141  Field_F psi5;
142 
143  m_fopr_w->mult_gm5(psi5, psi);
144 
145  double ff = m_M0 * m_M0 - 0.25 * m_mq * m_mq;
146  scal(psi5, ff);
147 
148  // force determination
149  force_core1(force_, psi, psi5);
150  scal(force_, -1.0);
151 }
152 
153 
154 //====================================================================
156 {
157  vout.crucial(m_vl, "Error at %s: not implemented.\n", __func__);
158  exit(EXIT_FAILURE);
159 }
160 
161 
162 //====================================================================
163 void Force_F_Overlap_Nf2::force_core1(Field& force_, const Field& psi_, const Field& psi5_)
164 {
165  const int Nvol = CommonParameters::Nvol();
166  const int Ndim = CommonParameters::Ndim();
167 
168  Field_G force(Nvol, Ndim);
169  Field_F psi(psi_);
170  Field_F psi5(psi5_);
171 
172  force_core1_impl(force, psi, psi5);
173 
174  force_ = force;
175 }
176 
177 
178 //====================================================================
179 void Force_F_Overlap_Nf2::force_core1_impl(Field_G& force, const Field_F& psi, const Field_F& psi5)
180 {
181  const int Nc = CommonParameters::Nc();
182  const int Nd = CommonParameters::Nd();
183  const int Nvol = CommonParameters::Nvol();
184  const int Ndim = CommonParameters::Ndim();
185  const int NinF = 2 * Nc * Nd;
186 
187  //- Zolotarev coefficient defined
188  double bmax = m_x_max / m_x_min;
189  Math_Sign_Zolotarev sign_func(m_Np, bmax);
190 
191  sign_func.get_sign_parameters(m_cl, m_bl);
192 
193  for (int i = 0; i < m_Np; ++i) {
194  m_sigma[i] = m_cl[2 * i] * m_x_min * m_x_min;
195  }
196 
197  for (int i = 0; i < m_Np; ++i) {
198  vout.general(m_vl, " %3d %12.4e %12.4e %12.4e\n",
199  i, m_cl[i], m_cl[i + m_Np], m_bl[i]);
200  }
201 
202  //- Shiftsolver
203  const int Nshift = m_Np;
204 
205  std::vector<Field> psi_l(Nshift);
206  for (int i = 0; i < Nshift; ++i) {
207  psi_l[i].reset(NinF, Nvol, 1);
208  }
209 
210  std::vector<Field> psi5_l(Nshift);
211  for (int i = 0; i < Nshift; ++i) {
212  psi5_l[i].reset(NinF, Nvol, 1);
213  }
214 
215  vout.general(m_vl, "Shift solver in MD\n");
216  vout.general(m_vl, " Number of shift values = %d\n", m_sigma.size());
217 
218  m_fopr_w->set_mode("DdagD");
219 
220  {
222  int Nconv;
223  double diff;
224  solver.solve(psi_l, m_sigma, psi, Nconv, diff);
225  solver.solve(psi5_l, m_sigma, psi5, Nconv, diff);
226  }
227 
228  force.set(0.0);
229 
230  Field_F psid;
231  psid.set(0.0);
232 
233  Field_F psi5d;
234  psi5d.set(0.0);
235 
236  Field_F w1, w2;
237  Field_G force1(Nvol, Ndim);
238 
239  for (int ip = 0; ip < m_Np; ++ip) {
240  psid.addpart_ex(0, psi_l[ip], 0, m_bl[ip]);
241  psi5d.addpart_ex(0, psi5_l[ip], 0, m_bl[ip]);
242 
243  m_fopr_w->set_mode("H");
244  m_fopr_w->mult(w1, psi_l[ip]);
245  m_fopr_w->mult(w2, psi5_l[ip]);
246 
247  double coeff_l = (m_cl[2 * ip] - m_cl[2 * m_Np - 1]) * m_bl[ip] * m_x_min;
248 
249  //- first term
250  Field_F w3;
251  m_fopr_w->mult(w3, w2);
252  Field_F w4 = (Field_F)psi_l[ip]; //-- convert Field to Field_F
253 
254  m_force_w->force_core1(force1, w3, w4);
255  axpy(force, coeff_l, force1);
256 
257  m_force_w->force_core1(force1, w2, w1);
258  axpy(force, coeff_l, force1);
259 
260  //- second term
261  m_fopr_w->mult(w3, w1);
262  w4 = (Field_F)psi5_l[ip]; //-- convert Field to Field_F
263 
264  m_force_w->force_core1(force1, w3, w4);
265  axpy(force, coeff_l, force1);
266  m_force_w->force_core1(force1, w1, w2);
267  axpy(force, coeff_l, force1);
268  }
269 
270  double coeff1 = m_cl[2 * m_Np - 1] * m_x_min * m_x_min;
271  double coeff2 = 1.0 / m_x_min;
272 
273  //- first term
274  m_fopr_w->mult(w1, psid);
275  m_fopr_w->mult(w2, w1);
276  w2.addpart_ex(0, psid, 0, coeff1);
277 
278  m_force_w->force_core1(force1, psi5, w2);
279  axpy(force, coeff2, force1);
280 
281  //- second term
282  m_fopr_w->mult(w1, psi5d);
283  m_fopr_w->mult(w2, w1);
284  w2.addpart_ex(0, psi5d, 0, coeff1);
285 
286  m_force_w->force_core1(force1, psi, w2);
287  axpy(force, coeff2, force1);
288 }
289 
290 
291 //====================================================================
292 void Force_F_Overlap_Nf2::force_udiv1(Field& force_, const Field& psi_, const Field& psi5_)
293 {
294  vout.crucial(m_vl, "Error at %s: not implemented.\n", __func__);
295  exit(EXIT_FAILURE);
296 }
297 
298 
299 //====================================================================
300 //===========================================================END======
Force_F_Overlap_Nf2::class_name
static const std::string class_name
Definition: force_F_Overlap_Nf2.h:43
Org::Fopr_Wilson::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_Wilson_impl.cpp:200
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
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
Force::force_core1
virtual void force_core1(Field &, const Field &, const Field &)
Definition: force_F.cpp:34
Math_Sign_Zolotarev::get_sign_parameters
void get_sign_parameters(std::vector< double > &cl, std::vector< double > &bl)
Definition: math_Sign_Zolotarev.cpp:25
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
Force_F_Overlap_Nf2::m_fopr_w
Fopr_Wilson * m_fopr_w
Definition: force_F_Overlap_Nf2.h:59
Force_F_Overlap_Nf2::force_core1
void force_core1(Field &, const Field &, const Field &)
Definition: force_F_Overlap_Nf2.cpp:163
Force_F_Overlap_Nf2::set_parameters
void set_parameters()
Force_F_Overlap_Nf2::m_bl
std::vector< double > m_bl
Definition: force_F_Overlap_Nf2.h:64
Force_F_Overlap_Nf2::m_boundary
std::vector< int > m_boundary
Definition: force_F_Overlap_Nf2.h:55
Force_F_Overlap_Nf2::m_Niter_ms
int m_Niter_ms
Definition: force_F_Overlap_Nf2.h:52
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Force_F_Overlap_Nf2::force_core
void force_core(Field &, const Field &)
Definition: force_F_Overlap_Nf2.cpp:138
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
Force_F_Overlap_Nf2::m_cl
std::vector< double > m_cl
Definition: force_F_Overlap_Nf2.h:63
Force_F_Overlap_Nf2::m_Np
int m_Np
Definition: force_F_Overlap_Nf2.h:49
Force_F_Overlap_Nf2::m_sigma
std::vector< double > m_sigma
Definition: force_F_Overlap_Nf2.h:65
Force::m_U
Field_G * m_U
Definition: force_F.h:66
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
Parameters::fetch_int_vector
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
Force_F_Overlap_Nf2::m_x_min
double m_x_min
Definition: force_F_Overlap_Nf2.h:50
Org::Fopr_Wilson::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_Wilson_impl.cpp:127
Force_F_Overlap_Nf2::m_kappa
double m_kappa
Definition: force_F_Overlap_Nf2.h:57
Force_F_Overlap_Nf2::get_parameters
void get_parameters(Parameters &params) const
Definition: force_F_Overlap_Nf2.cpp:55
ParameterCheck::square_non_zero
int square_non_zero(const double v)
Definition: parameterCheck.cpp:43
Force_F_Overlap_Nf2::force_udiv
void force_udiv(Field &, const Field &)
Definition: force_F_Overlap_Nf2.cpp:155
force_F_Overlap_Nf2.h
Org::Fopr_Wilson::mult
void mult(Field &v, const Field &w)
multiplies fermion operator to a given field.
Definition: fopr_Wilson_impl.cpp:210
Force_F_Overlap_Nf2::force_udiv1
void force_udiv1(Field &, const Field &, const Field &)
Definition: force_F_Overlap_Nf2.cpp:292
Force_F_Overlap_Nf2::force_core1_impl
void force_core1_impl(Field_G &, const Field_F &, const Field_F &)
Definition: force_F_Overlap_Nf2.cpp:179
Test_Solver_Wilson::solver
int solver(const std::string &)
Definition: test_Solver_Wilson.cpp:134
Force_F_Overlap_Nf2::m_mq
double m_mq
Definition: force_F_Overlap_Nf2.h:48
Parameters::set_int_vector
void set_int_vector(const string &key, const vector< int > &value)
Definition: parameters.cpp:45
Org::Fopr_Wilson::mult_gm5
void mult_gm5(Field &v, const Field &w)
multiplies gamma_5 matrix.
Definition: fopr_Wilson_impl.cpp:370
Force_F_Overlap_Nf2::m_M0
double m_M0
Definition: force_F_Overlap_Nf2.h:48
CommonParameters::Nd
static int Nd()
Definition: commonParameters.h:116
Force_F_Wilson_Nf2::set_parameters
void set_parameters(const Parameters &params)
Definition: force_F_Wilson_Nf2.cpp:19
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
ParameterCheck::non_zero
int non_zero(const double v)
Definition: parameterCheck.cpp:32
Force_F_Overlap_Nf2::m_force_w
Force_F_Wilson_Nf2 * m_force_w
Definition: force_F_Overlap_Nf2.h:60
Parameters::set_int
void set_int(const string &key, const int value)
Definition: parameters.cpp:36
Force_F_Overlap_Nf2::m_Stop_cond_ms
double m_Stop_cond_ms
Definition: force_F_Overlap_Nf2.h:53
scal
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:261
Org::Fopr_Wilson::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: fopr_Wilson_impl.cpp:188
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Force_F_Wilson_Nf2
Force for the standard Wilson fermion operator.
Definition: force_F_Wilson_Nf2.h:38
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_Overlap_Nf2::m_vl
Bridge::VerboseLevel m_vl
Definition: force_F_Overlap_Nf2.h:46
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Field
Container of Field-type object.
Definition: field.h:46
Force_F_Overlap_Nf2::m_x_max
double m_x_max
Definition: force_F_Overlap_Nf2.h:50
AShiftsolver_CG
Multishift Conjugate Gradient solver.
Definition: ashiftsolver_CG.h:32
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Parameters::fetch_int
int fetch_int(const string &key, int &value) const
Definition: parameters.cpp:346
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Force_F_Wilson_Nf2::set_config
void set_config(Field *U)
Definition: force_F_Wilson_Nf2.h:96
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
Fopr_Wilson
Org::Fopr_Wilson Fopr_Wilson
Wilson fermion operator.
Definition: fopr_Wilson.h:50
Math_Sign_Zolotarev
Determination of Zolotarev coefficients.
Definition: math_Sign_Zolotarev.h:36