57 const std::string
test_name =
"Spectrum.Hadron2ptFunction_withFileIO_initial_guess";
101 #ifdef USE_TESTMANAGER_AUTOREGISTER
103 #if defined(USE_GROUP_SU2)
107 "Spectrum.Clover.Hadron2ptFunction_withFileIO_initial_guess",
147 const int N_quark = params_test.
get_int(
"number_of_valence_quarks");
149 const std::string str_gconf_status = params_test.
get_string(
"gauge_config_status");
150 const std::string str_gconf_read = params_test.
get_string(
"gauge_config_type_input");
151 const std::string readfile = params_test.
get_string(
"config_filename_input");
152 const vector<int> Nshift_origin = params_test.
get_int_vector(
"shift_origin");
153 const std::string str_vlevel = params_test.
get_string(
"verbose_level");
155 const std::string str_gfix_type = params_all.
lookup(
"GaugeFixing").
get_string(
"gauge_fixing_type");
156 const std::string str_proj_type = params_all.
lookup(
"Projection").
get_string(
"projection_type");
157 const std::string str_smear_type = params_all.
lookup(
"Smear").
get_string(
"smear_type");
158 const int Nsmear = params_all.
lookup(
"Director_Smear").
get_int(
"number_of_smearing");
163 vout.
general(
vl,
" gconf_status = %s\n", str_gconf_status.c_str());
164 vout.
general(
vl,
" gconf_read = %s\n", str_gconf_read.c_str());
166 for (
int mu = 0; mu < Ndim; ++mu) {
167 vout.
general(
vl,
" shift_origin[%d] = %d\n", mu, Nshift_origin[mu]);
170 vout.
general(
vl,
" gfix_type = %s\n", str_gfix_type.c_str());
171 vout.
general(
vl,
" proj_type = %s\n", str_proj_type.c_str());
172 vout.
general(
vl,
" smear_type = %s\n", str_smear_type.c_str());
174 vector<Parameters> params_quark;
175 for (
int iq = 0; iq < N_quark; ++iq) {
177 params_quark.push_back(params_all.
lookup(qlabel));
181 std::string str_gmset_type = params_quark[0].lookup(
"Fopr").get_string(
"gamma_matrix_type");
182 vout.
general(
vl,
" gmset_type = %s\n", str_gmset_type.c_str());
184 std::vector<std::string> savefile_base(N_quark);
185 for (
int iq = 0; iq < N_quark; ++iq) {
186 savefile_base[iq] = params_quark[iq].get_string(
"temporary_filename_base");
189 for (
int iq = 0; iq < N_quark; ++iq) {
190 std::string str_solver_type = params_quark[iq].lookup(
"Solver").get_string(
"solver_type");
191 std::string str_source_type = params_quark[iq].lookup(
"Source").get_string(
"source_type");
192 vector<int> source_position = params_quark[iq].lookup(
"Source").get_int_vector(
"source_position");
195 vout.
general(
vl,
" savefile_base[iq] = %s[%d]\n", savefile_base[iq].c_str(), iq);
196 vout.
general(
vl,
" solver_type = %s\n", str_solver_type.c_str());
197 vout.
general(
vl,
" source_type = %s\n", str_source_type.c_str());
198 for (
int mu = 0; mu < Ndim; ++mu) {
199 vout.
general(
vl,
" source_position[%d] = %d\n", mu, source_position[mu]);
214 for (
int iq = 0; iq < N_quark; ++iq) {
215 std::string str_solver_type = params_quark[iq].lookup(
"Solver").get_string(
"solver_type");
217 if (str_solver_type ==
"CG") {
223 if ((Nsmear > 0) && (str_proj_type ==
"Stout_SU3")) {
232 if ((str_gfix_type ==
"Coulomb") || (str_gfix_type ==
"Landau")) {
246 if (str_gconf_status ==
"Continue") {
248 }
else if (str_gconf_status ==
"Cold_start") {
250 }
else if (str_gconf_status ==
"Hot_start") {
253 vout.
crucial(
vl,
"Error at %s: unsupported gconf status \"%s\"\n",
test_name.c_str(), str_gconf_status.c_str());
259 for (
int i_dir = 0; i_dir < Ndim; ++i_dir) {
260 for (
int i_shift = 0; i_shift < Nshift_origin[i_dir]; ++i_shift) {
262 shift.backward(Ushift, U, i_dir);
269 unique_ptr<Projection> proj(Projection::New(str_proj_type, params_all.
lookup(
"Projection")));
270 unique_ptr<Smear> smear(Smear::New(str_smear_type, proj.get(), params_all.
lookup(
"Smear")));
271 unique_ptr<Director_Smear> dr_smear(
new Director_Smear(smear.get(), params_all.
lookup(
"Director_Smear")));
272 dr_smear->set_config(&U);
274 const Field_G *Usmear = (
Field_G *)dr_smear->getptr_smearedConfig(Nsmear);
281 unique_ptr<GaugeFixing> gfix(GaugeFixing::New(str_gfix_type, params_all.
lookup(
"GaugeFixing")));
292 unique_ptr<Fopr> fopr;
293 unique_ptr<Solver>
solver;
294 unique_ptr<Fprop> fprop;
295 unique_ptr<Source> source;
299 std::vector<QuarkType> quark(N_quark);
301 for (
int iq = 0; iq < N_quark; ++iq) {
306 quark[iq].fopr.reset(Fopr::New(params_fopr.
get_string(
"fermion_type"),
308 quark[iq].fopr->set_config(&U);
310 quark[iq].solver.reset(Solver::New(params_solver.
get_string(
"solver_type"),
311 quark[iq].fopr.get(),
313 quark[iq].use_init_guess = params_solver.
get_bool(
"use_initial_guess");
317 quark[iq].source.reset(Source::New(params_source.
get_string(
"source_type"),
326 for (
int iq = 0; iq < N_quark; ++iq) {
327 vout.
general(
vl,
"Solving quark propagator, flavor = %d:\n", iq + 1);
330 for (
int ispin = 0; ispin < Nd; ++ispin) {
331 for (
int icolor = 0; icolor < Nc; ++icolor) {
332 int i_cd = icolor + Nc * ispin;
335 quark[iq].source->
set(b, i_cd);
343 savefile_base[iq].c_str(), (icolor + 1), (ispin + 1));
345 if (quark[iq].use_init_guess) {
347 std::ifstream ifs(filename);
349 field_io->read_file(xq, filename);
353 quark[iq].fprop->invert_D(xq, b, Nconv, diff);
356 quark[iq].fopr->set_mode(
"D");
357 quark[iq].fopr->mult(y, xq);
362 icolor, ispin, Nconv, diff, diff2);
364 field_io->write_file(xq, filename);
388 const int N_quark = params_test.
get_int(
"number_of_valence_quarks");
390 const std::string str_vlevel = params_test.
get_string(
"verbose_level");
392 const bool do_check = params_test.
is_set(
"expected_result");
393 const double expected_result = do_check ? params_test.
get_double(
"expected_result") : 0.0;
395 const std::string str_proj_type = params_all.
lookup(
"Projection").
get_string(
"projection_type");
396 const int Nsmear = params_all.
lookup(
"Director_Smear").
get_int(
"number_of_smearing");
398 std::vector<std::string> savefile_base(N_quark);
400 for (
int iq = 0; iq < N_quark; ++iq) {
401 savefile_base[iq] = params_all
412 const std::string str_gmset_type = params_all.
lookup(
"Quark_1").
lookup(
"Fopr").
get_string(
"gamma_matrix_type");
413 vout.
general(
vl,
" gmset_type = %s\n", str_gmset_type.c_str());
415 for (
int iq = 0; iq < N_quark; ++iq) {
416 vout.
general(
vl,
" savefile_base[iq] = %s[%d]\n", savefile_base[iq].c_str(), iq);
419 if ((Nsmear > 0) && (str_proj_type ==
"Stout_SU3")) {
428 unique_ptr<GammaMatrixSet> gmset(GammaMatrixSet::New(str_gmset_type));
436 typedef std::vector<Field_F> PropagatorSet;
437 std::vector<PropagatorSet> sq(N_quark);
438 for (
int iq = 0; iq < N_quark; ++iq) {
439 sq[iq].resize(Nc * Nd);
441 for (
int i_cd = 0; i_cd < Nc * Nd; ++i_cd) {
442 sq[iq][i_cd].set(0.0);
447 for (
int iq = 0; iq < N_quark; ++iq) {
448 for (
int ispin = 0; ispin < Nd; ++ispin) {
449 for (
int icolor = 0; icolor < Nc; ++icolor) {
450 int i_cd = icolor + Nc * ispin;
453 field_io->read_file(sq[iq][i_cd], filename);
460 std::vector<double> result(N_quark);
465 for (
int iq = 0; iq < N_quark; ++iq) {
466 vout.
general(
vl,
"Flavor combination = %d, %d\n", iq + 1, iq + 1);
467 result[iq] = corr.
meson_all(sq[iq], sq[iq]);
473 for (
int iq = 0; iq < N_quark; ++iq) {
474 for (
int jq = iq + 1; jq < N_quark; ++jq) {
475 vout.
general(
vl,
"Flavor combination = %d, %d\n", iq + 1, jq + 1);
476 double result_2 = corr.
meson_all(sq[iq], sq[jq]);