Bridge++  Ver. 1.3.x
test_Gauge_Plaquette.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "gaugeConfig.h"
17 #include "staples.h"
18 
19 #include "randomNumbers_Mseries.h"
20 
21 //====================================================================
23 
32 namespace Test_Gauge {
33  const std::string test_name = "Gauge.Plaquette";
34 
35  //- test-private parameters
36  namespace {
37  const std::string filename_input = "test_Gauge.yaml";
38  const std::string filename_output = "stdout";
39 
40  class Parameters_Test_Gauge : public Parameters {
41  public:
42  Parameters_Test_Gauge()
43  {
44  Register_string("gauge_config_status", "NULL");
45  Register_string("gauge_config_type_input", "NULL");
46  Register_string("config_filename_input", "NULL");
47 
48  Register_string("verbose_level", "NULL");
49 
50  Register_double("expected_result", 0.0);
51  }
52  };
53  }
54 
55  //- prototype declaration
56  int plaquette(void);
57 
58 #ifdef USE_TESTMANAGER_AUTOREGISTER
59  namespace {
60 #if defined(USE_GROUP_SU2)
61  // Nc=2 is not available.
62 #else
63  static const bool is_registered = TestManager::RegisterTest(
64  test_name,
65  plaquette
66  );
67 #endif
68  }
69 #endif
70 
71  //====================================================================
72  int plaquette(void)
73  {
74  // ##### parameter setup #####
75  int Nvol = CommonParameters::Nvol();
76  int Ndim = CommonParameters::Ndim();
77 
78  unique_ptr<Parameters> params_test(new Parameters_Test_Gauge);
79  unique_ptr<Parameters> params_all(new Parameters);
80 
81  params_all->Register_Parameters("Test_Gauge", params_test);
82 
83  ParameterManager::read(filename_input, params_all);
84 
85  const string str_gconf_status = params_test->get_string("gauge_config_status");
86  const string str_gconf_read = params_test->get_string("gauge_config_type_input");
87  const string readfile = params_test->get_string("config_filename_input");
88  const string str_vlevel = params_test->get_string("verbose_level");
89 
90  const bool do_check = params_test->is_set("expected_result");
91  const double expected_result = do_check ? params_test->get_double("expected_result") : 0.0;
92 
94 
95  //- print input parameters
96  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
97  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
98  vout.general(vl, " readfile = %s\n", readfile.c_str());
99  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
100  vout.general(vl, "\n");
101 
102  //- input parameter check
103  int err = 0;
104  err += ParameterCheck::non_NULL(str_gconf_status);
105 
106  if (err) {
107  vout.crucial(vl, "%s: Input parameters have not been set.\n", test_name.c_str());
108  exit(EXIT_FAILURE);
109  }
110 
111 
112  // #### Set up a gauge configuration ####
113  unique_ptr<Field_G> U(new Field_G(Nvol, Ndim));
114  unique_ptr<GaugeConfig> gconf_read(new GaugeConfig(str_gconf_read));
115 
116  if (str_gconf_status == "Continue") {
117  gconf_read->read_file(U, readfile);
118  } else if (str_gconf_status == "Cold_start") {
119  U->set_unit();
120  } else if (str_gconf_status == "Hot_start") {
121  int i_seed_noise = 1234567;
122  unique_ptr<RandomNumbers> rand(new RandomNumbers_Mseries(i_seed_noise));
123  U->set_random(rand);
124  } else {
125  vout.crucial(vl, "%s: unsupported gconf status \"%s\".\n", test_name.c_str(), str_gconf_status.c_str());
126  exit(EXIT_FAILURE);
127  }
128 
129 
130  // #### object setup #####
131  unique_ptr<Staples> staple(new Staples);
132  unique_ptr<Timer> timer(new Timer(test_name));
133 
134 
135  // #### Execution main part ####
136  timer->start();
137 
138  double result = staple->plaquette(*U);
139  vout.general(vl, "plaq = %.8f\n", result);
140 
141  timer->report();
142 
143 
144  if (do_check) {
145  return Test::verify(result, expected_result);
146  } else {
147  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
148  return EXIT_SKIP;
149  }
150  }
151 } // namespace Test_Gauge
#define EXIT_SKIP
Definition: test.h:17
Random number generator base on M-series.
BridgeIO vout
Definition: bridgeIO.cpp:278
void detailed(const char *format,...)
Definition: bridgeIO.cpp:82
Staple construction.
Definition: staples.h:40
void general(const char *format,...)
Definition: bridgeIO.cpp:65
double plaquette(const Field_G &)
calculates plaquette value.
Definition: staples.cpp:36
Class for parameters.
Definition: parameters.h:38
void read_file(Field *U, const string &filename)
Definition: gaugeConfig.cpp:56
void set_random(RandomNumbers *rand)
Definition: field_G_imp.cpp:62
void set_unit()
Definition: field_G_imp.cpp:39
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:80
const std::string test_name
SU(N) gauge field.
Definition: field_G.h:38
bool is_set(const string &) const
Definition: parameters.cpp:372
Test of gauge quantities.
double get_double(const string &key) const
Definition: parameters.cpp:27
int non_NULL(const std::string v)
Definition: checker.cpp:61
void start()
Definition: timer.cpp:44
void crucial(const char *format,...)
Definition: bridgeIO.cpp:48
void Register_Parameters(const string &, Parameters *const)
Definition: parameters.cpp:358
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:39
static void read(const std::string &params_file, Parameters *params)
GaugeConfig class for file I/O of gauge configuration.
Definition: gaugeConfig.h:61
Definition: timer.h:31
string get_string(const string &key) const
Definition: parameters.cpp:87
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
Definition: timer.cpp:128
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:28