Bridge++  Ver. 2.0.2
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 
48 namespace Test_SF_fAfP {
49  const std::string test_name = "SF_fAfP.Boundary_Meson_2ptFunction";
50 
51  //- test-private parameters
52  namespace {
53  const std::string filename_input = "test_SF_fAfP_Boundary_Meson_2ptFunction.yaml";
54  }
55 
56  //- prototype declaration
58 
59 #ifdef USE_TESTMANAGER_AUTOREGISTER
60  namespace {
61 #if defined(USE_OPENMP) || defined(USE_GROUP_SU2)
62  // Nc=2 is not available.
63 #else
64  static const bool is_registered = TestManager::RegisterTest(
65  test_name,
67  );
68 #endif
69  }
70 #endif
71 
72  //====================================================================
74  {
75  // ##### parameter setup #####
76  const int Nc = CommonParameters::Nc();
77  const int Nd = CommonParameters::Nd();
78  const int Ndim = CommonParameters::Ndim();
79  const int Nvol = CommonParameters::Nvol();
80 
81  const Parameters params_all = ParameterManager::read(filename_input);
82 
83  const Parameters params_test = params_all.lookup("Test_SF_fAfP");
84  const Parameters params_clover = params_all.lookup("Fopr_Clover_SF");
85  const Parameters params_proj = params_all.lookup("Projection");
86  const Parameters params_smear = params_all.lookup("Smear_SF");
87  const Parameters params_dr_smear = params_all.lookup("Director_Smear");
88  const Parameters params_solver = params_all.lookup("Solver");
89  const Parameters params_source = params_all.lookup("Source_Wall_SF");
90 
91  const string str_gconf_status = params_test.get_string("gauge_config_status");
92  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
93  const string readfile = params_test.get_string("config_filename_input");
94  const string str_rand_type = params_test.get_string("random_number_type");
95  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
96  const string str_vlevel = params_test.get_string("verbose_level");
97 
98  const bool do_check = params_test.is_set("expected_result");
99  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
100 
101  const string str_gmset_type = params_clover.get_string("gamma_matrix_type");
102  const string str_proj_type = params_proj.get_string("projection_type");
103  const string str_smear_type = params_smear.get_string("smear_type");
104  const int Nsmear = params_dr_smear.get_int("number_of_smearing");
105  const string str_solver_type = params_solver.get_string("solver_type");
106 
107  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
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  if ((Nsmear > 0) && (str_proj_type == "Stout_SU3")) {
132  if (CommonParameters::Nc() != 3) {
133  vout.crucial(vl, "check skipped: Nc = 3 is needed, but Nc = %d.\n\n", CommonParameters::Nc());
134  return EXIT_SKIP;
135  }
136  }
137 
138 
139  RandomNumberManager::initialize(str_rand_type, seed);
140 
141 
142  // #### Set up a gauge configuration ####
143  Field_G U(Nvol, Ndim);
144 
145  if (str_gconf_status == "Continue") {
146  GaugeConfig(str_gconf_read).read(U, readfile);
147  } else if (str_gconf_status == "Cold_start") {
148  GaugeConfig("Unit").read(U);
149  } else if (str_gconf_status == "Hot_start") {
150  GaugeConfig("Random").read(U);
151  } else {
152  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
153  exit(EXIT_FAILURE);
154  }
155 
156  if (Nsmear > 0) {
157  unique_ptr<Projection> proj(Projection::New(str_proj_type, params_all.lookup("Projection")));
158  unique_ptr<Smear> smear(Smear::New(str_smear_type, proj.get(), params_all.lookup("Smear_SF")));
159  unique_ptr<Director_Smear> dr_smear(new Director_Smear(smear.get(), params_all.lookup("Director_Smear")));
160  dr_smear->set_config(&U);
161 
162  const Field_G *Usmear = (Field_G *)dr_smear->getptr_smearedConfig(Nsmear);
163  copy(U, *Usmear);
164  }
165 
166  // #### object setup #####
167  unique_ptr<GammaMatrixSet> gmset(GammaMatrixSet::New(str_gmset_type));
168 
169  //- NB. Chiral repr has not been implemented for SF, yet.
170  unique_ptr<Fopr> fopr(new Fopr_Clover_SF(params_clover));
171  fopr->set_config(&U);
172 
173  unique_ptr<Solver> solver(Solver::New(str_solver_type, fopr.get(), params_solver));
174 
175  unique_ptr<Fprop> fprop_lex(new Fprop_Standard_lex(solver.get()));
176 
177  unique_ptr<Source_Wall_SF> source(new Source_Wall_SF(params_source));
178  source->set_config(&U);
179 
180  Timer timer(test_name);
181 
182 
183  // #### Execution main part ####
184  timer.start();
185 
186  std::vector<Field_F> H(Nc * Nd);
187  std::vector<Field_F> Hpr(Nc * Nd);
188 
189  vout.general(vl, "\n");
190  vout.general(vl, "Solving quark propagator:\n");
191  vout.general(vl, " color spin Nconv diff diff2\n");
192 
193  for (int icolor = 0; icolor < Nc; ++icolor) {
194  for (int ispin = 0; ispin < Nd / 2; ++ispin) {
195  Field_F b;
196  source->set_t0(b, icolor, ispin);
197 
198  int idx = icolor + Nc * ispin;
199 
200  Field_F xq;
201  int Nconv;
202  double diff;
203  fprop_lex->invert_D(xq, b, Nconv, diff);
204 
205  Field_F y(b);
206  fopr->set_mode("D");
207 
208  fopr->mult(y, xq); // y = fopr_w->mult(xq);
209  axpy(y, -1.0, b); // y -= b;
210  double diff2 = y.norm2();
211 
212  vout.general(vl, " %2d %2d %6d %12.4e %12.4e\n",
213  icolor, ispin, Nconv, diff, diff2);
214 
215  H[idx] = xq;
216  xq.set(0.0);
217  Hpr[idx] = xq;
218  }
219 
220  for (int ispin = Nd / 2; ispin < Nd; ++ispin) {
221  Field_F b;
222  source->set_tT(b, icolor, ispin);
223 
224  int idx = icolor + Nc * ispin;
225 
226  Field_F xq;
227  int Nconv;
228  double diff;
229  fprop_lex->invert_D(xq, b, Nconv, diff);
230 
231  Field_F y(b);
232  fopr->set_mode("D");
233 
234  fopr->mult(y, xq); // y = fopr_w->mult(xq);
235  axpy(y, -1.0, b); // y -= b;
236  double diff2 = y.norm2();
237 
238  vout.general(vl, " %2d %2d %6d %12.4e %12.4e\n",
239  icolor, ispin, Nconv, diff, diff2);
240 
241  Hpr[idx] = xq;
242  xq.set(0.0);
243  H[idx] = xq;
244  }
245  }
246 
247 #ifdef DEBUG
248  Index_lex index;
249  for (int t = 0; t < 2; ++t) {
250  int site = index.site(0, 0, 0, t);
251  for (int c1 = 0; c1 < Nc; ++c1) {
252  for (int c0 = 0; c0 < Nc; ++c0) {
253  for (int s1 = 0; s1 < Nd; ++s1) {
254  for (int s0 = 0; s0 < Nd; ++s0) {
255  vout.general(vl, "H[%d,%d,%d,%d,%d]=%lf %lf\n",
256  t, c1, c0, s1, s0,
257  H[c0 + Nc * s0].cmp_r(c1, s1, site),
258  H[c0 + Nc * s0].cmp_i(c1, s1, site));
259  }
260  }
261  }
262  }
263  }
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, "Hpr[%d,%d,%d,%d,%d]=%lf %lf\n",
271  t, c1, c0, s1, s0,
272  Hpr[c0 + Nc * s0].cmp_r(c1, s1, site),
273  Hpr[c0 + Nc * s0].cmp_i(c1, s1, site));
274  }
275  }
276  }
277  }
278  }
279 #endif
280 
281  //- meson correlators
282  vout.general(vl, "\n");
283  vout.general(vl, "boundary 2-point correlator with SF BC:\n");
284 
285  Corr2pt_Wilson_SF corr(gmset.get());
286  const double result = corr.fAfP(H, Hpr);
287 
288  timer.report();
289 
291 
292 
293  if (do_check) {
294  return Test::verify(result, expected_result);
295  } else {
296  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
297  return EXIT_SKIP;
298  }
299  }
300 } // namespace Test_SF_fAfP
Test::verify
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
ParameterCheck::non_NULL
int non_NULL(const std::string v)
Definition: parameterCheck.cpp:65
Fprop_Standard_lex
Get quark propagator for Fopr with lexical site index.
Definition: fprop_Standard_lex.h:33
Index_lex
Lexical site index.
Definition: index_lex.h:34
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Test_SF_fAfP
Definition: test_SF_fAfP_Boundary_Meson_2ptFunction.cpp:48
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
corr2pt_Wilson_SF.h
Parameters::get_int
int get_int(const string &key) const
Definition: parameters.cpp:192
Bridge::BridgeIO::detailed
void detailed(const char *format,...)
Definition: bridgeIO.cpp:219
GaugeConfig::read
void read(Field_G &U, const string &filename=string())
Definition: gaugeConfig.cpp:121
fprop_Standard_lex.h
gaugeConfig.h
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
Fopr_Clover_SF
Clover fermion operator.
Definition: fopr_Clover_SF.h:44
Timer
Definition: timer.h:31
RandomNumberManager::finalize
static void finalize()
Definition: randomNumberManager.cpp:80
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
Source_Wall_SF
Wall source for SF boundary propagator.
Definition: source_Wall_SF.h:36
RandomNumberManager::initialize
static bool initialize(const std::string &rng_type, unsigned long seed)
Definition: randomNumberManager.cpp:57
Field::norm2
double norm2() const
Definition: field.cpp:113
Timer::start
void start()
Definition: timer.cpp:44
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
ParameterCheck::vl
Bridge::VerboseLevel vl
Definition: parameterCheck.cpp:18
AIndex_eo_qxs::idx
int idx(const int in, const int Nin, const int ist, const int Nx2, const int Ny, const int leo, const int Nvol2, const int ex)
Definition: aindex_eo.h:27
test.h
ParameterManager::read
static void read(const std::string &params_file, Parameters &params)
Definition: parameterManager.cpp:33
Test_SF_fAfP::test_name
const std::string test_name
Definition: test_SF_fAfP_Boundary_Meson_2ptFunction.cpp:49
Parameters::get_double
double get_double(const string &key) const
Definition: parameters.cpp:175
source_Wall_SF.h
Index_lex::site
int site(const int &x, const int &y, const int &z, const int &t) const
Definition: index_lex.h:55
Director_Smear
Manager of smeared configurations.
Definition: director_Smear.h:39
Test_Solver_Wilson::solver
int solver(const std::string &)
Definition: test_Solver_Wilson.cpp:134
Corr2pt_Wilson_SF
Two-point correlator for Wilson-type fermions with SF BC.
Definition: corr2pt_Wilson_SF.h:36
Parameters::get_unsigned_long
unsigned long get_unsigned_long(const string &key) const
Definition: parameters.cpp:209
EXIT_SKIP
#define EXIT_SKIP
Definition: test.h:17
CommonParameters::Nd
static int Nd()
Definition: commonParameters.h:116
randomNumberManager.h
GaugeConfig
GaugeConfig class for file I/O of gauge configuration.
Definition: gaugeConfig.h:80
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
Parameters::is_set
bool is_set(const string &key) const
Definition: parameters.cpp:525
fopr_Clover_SF.h
Field_F
Wilson-type fermion field.
Definition: field_F.h:37
fopr_Smeared.h
Parameters::get_string
string get_string(const string &key) const
Definition: parameters.cpp:221
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Corr2pt_Wilson_SF::fAfP
double fAfP(const std::vector< Field_F > &sq1, const std::vector< Field_F > &sq2)
Definition: corr2pt_Wilson_SF.cpp:84
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
gammaMatrixSet.h
Parameters::lookup
Parameters lookup(const string &key) const
Definition: parameters.h:79
Timer::report
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
Definition: timer.cpp:128
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
TestManager::RegisterTest
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:69
Test_SF_fAfP::boundary_meson_2ptFunction
int boundary_meson_2ptFunction(void)
Definition: test_SF_fAfP_Boundary_Meson_2ptFunction.cpp:73