Bridge++  Ver. 2.0.2
polyakovLoop.cpp
Go to the documentation of this file.
1 
14 #include "polyakovLoop.h"
16 #include "Field/field_thread-inc.h"
17 
18 const std::string PolyakovLoop::class_name = "PolyakovLoop";
19 
20 //====================================================================
22 {
23  m_filename_output = params.get_string("filename_output");
24  if (m_filename_output.empty()) {
25  m_filename_output = "stdout";
26  }
27 
28  std::string vlevel;
29  if (!params.fetch_string("verbose_level", vlevel)) {
30  m_vl = vout.set_verbose_level(vlevel);
31  }
32 
33 #if 0
34  //- fetch and check input parameters
35  int Nspc_size, Ntype;
36 
37  int err = 0;
38  err += params.fetch_int("spatial_correlator_size", Nspc_size);
39  err += params.fetch_int("number_of_correlator_type", Ntype);
40 
41  if (err) {
42  vout.crucial(m_vl, "Error at %s: input parameter not found.\n",
43  class_name.c_str());
44  exit(EXIT_FAILURE);
45  }
46 
47 
48  set_parameters(Nspc_size, Ntype);
49 #endif
50 }
51 
52 
53 //====================================================================
55 {
56  params.set_int("spatial_correlator_size", m_Nspc_size);
57  params.set_int("number_of_correlator_type", m_Ntype);
58 
59  params.set_string("filename_output", m_filename_output);
60  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
61 }
62 
63 
64 //====================================================================
65 void PolyakovLoop::set_parameters(const int Nspc_size, const int Ntype)
66 {
67 #if 0
68  //- print input parameters
69  vout.general(m_vl, "Polyakov loop measurement:\n");
70  vout.general(m_vl, " Nspc_size = %d\n", Nspc_size);
71  vout.general(m_vl, " Ntype = %d\n", Ntype);
72 
73  //- range check
74  int err = 0;
75  err += ParameterCheck::non_negative(Nspc_size);
76  err += ParameterCheck::non_negative(Ntype);
77 
80  if (Ntype > 6) ++err;
81 
82  if (err) {
83  vout.crucial(m_vl, "Error at %s: parameter range check failed.\n", class_name.c_str());
84  exit(EXIT_FAILURE);
85  }
86 
87  //- store values
88  m_Nspc_size = Nspc_size;
89  m_Ntype = Ntype;
90 
91 
92  //- post-process
93  m_Nx_ext = CommonParameters::Nx() + m_Nspc_size + 1;
94  m_Ny_ext = CommonParameters::Ny() + m_Nspc_size + 1;
95  m_Nz_ext = CommonParameters::Nz() + m_Nspc_size + 1;
96  m_Nt_ext = 1;
97  m_Nvol_ext = m_Nx_ext * m_Ny_ext * m_Nz_ext * m_Nt_ext;
98 
101  m_Nmax[0] = Nspc_size;
102  m_Nmax[1] = Nspc_size;
103  m_Nmax[2] = Nspc_size / 2;
104  m_Nmax[3] = Nspc_size;
105  m_Nmax[4] = Nspc_size / 2;
106  m_Nmax[5] = Nspc_size / 2;
107 #endif
108 }
109 
110 
111 //====================================================================
113 {
114  const int Ndim = CommonParameters::Ndim();
115 
116  assert(Ndim == 4);
117 
118  m_filename_output = "stdout";
119 
120  const int Nx = CommonParameters::Nx();
121  const int Ny = CommonParameters::Ny();
122  const int Nz = CommonParameters::Nz();
123  const int Nvol_spc = Nx * Ny * Nz;
124 
125  m_P.reset(Nvol_spc, 1);
126  m_Pcp1.reset(Nvol_spc, 1);
127  m_Pcp2.reset(Nvol_spc, 1);
128 
129 #if 0
130  m_Ntype_max = 6;
131  const int Ndim_spc = Ndim - 1;
132 
133  m_Nunit.resize(m_Ntype_max);
134  m_Nmax.resize(m_Ntype_max);
135 
136  for (int i = 0; i < m_Ntype_max; ++i) {
137  m_Nunit[i].resize(Ndim_spc);
138  }
139 
140  // The following setting explicitly depends on the definition
141  // of unit vectors.
142  assert(m_Ntype_max >= 6);
143 
144  m_Nunit[0][0] = 1;
145  m_Nunit[0][1] = 0;
146  m_Nunit[0][2] = 0;
147 
148  m_Nunit[1][0] = 1;
149  m_Nunit[1][1] = 1;
150  m_Nunit[1][2] = 0;
151 
152  m_Nunit[2][0] = 2;
153  m_Nunit[2][1] = 1;
154  m_Nunit[2][2] = 0;
155 
156  m_Nunit[3][0] = 1;
157  m_Nunit[3][1] = 1;
158  m_Nunit[3][2] = 1;
159 
160  m_Nunit[4][0] = 2;
161  m_Nunit[4][1] = 1;
162  m_Nunit[4][2] = 1;
163 
164  m_Nunit[5][0] = 2;
165  m_Nunit[5][1] = 2;
166  m_Nunit[5][2] = 1;
167 #endif
168 }
169 
170 
171 //====================================================================
173 {
175 
176  dcomplex ploop;
177 
178 #pragma omp parallel
179  {
180  dcomplex ploop1;
181  calc_ploop(ploop1, U);
182 
183  int ith = ThreadManager::get_thread_id();
184  if (ith == 0) ploop = ploop1;
185  }
186 
187  std::ostream& log_file_previous = vout.getStream();
188  std::ofstream log_file;
189 
190  if (m_filename_output != "stdout") {
191  log_file.open(m_filename_output.c_str(), std::ios::app);
192  vout.init(log_file);
193  }
194 
195  vout.general(m_vl, "PolyakovLoop(Re,Im) = %20.16e %20.16e\n",
196  real(ploop), imag(ploop));
197 
198  if (m_filename_output != "stdout") {
199  log_file.close();
200  vout.init(log_file_previous);
201  }
202 
203  return ploop;
204 }
205 
206 
207 //====================================================================
208 void PolyakovLoop::calc_ploop(dcomplex& ploop, const Field_G& U)
209 {
210 #pragma omp barrier
211 
212  const int Nc = CommonParameters::Nc();
213  const int Ndim = CommonParameters::Ndim();
214 
215  const int Nx = CommonParameters::Nx();
216  const int Ny = CommonParameters::Ny();
217  const int Nz = CommonParameters::Nz();
218  const int Nt = CommonParameters::Nt();
219 
220  const int Nvol = U.nvol();
221  assert(Nvol == Nx * Ny * Nz * Nt);
222 
223  const int Nvol_spc = m_P.nvol();
224  assert(Nvol_spc == Nx * Ny * Nz);
225 
226  copy(m_Ut, 0, U, Ndim - 1);
227 #pragma omp barrier
228 
229  int ith, nth, is, ns;
230  set_threadtask(ith, nth, is, ns, Nvol_spc);
231 
232  const Index_lex index;
233  const Index_lex index_spc(Nx, Ny, Nz, 1);
234 
235  //- Definition of local Polyakov loops
236  const int t = 0;
237 
238  for (int site2 = is; site2 < ns; ++site2) {
239  int x = site2 % Nx;
240  int y = (site2 % (Nx * Ny) - x) / Nx;
241  int z = (site2 - Nx * y - x) / (Nx * Ny);
242 
243  int site = index.site(x, y, z, t);
244 
245  Mat_SU_N utmp1(Nc);
246  m_Ut.mat(utmp1, site, 0);
247 
248  m_P.set_mat(site2, 0, utmp1);
249  }
250 #pragma omp barrier
251 
252  for (int t = 1; t < Nt; ++t) {
253  for (int site2 = is; site2 < ns; ++site2) {
254  int x = site2 % Nx;
255  int y = (site2 % (Nx * Ny) - x) / Nx;
256  int z = (site2 - Nx * y - x) / (Nx * Ny);
257 
258  int site = index.site(x, y, z, t);
259 
260  Mat_SU_N utmp1(Nc);
261  m_Ut.mat(utmp1, site, 0);
262 
263  Mat_SU_N utmp2(Nc);
264  m_P.mat(utmp2, site2, 0);
265 
266  Mat_SU_N utmp3(Nc);
267  utmp3.mult_nn(utmp2, utmp1);
268 
269  m_P.set_mat(site2, 0, utmp3);
270  }
271 #pragma omp barrier
272  }
273 
274  //- global Polyakov loops
275  const int Npe_t = Communicator::npe(Ndim - 1);
276  if (Npe_t > 1) {
277  const int size_cp = m_P.nin() * Nvol_spc;
278 
279  for (int ipe_t = 1; ipe_t < Npe_t; ++ipe_t) {
280  if (ipe_t == 1) {
281  copy(m_Pcp1, 0, m_P, 0);
282  } else {
283  copy(m_Pcp1, 0, m_Pcp2, 0);
284  }
285 
286 #pragma omp barrier
287 
288  if (ith == 0) {
289  Communicator::exchange(size_cp, m_Pcp2.ptr(0), m_Pcp1.ptr(0),
290  Ndim - 1, 1, 0);
291  }
292 #pragma omp barrier
293 
294  mult_Field_Gnn(m_Pcp1, 0, m_P, 0, m_Pcp2, 0);
295 #pragma omp barrier
296 
297  copy(m_P, 0, m_Pcp1, 0);
298 #pragma omp barrier
299  }
300  }
301 
302  //- Take the trace
303  dcomplex tr = 0.0;
304 
305  for (int site = is; site < ns; ++site) {
306  Mat_SU_N utmp(Nc);
307  m_P.mat(utmp, site, 0);
308 
309  tr += Tr(utmp);
310  }
311 #pragma omp barrier
312 
313  ThreadManager::reduce_sum_global(tr, ith, nth);
314 
315  const int Lvol_spc = CommonParameters::Lvol() / CommonParameters::Lt();
316 
317  const double re_ploop = real(tr) / (Nc * Lvol_spc * Npe_t);
318  const double im_ploop = imag(tr) / (Nc * Lvol_spc * Npe_t);
319 
320  ploop = cmplx(re_ploop, im_ploop);
321 
322 #pragma omp barrier
323 }
324 
325 
326 //============================================================END=====
CommonParameters::Ny
static int Ny()
Definition: commonParameters.h:106
CommonParameters::Nz
static int Nz()
Definition: commonParameters.h:107
CommonParameters::Lvol
static long_t Lvol()
Definition: commonParameters.h:95
Bridge::BridgeIO::init
void init(const std::string &filename)
Definition: bridgeIO.cpp:53
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
Index_lex
Lexical site index.
Definition: index_lex.h:34
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Parameters
Class for parameters.
Definition: parameters.h:46
PolyakovLoop::m_filename_output
std::string m_filename_output
Definition: polyakovLoop.h:50
PolyakovLoop::class_name
static const std::string class_name
Definition: polyakovLoop.h:44
PolyakovLoop::m_Ut
Field_G m_Ut
Definition: polyakovLoop.h:57
Field_G::set_mat
void set_mat(const int site, const int mn, const Mat_SU_N &U)
Definition: field_G.h:160
PolyakovLoop::m_Nspc_size
int m_Nspc_size
parameters set by user
Definition: polyakovLoop.h:53
polyakovLoop.h
PolyakovLoop::get_parameters
virtual void get_parameters(Parameters &params) const
Definition: polyakovLoop.cpp:54
PolyakovLoop::m_vl
Bridge::VerboseLevel m_vl
Definition: polyakovLoop.h:47
ParameterCheck::non_negative
int non_negative(const int v)
Definition: parameterCheck.cpp:21
PolyakovLoop::m_Ntype
int m_Ntype
number of measured loop-type
Definition: polyakovLoop.h:54
Field::nin
int nin() const
Definition: field.h:126
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
CommonParameters::Nx
static int Nx()
Definition: commonParameters.h:105
PolyakovLoop::calc_ploop
void calc_ploop(dcomplex &ploop, const Field_G &U)
Polyakov loop measurement (multi-threaded).
Definition: polyakovLoop.cpp:208
CommonParameters::Lt
static int Lt()
Definition: commonParameters.h:94
SU_N::Tr
dcomplex Tr(const Mat_SU_N &m)
Definition: mat_SU_N.h:558
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
PolyakovLoop::measure_ploop
dcomplex measure_ploop(const Field_G &U)
Polyakov loop measurement.
Definition: polyakovLoop.cpp:172
CommonParameters::Nt
static int Nt()
Definition: commonParameters.h:108
Communicator::npe
static int npe(const int dir)
logical grid extent
Definition: communicator.cpp:112
SU_N::Mat_SU_N
Definition: mat_SU_N.h:36
ThreadManager::reduce_sum_global
static void reduce_sum_global(dcomplex &value, const int i_thread, const int Nthread)
global reduction with summation: dcomplex values are assumed thread local.
Definition: threadManager.cpp:288
threadManager.h
PolyakovLoop::m_Pcp2
Field_G m_Pcp2
Definition: polyakovLoop.h:57
Field_G::reset
void reset(const int Nvol, const int Nex)
Definition: field_G.h:79
PolyakovLoop::set_parameters
virtual void set_parameters(const Parameters &params)
setting parameters: only for Polyakov loop correlators.
Definition: polyakovLoop.cpp:21
SU_N::Mat_SU_N::mult_nn
void mult_nn(const Mat_SU_N &u1, const Mat_SU_N &u2)
Definition: mat_SU_N.h:189
Field::nvol
int nvol() const
Definition: field.h:127
Index_lex::site
int site(const int &x, const int &y, const int &z, const int &t) const
Definition: index_lex.h:55
Field::ptr
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:153
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
Parameters::set_int
void set_int(const string &key, const int value)
Definition: parameters.cpp:36
PolyakovLoop::m_Pcp1
Field_G m_Pcp1
Definition: polyakovLoop.h:57
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
field_thread-inc.h
PolyakovLoop::m_P
Field_G m_P
working area
Definition: polyakovLoop.h:57
Parameters::get_string
string get_string(const string &key) const
Definition: parameters.cpp:221
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
PolyakovLoop::init
void init()
Polyakov loop correlator measurement (to be implemented).
Definition: polyakovLoop.cpp:112
Communicator::exchange
static int exchange(int count, dcomplex *recv_buf, dcomplex *send_buf, int idir, int ipm, int tag)
receive array of dcomplex from upstream specified by idir and ipm, and send array to downstream.
Definition: communicator.cpp:207
ThreadManager::get_thread_id
static int get_thread_id()
returns thread id.
Definition: threadManager.cpp:253
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
Bridge::BridgeIO::getStream
std::ostream & getStream()
Definition: bridgeIO.cpp:396
Parameters::fetch_int
int fetch_int(const string &key, int &value) const
Definition: parameters.cpp:346
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
ThreadManager::assert_single_thread
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
Definition: threadManager.cpp:372
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