Bridge++  Ver. 2.0.2
force_G_Rectangle.cpp
Go to the documentation of this file.
1 
14 #include "force_G_Rectangle.h"
15 
16 #ifdef USE_FACTORY_AUTOREGISTER
17 namespace {
18  bool init = Force_G_Rectangle::register_factory();
19 }
20 #endif
21 
22 const std::string Force_G_Rectangle::class_name = "Force_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 
49 
50 //====================================================================
52 {
53  params.set_double("beta", m_beta);
54  params.set_double("c_plaq", m_c_plaq);
55  params.set_double("c_rect", m_c_rect);
56 
57  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
58 }
59 
60 
61 //====================================================================
62 void Force_G_Rectangle::set_parameters(const double beta,
63  const double c_plaq, const 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  const int Nc = CommonParameters::Nc();
87  const int Nvol = CommonParameters::Nvol();
88  const int Ndim = CommonParameters::Ndim();
89  const double eps = CommonParameters::epsilon_criterion();
90 
91  assert(m_U->nin() == Nc * Nc * 2);
92  assert(m_U->nvol() == Nvol);
93  assert(m_U->nex() == Ndim);
94 
95  assert(force.nin() == Nc * Nc * 2);
96  assert(force.nvol() == Nvol);
97  assert(force.nex() == Ndim);
98 
99  for (int mu = 0; mu < Ndim; ++mu) {
100  Field_G force1;
101  force1.set(0.0);
102 
103  for (int nu = 0; nu < Ndim; ++nu) {
104  if (nu == mu) continue;
105 
106  Field_G Cup1;
107  m_staple.upper(Cup1, *m_U, mu, nu);
108 
109  Field_G Cup2;
110  m_staple.upper(Cup2, *m_U, nu, mu);
111 
112  Field_G Cdn1;
113  m_staple.lower(Cdn1, *m_U, mu, nu);
114 
115  Field_G Cdn2;
116  m_staple.lower(Cdn2, *m_U, nu, mu);
117 
118  //- plaquette term
119  force1.addpart_ex(0, Cup1, 0, m_c_plaq);
120  force1.addpart_ex(0, Cdn1, 0, m_c_plaq);
121 
122 
123  //- rectangular term
124  // NB. skip this part, if m_c_rect = 0.0
125  if (fabs(m_c_rect) > eps) {
126  Field_G Umu;
127  Umu.setpart_ex(0, *m_U, mu);
128 
129  Field_G Unu;
130  Unu.setpart_ex(0, *m_U, nu);
131 
132  // +---+---+
133  // | | term
134  // x <---+
135  Field_G v;
136  m_shift.backward(v, Cup2, mu);
137 
138  Field_G c;
139  m_shift.backward(c, Umu, nu);
140 
141  Field_G w;
142  mult_Field_Gnd(w, 0, c, 0, v, 0);
143 
144  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
145 
146  force1.addpart_ex(0, c, 0, m_c_rect);
147 
148  // +---+
149  // | |
150  // + + term
151  // | |
152  // x v
153 
154  m_shift.backward(v, Unu, mu);
155  m_shift.backward(c, Cup1, nu);
156 
157  mult_Field_Gnd(w, 0, c, 0, v, 0);
158  mult_Field_Gnn(c, 0, Unu, 0, w, 0);
159 
160  force1.addpart_ex(0, c, 0, m_c_rect);
161 
162  // +---+---+
163  // | | term
164  // +---x v
165 
166  m_shift.backward(v, Unu, mu);
167  m_shift.backward(c, Umu, nu);
168 
169  mult_Field_Gnd(w, 0, c, 0, v, 0);
170  mult_Field_Gnn(c, 0, Cdn2, 0, w, 0);
171 
172  force1.addpart_ex(0, c, 0, m_c_rect);
173 
174  // x <---+
175  // | | term
176  // +---+---+
177 
178  m_shift.backward(v, Cup2, mu);
179 
180  mult_Field_Gnn(w, 0, Umu, 0, v, 0);
181  mult_Field_Gdn(v, 0, Unu, 0, w, 0);
182 
183  m_shift.forward(c, v, nu);
184 
185  force1.addpart_ex(0, c, 0, m_c_rect);
186 
187  // x ^
188  // | |
189  // + + term
190  // | |
191  // +---+
192 
193  m_shift.backward(v, Unu, mu);
194 
195  mult_Field_Gnn(w, 0, Cdn1, 0, v, 0);
196  mult_Field_Gdn(v, 0, Unu, 0, w, 0);
197 
198  m_shift.forward(c, v, nu);
199 
200  force1.addpart_ex(0, c, 0, m_c_rect);
201 
202  // +---x ^
203  // | | term
204  // +---+---+
205 
206  m_shift.backward(v, Unu, mu);
207 
208  mult_Field_Gnn(w, 0, Umu, 0, v, 0);
209  mult_Field_Gdn(v, 0, Cdn2, 0, w, 0);
210 
211  m_shift.forward(c, v, nu);
212 
213  force1.addpart_ex(0, c, 0, m_c_rect);
214  }
215  }
216 
217  Field_G force2;
218  mult_Field_Gnd(force2, 0, *m_U, mu, force1, 0);
219  at_Field_G(force2, 0);
220 
221  axpy(force, mu, -(m_beta / Nc), force2, 0);
222  }
223 
224  double Fave, Fmax, Fdev;
225  force.stat(Fave, Fmax, Fdev);
226  vout.general(m_vl, " Fave = %12.6f Fmax = %12.6f Fdev = %12.6f\n",
227  Fave, Fmax, Fdev);
228 }
229 
230 
231 //====================================================================
232 //============================================================END=====
Field::setpart_ex
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:201
mult_Field_Gdn
void mult_Field_Gdn(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:134
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
ShiftField_lex::forward
void forward(Field &, const Field &, const int mu)
Definition: shiftField_lex.cpp:79
Force_G_Rectangle::m_staple
Staple_lex m_staple
Definition: force_G_Rectangle.h:51
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Field::set
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
Parameters
Class for parameters.
Definition: parameters.h:46
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
Field::nex
int nex() const
Definition: field.h:128
force_G_Rectangle.h
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Field::stat
void stat(double &Fave, double &Fmax, double &Fdev) const
determines the statistics of the field. average, maximum value, and deviation is determined over glob...
Definition: field.cpp:169
Staple_lex::lower
void lower(Field_G &, const Field_G &, const int mu, const int nu)
constructs lower staple in mu-nu plane.
Definition: staple_lex.cpp:286
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
Field::nin
int nin() const
Definition: field.h:126
at_Field_G
void at_Field_G(Field_G &W, const int ex)
Definition: field_G_imp.cpp:419
Force_G_Rectangle::m_shift
ShiftField_lex m_shift
Definition: force_G_Rectangle.h:52
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Field::addpart_ex
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:208
Force_G_Rectangle::m_c_rect
double m_c_rect
Definition: force_G_Rectangle.h:49
Field::nvol
int nvol() const
Definition: field.h:127
Force_G_Rectangle::force_core
void force_core(Field &)
Definition: force_G_Rectangle.cpp:84
Force_G_Rectangle::m_c_plaq
double m_c_plaq
Definition: force_G_Rectangle.h:48
Force_G_Rectangle::class_name
static const std::string class_name
Definition: force_G_Rectangle.h:39
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
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
Force_G::m_U
Field_G * m_U
Definition: force_G.h:34
ShiftField_lex::backward
void backward(Field &, const Field &, const int mu)
Definition: shiftField_lex.cpp:59
Force_G_Rectangle::m_beta
double m_beta
Definition: force_G_Rectangle.h:47
Force_G_Rectangle::set_parameters
void set_parameters(const Parameters &params)
Definition: force_G_Rectangle.cpp:25
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
Field
Container of Field-type object.
Definition: field.h:46
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Force_G_Rectangle::m_vl
Bridge::VerboseLevel m_vl
Definition: force_G_Rectangle.h:42
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
Force_G_Rectangle::get_parameters
void get_parameters(Parameters &params) const
Definition: force_G_Rectangle.cpp:51
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