Bridge++  Ver. 2.0.2
test_Spectrum_Domainwall_2ptFunction.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "IO/gaugeConfig.h"
17 
22 #include "Fopr/fopr_Domainwall.h"
23 #include "Tools/gammaMatrixSet.h"
25 
26 //====================================================================
28 
49  const std::string test_name = "Spectrum.Domainwall.Hadron2ptFunction";
50 
51  //- test-private parameters
52  namespace {
53  const std::string filename_input = "test_Spectrum_Domainwall_Hadron2ptFunction.yaml";
54  }
55 
56  //- prototype declaration
57  int hadron_2ptFunction(void);
58 
59 #ifdef USE_TESTMANAGER_AUTOREGISTER
60  namespace {
61 #if 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 Nvol = CommonParameters::Nvol();
79  const int Ndim = CommonParameters::Ndim();
80 
81  const Parameters params_all = ParameterManager::read(filename_input);
82 
83  const Parameters params_test = params_all.lookup("Test_Spectrum_Domainwall");
84  const Parameters params_gfix = params_all.lookup("GaugeFixing");
85  const Parameters params_dw = params_all.lookup("Fopr_Domainwall");
86  const Parameters params_solver = params_all.lookup("Solver");
87  const Parameters params_source = params_all.lookup("Source");
88 
89  const string str_gconf_status = params_test.get_string("gauge_config_status");
90  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
91  const string readfile = params_test.get_string("config_filename_input");
92  const string str_rand_type = params_test.get_string("random_number_type");
93  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
94  const string str_vlevel = params_test.get_string("verbose_level");
95 
96  const bool do_check = params_test.is_set("expected_result");
97  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
98 
99  const string str_gfix_type = params_gfix.get_string("gauge_fixing_type");
100  const string str_gmset_type = params_dw.get_string("gamma_matrix_type");
101  const string str_solver_type = params_solver.get_string("solver_type");
102  const string str_source_type = params_source.get_string("source_type");
103 
104  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
105 
106  //- print input parameters
107  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
108  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
109  vout.general(vl, " readfile = %s\n", readfile.c_str());
110  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
111  vout.general(vl, " seed = %lu\n", seed);
112  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
113  vout.general(vl, " gfix_type = %s\n", str_gfix_type.c_str());
114  vout.general(vl, " gmset_type = %s\n", str_gmset_type.c_str());
115  vout.general(vl, " solver_type = %s\n", str_solver_type.c_str());
116  vout.general(vl, " source_type = %s\n", str_source_type.c_str());
117 
118  //- input parameter check
119  int err = 0;
120  err += ParameterCheck::non_NULL(str_gconf_status);
121 
122  if (err) {
123  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
124  exit(EXIT_FAILURE);
125  }
126 
127  if ((str_gfix_type == "Coulomb") || (str_gfix_type == "Landau")) {
128  if (CommonParameters::Nc() != 3) {
129  vout.crucial(vl, "check skipped: Nc = 3 is needed, but Nc = %d.\n\n", CommonParameters::Nc());
130  return EXIT_SKIP;
131  }
132  }
133 
134 
135  RandomNumberManager::initialize(str_rand_type, seed);
136 
137 
138  // #### Set up a gauge configuration ####
139  Field_G U(Nvol, Ndim);
140 
141  if (str_gconf_status == "Continue") {
142  GaugeConfig(str_gconf_read).read(U, readfile);
143  } else if (str_gconf_status == "Cold_start") {
144  GaugeConfig("Unit").read(U);
145  } else if (str_gconf_status == "Hot_start") {
146  GaugeConfig("Random").read(U);
147  } else {
148  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
149  exit(EXIT_FAILURE);
150  }
151 
152 
153  // #### Gauge fixing ####
154  {
155  Field_G Ufix(Nvol, Ndim);
156  unique_ptr<GaugeFixing> gfix(GaugeFixing::New(str_gfix_type, params_gfix));
157 
158  gfix->fix(Ufix, U);
159  copy(U, Ufix);
160  }
161 
162 
163  // #### object setup #####
164  unique_ptr<GammaMatrixSet> gmset(GammaMatrixSet::New(str_gmset_type));
165 
166  // Fopr *fopr_w = Fopr::New("Wilson", str_gmset_type);
167  // Fopr *fopr_dw = Fopr::New("Domainwall", fopr_w);
168  // fopr_dw->set_parameters(params_dw);
169  // fopr_dw->set_config(&U);
170 
171  // Fopr_Wilson *fopr_w = new Fopr_Wilson(str_gmset_type);
172  // Fopr_Domainwall *fopr_dw = new Fopr_Domainwall(fopr_w, params_dw);
173  // fopr_dw->set_config(&U);
174 
175  unique_ptr<Fopr_Domainwall> fopr_dw(new Fopr_Domainwall(params_dw));
176  fopr_dw->set_mode("D");
177  fopr_dw->set_config(&U);
178 
179  // kernel operator for 4d <--> 5d conversion
180  Parameters params_dw_tmp;
181  fopr_dw->get_parameters(params_dw_tmp); // params_dw may not have coefficeint_c
182  const string kernel_type = params_dw_tmp.get_string("kernel_type");
183  const double M0 = params_dw_tmp.get_double("domain_wall_height");
184  const double coeff_c = params_dw_tmp.get_double("coefficient_c");
185  const int Ns = params_dw_tmp.get_int("extent_of_5th_dimension");
186 
187  Parameters params_kernel = params_dw;
188  double kappa = 1.0 / (8.0 - 2.0 * M0);
189  double one_over_2kappa = 4.0 - M0;
190  params_kernel.set_double("hopping_parameter", kappa);
191 
192  unique_ptr<Fopr> foprw(Fopr::New(kernel_type, params_kernel));
193  foprw->set_mode("D");
194  foprw->set_config(&U);
195 
196  unique_ptr<Solver> solver(Solver::New(str_solver_type, fopr_dw.get(), params_solver));
197 
198  // unique_ptr<Fprop_Domainwall_4d> fprop(new Fprop_Domainwall_4d(fopr_dw.get(), solver.get()));
199  unique_ptr<Fprop> fprop_lex(new Fprop_Standard_lex(solver.get()));
200 
201  unique_ptr<Source> source(Source::New(str_source_type, params_source));
202 
203  Corr2pt_4spinor corr(gmset.get(), params_all.lookup("Corr2pt_4spinor"));
204 
205  Timer timer(test_name);
206 
207 
208  // #### Execution main part ####
209  timer.start();
210 
211  std::vector<Field_F> sq(Nc * Nd);
212  for (int i_cd = 0; i_cd < Nc * Nd; ++i_cd) {
213  sq[i_cd].set(0.0);
214  }
215 
216  Field_F b;
217  Field_F vtmp_p, vtmp_m, vtmp;
218 
219  Field b5(b.nin(), b.nvol(), Ns);
220  Field y5(b.nin(), b.nvol(), Ns);
221  Field x5(b.nin(), b.nvol(), Ns);
222 
223  vout.general(vl, "\n");
224  vout.general(vl, "Solving quark propagator:\n");
225  vout.general(vl, " color spin Nconv diff diff2\n");
226 
227  for (int ispin = 0; ispin < Nd; ++ispin) {
228  for (int icolor = 0; icolor < Nc; ++icolor) {
229  int i_cd = icolor + Nc * ispin;
230 
231  source->set(b, i_cd);
232 
233  // set 5d source as
234  // - D_- ( P_+ 0 ....0 P_-)^T b4
235 #pragma omp parallel
236  {
237  // build 5dim vector
238  b5.set(0.0);
239 
240  // s5=0
241  fopr_dw->mult_chproj_4d(vtmp_p, b, +1);
242  fopr_dw->mult_chproj_4d(vtmp_m, b, -1);
243 
244  foprw->mult(vtmp, vtmp_p);
245  axpy(vtmp_p, -one_over_2kappa * coeff_c, vtmp); // (-cD+1) (1+gm5)b/2
246 
247  foprw->mult(vtmp, vtmp_m);
248  axpy(vtmp_m, -one_over_2kappa * coeff_c, vtmp); // (-cD+1) (1-gm5)b/2
249 
250  copy(b5, 0, vtmp_p, 0);
251  copy(b5, Ns - 1, vtmp_m, 0);
252  } // omp parallel
253  int Nconv;
254  double diff;
255  fprop_lex->invert_D(x5, b5, Nconv, diff);
256 #pragma omp parallel
257  {
258  fopr_dw->set_mode("D");
259  fopr_dw->mult(y5, x5);
260  axpy(y5, -1.0, b5);
261  double diff2 = y5.norm();
262 
263  vout.general(vl, " %2d %2d %6d %12.4e %12.4e\n",
264  icolor, ispin, Nconv, diff, diff2);
265 
266 
267  // convert to 4D propagator
268  copy(vtmp, 0, x5, 0);
269  fopr_dw->mult_chproj_4d(vtmp_m, vtmp, -1);
270  copy(vtmp, 0, x5, Ns - 1);
271  fopr_dw->mult_chproj_4d(vtmp_p, vtmp, +1);
272 
273  copy(sq[i_cd], vtmp_m);
274  axpy(sq[i_cd], 1.0, vtmp_p);
275  } // omp parallel
276  }
277  }
278 
279  //- hadron correlators
280  vout.general(vl, "\n");
281  vout.general(vl, "2-point correlator:\n");
282 
283  const double result = corr.meson_all(sq, sq);
284 
285  timer.report();
286 
288 
289 
290  if (do_check) {
291  return Test::verify(result, expected_result);
292  } else {
293  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
294  return EXIT_SKIP;
295  }
296  }
297 } // namespace Test_Spectrum_Domainwall
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
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Test_Spectrum_Domainwall::test_name
const std::string test_name
Definition: test_Spectrum_Domainwall_2ptFunction.cpp:49
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_4spinor::meson_all
double meson_all(const std::vector< Field_F > &sq1, const std::vector< Field_F > &sq2)
Definition: corr2pt_4spinor.cpp:53
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
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
fopr_Domainwall.h
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
Field::nin
int nin() const
Definition: field.h:126
Test_Spectrum_Domainwall::hadron_2ptFunction
int hadron_2ptFunction(void)
Definition: test_Spectrum_Domainwall_2ptFunction.cpp:73
source.h
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
RandomNumberManager::initialize
static bool initialize(const std::string &rng_type, unsigned long seed)
Definition: randomNumberManager.cpp:57
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
Fopr_Domainwall
AFopr_Domainwall< Field > Fopr_Domainwall
Domain-wall fermion operator.
Definition: fopr_Domainwall.h:33
Field::norm
double norm() const
Definition: field.h:226
test.h
ParameterManager::read
static void read(const std::string &params_file, Parameters &params)
Definition: parameterManager.cpp:33
Parameters::get_double
double get_double(const string &key) const
Definition: parameters.cpp:175
Field::nvol
int nvol() const
Definition: field.h:127
Corr2pt_4spinor
Two-point correlator for Wilson-type fermions.
Definition: corr2pt_4spinor.h:42
Test_Solver_Wilson::solver
int solver(const std::string &)
Definition: test_Solver_Wilson.cpp:134
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
Field_F
Wilson-type fermion field.
Definition: field_F.h:37
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
Test_Spectrum_Domainwall
Test of spectroscopy for the domain-wall fermion operator.
Definition: test_Spectrum_Domainwall_2ptFunction.cpp:48
Field
Container of Field-type object.
Definition: field.h:46
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
Field_G
SU(N) gauge field.
Definition: field_G.h:38
gaugeFixing.h
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
corr2pt_4spinor.h
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