55 namespace Test_Spectrum {
56 const std::string
test_name =
"Spectrum.Hadron2ptFunction_withFileIO";
94 #ifdef USE_TESTMANAGER_AUTOREGISTER
96 #if defined(USE_GROUP_SU2)
100 "Spectrum.Clover.Hadron2ptFunction_withFileIO",
105 "Spectrum.CloverGeneral.Hadron2ptFunction_withFileIO",
116 "Spectrum.WilsonGeneral.Hadron2ptFunction_withFileIO",
156 const int N_quark = params_test.
get_int(
"number_of_valence_quarks");
158 const std::string str_gconf_status = params_test.
get_string(
"gauge_config_status");
159 const std::string str_gconf_read = params_test.
get_string(
"gauge_config_type_input");
160 const std::string readfile = params_test.
get_string(
"config_filename_input");
161 const vector<int> Nshift_origin = params_test.
get_int_vector(
"shift_origin");
162 const std::string str_vlevel = params_test.
get_string(
"verbose_level");
164 const std::string str_gfix_type = params_all.
lookup(
"GaugeFixing").
get_string(
"gauge_fixing_type");
165 const std::string str_proj_type = params_all.
lookup(
"Projection").
get_string(
"projection_type");
166 const std::string str_smear_type = params_all.
lookup(
"Smear").
get_string(
"smear_type");
167 const int Nsmear = params_all.
lookup(
"Director_Smear").
get_int(
"number_of_smearing");
172 vout.
general(vl,
" gconf_status = %s\n", str_gconf_status.c_str());
173 vout.
general(vl,
" gconf_read = %s\n", str_gconf_read.c_str());
174 vout.
general(vl,
" readfile = %s\n", readfile.c_str());
175 for (
int mu = 0; mu < Ndim; ++mu) {
176 vout.
general(vl,
" shift_origin[%d] = %d\n", mu, Nshift_origin[mu]);
178 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
179 vout.
general(vl,
" gfix_type = %s\n", str_gfix_type.c_str());
180 vout.
general(vl,
" proj_type = %s\n", str_proj_type.c_str());
181 vout.
general(vl,
" smear_type = %s\n", str_smear_type.c_str());
183 vector<Parameters> params_quark;
184 for (
int iq = 0; iq < N_quark; ++iq) {
186 params_quark.push_back(params_all.
lookup(qlabel));
190 std::string str_gmset_type = params_quark[0].lookup(
"Fopr").get_string(
"gamma_matrix_type");
191 vout.
general(vl,
" gmset_type = %s\n", str_gmset_type.c_str());
193 std::vector<std::string> savefile_base(N_quark);
194 for (
int iq = 0; iq < N_quark; ++iq) {
195 savefile_base[iq] = params_quark[iq].get_string(
"temporary_filename_base");
198 for (
int iq = 0; iq < N_quark; ++iq) {
199 std::string str_solver_type = params_quark[iq].lookup(
"Solver").get_string(
"solver_type");
200 std::string str_source_type = params_quark[iq].lookup(
"Source").get_string(
"source_type");
201 vector<int> source_position = params_quark[iq].lookup(
"Source").get_int_vector(
"source_position");
204 vout.
general(vl,
" savefile_base[iq] = %s[%d]\n", savefile_base[iq].c_str(), iq);
205 vout.
general(vl,
" solver_type = %s\n", str_solver_type.c_str());
206 vout.
general(vl,
" source_type = %s\n", str_source_type.c_str());
207 for (
int mu = 0; mu < Ndim; ++mu) {
208 vout.
general(vl,
" source_position[%d] = %d\n", mu, source_position[mu]);
223 for (
int iq = 0; iq < N_quark; ++iq) {
224 std::string str_solver_type = params_quark[iq].lookup(
"Solver").get_string(
"solver_type");
226 if (str_solver_type ==
"CG") {
227 vout.
crucial(vl,
"Error at %s: CG can not be adopted. Use CGNE,CGNR, instead.\n",
test_name.c_str());
232 if ( (Nsmear > 0) && (str_proj_type ==
"Stout_SU3") ) {
241 if ( (str_gfix_type ==
"Coulomb") || (str_gfix_type ==
"Landau") ) {
255 if (str_gconf_status ==
"Continue") {
257 }
else if (str_gconf_status ==
"Cold_start") {
259 }
else if (str_gconf_status ==
"Hot_start") {
262 vout.
crucial(vl,
"Error at %s: unsupported gconf status \"%s\"\n",
test_name.c_str(), str_gconf_status.c_str());
268 for (
int i_dir = 0; i_dir < Ndim; ++i_dir) {
269 for (
int i_shift = 0; i_shift < Nshift_origin[i_dir]; ++i_shift) {
299 gfix->
fix(*Ufix, *U);
307 std::vector<unique_ptr<Fopr> > fopr(N_quark);
308 std::vector<unique_ptr<Solver> >
solver(N_quark);
309 std::vector<unique_ptr<Fprop> > fprop_lex(N_quark);
310 std::vector<unique_ptr<Source> > source(N_quark);
312 for (
int iq = 0; iq < N_quark; ++iq) {
313 std::string str_fopr_type = params_quark[iq].lookup(
"Fopr").get_string(
"fermion_type");
314 fopr[iq].reset(Fopr::New(str_fopr_type, str_gmset_type));
315 fopr[iq]->set_parameters(params_quark[iq].lookup(
"Fopr"));
316 fopr[iq]->set_config(U);
318 std::string str_solver_type = params_quark[iq].lookup(
"Solver").get_string(
"solver_type");
319 solver[iq].reset(Solver::New(str_solver_type, fopr[iq]));
320 solver[iq]->set_parameters(params_quark[iq].lookup(
"Solver"));
324 std::string str_source_type = params_quark[iq].lookup(
"Source").get_string(
"source_type");
325 source[iq].reset(Source::New(str_source_type));
326 source[iq]->set_parameters(params_quark[iq].lookup(
"Source"));
329 std::vector<Fopr *> fopr(N_quark);
330 std::vector<Solver *>
solver(N_quark);
331 std::vector<Fprop *> fprop_lex(N_quark);
332 std::vector<Source *> source(N_quark);
334 for (
int iq = 0; iq < N_quark; ++iq) {
335 std::string str_fopr_type = params_quark[iq].lookup(
"Fopr").get_string(
"fermion_type");
336 fopr[iq] = Fopr::New(str_fopr_type, str_gmset_type);
337 fopr[iq]->set_parameters(params_quark[iq].lookup(
"Fopr"));
338 fopr[iq]->set_config(U);
340 std::string str_solver_type = params_quark[iq].lookup(
"Solver").get_string(
"solver_type");
341 solver[iq] = Solver::New(str_solver_type, fopr[iq]);
342 solver[iq]->set_parameters(params_quark[iq].lookup(
"Solver"));
346 std::string str_source_type = params_quark[iq].lookup(
"Source").get_string(
"source_type");
347 source[iq] = Source::New(str_source_type);
348 source[iq]->set_parameters(params_quark[iq].lookup(
"Source"));
357 for (
int iq = 0; iq < N_quark; ++iq) {
358 vout.
general(vl,
"Solving quark propagator, flavor = %d:\n", iq + 1);
359 vout.
general(vl,
" color spin Nconv diff diff2\n");
361 for (
int ispin = 0; ispin < Nd; ++ispin) {
362 for (
int icolor = 0; icolor < Nc; ++icolor) {
363 int i_cd = icolor + Nc * ispin;
366 source[iq]->
set(b, i_cd);
371 fprop_lex[iq]->invert_D(xq, b, Nconv, diff);
374 fopr[iq]->set_mode(
"D");
375 fopr[iq]->mult(y, xq);
380 icolor, ispin, Nconv, diff, diff2);
394 for (
int iq = 0; iq < N_quark; ++iq) {
397 delete fprop_lex[iq];
420 const int N_quark = params_test.
get_int(
"number_of_valence_quarks");
422 const std::string str_vlevel = params_test.
get_string(
"verbose_level");
424 const bool do_check = params_test.
is_set(
"expected_result");
425 const double expected_result = do_check ? params_test.
get_double(
"expected_result") : 0.0;
427 const std::string str_proj_type = params_all.
lookup(
"Projection").
get_string(
"projection_type");
428 const int Nsmear = params_all.
lookup(
"Director_Smear").
get_int(
"number_of_smearing");
430 std::vector<std::string> savefile_base(N_quark);
432 for (
int iq = 0; iq < N_quark; ++iq) {
433 savefile_base[iq] = params_all
441 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
444 const std::string str_gmset_type = params_all.
lookup(
"Quark_1").
lookup(
"Fopr").
get_string(
"gamma_matrix_type");
445 vout.
general(vl,
" gmset_type = %s\n", str_gmset_type.c_str());
447 for (
int iq = 0; iq < N_quark; ++iq) {
448 vout.
general(vl,
" savefile_base[iq] = %s[%d]\n", savefile_base[iq].c_str(), iq);
451 if ( (Nsmear > 0) && (str_proj_type ==
"Stout_SU3") ) {
469 typedef std::vector<Field_F> PropagatorSet;
470 std::vector<PropagatorSet> sq(N_quark);
471 for (
int iq = 0; iq < N_quark; ++iq) {
472 sq[iq].resize(Nc * Nd);
474 for (
int i_cd = 0; i_cd < Nc * Nd; ++i_cd) {
475 sq[iq][i_cd].set(0.0);
480 for (
int iq = 0; iq < N_quark; ++iq) {
481 for (
int ispin = 0; ispin < Nd; ++ispin) {
482 for (
int icolor = 0; icolor < Nc; ++icolor) {
483 int i_cd = icolor + Nc * ispin;
486 field_io->
read_file(&sq[iq][i_cd], filename);
493 std::vector<double> result(N_quark);
498 for (
int iq = 0; iq < N_quark; ++iq) {
499 vout.
general(vl,
"Flavor combination = %d, %d\n", iq + 1, iq + 1);
500 result[iq] = corr.
meson_all(sq[iq], sq[iq]);
506 for (
int iq = 0; iq < N_quark; ++iq) {
507 for (
int jq = iq + 1; jq < N_quark; ++jq) {
508 vout.
general(vl,
"Flavor combination = %d, %d\n", iq + 1, jq + 1);
509 double result_2 = corr.
meson_all(sq[iq], sq[jq]);
526 vout.
detailed(vl,
"check skipped: expected_result not set.\n\n");
void detailed(const char *format,...)
double meson_all(const std::vector< Field_F > &sq1, const std::vector< Field_F > &sq2)
void set(const int jin, const int site, const int jex, double v)
virtual void set_parameters(const Parameters ¶m)=0
virtual void read_file(Field *v, const std::string)=0
read data from file. (`const' is added [18 Mar 2021])
void general(const char *format,...)
int calculate_hadron_correlator_withFileIO(const std::string &)
int solver(const std::string &)
int calculate_quark_propagator_withFileIO(const std::string &)
Two-point correlator for Wilson-type fermions.
virtual void set_parameters(const Parameters &)=0
int get_int(const string &key) const
void copy(Field &y, const Field &x)
copy(y, x): y = x
Wilson-type fermion field.
Parameters lookup(const string &key) const
static bool RegisterTest(const std::string &key, const Test_function func)
static bool initialize(const std::string &rng_type, unsigned long seed)
void read(Field_G *U, const string &filename=string())
double get_double(const string &key) const
std::string generate_filename(const char *fmt,...)
int hadron_2ptFunction_withFileIO_Clover()
void backward(Field &, const Field &, const int mu)
int non_NULL(const std::string v)
bool is_set(const string &key) const
int hadron_2ptFunction_withFileIO(const std::string &)
int hadron_2ptFunction_withFileIO_WilsonGeneral()
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Get quark propagator for Fopr with lexical site index.
void set_config(Field *U)
set pointer to original thin link variable
void crucial(const char *format,...)
static void read(const std::string ¶ms_file, Parameters ¶ms)
Manager of smeared configurations.
int verify(const double result, const double expected, double eps)
FieldIO_Binary class for file I/O of Field data in binary format.
const std::string test_name
Field * getptr_smearedConfig(const int i_smear)
get pointer to i-th smeared config (0th is original thin link)
int hadron_2ptFunction_withFileIO_Wilson()
void set_parameters(const Parameters ¶ms)
set parameters, must be called before set_config
virtual void write_file(Field *v, const std::string)=0
write data to file. (`const' is added [18 Mar 2021])
Methods to shift a field in the lexical site index.
int hadron_2ptFunction_withFileIO_CloverGeneral()
GaugeConfig class for file I/O of gauge configuration.
virtual void fix(Field_G &Ufix, const Field_G &Uorg)=0
virtual void set_parameters(const Parameters ¶ms)
string get_string(const string &key) const
vector< int > get_int_vector(const string &key) const
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
static VerboseLevel set_verbose_level(const std::string &str)
virtual void set_parameters(const Parameters ¶ms)=0