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