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