Bridge++  Ver. 2.0.2
force_F_Rational.cpp
Go to the documentation of this file.
1 
14 #include "force_F_Rational.h"
16 
17 const std::string Force_F_Rational::class_name = "Force_F_Rational";
18 
19 //====================================================================
21 {
22  std::string vlevel;
23  if (!params.fetch_string("verbose_level", vlevel)) {
24  m_vl = vout.set_verbose_level(vlevel);
25  }
26 
27  //- fetch and check input parameters
28  int Np, n_exp, d_exp;
29  double x_min, x_max;
30  int Niter;
31  double Stop_cond;
32 
33  int err = 0;
34  err += params.fetch_int("number_of_poles", Np);
35  err += params.fetch_int("exponent_numerator", n_exp);
36  err += params.fetch_int("exponent_denominator", d_exp);
37  err += params.fetch_double("lower_bound", x_min);
38  err += params.fetch_double("upper_bound", x_max);
39  err += params.fetch_int("maximum_number_of_iteration", Niter);
40  err += params.fetch_double("convergence_criterion_squared", Stop_cond);
41 
42  if (err) {
43  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
44  exit(EXIT_FAILURE);
45  }
46 
47 
48  set_parameters(Np, n_exp, d_exp, x_min, x_max, Niter, Stop_cond);
49 }
50 
51 
52 //====================================================================
54 {
55  params.set_int("number_of_poles", m_Np);
56  params.set_int("exponent_numerator", m_n_exp);
57  params.set_int("exponent_denominator", m_d_exp);
58  params.set_double("lower_bound", m_x_min);
59  params.set_double("upper_bound", m_x_max);
60  params.set_int("maximum_number_of_iteration", m_Niter);
61  params.set_double("convergence_criterion_squared", m_Stop_cond);
62 
63  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
64 }
65 
66 
67 //====================================================================
68 void Force_F_Rational::set_parameters(const int Np, const int n_exp, const int d_exp,
69  const double x_min, const double x_max,
70  const int Niter, const double Stop_cond)
71 {
72  //- print input parameters
73  vout.general(m_vl, "%s:\n", class_name.c_str());
74  vout.general(m_vl, " Np = %d\n", Np);
75  vout.general(m_vl, " n_exp = %d\n", n_exp);
76  vout.general(m_vl, " d_exp = %d\n", d_exp);
77  vout.general(m_vl, " x_min = %12.8f\n", x_min);
78  vout.general(m_vl, " x_max = %12.8f\n", x_max);
79  vout.general(m_vl, " Niter = %d\n", Niter);
80  vout.general(m_vl, " Stop_cond = %8.2e\n", Stop_cond);
81 
82  //- range check
83  int err = 0;
84  err += ParameterCheck::non_zero(Np);
85  err += ParameterCheck::non_zero(n_exp);
86  err += ParameterCheck::non_zero(d_exp);
87  // NB. x_min,x_max=0 is allowed.
88  err += ParameterCheck::non_zero(Niter);
89  err += ParameterCheck::square_non_zero(Stop_cond);
90 
91  if (err) {
92  vout.crucial(m_vl, "Error at %s: parameter range check failed.\n", class_name.c_str());
93  exit(EXIT_FAILURE);
94  }
95 
96  //- store values
97  m_Np = Np;
98  m_n_exp = n_exp;
99  m_d_exp = d_exp;
100  m_x_min = x_min;
101  m_x_max = x_max;
102  m_Niter = Niter;
103  m_Stop_cond = Stop_cond;
104 
105  //- post-process
106  m_cl.resize(m_Np);
107  m_bl.resize(m_Np);
108 
109  //- Rational approximation
110  const double x_min2 = m_x_min * m_x_min;
111  const double x_max2 = m_x_max * m_x_max;
112 
113  Math_Rational rational;
114  rational.set_parameters(m_Np, m_n_exp, m_d_exp, x_min2, x_max2);
115  rational.get_parameters(m_a0, m_bl, m_cl);
116 
117  vout.general(m_vl, " a0 = %18.14f\n", m_a0);
118  for (int i = 0; i < m_Np; i++) {
119  vout.general(m_vl, " bl[%d] = %18.14f cl[%d] = %18.14f\n",
120  i, m_bl[i], i, m_cl[i]);
121  }
122 }
123 
124 
125 //====================================================================
126 void Force_F_Rational::force_udiv(Field& force_, const Field& eta_)
127 {
128  const int Nvol = CommonParameters::Nvol();
129  const int Ndim = CommonParameters::Ndim();
130 
131  Field_G force(Nvol, Ndim);
132  Field_F eta(eta_);
133 
134  force_udiv_impl(force, eta);
135 
136  copy(force_, force); // force_ = force;
137 }
138 
139 
140 //====================================================================
142 {
143  const int Nvol = CommonParameters::Nvol();
144  const int Ndim = CommonParameters::Ndim();
145 
146  const int NinF = eta.nin();
147  const int NvolF = eta.nvol();
148  const int NexF = eta.nex();
149 
150  //- Shiftsolver
151  const int Nshift = m_Np;
152 
153  std::vector<Field> psi(Nshift);
154 
155  for (int i = 0; i < Nshift; ++i) {
156  psi[i].reset(NinF, NvolF, NexF);
157  }
158 
159  vout.general(m_vl, " Shift solver in force calculation\n");
160  vout.general(m_vl, " Number of shift values = %d\n", m_cl.size());
161  m_fopr->set_mode("DdagD");
162 
164  int Nconv;
165  double diff;
166  solver.solve(psi, m_cl, eta, Nconv, diff);
167  vout.general(m_vl, " diff(max) = %22.15e \n", diff);
168 
169  force.set(0.0);
170 
171  for (int i = 0; i < Nshift; ++i) {
172  Field_G force1(Nvol, Ndim);
173  m_force->force_udiv(force1, psi[i]);
174  scal(force1, m_bl[i]); // force1 *= m_bl[i];
175  axpy(force, 1.0, force1); // force += force1;
176  }
177 }
178 
179 
180 //====================================================================
182 {
183  vout.crucial(m_vl, "Error at %s: not implemented.\n", __func__);
184  exit(EXIT_FAILURE);
185 }
186 
187 
188 //====================================================================
190 {
191  vout.crucial(m_vl, "Error at %s: not implemented.\n", __func__);
192  exit(EXIT_FAILURE);
193 }
194 
195 
196 //====================================================================
197 //===========================================================END======
Force_F_Rational::m_Niter
int m_Niter
Definition: force_F_Rational.h:50
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
force_F_Rational.h
Force_F_Rational::m_Stop_cond
double m_Stop_cond
Definition: force_F_Rational.h:51
Parameters
Class for parameters.
Definition: parameters.h:46
Force_F_Rational::m_d_exp
int m_d_exp
Definition: force_F_Rational.h:48
Force_F_Rational::force_udiv_impl
void force_udiv_impl(Field_G &, const Field_F &)
Definition: force_F_Rational.cpp:141
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
Force_F_Rational::force_udiv
void force_udiv(Field &, const Field &)
Definition: force_F_Rational.cpp:126
Field::nex
int nex() const
Definition: field.h:128
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Math_Rational::get_parameters
void get_parameters(double &norm, std::vector< double > &res, std::vector< double > &pole)
Definition: math_Rational.cpp:100
Force_F_Rational::force_udiv1
void force_udiv1(Field &, const Field &, const Field &)
Definition: force_F_Rational.cpp:189
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_Rational::m_n_exp
int m_n_exp
Definition: force_F_Rational.h:48
shiftsolver_CG.h
AFopr::set_mode
virtual void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: afopr.h:81
Field::nin
int nin() const
Definition: field.h:126
Force_F_Rational::m_a0
double m_a0
Definition: force_F_Rational.h:58
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
Math_Rational::set_parameters
void set_parameters(const Parameters &params)
Definition: math_Rational.cpp:20
Force_F_Rational::class_name
static const std::string class_name
Definition: force_F_Rational.h:42
Force_F_Rational::m_bl
std::vector< double > m_bl
Definition: force_F_Rational.h:59
Force_F_Rational::m_x_max
double m_x_max
Definition: force_F_Rational.h:49
Force_F_Rational::m_Np
int m_Np
Definition: force_F_Rational.h:47
ParameterCheck::square_non_zero
int square_non_zero(const double v)
Definition: parameterCheck.cpp:43
Field::nvol
int nvol() const
Definition: field.h:127
Force_F_Rational::set_parameters
void set_parameters(const Parameters &params)
Definition: force_F_Rational.cpp:20
Test_Solver_Wilson::solver
int solver(const std::string &)
Definition: test_Solver_Wilson.cpp:134
Force_F_Rational::force_core1
void force_core1(Field &, const Field &, const Field &)
Definition: force_F_Rational.cpp:181
Force_F_Rational::m_x_min
double m_x_min
Definition: force_F_Rational.h:49
Force_F_Rational::m_cl
std::vector< double > m_cl
Definition: force_F_Rational.h:60
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_Rational::m_force
Force * m_force
Definition: force_F_Rational.h:55
Parameters::set_int
void set_int(const string &key, const int value)
Definition: parameters.cpp:36
Force::force_udiv
virtual void force_udiv(Field &, const Field &)
Definition: force_F.h:59
scal
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:261
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_Rational::m_vl
Bridge::VerboseLevel m_vl
Definition: force_F_Rational.h:45
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Field
Container of Field-type object.
Definition: field.h:46
AShiftsolver_CG
Multishift Conjugate Gradient solver.
Definition: ashiftsolver_CG.h:32
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Force_F_Rational::m_fopr
Fopr * m_fopr
Definition: force_F_Rational.h:54
Math_Rational
Determionation of coefficients of rational approximation.
Definition: math_Rational.h:40
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_Rational::get_parameters
void get_parameters(Parameters &params) const
Definition: force_F_Rational.cpp:53
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