Bridge++  Version 1.4.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 
17 #ifdef USE_FACTORY
18 namespace {
19  Action *create_object()
20  {
21  return new Action_G_Rectangle();
22  }
23 
24 
25  bool init = Action::Factory::Register("Action_G_Rectangle", create_object);
26 }
27 #endif
28 
29 
30 
31 const std::string Action_G_Rectangle::class_name = "Action_G_Rectangle";
32 
33 //====================================================================
35 {
36  const string str_vlevel = params.get_string("verbose_level");
37 
38  m_vl = vout.set_verbose_level(str_vlevel);
39 
40  //- fetch and check input parameters
41  double beta, c_plaq, c_rect;
42 
43  int err = 0;
44  err += params.fetch_double("beta", beta);
45  err += params.fetch_double("c_plaq", c_plaq);
46  err += params.fetch_double("c_rect", c_rect);
47 
48  if (err) {
49  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
50  exit(EXIT_FAILURE);
51  }
52 
53 
54  set_parameters(beta, c_plaq, c_rect);
55 
56  //- post-process
57  m_force_G->set_parameters(params);
58 }
59 
60 
61 //====================================================================
63  double c_plaq, double c_rect)
64 {
65  //- print input parameters
66  vout.general(m_vl, "%s:\n", class_name.c_str());
67  vout.general(m_vl, " beta = %12.6f\n", beta);
68  vout.general(m_vl, " c_plaq = %12.6f\n", c_plaq);
69  vout.general(m_vl, " c_rect = %12.6f\n", c_rect);
70 
71  //- range check
72  // NB. beta,c_plaq,c_rect == 0 is allowed.
73 
74  //- store values
75  m_beta = beta;
76  m_c_plaq = c_plaq;
77  m_c_rect = c_rect;
78 
79  //- post-process
80 }
81 
82 
83 //====================================================================
85 {
86  double H_U = calcH();
87 
88  return H_U;
89 }
90 
91 
92 //====================================================================
94 {
95  int Nc = CommonParameters::Nc();
96  int Ndim = CommonParameters::Ndim();
97  int Nvol = CommonParameters::Nvol();
98  int Lvol = CommonParameters::Lvol();
99  const double eps = CommonParameters::epsilon_criterion();
100 
101 
102  int Ndim2 = Ndim * (Ndim - 1) / 2;
103  int size_U = Lvol * Ndim2;
104 
105  Field_G Cup1(Nvol, 1), Cup2(Nvol, 1);
106  Field_G Cdn1(Nvol, 1), Cdn2(Nvol, 1);
107  Field_G Umu(Nvol, 1), Unu(Nvol, 1);
108  Field_G v(Nvol, 1), w(Nvol, 1), c(Nvol, 1);
109 
110  double plaqF = 0.0;
111  double rectF = 0.0;
112 
113  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
114 
115 
116  for (int mu = 0; mu < Ndim; ++mu) {
117  for (int nu = mu + 1; nu < Ndim; ++nu) {
118  m_staple.upper(Cup1, *m_U, mu, nu);
119 
120  //- plaquette term
121  for (int site = 0; site < Nvol; ++site) {
122  plaqF += ReTr(m_U->mat(site, mu) * Cup1.mat_dag(site));
123  }
124 
125  //- rectangular terms
126  // NB. skip this part, if m_c_rect = 0.0
127  if (fabs(m_c_rect) > eps) {
128  m_staple.upper(Cup2, *m_U, nu, mu);
129 
130  // +---+---+
131  // | | term
132  // x <---+
133 
134  copy(Umu, 0, *m_U, mu);
135  copy(Unu, 0, *m_U, nu);
136 
137  m_shift.backward(v, Cup2, mu);
138  m_shift.backward(c, Umu, nu);
139 
140  mult_Field_Gnd(w, 0, c, 0, v, 0);
141  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
142 
143  for (int site = 0; site < Nvol; ++site) {
144  rectF += ReTr(m_U->mat(site, mu) * c.mat_dag(site));
145  }
146 
147  // +---+
148  // | |
149  // + + term
150  // | |
151  // x v
152 
153  m_shift.backward(v, Unu, mu);
154  m_shift.backward(c, Cup1, nu);
155 
156  mult_Field_Gnd(w, 0, c, 0, v, 0);
157  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
158  for (int site = 0; site < Nvol; ++site) {
159  rectF += ReTr(m_U->mat(site, mu) * c.mat_dag(site));
160  }
161  }
162  }
163  }
164 
165  plaqF = Communicator::reduce_sum(plaqF);
166  rectF = Communicator::reduce_sum(rectF);
167 
168  double plaq = plaqF / Nc;
169  vout.general(m_vl, " Plaquette = %18.8f\n", plaq / size_U);
170 
171  double H_U = m_c_plaq * (Ndim2 * Lvol - plaqF / Nc)
172  + m_c_rect * (Ndim2 * Lvol * 2 - rectF / Nc);
173 
174  H_U = m_beta * H_U;
175 
176  vout.general(m_vl, " H_Grectangle = %18.8f\n", H_U);
177  vout.general(m_vl, " H_G/dof = %18.8f\n", H_U / size_U);
178 
179  return H_U;
180 }
181 
182 
183 //====================================================================
185 {
186  //- check of argument type
187  assert(force.nin() == m_U->nin());
188  assert(force.nvol() == m_U->nvol());
189  assert(force.nex() == m_U->nex());
190 
191  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
192 
193  force.set(0.0);
194 
195  m_force_G->force_core(force, m_U);
196 }
197 
198 
199 //====================================================================
200 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:495
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:164
void general(const char *format,...)
Definition: bridgeIO.cpp:195
HMC action class for rectangular gauge action.
Container of Field-type object.
Definition: field.h:39
ShiftField_lex m_shift
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:211
int nvol() const
Definition: field.h:116
Class for parameters.
Definition: parameters.h:46
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:381
static int Lvol()
virtual void force_core(Field &)=0
Base class of HMC action class family.
Definition: action.h:36
double calcH()
calculate Hamiltonian of this action term.
int nin() const
Definition: field.h:115
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:117
void upper(Field_G &, const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane.
Definition: staple_lex.cpp:156
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:36
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:126
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:116
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:113
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)