Bridge++  Ver. 2.0.2
test_Spectrum_Nonrelativistic_2ptFunction.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
17 #include "lib/IO/gaugeConfig.h"
23 
24 //====================================================================
26 
34  const std::string test_name
35  = "Spectrum.NonRelativistic.heavy-heavy-2ptFunction";
36 
37  //- test-private parameters
38  namespace {
39  const std::string parameter_file
40  = "test_Spectrum_NonRelativistic_heavy_heavy_2ptFunction.yaml";
41  }
42 
43  //- prototype declaration
45 
46 #ifdef USE_TESTMANAGER_AUTOREGISTER
47  namespace {
48 #if defined(USE_GROUP_SU2)
49  // Nc=2 is not available.
50 #else
51  static const bool is_registered = TestManager::RegisterTest(
52  test_name,
54  );
55 #endif
56  }
57 #endif
58 
59 //====================================================================
61  {
62  using namespace std;
63 
64  // #### parameter setup ####
65  const int Nc = CommonParameters::Nc();
66  const int Nd = CommonParameters::Nd();
67  const int Ndim = CommonParameters::Ndim();
68  const int Nvol = CommonParameters::Nvol();
69 
70  Parameters params_all = ParameterManager::read(parameter_file);
71 
72  Parameters params_spectrum = params_all.lookup("Spectrum");
73  Parameters params_gfix = params_all.lookup("GaugeFixing");
74  Parameters params_fopr_heavy = params_all.lookup("Fopr_heavy");
75  Parameters params_source_heavy = params_all.lookup("Source_heavy");
76 
77  string gconf_status = params_spectrum.get_string("gauge_config_status");
78  string gconf_type_read
79  = params_spectrum.get_string("gauge_config_type_input");
80  string readfile = params_spectrum.get_string("config_filename_input");
81  string rand_type = params_spectrum.get_string("random_number_type");
82 
83  unsigned long seed
84  = params_spectrum.get_unsigned_long("seed_for_random_number");
85  string vlevel = params_spectrum.get_string("verbose_level");
86 
87  const bool do_check = params_spectrum.is_set("expected_result");
88  const double expected_result
89  = do_check ? params_spectrum.get_double("expected_result") : 0.0;
90 
91  string gfix_type = params_gfix.get_string("gauge_fixing_type");
92  string fopr_heavy_type = params_fopr_heavy.get_string("fermion_type");
93  string gmset_type = params_fopr_heavy.get_string("gamma_matrix_type");
94  string source_heavy_type = params_source_heavy.get_string("source_type");
95 
97 
98  //- print input parameters
99  vout.general(vl, "Measurement parameters\n");
100  vout.general(vl, " gconf_status = %s\n", gconf_status.c_str());
101  vout.general(vl, " gconf_type_read = %s\n", gconf_type_read.c_str());
102  vout.general(vl, " readfile = %s\n", readfile.c_str());
103  vout.general(vl, " rand_type = %s\n", rand_type.c_str());
104  vout.general(vl, " seed = %lu\n", seed);
105  vout.general(vl, " vlevel = %s\n", vlevel.c_str());
106  vout.general(vl, " gfix_type = %s\n", gfix_type.c_str());
107  vout.general(vl, " gmset_type = %s\n", gmset_type.c_str());
108  vout.general(vl, " source_heavy_type = %s\n", source_heavy_type.c_str());
109 
110  //- input parameter check
111  int err = 0;
112  err += ParameterCheck::non_NULL(gconf_status);
113 
114  if (err) {
115  vout.crucial(vl, "Error at %s: input parameters have not been set\n",
116  test_name.c_str());
117  exit(EXIT_FAILURE);
118  }
119 
120  RandomNumberManager::initialize(rand_type, seed);
121 
122 
123  // #### Set up a gauge configuration ####
124  unique_ptr<Field_G> U(new Field_G(Nvol, Ndim));
125 
126  if (gconf_status == "Continue") {
127  GaugeConfig(gconf_type_read).read(*U, readfile);
128  } else if (gconf_status == "Cold_start") {
129  GaugeConfig("Unit").read(*U);
130  } else if (gconf_status == "Hot_start") {
131  GaugeConfig("Random").read(*U);
132  } else {
133  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n",
134  test_name.c_str(), gconf_status.c_str());
135  exit(EXIT_FAILURE);
136  }
137 
138  // #### Gauge fixing ####
139  {
140  unique_ptr<Field_G> Ufix(new Field_G(Nvol, Ndim));
141  const unique_ptr<GaugeFixing> gfix(GaugeFixing::New(gfix_type));
142  gfix->set_parameters(params_gfix);
143  // gfix->fix(*Ufix, *U);
144  // copy(*U, *Ufix);
145  }
146 
147  // object setup for light quark
148  unique_ptr<GammaMatrixSet> gmset(GammaMatrixSet::New(gmset_type));
149 
150  // heavy quark
151  unique_ptr<Fopr> fopr_heavy(Fopr::New(fopr_heavy_type, params_fopr_heavy));
152  fopr_heavy->set_config(U.get());
153 
154  const unique_ptr<Source> source_heavy(Source::New(source_heavy_type));
155  source_heavy->set_parameters(params_source_heavy);
156 
157 
158  // meason correlator
159  Corr2pt_4spinor corr(gmset.get());
160  corr.set_parameters(params_all.lookup("Corr2pt_4spinor"));
161 
162  const unique_ptr<Timer> timer(new Timer(test_name));
163 
164 
165  // #### Execution main part ####
166  timer->start();
167 
168  // heavy quark propagator
169  vout.general(vl, "Solving heavy quark propagator:\n");
170 
171  std::vector<Field_F> sq_heavy(Nc * Nd);
172  for (int icd = 0; icd < Nc * Nd; ++icd) {
173  sq_heavy[icd].set(0.0);
174  }
175 
176  fopr_heavy->set_mode("Evolve");
177  for (int id = 0; id < Nd / 2; ++id) {
178  for (int ic = 0; ic < Nc; ++ic) {
179  int icd = ic + Nc * id;
180 
181  Field_F b; // b.set(0.0);
182  source_heavy->set(b, icd);
183 
184  int Nconv;
185 #pragma omp parallel
186  {
187  fopr_heavy->mult(sq_heavy[icd], b);
188  }
189  }
190  }
191 
192  //- heavy-heavy meson correlators
193  vout.general(vl, "\n");
194  vout.general(vl, "heavy-heavy meson correlator:\n");
195  const double result = corr.meson_all(sq_heavy, sq_heavy);
196 
197  timer->report();
198 
200 
201 
202  if (do_check) {
203  return Test::verify(result, expected_result);
204  } else {
205  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
206  return EXIT_SKIP;
207  }
208  return EXIT_SUCCESS;
209  }
210 } //namespace Test_Spectrum_Nonrelativistic
211 
212 //============================================================END=====
Test::verify
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
Corr2pt_4spinor::set_parameters
virtual void set_parameters(const Parameters &params)
Definition: corr2pt_4spinor.cpp:21
ParameterCheck::non_NULL
int non_NULL(const std::string v)
Definition: parameterCheck.cpp:65
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
fopr_NonRelativistic.h
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
Test_Spectrum_NonRelativistic
Test class of NonRelativistic fermion operators.
Definition: test_Spectrum_Nonrelativistic_2ptFunction.cpp:33
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
gaugeConfig.h
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Test_Spectrum_NonRelativistic::test_name
const std::string test_name
Definition: test_Spectrum_Nonrelativistic_2ptFunction.cpp:35
source.h
Timer
Definition: timer.h:31
RandomNumberManager::finalize
static void finalize()
Definition: randomNumberManager.cpp:80
RandomNumberManager::initialize
static bool initialize(const std::string &rng_type, unsigned long seed)
Definition: randomNumberManager.cpp:57
Test_Spectrum_NonRelativistic::heavy_heavy_2ptFunction
int heavy_heavy_2ptFunction()
Definition: test_Spectrum_Nonrelativistic_2ptFunction.cpp:60
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
ParameterCheck::vl
Bridge::VerboseLevel vl
Definition: parameterCheck.cpp:18
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
Corr2pt_4spinor
Two-point correlator for Wilson-type fermions.
Definition: corr2pt_4spinor.h:42
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
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
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