Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  unique_ptr<Field_G> U(new Field_G(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  const unique_ptr<PolyakovLoop> ploop(new PolyakovLoop());
121  ploop->set_parameters(params_ploop);
122 
123  const unique_ptr<Timer> timer(new Timer(test_name));
124 
125 
126  // #### Execution main part ####
127  timer->start();
128 
129  const dcomplex result = ploop->measure_ploop(*U);
130 
131  timer->report();
132 
134 
135 
136  if (do_check) {
137  return Test::verify(real(result), expected_result);
138  } else {
139  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
140  return EXIT_SKIP;
141  }
142  }
143 } // namespace Test_PolyakovLoop
#define EXIT_SKIP
Definition: test.h:17
BridgeIO vout
Definition: bridgeIO.cpp:503
virtual void set_parameters(const Parameters &params)
setting parameters: only for Polyakov loop correlators.
const std::string test_name
void detailed(const char *format,...)
Definition: bridgeIO.cpp:216
void general(const char *format,...)
Definition: bridgeIO.cpp:197
Class for parameters.
Definition: parameters.h:46
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
Polyakov loop measurement.
Definition: polyakovLoop.h:40
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
Bridge::VerboseLevel vl
VerboseLevel
Definition: bridgeIO.h:42
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
dcomplex measure_ploop(const Field_G &U)
Polyakov loop measurement.