CHROMA
qtopcor.cc
Go to the documentation of this file.
1 
2 #error "NOT FULLY CONVERTED"
3 
4 /* QTOPCOR: Calculate topological charge correlation function. The routine */
5 /* only calculates the squared piece (assumes the disconnected piece */
6 /* averages to 0. */
7 
8 /* qtop_corr -- topological charge correlation function ( Write ) */
9 /* qtop_den -- topological charge density ( Read ) */
10 
11 include(types.mh)
12 
13 SUBROUTINE(qtopcor, qtop_corr, qtop_den, num_points)
14 
15 multi1d<Real> qtop_corr(num_points);
16 LatticeReal qtop_den;
18 {
19  include(COMMON_DECLARATIONS)
20 
21  /* Local Variables */
22  LatticeComplex cqtop;
23  LatticeComplex tmp_1;
24  LatticeReal tmp_2;
25  LatticeReal qtop_corr_den;
26  LatticeReal lzero;
27  LatticeBoolean lbit;
28  LatticeBoolean lmask;
29  LatticeInteger lcoord;
30  LatticeInteger lradius_sq;
31  LatticeInteger ltmp_1;
32  LatticeInteger ltmp_2;
33 
34  int itmp;
35  int norm;
36  Real dummy;
38  Real rdummy;
39  int cb;
40  int mu;
41  int r0;
42  int two;
43 
45 
46  two = 2;
47 
48  /* Initialize FFT and allocate memory */
49  fftinit ();
50 
51  /* Initialize correlation function to 0 */
52  qtop_corr = 0;
53 
54 
55  /* FFT the topological charge density */
56 
57  lzero = 0;
58 
59  cqtop[0] = cmplx(qtop_den[0],lzero);
60  cqtop[1] = cmplx(qtop_den[1],lzero);
61 
62 
63  /* NOTE: I use some decay direction > Nd-1, so I fft in all directions */
64  ccfft (cqtop[0], cqtop[1], Nd, FORWARD);
65 
66 
67  /* Construct squared piece (the disconnected piece should average to zero) */
68 
69  /* tmp_1 = adj(FFT[qtop_den]) * FFT(qtop_den) */
70  tmp_1 = adj(cqtop) * cqtop;
71 
72  /* FFT back to coordinate space. */
73  /* NOTE: I use some decay direction > Nd-1, so I fft in all directions */
74  ccfft (tmp_1[0], tmp_1[1], Nd, BACKWARD);
75 
76  qtop_corr_den = real(tmp_1);
77 
78 
79  /* Gather the coordinates of all sites and compute the radius_sq */
80  lradius_sq[0] = 0;
81 
82  if ( Nd > 1 )
83  for(mu=1; mu<=Nd-1; ++mu)
84  {
85  lcoord = Layout::latticeCoordinate(mu);
86  itmp = nrow[mu];
87  FILL(ltmp_1, itmp);
88  ltmp_1 -= lcoord; /* ltmp_1 = L(mu) - lcoord */
89  itmp = itmp / two;
90  lbit = lcoord > itmp; /* lbit = lcoord > L(mu)/2 */
91  copymask(lcoord, lbit, ltmp_1, REPLACE);
92  lradius_sq[0] += lcoord * lcoord;
93  }
94 
95  lradius_sq[1] = lradius_sq[0];
96 
97  /* x-direction. x coord is set according to the checkerboard */
98 
99  mu = 0;
100 
101  ltmp_1 = 1;
102  lcoord = Layout::latticeCoordinate(mu);
103  lcoord = lcoord * two;
104  ltmp_2 = lcoord;
105  copymask(ltmp_2, lattice_odd_context, ltmp_1, ADD); /* ltmp_2 = true x coord */
106  itmp = nrow[mu];
108  ltmp_1 -= ltmp_2; /* ltmp_1 = L(mu) - lcoord */
109  itmp = nrow[mu] / two;
110  lbit = ltmp_2 > itmp; /* lbit = lcoord > L(mu)/2 */
111  copymask(ltmp_2, lbit, ltmp_1, REPLACE);
112  lradius_sq[0] += ltmp_2 * ltmp_2;
113 
114  ltmp_1 = 1;
115  ltmp_2 = lcoord;
116  copymask(ltmp_2, lattice_even_context, ltmp_1, ADD);
117  itmp = nrow[mu];
118  FILL(ltmp_1, itmp);
119  ltmp_1 -= ltmp_2; /* ltmp_1 = L(mu) - lcoord */
120  itmp = nrow[mu] / two;
121  lbit = ltmp_2 > itmp; /* lbit = lcoord > L(mu)/2 */
122  copymask(ltmp_2, lbit, ltmp_1, REPLACE);
123  lradius_sq[1] += ltmp_2 * ltmp_2;
124 
125 
126 
127  /* For each squared radial length, sum all the qualifying density values */
128 
129  for(r0=0; r0 < num_points; ++r0)
130  {
131  /* Find the coordinates matching the current radial length */
132  lmask[0] = lradius_sq[0] == r0;
133  lmask[1] = lradius_sq[1] == r0;
134 
135  /* Find the total number of sites matching this radial condition */
136  norm = sum(lmask[0]);
137  norm += sum(lmask[1]);
138 
139  /* If some coordinates were found, sum over them */
140  if ( norm > 0 )
141  {
142  tmp_2 = 0;
143  copymask(tmp_2, lmask, qtop_corr_den, REPLACE);
144 
145  /* hypercubic sum */
146  sum = sum(tmp_2[0]);
147  sum += sum(tmp_2[1]);
148 
149  rdummy = FLOAT(sum);
150  dummy = FLOAT(norm);
151  qtop_corr[r0] = rdummy / dummy;
152  }
153  }
154 
155  /* Clean up */
156  fftclr ();
157 
159 }
Nd
Definition: meslate.cc:74
FloatingPoint< double > Double
Definition: gtest.h:7351
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
START_CODE()
int cb
Definition: qtopcor.cc:39
fftinit()
fftclr()
copymask(lcoord, lbit, ltmp_1, REPLACE)
LatticeReal tmp_2
Definition: qtopcor.cc:24
FILL(ltmp_1, itmp)
include(types.mh) multi1d< Real > qtop_corr(num_points)
int mu
Definition: qtopcor.cc:40
END_CODE()
qtop_corr
Definition: qtopcor.cc:52
Double sum
Definition: qtopcor.cc:37
LatticeBoolean lmask
Definition: qtopcor.cc:28
int norm
Definition: qtopcor.cc:35
int r0
Definition: qtopcor.cc:41
LatticeReal qtop_den
Definition: qtopcor.cc:16
LatticeInteger lradius_sq
Definition: qtopcor.cc:30
LatticeInteger ltmp_1
Definition: qtopcor.cc:31
ccfft(cqtop[0], cqtop[1], Nd, FORWARD)
LatticeComplex tmp_1
Definition: qtopcor.cc:18
Real dummy
Definition: qtopcor.cc:36
cqtop[0]
Definition: qtopcor.cc:59
int num_points
Definition: qtopcor.cc:17
Real rdummy
Definition: qtopcor.cc:38
int two
Definition: qtopcor.cc:42
LatticeInteger ltmp_2
Definition: qtopcor.cc:32
LatticeInteger lcoord
Definition: qtopcor.cc:29
LatticeReal lzero
Definition: qtopcor.cc:26
int itmp
Definition: qtopcor.cc:34
LatticeReal qtop_corr_den
Definition: qtopcor.cc:25
LatticeBoolean lbit
Definition: qtopcor.cc:27