Bridge++  Ver. 2.0.2
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  std::string vlevel;
28  if (!params.fetch_string("verbose_level", vlevel)) {
29  m_vl = vout.set_verbose_level(vlevel);
30  }
31 
32  //- fetch and check input parameters
33  double beta, c_plaq, c_rect;
34 
35  int err = 0;
36  err += params.fetch_double("beta", beta);
37  err += params.fetch_double("c_plaq", c_plaq);
38  err += params.fetch_double("c_rect", c_rect);
39 
40  if (err) {
41  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
42  exit(EXIT_FAILURE);
43  }
44 
45 
46  set_parameters(beta, c_plaq, c_rect);
47 
48  //- post-process
49  m_force_G->set_parameters(params);
50 }
51 
52 
53 //====================================================================
55 {
56  params.set_double("beta", m_beta);
57  params.set_double("c_plaq", m_c_plaq);
58  params.set_double("c_rect", m_c_rect);
59 
60  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
61 }
62 
63 
64 //====================================================================
65 void Action_G_Rectangle::set_parameters(const double beta,
66  const double c_plaq, const double c_rect)
67 {
68  //- print input parameters
69  vout.general(m_vl, "%s:\n", class_name.c_str());
70  vout.general(m_vl, " beta = %12.6f\n", beta);
71  vout.general(m_vl, " c_plaq = %12.6f\n", c_plaq);
72  vout.general(m_vl, " c_rect = %12.6f\n", c_rect);
73 
74  //- range check
75  // NB. beta,c_plaq,c_rect == 0 is allowed.
76 
77  //- store values
78  m_beta = beta;
79  m_c_plaq = c_plaq;
80  m_c_rect = c_rect;
81 
82  //- post-process
83 }
84 
85 
86 //====================================================================
88 {
89  const double H_U = calcH();
90 
91  return H_U;
92 }
93 
94 
95 //====================================================================
97 {
98  const int Nc = CommonParameters::Nc();
99  const int Ndim = CommonParameters::Ndim();
100  const int Ndim2 = Ndim * (Ndim - 1) / 2;
101 
102  const int Nvol = CommonParameters::Nvol();
103  const int NPE = CommonParameters::NPE();
104 
105  const double eps = CommonParameters::epsilon_criterion();
106 
107 
108  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
109 
110  double plaqF = 0.0;
111  double rectF = 0.0;
112 
113  for (int mu = 0; mu < Ndim; ++mu) {
114  for (int nu = mu + 1; nu < Ndim; ++nu) {
115  Field_G Cup1;
116  m_staple.upper(Cup1, *m_U, mu, nu);
117 
118  //- plaquette term
119  for (int site = 0; site < Nvol; ++site) {
120  plaqF += ReTr(m_U->mat(site, mu) * Cup1.mat_dag(site));
121  }
122 
123  //- rectangular terms
124  // NB. skip this part, if m_c_rect = 0.0
125  if (fabs(m_c_rect) > eps) {
126  Field_G Cup2;
127  m_staple.upper(Cup2, *m_U, nu, mu);
128 
129  // +---+---+
130  // | | term
131  // x <---+
132 
133  Field_G Umu;
134  copy(Umu, 0, *m_U, mu);
135 
136  Field_G Unu;
137  copy(Unu, 0, *m_U, nu);
138 
139  Field_G v;
140  m_shift.backward(v, Cup2, mu);
141 
142  Field_G c;
143  m_shift.backward(c, Umu, nu);
144 
145  Field_G w;
146  mult_Field_Gnd(w, 0, c, 0, v, 0);
147 
148  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
149 
150  for (int site = 0; site < Nvol; ++site) {
151  rectF += ReTr(m_U->mat(site, mu) * c.mat_dag(site));
152  }
153 
154  // +---+
155  // | |
156  // + + term
157  // | |
158  // x v
159 
160  m_shift.backward(v, Unu, mu);
161  m_shift.backward(c, Cup1, nu);
162 
163  mult_Field_Gnd(w, 0, c, 0, v, 0);
164  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
165  for (int site = 0; site < Nvol; ++site) {
166  rectF += ReTr(m_U->mat(site, mu) * c.mat_dag(site));
167  }
168  }
169  }
170  }
171 
172  plaqF = Communicator::reduce_sum(plaqF);
173  rectF = Communicator::reduce_sum(rectF);
174 
175  const double plaq = plaqF / Nc;
176  vout.general(m_vl, " Plaquette = %18.8f\n", plaq / Nvol / NPE / Ndim2);
177 
178  double H_U = m_c_plaq * Ndim2 * Nvol * NPE - m_c_plaq * plaqF / Nc
179  + m_c_rect * Ndim2 * Nvol * NPE * 2 - m_c_rect * rectF / Nc;
180 
181  H_U = m_beta * H_U;
182 
183  vout.general(m_vl, " H_Grectangle = %18.8f\n", H_U);
184  vout.general(m_vl, " H_G/dof = %18.8f\n", H_U / Nvol / NPE / Ndim2);
185 
186  return H_U;
187 }
188 
189 
190 //====================================================================
192 {
193  //- check of argument type
194  assert(force.nin() == m_U->nin());
195  assert(force.nvol() == m_U->nvol());
196  assert(force.nex() == m_U->nex());
197 
198  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
199 
200  force.set(0.0);
201 
203 }
204 
205 
206 //====================================================================
207 //============================================================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:191
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
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:87
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
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
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
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Action_G_Rectangle::calcH
double calcH()
calculate Hamiltonian of this action term.
Definition: action_G_Rectangle.cpp:96
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:25
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:263
Action_G_Rectangle::get_parameters
void get_parameters(Parameters &params) const
Definition: action_G_Rectangle.cpp:54
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
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:180
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
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:200
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
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:154
CommonParameters::epsilon_criterion
static double epsilon_criterion()
Definition: commonParameters.h:119