54 namespace Test_Spectrum {
55 const std::string
test_name =
"Spectrum.Hadron2ptFunction_withFileIO";
93 #ifdef USE_TESTMANAGER_AUTOREGISTER
95 #if defined(USE_GROUP_SU2)
99 "Spectrum.Clover.Hadron2ptFunction_withFileIO",
103 #if defined(USE_IMP_BGQ)
107 "Spectrum.CloverGeneral.Hadron2ptFunction_withFileIO",
119 #if defined(USE_IMP_BGQ)
123 "Spectrum.WilsonGeneral.Hadron2ptFunction_withFileIO",
164 const int N_quark = params_test.
get_int(
"number_of_valence_quarks");
166 const string str_gconf_status = params_test.
get_string(
"gauge_config_status");
167 const string str_gconf_read = params_test.
get_string(
"gauge_config_type_input");
168 const string readfile = params_test.
get_string(
"config_filename_input");
169 const string str_vlevel = params_test.
get_string(
"verbose_level");
171 const string str_gfix_type = params_all.
lookup(
"GaugeFixing").
get_string(
"gauge_fixing_type");
172 const string str_proj_type = params_all.
lookup(
"Projection").
get_string(
"projection_type");
173 const string str_smear_type = params_all.
lookup(
"Smear").
get_string(
"smear_type");
174 const string str_solver_type = params_all.
lookup(
"Solver").
get_string(
"solver_type");
179 vout.
general(vl,
" gconf_status = %s\n", str_gconf_status.c_str());
180 vout.
general(vl,
" gconf_read = %s\n", str_gconf_read.c_str());
181 vout.
general(vl,
" readfile = %s\n", readfile.c_str());
182 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
183 vout.
general(vl,
" gfix_type = %s\n", str_gfix_type.c_str());
184 vout.
general(vl,
" proj_type = %s\n", str_proj_type.c_str());
185 vout.
general(vl,
" smear_type = %s\n", str_smear_type.c_str());
186 vout.
general(vl,
" solver_type = %s\n", str_solver_type.c_str());
188 vector<Parameters> params_quark;
190 for (
int iq = 0; iq < N_quark; ++iq) {
192 params_quark.push_back(params_all.
lookup(qlabel));
196 string str_gmset_type = params_quark[0].lookup(
"Fopr").get_string(
"gamma_matrix_type");
197 vout.
general(vl,
" gmset_type = %s\n", str_gmset_type.c_str());
199 std::vector<std::string> savefile_base(N_quark);
200 for (
int iq = 0; iq < N_quark; ++iq) {
201 savefile_base[iq] = params_quark[iq].get_string(
"temporary_filename_base");
204 for (
int iq = 0; iq < N_quark; ++iq) {
206 vout.
general(vl,
" savefile_base[iq] = %s[%d]\n", savefile_base[iq].c_str(), iq);
208 params_quark[iq].lookup(
"Source").get_string(
"source_type").c_str());
210 vector<int> pos = params_quark[iq].lookup(
"Source").get_int_vector(
"source_position");
212 for (
int mu = 0; mu < Ndim; ++mu) {
213 vout.
general(vl,
" source_position[%d] = %d\n", mu, pos[mu]);
228 if (str_solver_type ==
"CG") {
229 vout.
crucial(vl,
"Error at %s: CG can not be adopted. Use CGNE,CGNR, instead.\n",
test_name.c_str());
239 if (str_gconf_status ==
"Continue") {
241 }
else if (str_gconf_status ==
"Cold_start") {
243 }
else if (str_gconf_status ==
"Hot_start") {
246 vout.
crucial(vl,
"Error at %s: unsupported gconf status \"%s\"\n",
test_name.c_str(), str_gconf_status.c_str());
269 gfix->
fix(*Ufix, *Usmear);
276 std::vector<unique_ptr<Fopr> > fopr(N_quark);
277 std::vector<unique_ptr<Solver> > solver(N_quark);
278 std::vector<unique_ptr<Fprop> > fprop_lex(N_quark);
279 std::vector<unique_ptr<Source> > source(N_quark);
281 for (
int iq = 0; iq < N_quark; ++iq) {
282 string str_fopr_type = params_quark[iq].lookup(
"Fopr").get_string(
"fermion_type");
284 fopr[iq].reset(Fopr::New(str_fopr_type, str_gmset_type));
285 fopr[iq]->set_parameters(params_quark[iq].lookup(
"Fopr"));
286 fopr[iq]->set_config(U);
288 solver[iq].reset(Solver::New(str_solver_type, fopr[iq]));
289 solver[iq]->set_parameters(params_all.
lookup(
"Solver"));
293 string str_source_type = params_quark[iq].lookup(
"Source").get_string(
"source_type");
294 source[iq].reset(Source::New(str_source_type));
295 source[iq]->set_parameters(params_quark[iq].lookup(
"Source"));
298 std::vector<Fopr *> fopr(N_quark);
299 std::vector<Solver *> solver(N_quark);
300 std::vector<Fprop *> fprop_lex(N_quark);
301 std::vector<Source *> source(N_quark);
303 for (
int iq = 0; iq < N_quark; ++iq) {
304 string str_fopr_type = params_quark[iq].lookup(
"Fopr").get_string(
"fermion_type");
306 fopr[iq] = Fopr::New(str_fopr_type, str_gmset_type);
307 fopr[iq]->set_parameters(params_quark[iq].lookup(
"Fopr"));
308 fopr[iq]->set_config(U);
310 solver[iq] = Solver::New(str_solver_type, fopr[iq]);
311 solver[iq]->set_parameters(params_all.
lookup(
"Solver"));
315 string str_source_type = params_quark[iq].lookup(
"Source").get_string(
"source_type");
316 source[iq] = Source::New(str_source_type);
317 source[iq]->set_parameters(params_quark[iq].lookup(
"Source"));
332 for (
int iq = 0; iq < N_quark; ++iq) {
333 vout.
general(vl,
"Solving quark propagator, flavor = %d:\n", iq + 1);
334 vout.
general(vl,
" color spin Nconv diff diff2\n");
336 for (
int ispin = 0; ispin < Nd; ++ispin) {
337 for (
int icolor = 0; icolor < Nc; ++icolor) {
338 int idx = icolor + Nc * ispin;
339 source[iq]->set(b, idx);
341 fprop_lex[iq]->invert_D(xq, b, Nconv, diff);
344 fopr[iq]->set_mode(
"D");
345 fopr[iq]->mult(y, xq);
350 icolor, ispin, Nconv, diff, diff2);
364 for (
int iq = 0; iq < N_quark; ++iq) {
367 delete fprop_lex[iq];
390 const int N_quark = params_test.
get_int(
"number_of_valence_quarks");
392 const string str_vlevel = params_test.
get_string(
"verbose_level");
394 const bool do_check = params_test.
is_set(
"expected_result");
395 const double expected_result = do_check ? params_test.
get_double(
"expected_result") : 0.0;
397 std::vector<std::string> savefile_base(N_quark);
399 for (
int iq = 0; iq < N_quark; ++iq) {
400 savefile_base[iq] = params_all
408 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
412 vout.
general(vl,
" gmset_type = %s\n", str_gmset_type.c_str());
414 for (
int iq = 0; iq < N_quark; ++iq) {
415 vout.
general(vl,
" savefile_base[iq] = %s[%d]\n", savefile_base[iq].c_str(), iq);
428 typedef std::vector<Field_F> PropagatorSet;
430 std::vector<PropagatorSet> sq(N_quark);
431 for (
int iq = 0; iq < N_quark; ++iq) {
432 sq[iq].resize(Nc * Nd);
434 for (
int i = 0; i < Nc * Nd; ++i) {
440 for (
int iq = 0; iq < N_quark; ++iq) {
441 for (
int ispin = 0; ispin < Nd; ++ispin) {
442 for (
int icolor = 0; icolor < Nc; ++icolor) {
443 int idx = icolor + Nc * ispin;
446 field_io->
read_file(&sq[iq][idx], filename);
453 std::vector<double> result(N_quark);
458 for (
int iq = 0; iq < N_quark; ++iq) {
459 vout.
general(vl,
"Flavor combination = %d, %d\n", iq + 1, iq + 1);
460 result[iq] = corr.
meson_all(sq[iq], sq[iq]);
466 for (
int iq = 0; iq < N_quark; ++iq) {
467 for (
int jq = iq + 1; jq < N_quark; ++jq) {
468 vout.
general(vl,
"Flavor combination = %d, %d\n", iq + 1, jq + 1);
469 double result_2 = corr.
meson_all(sq[iq], sq[jq]);
486 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
void general(const char *format,...)
int calculate_hadron_correlator_withFileIO(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)
Field * getptr_smearedConfig(int i_smear)
get pointer to i-th smeared config (0th is original thin link)
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()
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
int get_Nsmear()
get number of applied smearing operation
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
virtual void read_file(Field *v, std::string)=0
read data from file.
virtual void write_file(Field *v, std::string)=0
write data to file.
int hadron_2ptFunction_withFileIO_Wilson()
void set_parameters(const Parameters ¶ms)
set parameters, must be called before set_config
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
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