Bridge++  Ver. 2.0.2
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  Field_G U(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 #####
130  WilsonLoop wilsonloop(params_wilsonloop);
131 
132  unique_ptr<Projection> proj(Projection::New(str_proj_type, params_proj));
133  unique_ptr<Smear> smear(Smear::New("APE_spatial", proj.get(), params_smear));
134 
135  Timer timer(test_name);
136 
137 
138  // #### Execution main part ####
139  timer.start();
140 
141  Field_G Uorg(Nvol, Ndim);
142  Uorg = U;
143 
144  double result = 0.0;
145  for (int i_smear = 0; i_smear <= Nsmear; ++i_smear) {
146  vout.general(vl, "i_smear = %d\n", i_smear);
147 
148  Field_G Usmear(Nvol, Ndim);
149  if (i_smear == 0) copy(Usmear, Uorg);
150  if (i_smear > 0) smear->smear(Usmear, Uorg);
151 
152  if ((i_smear % Nmeas) == 0) {
153  result = wilsonloop.measure(Usmear);
154  }
155 
156  Uorg = Usmear;
157  }
158 
159  timer.report();
160 
162 
163 
164  if (do_check) {
165  return Test::verify(result, expected_result);
166  } else {
167  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
168  return EXIT_SKIP;
169  }
170  }
171 } // namespace Test_WilsonLoop
WilsonLoop
Wilson loop measurement.
Definition: wilsonLoop.h:44
Test::verify
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
smear_APE_spatial.h
ParameterCheck::non_NULL
int non_NULL(const std::string v)
Definition: parameterCheck.cpp:65
projection_Maximum_SU_N.h
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Parameters
Class for parameters.
Definition: parameters.h:46
wilsonLoop.h
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
gaugeConfig.h
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Test_WilsonLoop
Test of Wilson loop measurement.
Definition: testlist.h:290
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
RandomNumberManager::initialize
static bool initialize(const std::string &rng_type, unsigned long seed)
Definition: randomNumberManager.cpp:57
Test_WilsonLoop::wilsonloop
int wilsonloop(void)
Definition: test_WilsonLoop.cpp:61
Timer::start
void start()
Definition: timer.cpp:44
ParameterCheck::vl
Bridge::VerboseLevel vl
Definition: parameterCheck.cpp:18
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
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
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
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Test_WilsonLoop::test_name
const std::string test_name
Definition: test_WilsonLoop.cpp:37
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