Bridge++  Ver. 2.0.2
test_QuarkNumberSusceptibility_Clover_Isochemical.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
17 #include "Fopr/fopr_Smeared.h"
18 
19 #include "IO/gaugeConfig.h"
20 
24 
27 
28 //====================================================================
30 
44  const std::string test_name = "QuarkNumberSusceptibility.Clover_Isochemical";
45 
46  // test-private parameters
47  namespace {
48  const std::string filename_input = "test_QuarkNumberSusceptibility_Clover_Isochemical.yaml";
49  }
50 
51  // prototype declaration
52  int quark_num_suscept(void);
53 
54 #ifdef USE_TESTMANAGER_AUTOREGISTER
55  namespace {
56 #if defined(USE_GROUP_SU2)
57  // Nc=2 is not available.
58 #else
59  static const bool is_registered = TestManager::RegisterTest(
60  test_name,
62  );
63 #endif
64  }
65 #endif
66 
67  //====================================================================
69  {
70  // ##### parameter setup #####
71  const int Nc = CommonParameters::Nc();
72  const int Nvol = CommonParameters::Nvol();
73  const int Ndim = CommonParameters::Ndim();
74 
75  const Parameters params_all = ParameterManager::read(filename_input);
76 
77  const Parameters params_test = params_all.lookup("Test_QuarkNumSuscept_Clover_Isochemical");
78  const Parameters params_clover = params_all.lookup("Fopr_Clover_Chemical");
79  const Parameters params_proj = params_all.lookup("Projection");
80  const Parameters params_smear = params_all.lookup("Smear");
81  const Parameters params_dr_smear = params_all.lookup("Director_Smear");
82  const Parameters params_solver = params_all.lookup("Solver");
83 
84  const string str_gconf_status = params_test.get_string("gauge_config_status");
85  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
86  const string readfile = params_test.get_string("config_filename_input");
87  const string str_rand_type = params_test.get_string("random_number_type");
88  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
89  const int i_seed_noise = params_test.get_int("int_seed_for_noise");
90  const string str_vlevel = params_test.get_string("verbose_level");
91 
92  const bool do_check = params_test.is_set("expected_result");
93  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
94 
95  const string str_gmset_type = params_clover.get_string("gamma_matrix_type");
96  const string str_proj_type = params_proj.get_string("projection_type");
97  const string str_smear_type = params_smear.get_string("smear_type");
98  const int Nsmear = params_dr_smear.get_int("number_of_smearing");
99  const string str_solver_type = params_solver.get_string("solver_type");
100 
101  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
102 
103  //- print input parameters
104  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
105  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
106  vout.general(vl, " readfile = %s\n", readfile.c_str());
107  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
108  vout.general(vl, " seed = %lu\n", seed);
109  vout.general(vl, " i_seed_noise = %d\n", i_seed_noise);
110  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
111  vout.general(vl, " gmset_type = %s\n", str_gmset_type.c_str());
112  vout.general(vl, " proj_type = %s\n", str_proj_type.c_str());
113  vout.general(vl, " smear_type = %s\n", str_smear_type.c_str());
114  vout.general(vl, " solver_type = %s\n", str_solver_type.c_str());
115 
116  //- input parameter check
117  int err = 0;
118  err += ParameterCheck::non_NULL(str_gconf_status);
119  err += ParameterCheck::non_zero(i_seed_noise);
120 
121  if (err) {
122  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
123  exit(EXIT_FAILURE);
124  }
125 
126  if ((Nsmear > 0) && (str_proj_type == "Stout_SU3")) {
127  if (CommonParameters::Nc() != 3) {
128  vout.crucial(vl, "check skipped: Nc = 3 is needed, but Nc = %d.\n\n", CommonParameters::Nc());
129  return EXIT_SKIP;
130  }
131  }
132 
133 
134  RandomNumberManager::initialize(str_rand_type, seed);
135 
136 
137  // ##### Set up a gauge configuration ####
138  Field_G U(Nvol, Ndim);
139 
140  if (str_gconf_status == "Continue") {
141  GaugeConfig(str_gconf_read).read(U, readfile);
142  } else if (str_gconf_status == "Cold_start") {
143  GaugeConfig("Unit").read(U);
144  } else if (str_gconf_status == "Hot_start") {
145  GaugeConfig("Random").read(U);
146  } else {
147  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
148  exit(EXIT_FAILURE);
149  }
150 
151  if (Nsmear > 0) {
152  unique_ptr<Projection> proj(Projection::New(str_proj_type, params_all.lookup("Projection")));
153  unique_ptr<Smear> smear(Smear::New(str_smear_type, proj.get(), params_all.lookup("Smear")));
154  unique_ptr<Director_Smear> dr_smear(new Director_Smear(smear.get(), params_all.lookup("Director_Smear")));
155  dr_smear->set_config(&U);
156 
157  const Field_G *Usmear = (Field_G *)dr_smear->getptr_smearedConfig(Nsmear);
158  copy(U, *Usmear);
159  }
160 
161 
162  // ##### object setup #####
163  unique_ptr<Fopr> fopr(new Fopr_Clover_Chemical(params_clover));
164  fopr->set_config(&U);
165 
166  //- Random number is initialized with a parameter specified by iseed
167  unique_ptr<RandomNumbers> rand(new RandomNumbers_Mseries(i_seed_noise));
168  unique_ptr<NoiseVector> nv(new NoiseVector_Z2(rand.get()));
169 
170  unique_ptr<Solver> solver(Solver::New(str_solver_type, fopr.get(), params_solver));
171  unique_ptr<Fprop> fprop_lex(new Fprop_Standard_lex(solver.get()));
172 
173  unique_ptr<QuarkNumberSusceptibility_Wilson> quark_suscept(new QuarkNumberSusceptibility_Wilson(fopr.get(), fprop_lex.get(), nv.get(), params_test));
174 
175  Timer timer(test_name);
176 
177 
178  // #### Execution main part ####
179  timer.start();
180 
181  const double result = quark_suscept->measure();
182 
183  timer.report();
184 
185 
187 
188 
189  if (do_check) {
190  return Test::verify(result, expected_result);
191  } else {
192  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
193  return EXIT_SKIP;
194  }
195  }
196 } // namespace Test_QuarkNumSuscept
Test::verify
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
randomNumbers_Mseries.h
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
Parameters
Class for parameters.
Definition: parameters.h:46
fopr_Clover_Chemical.h
Fopr_Clover_Chemical
AFopr_Clover_Chemical< Field > Fopr_Clover_Chemical
Definition: fopr_Clover_Chemical.h:19
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
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
QuarkNumberSusceptibility_Wilson
Quark number susceptibility for the Wilson-type fermion.
Definition: quarkNumberSusceptibility_Wilson.h:37
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
noiseVector_Z2.h
ParameterCheck::vl
Bridge::VerboseLevel vl
Definition: parameterCheck.cpp:18
RandomNumbers_Mseries
Random number generator base on M-series.
Definition: randomNumbers_Mseries.h:46
quarkNumberSusceptibility_Wilson.h
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
NoiseVector_Z2
Z2 Noise vector for a trace calculation.
Definition: noiseVector_Z2.h:28
Director_Smear
Manager of smeared configurations.
Definition: director_Smear.h:39
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
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
ParameterCheck::non_zero
int non_zero(const double v)
Definition: parameterCheck.cpp:32
fopr_Smeared.h
Test_QuarkNumSuscept::test_name
const std::string test_name
Definition: test_QuarkNumberSusceptibility_Clover_Isochemical.cpp:44
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
Test_QuarkNumSuscept::quark_num_suscept
int quark_num_suscept(void)
Definition: test_QuarkNumberSusceptibility_Clover_Isochemical.cpp:68
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Test_QuarkNumSuscept
Quark number susceptibility for the Wilson-type fermion.
Definition: test_QuarkNumberSusceptibility_Clover_Isochemical.cpp:43
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