Bridge++  Ver. 1.2.x
 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 "gaugeConfig.h"
17 
18 #include "fopr_Clover_SF.h"
19 #include "source_Wall_SF.h"
20 
21 #include "director_Smear.h"
22 #include "fopr_Smeared.h"
23 
24 #include "gammaMatrixSet.h"
25 #include "projection.h"
26 #include "smear.h"
27 #include "solver.h"
28 
29 #include "fprop_Standard_lex.h"
30 
31 #include "corr2pt_Wilson_SF.h"
32 
33 #include "randomNumbers_Mseries.h"
34 
35 //====================================================================
36 
52 namespace Test_SF_fAfP {
53  const std::string test_name = "SF_fAfP.Boundary_Meson_2ptFunction";
54 
55  //- test-private parameters
56  namespace {
57  const std::string filename_input = "test_SF_fAfP_Boundary_Meson_2ptFunction.yaml";
58  const std::string filename_output = "stdout";
59 
60  class Parameters_Test_SF_fAfP : public Parameters {
61  public:
62  Parameters_Test_SF_fAfP()
63  {
64  Register_string("gauge_config_status", "NULL");
65  Register_string("gauge_config_type_input", "NULL");
66  Register_string("config_filename_input", "NULL");
67 
68  Register_string("verbose_level", "NULL");
69 
70  Register_double("expected_result", 0.0);
71  }
72  };
73  }
74 
75  //- prototype declaration
77 
78 #ifdef USE_TESTMANAGER_AUTOREGISTER
79  namespace {
80 #if defined(USE_OPENMP) || defined(USE_GROUP_SU2)
81  // Nc=2 is not available.
82 #else
83  static const bool is_registered = TestManager::RegisterTest(
84  test_name,
86  );
87 #endif
88  }
89 #endif
90 
91  //====================================================================
93  {
94  // ##### parameter setup #####
95  int Nc = CommonParameters::Nc();
96  int Nd = CommonParameters::Nd();
97  int Ndim = CommonParameters::Ndim();
98  int Nvol = CommonParameters::Nvol();
99 
100  Parameters *params_test = new Parameters_Test_SF_fAfP;
101  Parameters *params_clover = ParametersFactory::New("Fopr.Clover_SF");
102  Parameters *params_proj = ParametersFactory::New("Projection");
103  Parameters *params_smear = ParametersFactory::New("Smear");
104  Parameters *params_dr_smear = ParametersFactory::New("Director_Smear");
105  Parameters *params_solver = ParametersFactory::New("Solver");
106  Parameters *params_source = ParametersFactory::New("Source_Wall_SF");
107  Parameters *params_all = new Parameters;
108 
109  params_all->Register_Parameters("Test_SF_fAfP", params_test);
110  params_all->Register_Parameters("Fopr_Clover_SF", params_clover);
111  params_all->Register_Parameters("Projection", params_proj);
112  params_all->Register_Parameters("Smear_SF", params_smear);
113  params_all->Register_Parameters("Director_Smear", params_dr_smear);
114  params_all->Register_Parameters("Solver", params_solver);
115  params_all->Register_Parameters("Source_Wall_SF", params_source);
116 
117  ParameterManager_YAML params_manager;
118  params_manager.read_params(filename_input, params_all);
119 
120  const string str_gconf_status = params_test->get_string("gauge_config_status");
121  const string str_gconf_read = params_test->get_string("gauge_config_type_input");
122  const string readfile = params_test->get_string("config_filename_input");
123  const string str_vlevel = params_test->get_string("verbose_level");
124 
125  const bool do_check = params_test->is_set("expected_result");
126  const double expected_result = do_check ? params_test->get_double("expected_result") : 0.0;
127 
128  const string str_gmset_type = params_clover->get_string("gamma_matrix_type");
129  const string str_proj_type = params_proj->get_string("projection_type");
130  const string str_smear_type = params_smear->get_string("smear_type");
131  const string str_solver_type = params_solver->get_string("solver_type");
132 
134 
135  //- print input parameters
136  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
137  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
138  vout.general(vl, " readfile = %s\n", readfile.c_str());
139  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
140  vout.general(vl, " gmset_type = %s\n", str_gmset_type.c_str());
141  vout.general(vl, " proj_type = %s\n", str_proj_type.c_str());
142  vout.general(vl, " smear_type = %s\n", str_smear_type.c_str());
143  vout.general(vl, " solver_type = %s\n", str_solver_type.c_str());
144  vout.general(vl, "\n");
145 
146  //- input parameter check
147  int err = 0;
148  err += ParameterCheck::non_NULL(str_gconf_status);
149 
150  if (err) {
151  vout.crucial(vl, "%s: Input parameters have not been set.\n", test_name.c_str());
152  abort();
153  }
154 
155 
156  // #### Set up a gauge configuration ####
157  Field_G *U = new Field_G(Nvol, Ndim);
158  GaugeConfig *gconf_read = new GaugeConfig(str_gconf_read);
159 
160  if (str_gconf_status == "Continue") {
161  gconf_read->read_file((Field *)U, readfile);
162  } else if (str_gconf_status == "Cold_start") {
163  U->set_unit();
164  } else if (str_gconf_status == "Hot_start") {
165  RandomNumbers_Mseries rand(1234567);
166  U->set_random(&rand);
167  } else {
168  vout.crucial(vl, "%s: unsupported gconf status \"%s\".\n", test_name.c_str(), str_gconf_status.c_str());
169  abort();
170  }
171 
172  Projection *proj = Projection::New(str_proj_type);
173  Smear *smear = Smear::New(str_smear_type, proj);
174  smear->set_parameters(*params_smear);
175 
176  Director_Smear *dr_smear = new Director_Smear((Smear *)smear);
177  dr_smear->set_parameters(*params_dr_smear);
178  dr_smear->set_config(U);
179 
180  int Nsmear = dr_smear->get_Nsmear();
181  Field_G *Usmear = (Field_G *)dr_smear->getptr_smearedConfig(Nsmear);
182 
183 
184  // #### object setup #####
185  GammaMatrixSet *gmset = GammaMatrixSet::New(str_gmset_type);
186 
187  //- NB. Chiral has not been implemented for SF, yet.
188  // Fopr_Clover_SF* fopr_c = new Fopr_Clover_SF(str_gmset_type);
189  Fopr_Clover_SF *fopr_c = new Fopr_Clover_SF();
190  fopr_c->set_parameters(*params_clover);
191 
192  Fopr_Smeared *fopr_smear = new Fopr_Smeared((Fopr *)fopr_c, dr_smear);
193  Fopr *fopr = fopr_smear;
194  //- NB. U will be converted to Usmear in fopr->set_config
195  fopr->set_config(U);
196 
197  Solver *solver = Solver::New(str_solver_type, fopr);
198  solver->set_parameters(*params_solver);
199 
200  Fprop *fprop_lex = new Fprop_Standard_lex(solver);
201 
202  Source_Wall_SF *source = new Source_Wall_SF();
203  source->set_parameters(*params_source);
204  source->set_config(Usmear);
205 
206  Timer *timer = new Timer(test_name);
207 
208 
209  // #### Execution main part ####
210  timer->start();
211 
212  valarray<Field_F> H(Nc * Nd);
213  valarray<Field_F> Hpr(Nc * Nd);
214  Field_F xq, b, b2;
215 
216  int Nconv;
217  double diff, diff2;
218 
219  vout.general(vl, "\n");
220  vout.general(vl, "Solving quark propagator:\n");
221  vout.general(vl, " color spin Nconv diff diff2\n");
222 
223  for (int icolor = 0; icolor < Nc; ++icolor) {
224  for (int ispin = 0; ispin < Nd / 2; ++ispin) {
225  source->set_t0(b, icolor, ispin);
226 
227  int idx = icolor + Nc * ispin;
228  fprop_lex->invert_D(xq, b, Nconv, diff);
229 
230  Field_F y(b);
231  fopr->set_mode("D");
232  y -= (Field_F)fopr->mult(xq);
233  diff2 = y.norm2();
234  vout.general(vl, " %2d %2d %6d %12.4e %12.4e\n",
235  icolor, ispin, Nconv, diff, diff2);
236 
237  H[idx] = xq;
238  xq = 0.0;
239  Hpr[idx] = xq;
240  }
241 
242  for (int ispin = Nd / 2; ispin < Nd; ++ispin) {
243  source->set_tT(b, icolor, ispin);
244 
245  int idx = icolor + Nc * ispin;
246  fprop_lex->invert_D(xq, b, Nconv, diff);
247 
248  Field_F y(b);
249  fopr->set_mode("D");
250  y -= (Field_F)fopr->mult(xq);
251  diff2 = y.norm2();
252  vout.general(vl, " %2d %2d %6d %12.4e %12.4e\n",
253  icolor, ispin, Nconv, diff, diff2);
254 
255  Hpr[idx] = xq;
256  xq = 0.0;
257  H[idx] = xq;
258  }
259  }
260 
261 #if 0
262  //For debug
263  Index_lex index;
264  for (int t = 0; t < 2; ++t) {
265  int site = index.site(0, 0, 0, t);
266  for (int c1 = 0; c1 < Nc; ++c1) {
267  for (int c0 = 0; c0 < Nc; ++c0) {
268  for (int s1 = 0; s1 < Nd; ++s1) {
269  for (int s0 = 0; s0 < Nd; ++s0) {
270  vout.general(vl, "H[%d,%d,%d,%d,%d]=%lf %lf\n",
271  t, c1, c0, s1, s0,
272  H[c0 + Nc * s0].cmp_r(c1, s1, site),
273  H[c0 + Nc * s0].cmp_i(c1, s1, site));
274  }
275  }
276  }
277  }
278  }
279  for (int t = 0; t < 2; ++t) {
280  int site = index.site(0, 0, 0, t);
281  for (int c1 = 0; c1 < Nc; ++c1) {
282  for (int c0 = 0; c0 < Nc; ++c0) {
283  for (int s1 = 0; s1 < Nd; ++s1) {
284  for (int s0 = 0; s0 < Nd; ++s0) {
285  vout.general(vl, "Hpr[%d,%d,%d,%d,%d]=%lf %lf\n",
286  t, c1, c0, s1, s0,
287  Hpr[c0 + Nc * s0].cmp_r(c1, s1, site),
288  Hpr[c0 + Nc * s0].cmp_i(c1, s1, site));
289  }
290  }
291  }
292  }
293  }
294 #endif
295 
296  //- meson correlators
297  vout.general(vl, "\n");
298  vout.general(vl, "boundary 2-point correlator with SF BC:\n");
299 
300  Corr2pt_Wilson_SF corr(gmset);
301  double result = corr.fAfP(H, Hpr);
302 
303  timer->report();
304 
305 
306  // ##### tidy up #####
307  delete params_test;
308  delete params_clover;
309  delete params_proj;
310  delete params_smear;
311  delete params_dr_smear;
312  delete params_solver;
313  delete params_source;
314  delete params_all;
315 
316  delete timer;
317 
318  delete U;
319  delete gconf_read;
320 
321  delete dr_smear;
322  delete fprop_lex;
323 
324  delete fopr_c;
325  delete fopr_smear;
326 
327  delete gmset;
328  delete proj;
329  delete smear;
330  delete solver;
331  delete source;
332 
333 
334  if (do_check) {
335  return Test::verify(expected_result, result);
336  } else {
337  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
338  return EXIT_SKIP;
339  }
340  }
341 } // namespace Test_SF_fAfP
#define EXIT_SKIP
Definition: test.h:17
Random number generator base on M-series.
BridgeIO vout
Definition: bridgeIO.cpp:207
void read_params(const std::string &params_file, Parameters *params)
read parameters from file.
void set_config(Field *U)
setting pointer to configuration
void detailed(const char *format,...)
Definition: bridgeIO.cpp:50
double norm2() const
Definition: field.cpp:469
int site(const int &x, const int &y, const int &z, const int &t) const
Definition: index_lex.h:53
virtual const Field mult(const Field &)=0
multiplies fermion operator to a given field and returns the resultant field.
void general(const char *format,...)
Definition: bridgeIO.cpp:38
double fAfP(const std::valarray< Field_F > &sq1, const std::valarray< Field_F > &sq2)
virtual void set_config(Field *)=0
setting pointer to the gauge configuration.
Definition: fprop.h:20
Container of Field-type object.
Definition: field.h:37
Two-point correlator for Wilson-type fermions with SF BC.
virtual void set_parameters(const Parameters &)=0
Class for parameters.
Definition: parameters.h:40
static Parameters * New(const std::string &realm)
void set_random(RandomNumbers *rand)
Definition: field_G_imp.cpp:62
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
smeared fermion operator.
Definition: fopr_Smeared.h:40
void set_unit()
Definition: field_G_imp.cpp:39
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:79
virtual void invert_D(Field &, const Field &, int &, double &)=0
SU(N) gauge field.
Definition: field_G.h:36
Field * getptr_smearedConfig(int i_smear)
get pointer to i-th smeared config (0th is original thin link)
bool is_set(const string &) const
Definition: parameters.cpp:366
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:25
void set_parameters(const Parameters &params)
Set of Gamma Matrices: basis class.
Lexical site index.
Definition: index_lex.h:34
int non_NULL(const std::string v)
Definition: checker.cpp:61
void start()
Definition: timer.cpp:44
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:26
void Register_Parameters(const string &, Parameters *const)
Definition: parameters.cpp:359
base class for projection operator into gauge group.
Definition: projection.h:33
Manager of smeared configurations.
Base class for linear solver class family.
Definition: solver.h:37
Bridge::VerboseLevel vl
Definition: checker.cpp:18
VerboseLevel
Definition: bridgeIO.h:25
void set_parameters(const Parameters &params)
set paramters, 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:75
base class for smearing of link variables.
Definition: smear.h:36
Parameter manager with YAML parser.
GaugeConfig class for file I/O of gauge configuration.
Definition: gaugeConfig.h:56
Definition: timer.h:31
Base class of fermion operator family.
Definition: fopr.h:39
int verify(const double expected, const double result)
Definition: test.cpp:27
void read_file(Field *u, const string &filename)
Definition: gaugeConfig.cpp:85
string get_string(const string &key) const
Definition: parameters.cpp:85
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
Definition: timer.cpp:128
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:191
void set_parameters(const Parameters &params)