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