Bridge++  Ver. 2.0.2
test_GradientFlow_EnergyMomentumTensor_Gauge.cpp
Go to the documentation of this file.
1 
13 #include "test.h"
14 
15 #include "IO/gaugeConfig.h"
16 
19 //#include "Measurements/Gauge/topologicalCharge.h"
20 
22 
23 #include <iomanip> // std::setw, std::setfill
24 
25 //====================================================================
27 
36  const std::string test_name = "GradientFlow.EnergyMomentumTensor.Gauge";
37  const std::string test_name_RK1 = "GradientFlow.EnergyMomentumTensor.Gauge.RK1";
38  const std::string test_name_RK2 = "GradientFlow.EnergyMomentumTensor.Gauge.RK2";
39  const std::string test_name_RK3 = "GradientFlow.EnergyMomentumTensor.Gauge.RK3";
40  const std::string test_name_RK4 = "GradientFlow.EnergyMomentumTensor.Gauge.RK4";
41  const std::string test_name_RK_adaptive = "GradientFlow.EnergyMomentumTensor.Gauge.RK_adaptive";
42 
43 #if 0
44  const std::string test_name = "Test_EnergyMomentumTensor_Gauge";
45  const std::string test_name_RK1 = "Test_EnergyMomentumTensor_Gauge.RK1";
46  const std::string test_name_RK2 = "Test_EnergyMomentumTensor_Gauge.RK2";
47  const std::string test_name_RK3 = "Test_EnergyMomentumTensor_Gauge.RK3";
48  const std::string test_name_RK4 = "Test_EnergyMomentumTensor_Gauge.RK4";
49  const std::string test_name_RK_adaptive = "Test_EnergyMomentumTensor_Gauge.RK_adaptive";
50 #endif
51 
52  //- test-private parameters
53  namespace {
54  const std::string filename_input_RK1 = "test_GradientFlow_EnergyMomentumTensor_Gauge_RK1.yaml";
55  const std::string filename_input_RK2 = "test_GradientFlow_EnergyMomentumTensor_Gauge_RK2.yaml";
56  const std::string filename_input_RK3 = "test_GradientFlow_EnergyMomentumTensor_Gauge_RK3.yaml";
57  const std::string filename_input_RK4 = "test_GradientFlow_EnergyMomentumTensor_Gauge_RK4.yaml";
58  const std::string filename_input_RK_adaptive = "test_GradientFlow_EnergyMomentumTensor_Gauge_RK_adaptive.yaml";
59  // const std::string filename_input = filename_input_RK4;
60  }
61 
62  //- prototype declaration
63  int update(const std::string& filename_input);
64 
66  { return update(filename_input_RK1); }
67 
69  { return update(filename_input_RK2); }
70 
72  { return update(filename_input_RK3); }
73 
75  { return update(filename_input_RK4); }
76 
78  { return update(filename_input_RK_adaptive); }
79 
80 #ifdef USE_TESTMANAGER_AUTOREGISTER
81  namespace {
82 #if defined(USE_GROUP_SU2)
83  // Nc=2 is not available.
84 #else
85  // static const bool is_registered_RK1 = TestManager::RegisterTest(
86  // test_name_RK1,
87  // run_test_RK1
88  // );
89  // static const bool is_registered_RK2 = TestManager::RegisterTest(
90  // test_name_RK2,
91  // run_test_RK2
92  // );
93  // static const bool is_registered_RK3 = TestManager::RegisterTest(
94  // test_name_RK3,
95  // run_test_RK3
96  // );
97  static const bool is_registered_RK4 = TestManager::RegisterTest(
100  );
101  // static const bool is_registered_RK_adaptive = TestManager::RegisterTest(
102  // test_name_RK_adaptive,
103  // run_test_RK_adaptive
104  // );
105 #endif
106  }
107 #endif
108 
109 
110  //====================================================================
111  int update(const std::string& filename_input)
112  {
113  // #### parameter setup ####
114  const int Nvol = CommonParameters::Nvol();
115  const int Ndim = CommonParameters::Ndim();
116  const int Nc = CommonParameters::Nc();
117 
118  const Parameters params_all = ParameterManager::read(filename_input);
119 
120  const Parameters params_test = params_all.lookup("Test_EnergyMomentumTensor_Gauge");
121  //- NB. additional parameter for action_G is set in the following object setup
122  Parameters params_action_G = params_all.lookup("Action_G");
123  const Parameters params_g_flow = params_all.lookup("GradientFlow");
124  const Parameters params_energy_momentum_tensor = params_all.lookup("EnergyMomentumTensor");
125  const Parameters params_topological_charge = params_all.lookup("TopologicalCharge");
126 
127  const string str_gconf_status = params_test.get_string("gauge_config_status");
128  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
129  const string readfile = params_test.get_string("config_filename_input");
130  const string str_gconf_write = params_test.get_string("gauge_config_type_output");
131  const string writefile = params_test.get_string("config_filename_output");
132  const string str_rand_type = params_test.get_string("random_number_type");
133  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
134  int i_conf = params_test.get_int("trajectory_number");
135  const int Nstep = params_test.get_int("number_of_steps");
136  const double t_flow_max = params_test.get_double("max_flow_time");
137  const string str_vlevel = params_test.get_string("verbose_level");
138 
139  const bool do_check = params_test.is_set("expected_result");
140  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
141 
142  const string str_action_G_type = params_action_G.get_string("action_type");
143 
144  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
145 
146  //- print input parameters
147  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
148  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
149  vout.general(vl, " readfile = %s\n", readfile.c_str());
150  vout.general(vl, " gconf_write = %s\n", str_gconf_write.c_str());
151  vout.general(vl, " writefile = %s\n", writefile.c_str());
152  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
153  vout.general(vl, " seed = %lu\n", seed);
154  vout.general(vl, " i_conf = %d\n", i_conf);
155  vout.general(vl, " Nstep = %d\n", Nstep);
156  vout.general(vl, " t_flow_max = %10.6f\n", t_flow_max);
157  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
158  vout.general(vl, "\n");
159 
160  //- input parameter check
161  int err = 0;
162  err += ParameterCheck::non_NULL(str_gconf_status);
163 
164  if (err) {
165  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
166  exit(EXIT_FAILURE);
167  }
168 
169 
170  RandomNumberManager::initialize(str_rand_type, seed);
171 
172 
173  // #### object setup #####
174  Field_G U(Nvol, Ndim);
175 
176  if (str_gconf_status == "Continue") {
177  GaugeConfig(str_gconf_read).read(U, readfile);
178  } else if (str_gconf_status == "Cold_start") {
179  GaugeConfig("Unit").read(U);
180  } else if (str_gconf_status == "Hot_start") {
181  GaugeConfig("Random").read(U);
182  } else if (str_gconf_status == "Branch") {
183  GaugeConfig(str_gconf_read).read(U, readfile);
184  } else if (str_gconf_status == "Read") {
185  std::ostringstream num;
186  num << i_conf;
187  string readfile_i_conf = readfile + num.str();
188  GaugeConfig(str_gconf_read).read(U, readfile_i_conf);
189  vout.general(vl, " conf_readfile = %s\n", readfile_i_conf.c_str());
190  } else if (str_gconf_status == "Read_gauge_heavy") {
191  std::ostringstream num;
192  num << "conf" << std::setw(4) << std::setfill('0') << i_conf << ".bin";
193  string readfile_i_conf = readfile + num.str();
194  GaugeConfig(str_gconf_read).read(U, readfile_i_conf);
195  vout.general(vl, " conf_readfile = %s\n", readfile_i_conf.c_str());
196  } else if (str_gconf_status == "Read_gauge_phys") {
197  std::ostringstream num;
198  num << std::setw(6) << std::setfill('0') << i_conf;
199  string readfile_i_conf = readfile + num.str();
200  GaugeConfig(str_gconf_read).read(U, readfile_i_conf);
201  vout.general(vl, " conf_readfile = %s\n", readfile_i_conf.c_str());
202  } else {
203  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
204  exit(EXIT_FAILURE);
205  }
206 
207  //- beta is overwritten to be Nc in GradientFlow
208  params_action_G.set_double("beta", static_cast<double>(Nc));
209 
210  unique_ptr<Action> action_G(Action::New(str_action_G_type, params_action_G));
211 
212  unique_ptr<GradientFlow> g_flow(new GradientFlow(action_G.get(), params_g_flow));
213 
214  EnergyMomentumTensor energy_momentum_tensor(params_energy_momentum_tensor);
215 
216  // TopologicalCharge topological_charge(params_topological_charge);
217 
218  Timer timer(test_name);
219 
220 
221  // #### Execution main part ####
222  timer.start();
223 
224  double t_flow = 0.0;
225  double result = 0.0;
226 
227  for (int i = 0; i < Nstep; ++i) {
228  double result_g_flow = g_flow->evolve(t_flow, U);
229 
230  energy_momentum_tensor.set_field_strength(U);
231 
232  result += energy_momentum_tensor.measure_EMT(t_flow);
233  result += energy_momentum_tensor.measure_EMT_at_t(t_flow);
234  result += energy_momentum_tensor.measure_EMT_at_t_FT(t_flow);
235 #if 0
236  result += energy_momentum_tensor.measure_EMT_at_x(t_flow);
237  result += energy_momentum_tensor.measure_EMT_at_x_FT(t_flow);
238  result += energy_momentum_tensor.measure_EMT_at_y(t_flow);
239  result += energy_momentum_tensor.measure_EMT_at_y_FT(t_flow);
240  result += energy_momentum_tensor.measure_EMT_at_z(t_flow);
241  result += energy_momentum_tensor.measure_EMT_at_z_FT(t_flow);
242 #endif
243 
244  // topological_charge.set_field_strength(U);
245  // topological_charge.measure_topological_charge(t_flow);
246  // topological_charge.measure_topological_density_t(t_flow);
247  // topological_charge.measure_topological_density_t_FT(t_flow);
248  // topological_charge.measure_topological_density_x(t_flow);
249  // topological_charge.measure_topological_density_x_FT(t_flow);
250  // topological_charge.measure_topological_density_y(t_flow);
251  // topological_charge.measure_topological_density_y_FT(t_flow);
252  // topological_charge.measure_topological_density_z(t_flow);
253  // topological_charge.measure_topological_density_z_FT(t_flow);
254 
255  if (t_flow > t_flow_max) break;
256  }
257  vout.general(vl, " result = %.16e\n", result);
258 
259  timer.report();
260 
262 
263 
264  if (do_check) {
265  return Test::verify(result, expected_result);
266  } else {
267  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
268  return EXIT_SKIP;
269  }
270  }
271 } // namespace Test_EnergyMomentumTensor_Gauge
energyMomentumTensor.h
EnergyMomentumTensor::measure_EMT_at_z
double measure_EMT_at_z(const double t_flow)
Measure energy momentum tensor density in z direction and print out the result using an argument t_f...
Definition: energyMomentumTensor.cpp:765
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
gradientFlow.h
Test_GradientFlow_EnergyMomentumTensor_Gauge::run_test_RK_adaptive
int run_test_RK_adaptive()
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:77
EnergyMomentumTensor::measure_EMT_at_x_FT
double measure_EMT_at_x_FT(const double t_flow)
Definition: energyMomentumTensor.cpp:460
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
EnergyMomentumTensor::measure_EMT_at_t
double measure_EMT_at_t(const double t_flow)
Measure energy momentum tensor density as a function of time and print out the result using an argum...
Definition: energyMomentumTensor.cpp:168
Parameters
Class for parameters.
Definition: parameters.h:46
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
Parameters::get_int
int get_int(const string &key) const
Definition: parameters.cpp:192
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
Test_GradientFlow_EnergyMomentumTensor_Gauge
Test of gauge contribution to the energy-momentum tensor.
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:35
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Test_GradientFlow_EnergyMomentumTensor_Gauge::test_name_RK1
const std::string test_name_RK1
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:37
Test_GradientFlow_EnergyMomentumTensor_Gauge::run_test_RK4
int run_test_RK4()
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:74
EnergyMomentumTensor::set_field_strength
void set_field_strength(const Field_G &U)
Construct the anti-Hermitian traceless field strength by the flowed link U. Should be called before ...
Definition: energyMomentumTensor.cpp:964
Timer
Definition: timer.h:31
RandomNumberManager::finalize
static void finalize()
Definition: randomNumberManager.cpp:80
EnergyMomentumTensor::measure_EMT_at_y_FT
double measure_EMT_at_y_FT(const double t_flow)
Definition: energyMomentumTensor.cpp:659
RandomNumberManager::initialize
static bool initialize(const std::string &rng_type, unsigned long seed)
Definition: randomNumberManager.cpp:57
EnergyMomentumTensor::measure_EMT_at_y
double measure_EMT_at_y(const double t_flow)
Measure energy momentum tensor density in y direction and print out the result using an argument t_f...
Definition: energyMomentumTensor.cpp:566
Test_GradientFlow_EnergyMomentumTensor_Gauge::test_name_RK_adaptive
const std::string test_name_RK_adaptive
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:41
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_GradientFlow_EnergyMomentumTensor_Gauge::run_test_RK2
int run_test_RK2()
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:68
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
Test_GradientFlow_EnergyMomentumTensor_Gauge::update
int update(const std::string &filename_input)
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:111
Test_GradientFlow_EnergyMomentumTensor_Gauge::test_name
const std::string test_name
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:36
EnergyMomentumTensor::measure_EMT_at_x
double measure_EMT_at_x(const double t_flow)
Measure energy momentum tensor density in x direction and print out the result using an argument t_f...
Definition: energyMomentumTensor.cpp:368
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
Test_GradientFlow_EnergyMomentumTensor_Gauge::test_name_RK2
const std::string test_name_RK2
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:38
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_GradientFlow_EnergyMomentumTensor_Gauge::test_name_RK4
const std::string test_name_RK4
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:40
EnergyMomentumTensor::measure_EMT_at_t_FT
double measure_EMT_at_t_FT(const double t_flow)
Definition: energyMomentumTensor.cpp:262
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
EnergyMomentumTensor
Energy Momentum Tensor measurement.
Definition: energyMomentumTensor.h:39
Test_GradientFlow_EnergyMomentumTensor_Gauge::run_test_RK1
int run_test_RK1()
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:65
EnergyMomentumTensor::measure_EMT
double measure_EMT(const double t_flow)
Definition: energyMomentumTensor.cpp:82
Test_GradientFlow_EnergyMomentumTensor_Gauge::test_name_RK3
const std::string test_name_RK3
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:39
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Test_GradientFlow_EnergyMomentumTensor_Gauge::run_test_RK3
int run_test_RK3()
Definition: test_GradientFlow_EnergyMomentumTensor_Gauge.cpp:71
EnergyMomentumTensor::measure_EMT_at_z_FT
double measure_EMT_at_z_FT(const double t_flow)
Definition: energyMomentumTensor.cpp:858
GradientFlow
GradientFlow construction.
Definition: gradientFlow.h:47
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