Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
projection_Maximum_SU_N.cpp
Go to the documentation of this file.
1 
15 
16 #ifdef USE_FACTORY_AUTOREGISTER
17 namespace {
18  bool init = Projection_Maximum_SU_N::register_factory();
19 }
20 #endif
21 
22 const std::string Projection_Maximum_SU_N::class_name = "Projection_Maximum_SU_N";
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  int Niter;
33  double Enorm;
34 
35  int err = 0;
36  err += params.fetch_int("maximum_number_of_iteration", Niter);
37  err += params.fetch_double("convergence_criterion", Enorm);
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(Niter, Enorm);
46 }
47 
48 
49 //====================================================================
50 void Projection_Maximum_SU_N::set_parameters(const int Niter, const double Enorm)
51 {
52  //- print input parameters
53  vout.general(m_vl, "%s:\n", class_name.c_str());
54  vout.general(m_vl, " Niter = %d\n", Niter);
55  vout.general(m_vl, " Enorm = %12.4e\n", Enorm);
56 
57  //- range check
58  int err = 0;
59  err += ParameterCheck::non_negative(Niter);
60  err += ParameterCheck::non_zero(Enorm);
61 
62  if (err) {
63  vout.crucial(m_vl, "Error at %s: parameter range check failed.\n", class_name.c_str());
64  exit(EXIT_FAILURE);
65  }
66 
67  //- store values
68  m_Niter = Niter;
69  m_Enorm = Enorm;
70 }
71 
72 
73 //====================================================================
75  const double alpha,
76  const Field_G& Cst, const Field_G& Uorg)
77 {
78  const int Nex = Uorg.nex();
79  const int Nvol = Uorg.nvol();
80  const int Nc = CommonParameters::Nc();
81 
82  assert(Cst.nex() == Nex);
83  assert(Cst.nvol() == Nvol);
84  assert(U.nex() == Nex);
85  assert(U.nvol() == Nvol);
86 
87  Field_G u_tmp(Nvol, Nex);
88  for (int ex = 0; ex < Nex; ++ex) {
89  u_tmp.setpart_ex(ex, Cst, ex);
90  u_tmp.addpart_ex(ex, Uorg, ex, 1.0 - alpha);
91  }
92 
93  maxTr(U, u_tmp);
94 }
95 
96 
97 //====================================================================
99  const double alpha, const Field_G& Sigmap,
100  const Field_G& Cst, const Field_G& Uorg)
101 {
102  vout.crucial(m_vl, "Error at %s: force_recursive() is not available.\n", class_name.c_str());
103  exit(EXIT_FAILURE);
104 }
105 
106 
107 //====================================================================
109 {
110  const int Nc = CommonParameters::Nc();
111  const int Nvol = Cst.nvol();
112  const int Nex = Cst.nex();
113 
114  assert(Nvol == G0.nvol());
115  assert(Nex == G0.nex());
116 
117  const static int Nmt = 1; // number of subgroup maximization loop:
118  // seems not important because of outer iter-loop.
119 
120  Mat_SU_N unity(Nc);
121  unity.unit();
122 
123  Field_G A(Nvol, Nex);
124  A = Cst;
125 
126  vout.detailed(m_vl, "Maximum projection start.\n");
127 
128  for (int ex = 0; ex < Nex; ++ex) {
129  for (int site = 0; site < Nvol; ++site) {
130  G0.set_mat(site, ex, unity);
131  }
132  }
133 
134  for (int iter = 0; iter < m_Niter; ++iter) {
135  Field_G Udelta(Nvol, Nex);
136 
137  for (int ex = 0; ex < Nex; ++ex) {
138  for (int site = 0; site < Nvol; ++site) {
139  Udelta.set_mat(site, ex, unity);
140  }
141  }
142 
143  for (int imt = 0; imt < Nmt; ++imt) {
144  for (int i1 = 0; i1 < Nc; ++i1) {
145  int i2 = (i1 + 1) % Nc;
146  maxTr_SU2(i1, i2, G0, A, Udelta);
147  }
148  }
149  // for exact check with Fortran version (passed).
150 
151  /*
152  for(int imt = 0; imt < Nmt; ++imt){
153  for(int i = Nc; i > 0; --i){
154  int i1 = i % Nc;
155  int i2 = (i1 + 1) % Nc;
156  maxTr_SU2(i1, i2, G0, A, Udelta);
157  }
158  }
159  */
160 
161  //- convergence test
162  double retr1 = 0.0;
163  for (int ex = 0; ex < Nex; ++ex) {
164  for (int site = 0; site < Nvol; ++site) {
165  for (int cc = 0; cc < Nc; ++cc) {
166  retr1 += Udelta.cmp_r(cc * (1 + Nc), site, ex);
167  }
168  }
169  }
170  double retr = Communicator::reduce_sum(retr1);
171 
172  const int Npe = Communicator::size();
173  double deltaV = 1.0 - retr / (Nc * Nvol * Nex * Npe);
174  vout.detailed(m_vl, " iter = %d deltaV = %12.4e\n", iter, deltaV);
175 
176  if (deltaV < m_Enorm) {
177  for (int ex = 0; ex < Nex; ++ex) {
178  for (int site = 0; site < Nvol; ++site) {
179  Mat_SU_N ut(Nc);
180  G0.mat_dag(ut, site, ex);
181  G0.set_mat(site, ex, ut);
182  }
183  }
184 
185  vout.detailed(m_vl, "Maximum projection converged.\n");
186 
187  return;
188  }
189  }
190 
191 
192  vout.crucial(m_vl, "Error at %s: Maximum projection not converged.\n", class_name.c_str());
193  exit(EXIT_FAILURE);
194 }
195 
196 
197 //====================================================================
198 void Projection_Maximum_SU_N::maxTr_SU2(const int i1, const int i2, Field_G& Gmax,
199  Field_G& A, Field_G& Udelta)
200 {
201  const int Nc = CommonParameters::Nc();
202  const int Nvol = A.nvol();
203  const int Nex = A.nex();
204 
205  assert(i1 < Nc);
206  assert(i2 < Nc);
207 
208  const int j1 = mindex(i1, i1, Nc);
209  const int j2 = mindex(i2, i2, Nc);
210  const int k1 = mindex(i1, i2, Nc);
211  const int k2 = mindex(i2, i1, Nc);
212 
213  //----------[ | # # 0 | <i1 ]--------------------------
214  //----------[ V = | # # 0 | <i2 ]--------------------------
215  //----------[ | 0 0 1 | ]--------------------------
216 
217  Field_G v(Nvol, Nex);
218  for (int ex = 0; ex < Nex; ++ex) {
219  for (int site = 0; site < Nvol; ++site) {
220  Mat_SU_N at(Nc);
221  at = A.mat(site, ex);
222 
223  double xlamd =
224  at.r(j1) * at.r(j1) + at.i(j1) * at.i(j1) + 2.0 * at.r(j1) * at.r(j2)
225  + at.r(k1) * at.r(k1) + at.i(k1) * at.i(k1) - 2.0 * at.i(j1) * at.i(j2)
226  + at.r(k2) * at.r(k2) + at.i(k2) * at.i(k2) - 2.0 * at.r(k1) * at.r(k2)
227  + at.r(j2) * at.r(j2) + at.i(j2) * at.i(j2) + 2.0 * at.i(k1) * at.i(k2);
228  xlamd = 1.0 / sqrt(xlamd);
229 
230  Mat_SU_N vt(Nc);
231  vt.unit();
232  vt.set(j1, (at.r(j1) + at.r(j2)) * xlamd, (-at.i(j1) + at.i(j2)) * xlamd);
233  vt.set(k1, (at.r(k2) - at.r(k1)) * xlamd, (-at.i(k2) - at.i(k1)) * xlamd);
234  vt.set(k2, (at.r(k1) - at.r(k2)) * xlamd, (-at.i(k1) - at.i(k2)) * xlamd);
235  vt.set(j2, (at.r(j1) + at.r(j2)) * xlamd, (at.i(j1) - at.i(j2)) * xlamd);
236 
237  v.set_mat(site, ex, vt);
238  }
239  }
240 
241  Field_G w(Nvol, Nex);
242  for (int ex = 0; ex < Nex; ++ex) {
243  mult_Field_Gnn(w, ex, A, ex, v, ex);
244  }
245  A = w;
246 
247  for (int ex = 0; ex < Nex; ++ex) {
248  mult_Field_Gnn(w, ex, Gmax, ex, v, ex);
249  }
250  Gmax = w;
251 
252  for (int ex = 0; ex < Nex; ++ex) {
253  mult_Field_Gnn(w, ex, Udelta, ex, v, ex);
254  }
255  Udelta = w;
256 }
257 
258 
259 //====================================================================
260 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:503
double i(int c) const
Definition: mat_SU_N.h:115
void detailed(const char *format,...)
Definition: bridgeIO.cpp:216
void maxTr(Field_G &U, const Field_G &V)
void general(const char *format,...)
Definition: bridgeIO.cpp:197
void set_parameters(const Parameters &params)
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
double m_Enorm
convergence criterion of maximization
int nvol() const
Definition: field.h:127
Class for parameters.
Definition: parameters.h:46
int mindex(const int i, const int j, const int Nc)
void force_recursive(Field_G &Xi, Field_G &iTheta, const double alpha, const Field_G &Sigmap, const Field_G &C, const Field_G &U)
force calculation: invalid in this class.
SU(N) gauge field.
Definition: field_G.h:38
int fetch_int(const string &key, int &value) const
Definition: parameters.cpp:346
int nex() const
Definition: field.h:128
void project(Field_G &U, const double alpha, const Field_G &C, const Field_G &Uorg)
projection U = P[alpha, C, Uorg]
int m_Niter
maximum iteration of maximization steps
void maxTr_SU2(const int, const int, Field_G &, Field_G &, Field_G &)
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
static const std::string class_name
static int size()
size of small world.
int non_zero(const double v)
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:127
int non_negative(const int v)
Mat_SU_N & unit()
Definition: mat_SU_N.h:373
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...
double r(int c) const
Definition: mat_SU_N.h:114
double cmp_r(const int cc, const int site, const int mn=0) const
Definition: field_G.h:87
void set(int c, double re, const double &im)
Definition: mat_SU_N.h:133
string get_string(const string &key) const
Definition: parameters.cpp:221
void set_mat(const int site, const int mn, const Mat_SU_N &U)
Definition: field_G.h:160
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:114
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
Bridge::VerboseLevel m_vl
Definition: projection.h:33