Bridge++  Ver. 2.0.2
test_PolyakovLoop.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "IO/gaugeConfig.h"
17 
19 
20 #include "Smear/smear.h"
21 
23 
24 //====================================================================
26 
34 namespace Test_PolyakovLoop {
35  const std::string test_name = "PolyakovLoop";
36 
37  //- test-private parameters
38  namespace {
39  const std::string filename_input = "test_PolyakovLoop.yaml";
40  }
41 
42  //- prototype declaration
43  int polyakovloop(void);
44 
45 #ifdef USE_TESTMANAGER_AUTOREGISTER
46  namespace {
47 #if defined(USE_GROUP_SU2)
48  // Nc=2 is not available.
49 #else
50  static const bool is_registered = TestManager::RegisterTest(
51  test_name,
53  );
54 #endif
55  }
56 #endif
57 
58  //====================================================================
59  int polyakovloop(void)
60  {
61  // ##### parameter setup #####
62  const int Nvol = CommonParameters::Nvol();
63  const int Ndim = CommonParameters::Ndim();
64 
65  const Parameters params_all = ParameterManager::read(filename_input);
66 
67  const Parameters params_test = params_all.lookup("Test_PolyakovLoop");
68  const Parameters params_ploop = params_all.lookup("PolyakovLoop");
69 
70  const string str_gconf_status = params_test.get_string("gauge_config_status");
71  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
72  const string readfile = params_test.get_string("config_filename_input");
73  const string str_rand_type = params_test.get_string("random_number_type");
74  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
75  const string str_vlevel = params_test.get_string("verbose_level");
76 
77  const bool do_check = params_test.is_set("expected_result");
78  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
79 
80  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
81 
82  //- print input parameters
83  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
84  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
85  vout.general(vl, " readfile = %s\n", readfile.c_str());
86  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
87  vout.general(vl, " seed = %lu\n", seed);
88  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
89  vout.general(vl, "\n");
90 
91  //- input parameter check
92  int err = 0;
93  err += ParameterCheck::non_NULL(str_gconf_status);
94 
95  if (err) {
96  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
97  exit(EXIT_FAILURE);
98  }
99 
100 
101  RandomNumberManager::initialize(str_rand_type, seed);
102 
103 
104  // ##### Set up a gauge configuration ####
105  Field_G U(Nvol, Ndim);
106 
107  if (str_gconf_status == "Continue") {
108  GaugeConfig(str_gconf_read).read(U, readfile);
109  } else if (str_gconf_status == "Cold_start") {
110  GaugeConfig("Unit").read(U);
111  } else if (str_gconf_status == "Hot_start") {
112  GaugeConfig("Random").read(U);
113  } else {
114  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
115  exit(EXIT_FAILURE);
116  }
117 
118 
119  // ##### object setup #####
120  PolyakovLoop ploop(params_ploop);
121 
122  Timer timer(test_name);
123 
124 
125  // #### Execution main part ####
126  timer.start();
127 
128  const dcomplex result = ploop.measure_ploop(U);
129 
130  timer.report();
131 
133 
134 
135  if (do_check) {
136  return Test::verify(real(result), expected_result);
137  } else {
138  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
139  return EXIT_SKIP;
140  }
141  }
142 } // namespace Test_PolyakovLoop
Test_PolyakovLoop::polyakovloop
int polyakovloop(void)
Definition: test_PolyakovLoop.cpp:59
Test::verify
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
ParameterCheck::non_NULL
int non_NULL(const std::string v)
Definition: parameterCheck.cpp:65
Test_PolyakovLoop::test_name
const std::string test_name
Definition: test_PolyakovLoop.cpp:35
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Parameters
Class for parameters.
Definition: parameters.h:46
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
polyakovLoop.h
Timer
Definition: timer.h:31
RandomNumberManager::finalize
static void finalize()
Definition: randomNumberManager.cpp:80
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
PolyakovLoop::measure_ploop
dcomplex measure_ploop(const Field_G &U)
Polyakov loop measurement.
Definition: polyakovLoop.cpp:172
Test_PolyakovLoop
Measurement of Polyakov loop.
Definition: test_PolyakovLoop.cpp:34
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
PolyakovLoop
Polyakov loop measurement.
Definition: polyakovLoop.h:41
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
smear.h
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
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