Bridge++  Version 1.5.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 "test.h"
15 
17 #include "Fopr/fopr_Smeared.h"
18 
19 #include "IO/gaugeConfig.h"
20 
24 
27 
28 //====================================================================
30 
43 namespace Test_QuarkNumSuscept {
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_Isochemical");
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 string str_solver_type = params_solver.get_string("solver_type");
99 
100  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
101 
102  //- print input parameters
103  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
104  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
105  vout.general(vl, " readfile = %s\n", readfile.c_str());
106  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
107  vout.general(vl, " seed = %lu\n", seed);
108  vout.general(vl, " i_seed_noise = %d\n", i_seed_noise);
109  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
110  vout.general(vl, " gmset_type = %s\n", str_gmset_type.c_str());
111  vout.general(vl, " proj_type = %s\n", str_proj_type.c_str());
112  vout.general(vl, " smear_type = %s\n", str_smear_type.c_str());
113  vout.general(vl, " solver_type = %s\n", str_solver_type.c_str());
114 
115  //- input parameter check
116  int err = 0;
117  err += ParameterCheck::non_NULL(str_gconf_status);
118  err += ParameterCheck::non_zero(i_seed_noise);
119 
120  if (err) {
121  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
122  exit(EXIT_FAILURE);
123  }
124 
125 
126  RandomNumberManager::initialize(str_rand_type, seed);
127 
128 
129  // ##### Set up a gauge configuration ####
130  unique_ptr<Field_G> U(new Field_G(Nvol, Ndim));
131 
132  if (str_gconf_status == "Continue") {
133  GaugeConfig(str_gconf_read).read(U, readfile);
134  } else if (str_gconf_status == "Cold_start") {
135  GaugeConfig("Unit").read(U);
136  } else if (str_gconf_status == "Hot_start") {
137  GaugeConfig("Random").read(U);
138  } else {
139  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
140  exit(EXIT_FAILURE);
141  }
142 
143 
144  // ##### object setup #####
145  unique_ptr<Fopr> fopr_c(Fopr::New("Clover_Isochemical", str_gmset_type));
146  fopr_c->set_parameters(params_clover);
147 
148  unique_ptr<Projection> proj(Projection::New(str_proj_type));
149  proj->set_parameters(params_proj);
150 
151  unique_ptr<Smear> smear(Smear::New(str_smear_type, proj));
152  smear->set_parameters(params_smear);
153 
154  unique_ptr<Director> dr_smear(new Director_Smear(smear));
155  dr_smear->set_parameters(params_dr_smear);
156 
157  unique_ptr<Fopr> fopr_smear(Fopr::New("Smeared", fopr_c, dr_smear));
158  fopr_smear->set_config(U);
159 
160 
161  //- Random number is initialized with a parameter specified by iseed
162  unique_ptr<RandomNumbers> rand(new RandomNumbers_Mseries(i_seed_noise));
164 
165  unique_ptr<Solver> solver(Solver::New(str_solver_type, fopr_smear));
166  solver->set_parameters(params_solver);
167  unique_ptr<Fprop> fprop_lex(new Fprop_Standard_lex(solver));
168 
169  const unique_ptr<QuarkNumberSusceptibility_Wilson> quark_suscept(new QuarkNumberSusceptibility_Wilson(fopr_smear, fprop_lex, nv));
170  quark_suscept->set_parameters(params_test);
171 
172  const unique_ptr<Timer> timer(new Timer(test_name));
173 
174 
175  // #### Execution main part ####
176  timer->start();
177 
178  const double result = quark_suscept->measure();
179 
180  timer->report();
181 
182 
184 
185 
186  if (do_check) {
187  return Test::verify(result, expected_result);
188  } else {
189  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
190  return EXIT_SKIP;
191  }
192  }
193 } // namespace Test_QuarkNumSuscept
#define EXIT_SKIP
Definition: test.h:17
Random number generator base on M-series.
BridgeIO vout
Definition: bridgeIO.cpp:503
void detailed(const char *format,...)
Definition: bridgeIO.cpp:216
virtual void set_parameters(const Parameters &param)=0
void general(const char *format,...)
Definition: bridgeIO.cpp:197
int solver(const std::string &)
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:192
Class for parameters.
Definition: parameters.h:46
virtual void set_parameters(const Parameters &params)=0
Parameters lookup(const string &key) const
Definition: parameters.h:79
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:209
double get_double(const string &key) const
Definition: parameters.cpp:175
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)
bool is_set(const string &key) const
Definition: parameters.cpp:528
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
VerboseLevel
Definition: bridgeIO.h:42
int non_zero(const double v)
GaugeConfig class for file I/O of gauge configuration.
Definition: gaugeConfig.h:78
Definition: timer.h:31
Z2 Noise vector for a trace calculation.
string get_string(const string &key) const
Definition: parameters.cpp:221
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