Bridge++  Ver.2.1.3
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  /*
98  static const bool is_registered_RK4 = TestManager::RegisterTest(
99  test_name_RK4,
100  run_test_RK4
101  );
102  */
103  // static const bool is_registered_RK_adaptive = TestManager::RegisterTest(
104  // test_name_RK_adaptive,
105  // run_test_RK_adaptive
106  // );
107 #endif
108  }
109 #endif
110 
111 
112  //====================================================================
113  int update(const std::string& filename_input)
114  {
115  // #### parameter setup ####
116  const int Nvol = CommonParameters::Nvol();
117  const int Ndim = CommonParameters::Ndim();
118  const int Nc = CommonParameters::Nc();
119 
120  const Parameters params_all = ParameterManager::read(filename_input);
121 
122  const Parameters params_test = params_all.lookup("Test_EnergyMomentumTensor_Gauge");
123  //- NB. additional parameter for action_G is set in the following object setup
124  Parameters params_action_G = params_all.lookup("Action_G");
125  const Parameters params_g_flow = params_all.lookup("GradientFlow");
126  const Parameters params_energy_momentum_tensor = params_all.lookup("EnergyMomentumTensor");
127  const Parameters params_topological_charge = params_all.lookup("TopologicalCharge");
128 
129  const string str_gconf_status = params_test.get_string("gauge_config_status");
130  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
131  const string readfile = params_test.get_string("config_filename_input");
132  const string str_gconf_write = params_test.get_string("gauge_config_type_output");
133  const string writefile = params_test.get_string("config_filename_output");
134  const string str_rand_type = params_test.get_string("random_number_type");
135  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
136  int i_conf = params_test.get_int("trajectory_number");
137  const int Nstep = params_test.get_int("number_of_steps");
138  const double t_flow_max = params_test.get_double("max_flow_time");
139  const string str_vlevel = params_test.get_string("verbose_level");
140 
141  const bool do_check = params_test.is_set("expected_result");
142  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
143 
144  const string str_action_G_type = params_action_G.get_string("action_type");
145 
146  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
147 
148  //- print input parameters
149  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
150  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
151  vout.general(vl, " readfile = %s\n", readfile.c_str());
152  vout.general(vl, " gconf_write = %s\n", str_gconf_write.c_str());
153  vout.general(vl, " writefile = %s\n", writefile.c_str());
154  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
155  vout.general(vl, " seed = %lu\n", seed);
156  vout.general(vl, " i_conf = %d\n", i_conf);
157  vout.general(vl, " Nstep = %d\n", Nstep);
158  vout.general(vl, " t_flow_max = %10.6f\n", t_flow_max);
159  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
160  vout.general(vl, "\n");
161 
162  //- input parameter check
163  int err = 0;
164  err += ParameterCheck::non_NULL(str_gconf_status);
165 
166  if (err) {
167  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
168  exit(EXIT_FAILURE);
169  }
170 
171 
172  RandomNumberManager::initialize(str_rand_type, seed);
173 
174 
175  // #### object setup #####
176  Field_G U(Nvol, Ndim);
177 
178  if (str_gconf_status == "Continue") {
179  GaugeConfig(str_gconf_read).read(U, readfile);
180  } else if (str_gconf_status == "Cold_start") {
181  GaugeConfig("Unit").read(U);
182  } else if (str_gconf_status == "Hot_start") {
183  GaugeConfig("Random").read(U);
184  } else if (str_gconf_status == "Branch") {
185  GaugeConfig(str_gconf_read).read(U, readfile);
186  } else if (str_gconf_status == "Read") {
187  std::ostringstream num;
188  num << i_conf;
189  string readfile_i_conf = readfile + num.str();
190  GaugeConfig(str_gconf_read).read(U, readfile_i_conf);
191  vout.general(vl, " conf_readfile = %s\n", readfile_i_conf.c_str());
192  } else if (str_gconf_status == "Read_gauge_heavy") {
193  std::ostringstream num;
194  num << "conf" << std::setw(4) << std::setfill('0') << i_conf << ".bin";
195  string readfile_i_conf = readfile + num.str();
196  GaugeConfig(str_gconf_read).read(U, readfile_i_conf);
197  vout.general(vl, " conf_readfile = %s\n", readfile_i_conf.c_str());
198  } else if (str_gconf_status == "Read_gauge_phys") {
199  std::ostringstream num;
200  num << std::setw(6) << std::setfill('0') << i_conf;
201  string readfile_i_conf = readfile + num.str();
202  GaugeConfig(str_gconf_read).read(U, readfile_i_conf);
203  vout.general(vl, " conf_readfile = %s\n", readfile_i_conf.c_str());
204  } else {
205  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
206  exit(EXIT_FAILURE);
207  }
208 
209  //- beta is overwritten to be Nc in GradientFlow
210  params_action_G.set_double("beta", static_cast<double>(Nc));
211 
212  unique_ptr<Action> action_G(Action::New(str_action_G_type, params_action_G));
213 
214  unique_ptr<GradientFlow> g_flow(new GradientFlow(action_G.get(), params_g_flow));
215 
216  EnergyMomentumTensor energy_momentum_tensor(params_energy_momentum_tensor);
217 
218  // TopologicalCharge topological_charge(params_topological_charge);
219 
220  Timer timer(test_name);
221 
222 
223  // #### Execution main part ####
224  timer.start();
225 
226  double t_flow = 0.0;
227  double result = 0.0;
228 
229  for (int i = 0; i < Nstep; ++i) {
230  double result_g_flow = g_flow->evolve(t_flow, U);
231 
232  energy_momentum_tensor.set_field_strength(U);
233 
234  result += energy_momentum_tensor.measure_EMT(t_flow);
235  result += energy_momentum_tensor.measure_EMT_at_t(t_flow);
236  result += energy_momentum_tensor.measure_EMT_at_t_FT(t_flow);
237 #if 0
238  result += energy_momentum_tensor.measure_EMT_at_x(t_flow);
239  result += energy_momentum_tensor.measure_EMT_at_x_FT(t_flow);
240  result += energy_momentum_tensor.measure_EMT_at_y(t_flow);
241  result += energy_momentum_tensor.measure_EMT_at_y_FT(t_flow);
242  result += energy_momentum_tensor.measure_EMT_at_z(t_flow);
243  result += energy_momentum_tensor.measure_EMT_at_z_FT(t_flow);
244 #endif
245 
246  // topological_charge.set_field_strength(U);
247  // topological_charge.measure_topological_charge(t_flow);
248  // topological_charge.measure_topological_density_t(t_flow);
249  // topological_charge.measure_topological_density_t_FT(t_flow);
250  // topological_charge.measure_topological_density_x(t_flow);
251  // topological_charge.measure_topological_density_x_FT(t_flow);
252  // topological_charge.measure_topological_density_y(t_flow);
253  // topological_charge.measure_topological_density_y_FT(t_flow);
254  // topological_charge.measure_topological_density_z(t_flow);
255  // topological_charge.measure_topological_density_z_FT(t_flow);
256 
257  if (t_flow > t_flow_max) break;
258  }
259  vout.general(vl, " result = %.16e\n", result);
260 
261  timer.report();
262 
264 
265 
266  if (do_check) {
267  return Test::verify(result, expected_result);
268  } else {
269  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
270  return EXIT_SKIP;
271  }
272  }
273 } // 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:746
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:450
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:165
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:281
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:939
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:643
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:553
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:113
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:360
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:195
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:257
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:242
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:45
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:836
GradientFlow
GradientFlow construction.
Definition: gradientFlow.h:47
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:262
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:572