Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_WilsonLoop.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "IO/gaugeConfig.h"
17 
19 
22 
24 
25 //====================================================================
27 
36 namespace Test_WilsonLoop {
37  const std::string test_name = "WilsonLoop";
38 
39  //- test-private parameters
40  namespace {
41  const std::string filename_input = "test_WilsonLoop.yaml";
42  }
43 
44  //- prototype declaration
45  int wilsonloop(void);
46 
47 #ifdef USE_TESTMANAGER_AUTOREGISTER
48  namespace {
49 #if defined(USE_GROUP_SU2)
50  // Nc=2 is not available.
51 #else
52  static const bool is_registered = TestManager::RegisterTest(
53  test_name,
55  );
56 #endif
57  }
58 #endif
59 
60  //====================================================================
61  int wilsonloop(void)
62  {
63  // #### parameter setup ####
64  const int Nvol = CommonParameters::Nvol();
65  const int Ndim = CommonParameters::Ndim();
66 
67  const Parameters params_all = ParameterManager::read(filename_input);
68 
69  const Parameters params_test = params_all.lookup("Test_WilsonLoop");
70  const Parameters params_wilsonloop = params_all.lookup("WilsonLoop");
71  const Parameters params_proj = params_all.lookup("Projection");
72  const Parameters params_smear = params_all.lookup("Smear_APE_spatial");
73 
74  const string str_gconf_status = params_test.get_string("gauge_config_status");
75  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
76  const string readfile = params_test.get_string("config_filename_input");
77  const string str_rand_type = params_test.get_string("random_number_type");
78  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
79  const int Nsmear = params_test.get_int("number_of_max_smearing");
80  const int Nmeas = params_test.get_int("number_of_measurement_step");
81  const string str_vlevel = params_test.get_string("verbose_level");
82 
83  const bool do_check = params_test.is_set("expected_result");
84  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
85 
86  const string str_proj_type = params_proj.get_string("projection_type");
87 
88  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
89 
90  //- print input parameters
91  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
92  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
93  vout.general(vl, " readfile = %s\n", readfile.c_str());
94  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
95  vout.general(vl, " seed = %lu\n", seed);
96  vout.general(vl, " Nsmear = %d\n", Nsmear);
97  vout.general(vl, " Nmeas = %d\n", Nmeas);
98  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
99  vout.general(vl, "\n");
100 
101  //- input parameter check
102  int err = 0;
103  err += ParameterCheck::non_NULL(str_gconf_status);
104 
105  if (err) {
106  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
107  exit(EXIT_FAILURE);
108  }
109 
110 
111  RandomNumberManager::initialize(str_rand_type, seed);
112 
113 
114  // #### Set up a gauge configuration ####
115  unique_ptr<Field_G> U(new Field_G(Nvol, Ndim));
116 
117  if (str_gconf_status == "Continue") {
118  GaugeConfig(str_gconf_read).read(U, readfile);
119  } else if (str_gconf_status == "Cold_start") {
120  GaugeConfig("Unit").read(U);
121  } else if (str_gconf_status == "Hot_start") {
122  GaugeConfig("Random").read(U);
123  } else {
124  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
125  exit(EXIT_FAILURE);
126  }
127 
128 
129  // #### object setup #####
131  wilsonloop.set_parameters(params_wilsonloop);
132 
133  unique_ptr<Projection> proj(Projection::New(str_proj_type));
134  proj->set_parameters(params_proj);
135 
136  const unique_ptr<Smear> smear(Smear::New("APE_spatial", proj));
137  smear->set_parameters(params_smear);
138 
139  const unique_ptr<Timer> timer(new Timer(test_name));
140 
141 
142  // #### Execution main part ####
143  timer->start();
144 
145  Field_G Uorg(Nvol, Ndim);
146  Uorg = *U;
147 
148  double result = 0.0;
149  for (int i_smear = 0; i_smear <= Nsmear; ++i_smear) {
150  vout.general(vl, "i_smear = %d\n", i_smear);
151 
152  Field_G Usmear(Nvol, Ndim);
153  if (i_smear == 0) copy(Usmear, Uorg);
154  if (i_smear > 0) smear->smear(Usmear, Uorg);
155 
156  if ((i_smear % Nmeas) == 0) {
157  result = wilsonloop.measure(Usmear);
158  }
159 
160  Uorg = Usmear;
161  }
162 
163  timer->report();
164 
166 
167 
168  if (do_check) {
169  return Test::verify(result, expected_result);
170  } else {
171  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
172  return EXIT_SKIP;
173  }
174  }
175 } // namespace Test_WilsonLoop
#define EXIT_SKIP
Definition: test.h:17
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
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
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:532
double measure(const Field_G &U)
main function to measure Wilson loops.
Definition: wilsonLoop.cpp:147
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
virtual void smear(Field_G &, const Field_G &)=0
int non_NULL(const std::string v)
bool is_set(const string &key) const
Definition: parameters.cpp:528
void start()
Definition: timer.cpp:44
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
static void read(const std::string &params_file, Parameters &params)
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
virtual void set_parameters(const Parameters &params)
setting parameters.
Definition: wilsonLoop.cpp:19
Bridge::VerboseLevel vl
VerboseLevel
Definition: bridgeIO.h:42
Wilson loop measurement.
Definition: wilsonLoop.h:44
const std::string test_name
GaugeConfig class for file I/O of gauge configuration.
Definition: gaugeConfig.h:78
Definition: timer.h:31
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