Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_SF_fAfP_Boundary_Meson_2ptFunction.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "Fopr/fopr_Clover_SF.h"
17 #include "Fopr/fopr_Smeared.h"
18 
19 #include "IO/gaugeConfig.h"
20 
24 
25 #include "Tools/gammaMatrixSet.h"
27 
28 //====================================================================
29 
47 namespace Test_SF_fAfP {
48  const std::string test_name = "SF_fAfP.Boundary_Meson_2ptFunction";
49 
50  //- test-private parameters
51  namespace {
52  const std::string filename_input = "test_SF_fAfP_Boundary_Meson_2ptFunction.yaml";
53  }
54 
55  //- prototype declaration
57 
58 #ifdef USE_TESTMANAGER_AUTOREGISTER
59  namespace {
60 #if defined(USE_OPENMP) || defined(USE_GROUP_SU2)
61  // Nc=2 is not available.
62 #else
63  static const bool is_registered = TestManager::RegisterTest(
64  test_name,
66  );
67 #endif
68  }
69 #endif
70 
71  //====================================================================
73  {
74  // ##### parameter setup #####
75  const int Nc = CommonParameters::Nc();
76  const int Nd = CommonParameters::Nd();
77  const int Ndim = CommonParameters::Ndim();
78  const int Nvol = CommonParameters::Nvol();
79 
80  const Parameters params_all = ParameterManager::read(filename_input);
81 
82  const Parameters params_test = params_all.lookup("Test_SF_fAfP");
83  const Parameters params_clover = params_all.lookup("Fopr_Clover_SF");
84  const Parameters params_proj = params_all.lookup("Projection");
85  const Parameters params_smear = params_all.lookup("Smear_SF");
86  const Parameters params_dr_smear = params_all.lookup("Director_Smear");
87  const Parameters params_solver = params_all.lookup("Solver");
88  const Parameters params_source = params_all.lookup("Source_Wall_SF");
89 
90  const string str_gconf_status = params_test.get_string("gauge_config_status");
91  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
92  const string readfile = params_test.get_string("config_filename_input");
93  const string str_rand_type = params_test.get_string("random_number_type");
94  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
95  const string str_vlevel = params_test.get_string("verbose_level");
96 
97  const bool do_check = params_test.is_set("expected_result");
98  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
99 
100  const string str_gmset_type = params_clover.get_string("gamma_matrix_type");
101  const string str_proj_type = params_proj.get_string("projection_type");
102  const string str_smear_type = params_smear.get_string("smear_type");
103  const string str_solver_type = params_solver.get_string("solver_type");
104 
105  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
106 
107  //- print input parameters
108  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
109  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
110  vout.general(vl, " readfile = %s\n", readfile.c_str());
111  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
112  vout.general(vl, " seed = %lu\n", seed);
113  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
114  vout.general(vl, " gmset_type = %s\n", str_gmset_type.c_str());
115  vout.general(vl, " proj_type = %s\n", str_proj_type.c_str());
116  vout.general(vl, " smear_type = %s\n", str_smear_type.c_str());
117  vout.general(vl, " solver_type = %s\n", str_solver_type.c_str());
118  vout.general(vl, "\n");
119 
120  //- input parameter check
121  int err = 0;
122  err += ParameterCheck::non_NULL(str_gconf_status);
123 
124  if (err) {
125  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
126  exit(EXIT_FAILURE);
127  }
128 
129 
130  RandomNumberManager::initialize(str_rand_type, seed);
131 
132 
133  // #### Set up a gauge configuration ####
134  unique_ptr<Field_G> U(new Field_G(Nvol, Ndim));
135 
136  if (str_gconf_status == "Continue") {
137  GaugeConfig(str_gconf_read).read(U, readfile);
138  } else if (str_gconf_status == "Cold_start") {
139  GaugeConfig("Unit").read(U);
140  } else if (str_gconf_status == "Hot_start") {
141  GaugeConfig("Random").read(U);
142  } else {
143  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
144  exit(EXIT_FAILURE);
145  }
146 
147  unique_ptr<Projection> proj(Projection::New(str_proj_type));
148  proj->set_parameters(params_proj);
149 
150  unique_ptr<Smear> smear(Smear::New(str_smear_type, proj));
151  smear->set_parameters(params_smear);
152 
153  unique_ptr<Director> dr_smear(new Director_Smear(smear));
154  dr_smear->set_parameters(params_dr_smear);
155  dr_smear->set_config(U);
156 
157  const unique_ptr<Director_Smear> dr_smear_config(new Director_Smear(smear));
158  dr_smear_config->set_parameters(params_dr_smear);
159  dr_smear_config->set_config(U);
160 
161  const int Nsmear = dr_smear_config->get_Nsmear();
162  Field_G *Usmear = (Field_G *)dr_smear_config->getptr_smearedConfig(Nsmear);
163 
164 
165  // #### object setup #####
166  unique_ptr<GammaMatrixSet> gmset(GammaMatrixSet::New(str_gmset_type));
167 
168  //- NB. Chiral repr has not been implemented for SF, yet.
169  // unique_ptr<Fopr> fopr_c(Fopr::New("Clover_SF", str_gmset_type));
170  unique_ptr<Fopr> fopr_c(new Fopr_Clover_SF());
171  fopr_c->set_parameters(params_clover);
172 
173  unique_ptr<Fopr> fopr_smear(Fopr::New("Smeared", fopr_c, dr_smear));
174  //- NB. U will be converted to Usmear in fopr->set_config
175  fopr_smear->set_config(U);
176 
177  unique_ptr<Solver> solver(Solver::New(str_solver_type, fopr_smear));
178  solver->set_parameters(params_solver);
179 
180  const unique_ptr<Fprop> fprop_lex(new Fprop_Standard_lex(solver));
181 
182  const unique_ptr<Source_Wall_SF> source(new Source_Wall_SF());
183  source->set_parameters(params_source);
184  source->set_config(Usmear);
185 
186  const unique_ptr<Timer> timer(new Timer(test_name));
187 
188 
189  // #### Execution main part ####
190  timer->start();
191 
192  std::vector<Field_F> H(Nc * Nd);
193  std::vector<Field_F> Hpr(Nc * Nd);
194 
195  vout.general(vl, "\n");
196  vout.general(vl, "Solving quark propagator:\n");
197  vout.general(vl, " color spin Nconv diff diff2\n");
198 
199  for (int icolor = 0; icolor < Nc; ++icolor) {
200  for (int ispin = 0; ispin < Nd / 2; ++ispin) {
201  Field_F b;
202  source->set_t0(b, icolor, ispin);
203 
204  int idx = icolor + Nc * ispin;
205 
206  Field_F xq;
207  int Nconv;
208  double diff;
209  fprop_lex->invert_D(xq, b, Nconv, diff);
210 
211  Field_F y(b);
212  fopr_smear->set_mode("D");
213 
214  fopr_smear->mult(y, xq); // y = fopr_w->mult(xq);
215  axpy(y, -1.0, b); // y -= b;
216  double diff2 = y.norm2();
217 
218  vout.general(vl, " %2d %2d %6d %12.4e %12.4e\n",
219  icolor, ispin, Nconv, diff, diff2);
220 
221  H[idx] = xq;
222  xq.set(0.0);
223  Hpr[idx] = xq;
224  }
225 
226  for (int ispin = Nd / 2; ispin < Nd; ++ispin) {
227  Field_F b;
228  source->set_tT(b, icolor, ispin);
229 
230  int idx = icolor + Nc * ispin;
231 
232  Field_F xq;
233  int Nconv;
234  double diff;
235  fprop_lex->invert_D(xq, b, Nconv, diff);
236 
237  Field_F y(b);
238  fopr_smear->set_mode("D");
239 
240  fopr_smear->mult(y, xq); // y = fopr_w->mult(xq);
241  axpy(y, -1.0, b); // y -= b;
242  double diff2 = y.norm2();
243 
244  vout.general(vl, " %2d %2d %6d %12.4e %12.4e\n",
245  icolor, ispin, Nconv, diff, diff2);
246 
247  Hpr[idx] = xq;
248  xq.set(0.0);
249  H[idx] = xq;
250  }
251  }
252 
253 #ifdef DEBUG
254  Index_lex index;
255  for (int t = 0; t < 2; ++t) {
256  int site = index.site(0, 0, 0, t);
257  for (int c1 = 0; c1 < Nc; ++c1) {
258  for (int c0 = 0; c0 < Nc; ++c0) {
259  for (int s1 = 0; s1 < Nd; ++s1) {
260  for (int s0 = 0; s0 < Nd; ++s0) {
261  vout.general(vl, "H[%d,%d,%d,%d,%d]=%lf %lf\n",
262  t, c1, c0, s1, s0,
263  H[c0 + Nc * s0].cmp_r(c1, s1, site),
264  H[c0 + Nc * s0].cmp_i(c1, s1, site));
265  }
266  }
267  }
268  }
269  }
270  for (int t = 0; t < 2; ++t) {
271  int site = index.site(0, 0, 0, t);
272  for (int c1 = 0; c1 < Nc; ++c1) {
273  for (int c0 = 0; c0 < Nc; ++c0) {
274  for (int s1 = 0; s1 < Nd; ++s1) {
275  for (int s0 = 0; s0 < Nd; ++s0) {
276  vout.general(vl, "Hpr[%d,%d,%d,%d,%d]=%lf %lf\n",
277  t, c1, c0, s1, s0,
278  Hpr[c0 + Nc * s0].cmp_r(c1, s1, site),
279  Hpr[c0 + Nc * s0].cmp_i(c1, s1, site));
280  }
281  }
282  }
283  }
284  }
285 #endif
286 
287  //- meson correlators
288  vout.general(vl, "\n");
289  vout.general(vl, "boundary 2-point correlator with SF BC:\n");
290 
291  Corr2pt_Wilson_SF corr(gmset);
292  const double result = corr.fAfP(H, Hpr);
293 
294  timer->report();
295 
297 
298 
299  if (do_check) {
300  return Test::verify(result, expected_result);
301  } else {
302  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
303  return EXIT_SKIP;
304  }
305  }
306 } // namespace Test_SF_fAfP
#define EXIT_SKIP
Definition: test.h:17
BridgeIO vout
Definition: bridgeIO.cpp:503
void set_config(Field *U)
setting pointer to configuration
void detailed(const char *format,...)
Definition: bridgeIO.cpp:216
double norm2() const
Definition: field.cpp:592
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
virtual void set_parameters(const Parameters &param)=0
int site(const int &x, const int &y, const int &z, const int &t) const
Definition: index_lex.h:53
Wall source for SF boundary propagator.
void general(const char *format,...)
Definition: bridgeIO.cpp:197
virtual void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: fopr.h:94
int solver(const std::string &)
virtual void set_config(Field *)=0
setting pointer to the gauge configuration.
Two-point correlator for Wilson-type fermions with SF BC.
virtual void set_parameters(const Parameters &)=0
Class for parameters.
Definition: parameters.h:46
Wilson-type fermion field.
Definition: field_F.h:37
virtual void set_parameters(const Parameters &params)=0
Parameters lookup(const string &key) const
Definition: parameters.h:79
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:69
virtual void invert_D(Field &, const Field &, int &, double &)=0
static bool initialize(const std::string &rng_type, unsigned long seed)
SU(N) gauge field.
Definition: field_G.h:38
void read(Field_G *U, const string &filename=string())
double fAfP(const std::vector< Field_F > &sq1, const std::vector< Field_F > &sq2)
unsigned long get_unsigned_long(const string &key) const
Definition: parameters.cpp:209
double get_double(const string &key) const
Definition: parameters.cpp:175
void set_parameters(const Parameters &params)
Lexical site index.
Definition: index_lex.h:34
virtual void set_parameters(const Parameters &)=0
void set_t0(Field_F &src, const int ic, const int id)
Set the 3D wall source at t=1.
int non_NULL(const std::string v)
bool is_set(const string &key) const
Definition: parameters.cpp:528
void start()
Definition: timer.cpp:44
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:319
Get quark propagator for Fopr with lexical site index.
void set_config(Field *U)
set pointer to original thin link variable
int get_Nsmear()
get number of applied smearing operation
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
virtual void set_parameters(const Parameters &params)=0
static void read(const std::string &params_file, Parameters &params)
void set_tT(Field_F &src, const int ic, const int id)
Set the 3D wall source at t=T-1.
Manager of smeared configurations.
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
Bridge::VerboseLevel vl
Field * getptr_smearedConfig(const int i_smear)
get pointer to i-th smeared config (0th is original thin link)
VerboseLevel
Definition: bridgeIO.h:42
virtual void mult(Field &, const Field &)=0
multiplies fermion operator to a given field (2nd argument)
void set_parameters(const Parameters &params)
set parameters, must be called before set_config
GaugeConfig class for file I/O of gauge configuration.
Definition: gaugeConfig.h:78
Definition: timer.h:31
string get_string(const string &key) const
Definition: parameters.cpp:221
virtual void set_config(Field *U)=0
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
Definition: timer.cpp:128
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
Clover fermion operator.