-
Notifications
You must be signed in to change notification settings - Fork 47
/
check_locallity.c
308 lines (274 loc) · 8.24 KB
/
check_locallity.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/***********************************************************************
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Carsten Urbach
*
* This file is part of tmLQCD.
*
* tmLQCD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* tmLQCD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with tmLQCD. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/
#include "lime.h"
#ifdef HAVE_CONFIG_H
# include<tmlqcd_config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <signal.h>
#ifdef TM_USE_MPI
#include <mpi.h>
#endif
#include "global.h"
#include "getopt.h"
#include "linalg_eo.h"
#include "geometry_eo.h"
#include "start.h"
#include "measure_gauge_action.h"
#ifdef TM_USE_MPI
#include "xchange/xchange.h"
#endif
#include "read_input.h"
#include "mpi_init.h"
#include "sighandler.h"
#include "boundary.h"
#include "solver/solver.h"
#include "init/init.h"
#include "smearing/stout.h"
#include "su3spinor.h"
#include "invert_eo.h"
#include "operator/D_psi.h"
#include "linalg/convert_eo_to_lexic.h"
void usage(){
fprintf(stdout, "Code for locallity check of the Dirac operator\n");
fprintf(stdout, "Version %s \n\n", TMLQCD_PACKAGE_VERSION);
fprintf(stdout, "Please send bug reports to %s\n", TMLQCD_PACKAGE_BUGREPORT);
fprintf(stdout, "Usage: invert [options]\n");
fprintf(stdout, "Options: [-f input-filename]\n");
fprintf(stdout, " [-o output-filename]\n");
fprintf(stdout, " [-h|-? this help]\n");
exit(0);
}
extern int nstore;
int check_geometry();
int main(int argc,char *argv[]) {
FILE *parameterfile=NULL;
int c, j, is=0, ic=0;
int x, X, y, Y, z, Z, t, tt, i, sum;
char * filename = NULL;
char datafilename[50];
char parameterfilename[50];
char conf_filename[50];
char * input_filename = NULL;
double plaquette_energy, nrm;
double * norm;
struct stout_parameters params_smear;
#ifdef _GAUGE_COPY
int kb=0;
#endif
#ifdef TM_USE_MPI
double atime=0., etime=0.;
#endif
#ifdef _KOJAK_INST
#pragma pomp inst init
#pragma pomp inst begin(main)
#endif
DUM_DERI = 6;
/* DUM_DERI + 2 is enough (not 7) */
DUM_MATRIX = DUM_DERI+8;
/* DUM_MATRIX + 2 is enough (not 6) */
NO_OF_SPINORFIELDS = DUM_MATRIX+2;
verbose = 0;
g_use_clover_flag = 0;
g_nr_of_psf = 1;
#ifdef TM_USE_MPI
MPI_Init(&argc, &argv);
#endif
while ((c = getopt(argc, argv, "h?f:o:")) != -1) {
switch (c) {
case 'f':
input_filename = calloc(200, sizeof(char));
strcpy(input_filename,optarg);
break;
case 'o':
filename = calloc(200, sizeof(char));
strcpy(filename,optarg);
break;
case 'h':
case '?':
default:
usage();
break;
}
}
if(input_filename == NULL){
input_filename = "hmc.input";
}
if(filename == NULL){
filename = "output";
}
/* Read the input file */
read_input(input_filename);
/* here we want no even/odd preconditioning */
even_odd_flag = 0;
/* this DBW2 stuff is not needed for the inversion ! */
g_rgi_C1 = 0;
if(Nsave == 0){
Nsave = 1;
}
tmlqcd_mpi_init(argc, argv);
g_dbw2rand = 0;
#ifndef TM_USE_MPI
g_dbw2rand = 0;
#endif
#ifdef _GAUGE_COPY
j = init_gauge_field(VOLUMEPLUSRAND, 1);
#else
j = init_gauge_field(VOLUMEPLUSRAND, 0);
#endif
if ( j!= 0) {
fprintf(stderr, "Not enough memory for gauge_fields! Aborting...\n");
exit(-1);
}
j = init_geometry_indices(VOLUMEPLUSRAND);
if ( j!= 0) {
fprintf(stderr, "Not enough memory for geometry indices! Aborting...\n");
exit(-1);
}
if(even_odd_flag) {
j = init_spinor_field(VOLUMEPLUSRAND/2, NO_OF_SPINORFIELDS);
}
else {
j = init_spinor_field(VOLUMEPLUSRAND, NO_OF_SPINORFIELDS);
}
if ( j!= 0) {
fprintf(stderr, "Not enough memory for spinor fields! Aborting...\n");
exit(-1);
}
g_mu = g_mu1;
if(g_proc_id == 0){
/*construct the filenames for the observables and the parameters*/
strcpy(datafilename,filename); strcat(datafilename,".data");
strcpy(parameterfilename,filename); strcat(parameterfilename,".para");
parameterfile=fopen(parameterfilename, "w");
write_first_messages(parameterfile, "check_locality", "NA");
}
/* define the geometry */
geometry();
/* define the boundary conditions for the fermion fields */
boundary();
#ifdef _USE_HALFSPINOR
j = init_dirac_halfspinor();
if ( j!= 0) {
fprintf(stderr, "Not enough memory for halffield! Aborting...\n");
exit(-1);
}
if(g_sloppy_precision_flag == 1) {
j = init_dirac_halfspinor32();
if ( j!= 0) {
fprintf(stderr, "Not enough memory for 32-Bit halffield! Aborting...\n");
exit(-1);
}
}
# if (defined _PERSISTENT)
init_xchange_halffield();
# endif
#endif
norm = (double*)calloc(3.*LX/2.+T/2., sizeof(double));
for(j=0;j<Nmeas; j++) {
sprintf(conf_filename,"%s.%.4d", gauge_input_filename, nstore);
if (g_proc_id == 0){
printf("Reading Gauge field from file %s\n", conf_filename); fflush(stdout);
}
read_lime_gauge_field(conf_filename);
if (g_proc_id == 0){
printf("done!\n"); fflush(stdout);
}
#ifdef TM_USE_MPI
xchange_gauge(g_gauge_field);
#endif
/* Compute minimal eigenvalues, if wanted */
if(compute_evs != 0) {
eigenvalues(&no_eigenvalues, 1000, eigenvalue_precision, 0, compute_evs, nstore, even_odd_flag);
}
/*compute the energy of the gauge field*/
plaquette_energy = measure_plaquette(g_gauge_field);
if(g_proc_id == 0) {
printf("The plaquette value is %e\n", plaquette_energy/(6.*VOLUME*g_nproc)); fflush(stdout);
}
if (use_stout_flag == 1){
params_smear.rho = stout_rho;
params_smear.iterations = stout_no_iter;
if (stout_smear((su3_tuple*)(g_gauge_field[0]), ¶ms_smear, (su3_tuple*)(g_gauge_field[0])) != 0)
exit(1) ;
g_update_gauge_copy = 1;
plaquette_energy = measure_plaquette(g_gauge_field);
if (g_proc_id == 0) {
printf("# The plaquette value after stouting is %e\n", plaquette_energy / (6.*VOLUME*g_nproc));
fflush(stdout);
}
}
source_spinor_field(g_spinor_field[0], g_spinor_field[1], 0, 0);
convert_eo_to_lexic(g_spinor_field[DUM_DERI], g_spinor_field[0], g_spinor_field[1]);
D_psi(g_spinor_field[DUM_DERI+1], g_spinor_field[DUM_DERI]);
if(even_odd_flag) {
i = invert_eo(g_spinor_field[2], g_spinor_field[3], g_spinor_field[0], g_spinor_field[1],
solver_precision, max_solver_iterations, solver_flag, g_relative_precision_flag,
sub_evs_cg_flag, even_odd_flag, 0, NULL, -1,
NO_EXT_INV, SLOPPY_DOUBLE, NO_COMPRESSION);
convert_eo_to_lexic(g_spinor_field[DUM_DERI+1], g_spinor_field[2], g_spinor_field[3]);
}
for(i = 0; i < 3*LX/2+T/2; i++){
norm[i] = 0.;
}
for(x = 0; x < LX; x++){
if(x > LX/2) X = LX-x;
else X = x;
for(y = 0; y < LY; y++){
if(y > LY/2) Y = LY-y;
else Y = y;
for(z = 0; z < LZ; z++){
if(z > LZ/2) Z = LZ-z;
else Z = z;
for(t = 0; t < T; t++){
if(t > T/2) tt = T - t;
else tt = t;
sum = X + Y + Z + tt;
_spinor_norm_sq(nrm, g_spinor_field[DUM_DERI+1][ g_ipt[t][x][y][z] ]);
/* _spinor_norm_sq(nrm, qprop[0][0][1][ g_ipt[t][x][y][z] ]); */
printf("%e %e\n", creal(g_spinor_field[DUM_DERI+1][ g_ipt[t][x][y][z] ].s0.c0), cimag(g_spinor_field[DUM_DERI+1][ g_ipt[t][x][y][z] ].s0.c0));
nrm = sqrt( nrm );
printf("%1.12e\n", nrm);
if(nrm > norm[sum]) norm[sum] = nrm;
}
}
}
}
for(i = 0; i < 3*L/2+T/2; i++){
printf("%d %1.12e\n", i, norm[i]);
}
printf("\n");
nstore+=Nsave;
}
#ifdef TM_USE_MPI
MPI_Finalize();
#endif
free_gauge_field();
free_geometry_indices();
free_spinor_field();
free_moment_field();
return(0);
#ifdef _KOJAK_INST
#pragma pomp inst end(main)
#endif
}