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