Bridge++  Version 1.4.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_QuarkNumberSusceptibility_Clover_Isochemical.cpp
Go to the documentation of this file.
1 
14 #include "Tests/test.h"
15 
17 #include "Fopr/fopr_Smeared.h"
18 
19 #include "IO/gaugeConfig.h"
20 
24 
25 #include "Smear/projection.h"
26 #include "Smear/smear.h"
27 
30 
31 //====================================================================
33 
46 namespace Test_QuarkNumSuscept {
47  const std::string test_name = "QuarkNumberSusceptibility.Clover_Isochemical";
48 
49  // test-private parameters
50  namespace {
51  const std::string filename_input = "test_QuarkNumberSusceptibility_Clover_Isochemical.yaml";
52  }
53 
54  // prototype declaration
55  int quark_num_suscept(void);
56 
57 #ifdef USE_TESTMANAGER_AUTOREGISTER
58  namespace {
59 #if defined(USE_GROUP_SU2)
60  // Nc=2 is not available.
61 #else
62  static const bool is_registered = TestManager::RegisterTest(
63  test_name,
65  );
66 #endif
67  }
68 #endif
69 
70  //====================================================================
72  {
73  // ##### parameter setup #####
74  int Nc = CommonParameters::Nc();
75  int Nvol = CommonParameters::Nvol();
76  int Ndim = CommonParameters::Ndim();
77 
78  Parameters params_all = ParameterManager::read(filename_input);
79 
80  Parameters params_test = params_all.lookup("Test_QuarkNumSuscept_Clover_Isochemical");
81  Parameters params_clover = params_all.lookup("Fopr_Clover_Isochemical");
82  Parameters params_proj = params_all.lookup("Projection");
83  Parameters params_smear = params_all.lookup("Smear");
84  Parameters params_dr_smear = params_all.lookup("Director_Smear");
85  Parameters params_solver = params_all.lookup("Solver");
86 
87  const string str_gconf_status = params_test.get_string("gauge_config_status");
88  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
89  const string readfile = params_test.get_string("config_filename_input");
90  const string str_rand_type = params_test.get_string("random_number_type");
91  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
92  int i_seed_noise = params_test.get_int("int_seed_for_noise");
93  const string str_vlevel = params_test.get_string("verbose_level");
94 
95  const bool do_check = params_test.is_set("expected_result");
96  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
97 
98  const string str_gmset_type = params_clover.get_string("gamma_matrix_type");
99  const string str_proj_type = params_proj.get_string("projection_type");
100  const string str_smear_type = params_smear.get_string("smear_type");
101  const string str_solver_type = params_solver.get_string("solver_type");
102 
104 
105  //- print input parameters
106  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
107  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
108  vout.general(vl, " readfile = %s\n", readfile.c_str());
109  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
110  vout.general(vl, " seed = %lu\n", seed);
111  vout.general(vl, " i_seed_noise = %d\n", i_seed_noise);
112  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
113  vout.general(vl, " gmset_type = %s\n", str_gmset_type.c_str());
114  vout.general(vl, " proj_type = %s\n", str_proj_type.c_str());
115  vout.general(vl, " smear_type = %s\n", str_smear_type.c_str());
116  vout.general(vl, " solver_type = %s\n", str_solver_type.c_str());
117 
118  //- input parameter check
119  int err = 0;
120  err += ParameterCheck::non_NULL(str_gconf_status);
121  err += ParameterCheck::non_zero(i_seed_noise);
122 
123  if (err) {
124  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
125  exit(EXIT_FAILURE);
126  }
127 
128 
129  RandomNumberManager::initialize(str_rand_type, seed);
130 
131 
132  // ##### Set up a gauge configuration ####
133  unique_ptr<Field_G> U(new Field_G(Nvol, Ndim));
134 
135  if (str_gconf_status == "Continue") {
136  GaugeConfig(str_gconf_read).read(U, readfile);
137  } else if (str_gconf_status == "Cold_start") {
138  GaugeConfig("Unit").read(U);
139  } else if (str_gconf_status == "Hot_start") {
140  GaugeConfig("Random").read(U);
141  } else {
142  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
143  exit(EXIT_FAILURE);
144  }
145 
146 
147  // ##### object setup #####
148  unique_ptr<Fopr> fopr_c(Fopr::New("Clover_Isochemical", str_gmset_type));
149  fopr_c->set_parameters(params_clover);
150 
151  unique_ptr<Projection> proj(Projection::New(str_proj_type));
152  proj->set_parameters(params_proj);
153 
154  unique_ptr<Smear> smear(Smear::New(str_smear_type, proj));
155  smear->set_parameters(params_smear);
156 
157  unique_ptr<Director> dr_smear(new Director_Smear(smear));
158  dr_smear->set_parameters(params_dr_smear);
159 
160  unique_ptr<Fopr> fopr_smear(Fopr::New("Smeared", fopr_c, dr_smear));
161  fopr_smear->set_config(U);
162 
163 
164  //- Random number is initialized with a parameter specified by iseed
165  unique_ptr<RandomNumbers> rand(new RandomNumbers_Mseries(i_seed_noise));
167 
168  unique_ptr<Solver> solver(Solver::New(str_solver_type, fopr_smear));
169  solver->set_parameters(params_solver);
170  unique_ptr<Fprop> fprop_lex(new Fprop_Standard_lex(solver));
171 
172  unique_ptr<QuarkNumberSusceptibility_Wilson> quark_suscept(new QuarkNumberSusceptibility_Wilson(fopr_smear, fprop_lex, nv));
173  quark_suscept->set_parameters(params_test);
174 
175  unique_ptr<Timer> timer(new Timer(test_name));
176 
177 
178  // #### Execution main part ####
179  timer->start();
180 
181  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
#define EXIT_SKIP
Definition: test.h:17
Random number generator base on M-series.
BridgeIO vout
Definition: bridgeIO.cpp:495
void detailed(const char *format,...)
Definition: bridgeIO.cpp:212
virtual void set_parameters(const Parameters &param)=0
void general(const char *format,...)
Definition: bridgeIO.cpp:195
virtual void set_config(Field *)=0
setting pointer to the gauge configuration.
virtual void set_parameters(const Parameters &)=0
int get_int(const string &key) const
Definition: parameters.cpp:87
Class for parameters.
Definition: parameters.h:46
virtual void set_parameters(const Parameters &params)=0
Parameters lookup(const string &key) const
Definition: parameters.h:78
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:69
static bool initialize(const std::string &rng_type, unsigned long seed)
SU(N) gauge field.
Definition: field_G.h:38
void read(Field_G *U, const string &filename=string())
unsigned long get_unsigned_long(const string &key) const
Definition: parameters.cpp:104
double get_double(const string &key) const
Definition: parameters.cpp:70
Quark number susceptibility for the Wilson-type fermion.
virtual void set_parameters(const Parameters &)=0
double measure()
measure tr1 = Tr[D1*Sq], tr2 = Tr[D2*Sq], tr3 = Tr[D1*Sq*D1*Sq].
int non_NULL(const std::string v)
Definition: checker.cpp:61
bool is_set(const string &key) const
Definition: parameters.cpp:396
void start()
Definition: timer.cpp:44
Get quark propagator for Fopr with lexical site index.
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
virtual void set_parameters(const Parameters &params)=0
static void read(const std::string &params_file, Parameters &params)
Manager of smeared configurations.
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
Bridge::VerboseLevel vl
Definition: checker.cpp:18
VerboseLevel
Definition: bridgeIO.h:42
int non_zero(const double v)
Definition: checker.cpp:31
GaugeConfig class for file I/O of gauge configuration.
Definition: gaugeConfig.h:75
Definition: timer.h:31
Z2 Noise vector for a trace calculation.
string get_string(const string &key) const
Definition: parameters.cpp:116
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
Definition: timer.cpp:128
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131