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