Bridge++  Ver.2.1.3
action_G_Rectangle.cpp
Go to the documentation of this file.
1 
15 #include "lib/Tools/timer.h"
16 
17 #ifdef USE_FACTORY_AUTOREGISTER
18 namespace {
19  bool init = Action_G_Rectangle::register_factory();
20 }
21 #endif
22 
23 const std::string Action_G_Rectangle::class_name = "Action_G_Rectangle";
24 
25 //====================================================================
27 {
28  std::string vlevel;
29  if (!params.fetch_string("verbose_level", vlevel)) {
30  m_vl = vout.set_verbose_level(vlevel);
31  }
32 
33  //- fetch and check input parameters
34  double beta, c_plaq, c_rect;
35 
36  int err = 0;
37  err += params.fetch_double("beta", beta);
38  err += params.fetch_double("c_plaq", c_plaq);
39  err += params.fetch_double("c_rect", c_rect);
40 
41  if (err) {
42  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
43  exit(EXIT_FAILURE);
44  }
45 
46 
47  set_parameters(beta, c_plaq, c_rect);
48 
49  //- post-process
50  m_force_G->set_parameters(params);
51 }
52 
53 
54 //====================================================================
56 {
57  params.set_double("beta", m_beta);
58  params.set_double("c_plaq", m_c_plaq);
59  params.set_double("c_rect", m_c_rect);
60 
61  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
62 }
63 
64 
65 //====================================================================
66 void Action_G_Rectangle::set_parameters(const double beta,
67  const double c_plaq, const double c_rect)
68 {
69  //- print input parameters
70  vout.general(m_vl, "%s:\n", class_name.c_str());
71  vout.general(m_vl, " beta = %12.6f\n", beta);
72  vout.general(m_vl, " c_plaq = %12.6f\n", c_plaq);
73  vout.general(m_vl, " c_rect = %12.6f\n", c_rect);
74 
75  //- range check
76  // NB. beta,c_plaq,c_rect == 0 is allowed.
77 
78  //- store values
79  m_beta = beta;
80  m_c_plaq = c_plaq;
81  m_c_rect = c_rect;
82 
83  //- post-process
84 }
85 
86 
87 //====================================================================
89 {
90  const double H_U = calcH();
91 
92  return H_U;
93 }
94 
95 
96 //====================================================================
98 {
99  const int Nc = CommonParameters::Nc();
100  const int Ndim = CommonParameters::Ndim();
101  const int Ndim2 = Ndim * (Ndim - 1) / 2;
102 
103  const int Nvol = CommonParameters::Nvol();
104  const int NPE = CommonParameters::NPE();
105 
106  const double eps = CommonParameters::epsilon_criterion();
107 
108  vout.general(m_vl, "%s %s: Hamiltonian\n",
109  class_name.c_str(), m_label.c_str());
111 
112  Timer timer;
113  timer.start();
114 
115  double plaqF = 0.0;
116  double rectF = 0.0;
117 
118  for (int mu = 0; mu < Ndim; ++mu) {
119  for (int nu = mu + 1; nu < Ndim; ++nu) {
120  Field_G Cup1;
121  m_staple.upper(Cup1, *m_U, mu, nu);
122 
123  //- plaquette term
124  for (int site = 0; site < Nvol; ++site) {
125  plaqF += ReTr(m_U->mat(site, mu) * Cup1.mat_dag(site));
126  }
127 
128  //- rectangular terms
129  // NB. skip this part, if m_c_rect = 0.0
130  if (fabs(m_c_rect) > eps) {
131  Field_G Cup2;
132  m_staple.upper(Cup2, *m_U, nu, mu);
133 
134  // +---+---+
135  // | | term
136  // x <---+
137 
138  Field_G Umu;
139  copy(Umu, 0, *m_U, mu);
140 
141  Field_G Unu;
142  copy(Unu, 0, *m_U, nu);
143 
144  Field_G v;
145  m_shift.backward(v, Cup2, mu);
146 
147  Field_G c;
148  m_shift.backward(c, Umu, nu);
149 
150  Field_G w;
151  mult_Field_Gnd(w, 0, c, 0, v, 0);
152 
153  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
154 
155  for (int site = 0; site < Nvol; ++site) {
156  rectF += ReTr(m_U->mat(site, mu) * c.mat_dag(site));
157  }
158 
159  // +---+
160  // | |
161  // + + term
162  // | |
163  // x v
164 
165  m_shift.backward(v, Unu, mu);
166  m_shift.backward(c, Cup1, nu);
167 
168  mult_Field_Gnd(w, 0, c, 0, v, 0);
169  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
170  for (int site = 0; site < Nvol; ++site) {
171  rectF += ReTr(m_U->mat(site, mu) * c.mat_dag(site));
172  }
173  }
174  }
175  }
176 
177  plaqF = Communicator::reduce_sum(plaqF);
178  rectF = Communicator::reduce_sum(rectF);
179 
180  const double plaq = plaqF / Nc;
181  vout.general(m_vl, "Plaquette = %18.8f\n", plaq / Nvol / NPE / Ndim2);
182 
183  double H_U = m_c_plaq * Ndim2 * Nvol * NPE - m_c_plaq * plaqF / Nc
184  + m_c_rect * Ndim2 * Nvol * NPE * 2 - m_c_rect * rectF / Nc;
185 
186  H_U = m_beta * H_U;
187 
188  vout.general(m_vl, "H_Grectangle = %18.8f\n", H_U);
189  vout.general(m_vl, "H_G/dof = %18.8f\n", H_U / Nvol / NPE / Ndim2);
190 
191  timer.stop();
192  double elapsed_time = timer.elapsed_sec();
193  vout.general(m_vl, "Elapsed time = %14.6f sec\n", elapsed_time);
194 
196 
197  return H_U;
198 }
199 
200 
201 //====================================================================
203 {
204  //- check of argument type
205  assert(force.nin() == m_U->nin());
206  assert(force.nvol() == m_U->nvol());
207  assert(force.nex() == m_U->nex());
208 
209  vout.general(m_vl, "%s %s: force\n",
210  class_name.c_str(), m_label.c_str());
212 
213  Timer timer;
214  timer.start();
215 
216  force.set(0.0);
217 
219 
220  //double Fave, Fmax, Fdev;
221  //force.stat(Fave, Fmax, Fdev);
222  //vout.general(m_vl, "Fave = %12.6f Fmax = %12.6f Fdev = %12.6f\n",
223  // Fave, Fmax, Fdev);
224 
225  timer.stop();
226  double elapsed_time = timer.elapsed_sec();
227  vout.general(m_vl, "Elapsed time = %14.6f sec\n", elapsed_time);
228 
230 
231 }
232 
233 //============================================================END=====
action_G_Rectangle.h
Action_G_Rectangle::force
void force(Field &)
returns force for molcular dynamical update of conjugate momenta.
Definition: action_G_Rectangle.cpp:202
Action_G_Rectangle::m_staple
Staple_lex m_staple
Definition: action_G_Rectangle.h:49
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Parameters
Class for parameters.
Definition: parameters.h:46
Field_G::mat_dag
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:127
Force_G::force_core
virtual void force_core(Field &)=0
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
Bridge::BridgeIO::decrease_indent
void decrease_indent()
Definition: bridgeIO.cpp:518
Action_G_Rectangle::m_beta
double m_beta
Definition: action_G_Rectangle.h:43
Action_G_Rectangle::langevin
double langevin(RandomNumbers *)
Langevis step.
Definition: action_G_Rectangle.cpp:88
Bridge::BridgeIO::increase_indent
void increase_indent()
Definition: bridgeIO.cpp:508
Action_G_Rectangle::m_shift
ShiftField_lex m_shift
Definition: action_G_Rectangle.h:50
Action_G_Rectangle::class_name
static const std::string class_name
Definition: action_G_Rectangle.h:38
Field::nex
int nex() const
Definition: field.h:128
Action_G_Rectangle::m_force_G
Force_G * m_force_G
Definition: action_G_Rectangle.h:51
RandomNumbers
Base class of random number generators.
Definition: randomNumbers.h:43
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Action_G_Rectangle::m_c_rect
double m_c_rect
Definition: action_G_Rectangle.h:45
Field::nin
int nin() const
Definition: field.h:126
Force_G::set_parameters
virtual void set_parameters(const Parameters &)=0
Timer
Definition: timer.h:31
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:213
Communicator::reduce_sum
static int reduce_sum(int count, dcomplex *recv_buf, dcomplex *send_buf, int pattern=0)
make a global sum of an array of dcomplex over the communicator. pattern specifies the dimensions to ...
Definition: communicator.cpp:263
Timer::start
void start()
Definition: timer.cpp:44
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
timer.h
Action_G_Rectangle::calcH
double calcH()
calculate Hamiltonian of this action term.
Definition: action_G_Rectangle.cpp:97
Action_G_Rectangle::m_U
Field_G * m_U
Definition: action_G_Rectangle.h:48
Action_G_Rectangle::m_c_plaq
double m_c_plaq
Definition: action_G_Rectangle.h:44
Field::nvol
int nvol() const
Definition: field.h:127
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
Action_G_Rectangle::set_parameters
void set_parameters(const Parameters &params)
Definition: action_G_Rectangle.cpp:26
Staple_lex::upper
void upper(Field_G &, const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane.
Definition: staple_lex.cpp:260
Action_G_Rectangle::get_parameters
void get_parameters(Parameters &params) const
Definition: action_G_Rectangle.cpp:55
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:195
mult_Field_Gnn
void mult_Field_Gnn(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
Definition: field_G_imp.cpp:95
ShiftField_lex::backward
void backward(Field &, const Field &, const int mu)
Definition: shiftField_lex.cpp:59
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Parameters::fetch_double
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:242
Action_G_Rectangle::m_vl
Bridge::VerboseLevel m_vl
Definition: action_G_Rectangle.h:41
SU_N::ReTr
double ReTr(const Mat_SU_N &m)
Definition: mat_SU_N.h:534
Field
Container of Field-type object.
Definition: field.h:46
Timer::elapsed_sec
double elapsed_sec() const
Definition: timer.cpp:107
Field_G::mat
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:114
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:262
Action_G_Rectangle::m_label
std::string m_label
Definition: action_G_Rectangle.h:46
mult_Field_Gnd
void mult_Field_Gnd(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
Definition: field_G_imp.cpp:173
Timer::stop
void stop()
Definition: timer.cpp:69
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:572
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:216
CommonParameters::epsilon_criterion
static double epsilon_criterion()
Definition: commonParameters.h:119