Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
polyakovLoop.cpp
Go to the documentation of this file.
1 
14 #include "polyakovLoop.h"
15 
16 const std::string PolyakovLoop::class_name = "PolyakovLoop";
17 
18 //====================================================================
20 {
21  m_filename_output = params.get_string("filename_output");
22  if (m_filename_output.empty()) {
23  m_filename_output = "stdout";
24  }
25 
26  const string str_vlevel = params.get_string("verbose_level");
27  m_vl = vout.set_verbose_level(str_vlevel);
28 
29 #if 0
30  //- fetch and check input parameters
31  int Nspc_size, Ntype;
32 
33  int err = 0;
34  err += params.fetch_int("spatial_correlator_size", Nspc_size);
35  err += params.fetch_int("number_of_correlator_type", Ntype);
36 
37  if (err) {
38  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
39  exit(EXIT_FAILURE);
40  }
41 
42 
43  set_parameters(Nspc_size, Ntype);
44 #endif
45 }
46 
47 
48 //====================================================================
49 void PolyakovLoop::set_parameters(const int Nspc_size, const int Ntype)
50 {
51 #if 0
52  //- print input parameters
53  vout.general(m_vl, "Polyakov loop measurement:\n");
54  vout.general(m_vl, " Nspc_size = %d\n", Nspc_size);
55  vout.general(m_vl, " Ntype = %d\n", Ntype);
56 
57  //- range check
58  int err = 0;
59  err += ParameterCheck::non_negative(Nspc_size);
60  err += ParameterCheck::non_negative(Ntype);
61 
64  if (Ntype > 6) ++err;
65 
66  if (err) {
67  vout.crucial(m_vl, "Error at %s: parameter range check failed.\n", class_name.c_str());
68  exit(EXIT_FAILURE);
69  }
70 
71  //- store values
72  m_Nspc_size = Nspc_size;
73  m_Ntype = Ntype;
74 
75 
76  //- post-process
80  m_Nt_ext = 1;
82 
85  m_Nmax[0] = Nspc_size;
86  m_Nmax[1] = Nspc_size;
87  m_Nmax[2] = Nspc_size / 2;
88  m_Nmax[3] = Nspc_size;
89  m_Nmax[4] = Nspc_size / 2;
90  m_Nmax[5] = Nspc_size / 2;
91 #endif
92 }
93 
94 
95 //====================================================================
97 {
98  const int Ndim = CommonParameters::Ndim();
99 
100  assert(Ndim == 4);
101 
102  m_filename_output = "stdout";
103 
104 #if 0
105  m_Ntype_max = 6;
106  const int Ndim_spc = Ndim - 1;
107 
108  m_Nunit.resize(m_Ntype_max);
109  m_Nmax.resize(m_Ntype_max);
110 
111  for (int i = 0; i < m_Ntype_max; ++i) {
112  m_Nunit[i].resize(Ndim_spc);
113  }
114 
115  // The following setting explicitly depends on the definition
116  // of unit vectors.
117  assert(m_Ntype_max >= 6);
118 
119  m_Nunit[0][0] = 1;
120  m_Nunit[0][1] = 0;
121  m_Nunit[0][2] = 0;
122 
123  m_Nunit[1][0] = 1;
124  m_Nunit[1][1] = 1;
125  m_Nunit[1][2] = 0;
126 
127  m_Nunit[2][0] = 2;
128  m_Nunit[2][1] = 1;
129  m_Nunit[2][2] = 0;
130 
131  m_Nunit[3][0] = 1;
132  m_Nunit[3][1] = 1;
133  m_Nunit[3][2] = 1;
134 
135  m_Nunit[4][0] = 2;
136  m_Nunit[4][1] = 1;
137  m_Nunit[4][2] = 1;
138 
139  m_Nunit[5][0] = 2;
140  m_Nunit[5][1] = 2;
141  m_Nunit[5][2] = 1;
142 #endif
143 }
144 
145 
146 //====================================================================
148 {
149  const int Ndim = CommonParameters::Ndim();
150  const int Nx = CommonParameters::Nx();
151  const int Ny = CommonParameters::Ny();
152  const int Nz = CommonParameters::Nz();
153  const int Nc = CommonParameters::Nc();
154  const int Npet = Communicator::npe(Ndim - 1);
155  const int Lvol_spc = CommonParameters::Lvol() / CommonParameters::Lt();
156  const int Nvol_spc = Nx * Ny * Nz;
157 
158  Field_G P(Nvol_spc, 1);
159 
160  calc_ploop(P, U);
161 
162  double re_tr = 0.0;
163  double im_tr = 0.0;
164  for (int site = 0; site < Nvol_spc; ++site) {
165  Mat_SU_N utmp(Nc);
166  P.mat(utmp, site, 0);
167 
168  re_tr += ReTr(utmp);
169  im_tr += ImTr(utmp);
170  }
171  re_tr /= (double(Nc));
172  im_tr /= (double(Nc));
173 
174  double re_ploop = Communicator::reduce_sum(re_tr);
175  double im_ploop = Communicator::reduce_sum(im_tr);
176 
177  re_ploop /= double(Lvol_spc * Npet);
178  im_ploop /= double(Lvol_spc * Npet);
179 
180 
181  std::ostream& log_file_previous = vout.getStream();
182  std::ofstream log_file;
183 
184  if (m_filename_output != "stdout") {
185  log_file.open(m_filename_output.c_str(), std::ios::app);
186  vout.init(log_file);
187  }
188 
189  vout.general(m_vl, "PolyakovLoop(Re,Im) = %20.16e %20.16e\n", re_ploop, im_ploop);
190 
191  if (m_filename_output != "stdout") {
192  log_file.close();
193  vout.init(log_file_previous);
194  }
195 
196 
197  const dcomplex ploop = cmplx(re_ploop, im_ploop);
198 
199  return ploop;
200 }
201 
202 
203 //====================================================================
205 {
206  const int Ndim = CommonParameters::Ndim();
207  // const int Ndim_spc = Ndim - 1;
208 
209  const int Nx = CommonParameters::Nx();
210  const int Ny = CommonParameters::Ny();
211  const int Nz = CommonParameters::Nz();
212  const int Nt = CommonParameters::Nt();
213  const int Nc = CommonParameters::Nc();
214 
215  const int Nvol = U.nvol();
216 
217  assert(Nvol == Nx * Ny * Nz * Nt);
218 
219  const int Nvol_spc = P.nvol();
220  assert(Nvol_spc == Nx * Ny * Nz);
221 
222  Index_lex index;
223  Index_lex index_spc(Nx, Ny, Nz, 1);
224 
225  Field_G Ut;
226  Ut.setpart_ex(0, U, Ndim - 1);
227 
228  //- Definition of local Polyakov loops
229  const int t = 0;
230  for (int z = 0; z < Nz; ++z) {
231  for (int y = 0; y < Ny; ++y) {
232  for (int x = 0; x < Nx; ++x) {
233  int site = index.site(x, y, z, t);
234  int site2 = index_spc.site(x, y, z, 0);
235 
236  Mat_SU_N utmp1(Nc);
237  Ut.mat(utmp1, site, 0);
238  P.set_mat(site2, 0, utmp1);
239  }
240  }
241  }
242 
243  for (int t = 1; t < Nt; ++t) {
244  for (int z = 0; z < Nz; ++z) {
245  for (int y = 0; y < Ny; ++y) {
246  for (int x = 0; x < Nx; ++x) {
247  int site = index.site(x, y, z, t);
248  int site2 = index_spc.site(x, y, z, 0);
249 
250  Mat_SU_N utmp1(Nc);
251  Ut.mat(utmp1, site, 0);
252 
253  Mat_SU_N utmp2(Nc);
254  P.mat(utmp2, site2, 0);
255 
256  Mat_SU_N utmp3(Nc);
257  utmp3.mult_nn(utmp2, utmp1);
258  P.set_mat(site2, 0, utmp3);
259  }
260  }
261  }
262  }
263 
264  //- global Polyakov loops
265  const int NPE_t = Communicator::npe(Ndim - 1);
266 
267  if (NPE_t > 1) {
268  const int size_cp = P.nin() * Nvol_spc;
269 
270  Field_G Pcp1(Nvol_spc, 1), Pcp2(Nvol_spc, 1);
271 
272  for (int ipe_t = 1; ipe_t < NPE_t; ++ipe_t) {
273  if (ipe_t == 1) {
274  Pcp1.setpart_ex(0, P, 0);
275  } else {
276  Pcp1.setpart_ex(0, Pcp2, 0);
277  }
278 
279  Communicator::exchange(size_cp, Pcp2.ptr(0), Pcp1.ptr(0), Ndim - 1, 1, 0);
280 
281  mult_Field_Gnn(Pcp1, 0, P, 0, Pcp2, 0);
282  P.setpart_ex(0, Pcp1, 0);
283  }
284  }
285 }
286 
287 
288 //====================================================================
289 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:503
virtual void set_parameters(const Parameters &params)
setting parameters: only for Polyakov loop correlators.
static int npe(const int dir)
logical grid extent
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:153
int site(const int &x, const int &y, const int &z, const int &t) const
Definition: index_lex.h:53
void general(const char *format,...)
Definition: bridgeIO.cpp:197
int nvol() const
Definition: field.h:127
void init(const std::string &filename)
Definition: bridgeIO.cpp:51
Class for parameters.
Definition: parameters.h:46
void calc_ploop(Field_G &P, const Field_G &U)
Polyakov loop measurement.
int nin() const
Definition: field.h:126
std::vector< int > m_Nmax
Definition: polyakovLoop.h:65
SU(N) gauge field.
Definition: field_G.h:38
int m_Nx_ext
size of extended gauge config.
Definition: polyakovLoop.h:57
Bridge::VerboseLevel m_vl
Definition: polyakovLoop.h:46
int fetch_int(const string &key, int &value) const
Definition: parameters.cpp:346
double ImTr(const Mat_SU_N &m)
Definition: mat_SU_N.h:500
static int exchange(int count, double *recv_buf, double *send_buf, int idir, int ipm, int tag)
receive array of double from upstream specified by idir and ipm, and send array to downstream...
Lexical site index.
Definition: index_lex.h:34
int m_Nvol_ext
volume of extended gauge config.
Definition: polyakovLoop.h:61
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
int m_Ntype_max
internal data members
Definition: polyakovLoop.h:56
void init()
initial setup independent of parameters.
std::string m_filename_output
Definition: polyakovLoop.h:49
static const std::string class_name
Definition: polyakovLoop.h:43
std::ostream & getStream()
Definition: bridgeIO.cpp:391
int m_Nspc_size
parameters set by user
Definition: polyakovLoop.h:52
int non_negative(const int v)
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...
int m_Nt_ext
size of extended gauge config.
Definition: polyakovLoop.h:60
int m_Ntype
number of measured loop-type
Definition: polyakovLoop.h:53
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:197
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
std::vector< unitvec > m_Nunit
Definition: polyakovLoop.h:64
int m_Ny_ext
size of extended gauge config.
Definition: polyakovLoop.h:58
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:114
int m_Nz_ext
size of extended gauge config.
Definition: polyakovLoop.h:59
void mult_nn(const Mat_SU_N &u1, const Mat_SU_N &u2)
Definition: mat_SU_N.h:163
static long_t Lvol()
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
double ReTr(const Mat_SU_N &m)
Definition: mat_SU_N.h:488
dcomplex measure_ploop(const Field_G &U)
Polyakov loop measurement.