Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
action_G_Rectangle.cpp
Go to the documentation of this file.
1 
14 #include "action_G_Rectangle.h"
15 
16 #ifdef USE_FACTORY_AUTOREGISTER
17 namespace {
18  bool init = Action_G_Rectangle::register_factory();
19 }
20 #endif
21 
22 const std::string Action_G_Rectangle::class_name = "Action_G_Rectangle";
23 
24 //====================================================================
26 {
27  const string str_vlevel = params.get_string("verbose_level");
28 
29  m_vl = vout.set_verbose_level(str_vlevel);
30 
31  //- fetch and check input parameters
32  double beta, c_plaq, c_rect;
33 
34  int err = 0;
35  err += params.fetch_double("beta", beta);
36  err += params.fetch_double("c_plaq", c_plaq);
37  err += params.fetch_double("c_rect", c_rect);
38 
39  if (err) {
40  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
41  exit(EXIT_FAILURE);
42  }
43 
44 
45  set_parameters(beta, c_plaq, c_rect);
46 
47  //- post-process
48  m_force_G->set_parameters(params);
49 }
50 
51 
52 //====================================================================
53 void Action_G_Rectangle::set_parameters(const double beta,
54  const double c_plaq, const double c_rect)
55 {
56  //- print input parameters
57  vout.general(m_vl, "%s:\n", class_name.c_str());
58  vout.general(m_vl, " beta = %12.6f\n", beta);
59  vout.general(m_vl, " c_plaq = %12.6f\n", c_plaq);
60  vout.general(m_vl, " c_rect = %12.6f\n", c_rect);
61 
62  //- range check
63  // NB. beta,c_plaq,c_rect == 0 is allowed.
64 
65  //- store values
66  m_beta = beta;
67  m_c_plaq = c_plaq;
68  m_c_rect = c_rect;
69 
70  //- post-process
71 }
72 
73 
74 //====================================================================
76 {
77  const double H_U = calcH();
78 
79  return H_U;
80 }
81 
82 
83 //====================================================================
85 {
86  const int Nc = CommonParameters::Nc();
87  const int Ndim = CommonParameters::Ndim();
88  const int Ndim2 = Ndim * (Ndim - 1) / 2;
89 
90  const int Nvol = CommonParameters::Nvol();
91  const int NPE = CommonParameters::NPE();
92 
93  const double eps = CommonParameters::epsilon_criterion();
94 
95 
96  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
97 
98  double plaqF = 0.0;
99  double rectF = 0.0;
100 
101  for (int mu = 0; mu < Ndim; ++mu) {
102  for (int nu = mu + 1; nu < Ndim; ++nu) {
103  Field_G Cup1;
104  m_staple.upper(Cup1, *m_U, mu, nu);
105 
106  //- plaquette term
107  for (int site = 0; site < Nvol; ++site) {
108  plaqF += ReTr(m_U->mat(site, mu) * Cup1.mat_dag(site));
109  }
110 
111  //- rectangular terms
112  // NB. skip this part, if m_c_rect = 0.0
113  if (fabs(m_c_rect) > eps) {
114  Field_G Cup2;
115  m_staple.upper(Cup2, *m_U, nu, mu);
116 
117  // +---+---+
118  // | | term
119  // x <---+
120 
121  Field_G Umu;
122  copy(Umu, 0, *m_U, mu);
123 
124  Field_G Unu;
125  copy(Unu, 0, *m_U, nu);
126 
127  Field_G v;
128  m_shift.backward(v, Cup2, mu);
129 
130  Field_G c;
131  m_shift.backward(c, Umu, nu);
132 
133  Field_G w;
134  mult_Field_Gnd(w, 0, c, 0, v, 0);
135 
136  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
137 
138  for (int site = 0; site < Nvol; ++site) {
139  rectF += ReTr(m_U->mat(site, mu) * c.mat_dag(site));
140  }
141 
142  // +---+
143  // | |
144  // + + term
145  // | |
146  // x v
147 
148  m_shift.backward(v, Unu, mu);
149  m_shift.backward(c, Cup1, nu);
150 
151  mult_Field_Gnd(w, 0, c, 0, v, 0);
152  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
153  for (int site = 0; site < Nvol; ++site) {
154  rectF += ReTr(m_U->mat(site, mu) * c.mat_dag(site));
155  }
156  }
157  }
158  }
159 
160  plaqF = Communicator::reduce_sum(plaqF);
161  rectF = Communicator::reduce_sum(rectF);
162 
163  const double plaq = plaqF / Nc;
164  vout.general(m_vl, " Plaquette = %18.8f\n", plaq / Nvol / NPE / Ndim2);
165 
166  double H_U = m_c_plaq * Ndim2 * Nvol * NPE - m_c_plaq * plaqF / Nc
167  + m_c_rect * Ndim2 * Nvol * NPE * 2 - m_c_rect * rectF / Nc;
168 
169  H_U = m_beta * H_U;
170 
171  vout.general(m_vl, " H_Grectangle = %18.8f\n", H_U);
172  vout.general(m_vl, " H_G/dof = %18.8f\n", H_U / Nvol / NPE / Ndim2);
173 
174  return H_U;
175 }
176 
177 
178 //====================================================================
180 {
181  //- check of argument type
182  assert(force.nin() == m_U->nin());
183  assert(force.nvol() == m_U->nvol());
184  assert(force.nex() == m_U->nex());
185 
186  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
187 
188  force.set(0.0);
189 
190  m_force_G->force_core(force, m_U);
191 }
192 
193 
194 //====================================================================
195 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:503
double langevin(RandomNumbers *)
Langevis step.
static double epsilon_criterion()
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
void general(const char *format,...)
Definition: bridgeIO.cpp:197
Container of Field-type object.
Definition: field.h:45
ShiftField_lex m_shift
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
int nvol() const
Definition: field.h:127
Class for parameters.
Definition: parameters.h:46
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:532
virtual void force_core(Field &)=0
double calcH()
calculate Hamiltonian of this action term.
int nin() const
Definition: field.h:126
SU(N) gauge field.
Definition: field_G.h:38
static const std::string class_name
void backward(Field &, const Field &, const int mu)
int nex() const
Definition: field.h:128
void upper(Field_G &, const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane.
Definition: staple_lex.cpp:151
void set_parameters(const Parameters &params)
void mult_Field_Gnn(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
Bridge::VerboseLevel m_vl
Definition: action.h:75
Base class of random number generators.
Definition: randomNumbers.h:43
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:127
static int reduce_sum(int count, double *recv_buf, double *send_buf, int pattern=0)
make a global sum of an array of double over the communicator. pattern specifies the dimensions to be...
virtual void set_parameters(const Parameters &)=0
string get_string(const string &key) const
Definition: parameters.cpp:221
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:114
void force(Field &)
returns force for molcular dynamical update of conjugate momenta.
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
double ReTr(const Mat_SU_N &m)
Definition: mat_SU_N.h:488
void mult_Field_Gnd(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)