00001 #include<config.h>
00002 CPS_START_NAMESPACE
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 CPS_END_NAMESPACE
00033 #include <util/qcdio.h>
00034 #include <alg/alg_pot2.h>
00035 #include <util/lattice.h>
00036 #include <util/gjp.h>
00037 #include <util/smalloc.h>
00038 #include <util/vector.h>
00039 #include <util/verbose.h>
00040 #include <util/error.h>
00041 #include <comms/glb.h>
00042 CPS_START_NAMESPACE
00043
00044
00045
00046
00047 AlgPot2::AlgPot2(Lattice& latt,
00048 CommonArg *c_arg,
00049 PotArg *arg) :
00050 Alg(latt, c_arg)
00051 {
00052 cname = "AlgPot2";
00053 char *fname = "AlgPot2(L&,CommonArg*,PotArg*)";
00054 VRB.Func(cname,fname);
00055
00056
00057
00058 if(arg == 0)
00059 ERR.Pointer(cname,fname, "arg");
00060 alg_pot_arg = arg;
00061
00062
00063
00064
00065 int total_sites = GJP.VolNodeSites() * GJP.Xnodes() *
00066 GJP.Ynodes() * GJP.Znodes() * GJP.Tnodes();
00067 int int_norm = GJP.Colors()*total_sites;
00068
00069 norm_fac = 1.0 / ( Float(int_norm) );
00070 xiB2 = GJP.XiBare()*GJP.XiBare();
00071 }
00072
00073
00074
00075
00076
00077 AlgPot2::~AlgPot2() {
00078 char *fname = "~AlgPot2()";
00079 VRB.Func(cname,fname);
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 void AlgPot2::run()
00091 {
00092 #if TARGET==cpsMPI
00093 using MPISCU::fprintf;
00094 #endif
00095
00096 char *fname = "run()";
00097 VRB.Func(cname,fname);
00098
00099 int sweep = alg_pot_arg->sweep;
00100 int prop_dir = alg_pot_arg->prop_dir;
00101 int check = alg_pot_arg->check;
00102
00103
00104
00105
00106 int max_ext[4];
00107
00108 int max_X = alg_pot_arg->max_X;
00109 int max_Y = alg_pot_arg->max_Y;
00110 int max_Z = alg_pot_arg->max_Z;
00111 int max_T = alg_pot_arg->max_T;
00112
00113 max_ext[0] = max_X;
00114 max_ext[1] = max_Y;
00115 max_ext[2] = max_Z;
00116 max_ext[3] = max_T;
00117
00118 int max_prop = max_ext[prop_dir];
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 int r2max = check*check;
00130
00131
00132 int dir_orth[3];
00133 int idir = 0;
00134 for (int i = 0; i < 4; i++)
00135 if( i != prop_dir ) {
00136 dir_orth[idir] = i;
00137 idir++;
00138 }
00139
00140 int max_1 = max_ext[dir_orth[0]];
00141 int max_2 = max_ext[dir_orth[1]];
00142 int max_3 = max_ext[dir_orth[2]];
00143
00144 int num_loop = 0;
00145 for (int ext1 = 0; ext1 <= max_1; ext1++){
00146 for (int ext2 = 0; ext2 <= max_2; ext2++){
00147 for (int ext3 = 0; ext3 <= max_3; ext3++){
00148
00149 int cmax = ext3;
00150 if (cmax <= ext2) {cmax = ext2;}
00151 if (cmax <= ext1) {cmax = ext1;}
00152 int cmin = ext1;
00153 if (cmin >= ext2) {cmin = ext2;}
00154 if (cmin >= ext3) {cmin = ext3;}
00155
00156 int cmid = ext1+ext2+ext3 - cmax - cmin;
00157
00158 int r2 = ext1*ext1 + ext2*ext2 + ext3*ext3;
00159 if( r2 <= r2max || cmid == 0 ) num_loop+=max_prop;
00160 }
00161 }
00162 }
00163
00164 Float aniso_factor;
00165 Float pot_real;
00166 Float pot_imag;
00167
00168
00169
00170 Lattice& lat = AlgLattice();
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 Complex *Wloop = new Complex[num_loop];
00183
00184
00185 int *qq_sep0 = new int[num_loop];
00186 int *qq_sep1 = new int[num_loop];
00187 int *qq_sep2 = new int[num_loop];
00188 int *qq_sep3 = new int[num_loop];
00189 int *qq_sep4 = new int[num_loop];
00190 int *qq_sep5 = new int[num_loop];
00191
00192
00193 for (int i = 0; i < num_loop; i++){
00194 Wloop[i] = 0.;
00195 qq_sep0[i] = -1;
00196 qq_sep1[i] = -1;
00197 qq_sep2[i] = -1;
00198 qq_sep3[i] = -1;
00199 qq_sep4[i] = 0;
00200 qq_sep5[i] = 0;
00201 }
00202
00203 int iloop = 0;
00204 for (int ext_prop=1; ext_prop <= max_prop ; ext_prop++){
00205
00206
00207 aniso_factor = power(xiB2,-1.*ext_prop);
00208
00209
00210
00211
00212
00213
00214
00215
00216 for (int ext1 = 0; ext1 <= max_1; ext1++){
00217 for (int ext2 = 0; ext2 <= max_2; ext2++){
00218 for (int ext3 = 0; ext3 <= max_3; ext3++){
00219
00220 int cmax = ext3;
00221 int dir_max = 2;
00222 if (cmax <= ext2) {cmax = ext2; dir_max=1;}
00223 if (cmax <= ext1) {cmax = ext1; dir_max=0;}
00224 int cmin = ext1;
00225 int dir_min = 0;
00226 if (cmin >= ext2) {cmin = ext2; dir_min=1;}
00227 if (cmin >= ext3) {cmin = ext3; dir_min=2;}
00228
00229 int cmid = ext1+ext2+ext3 - cmax - cmin;
00230 int dir_mid = 0+1+2 - dir_max - dir_min;
00231
00232 int r2 = ext1*ext1 + ext2*ext2 + ext3*ext3;
00233
00234 if( r2 <= r2max || cmid == 0 ) {
00235
00236 int check1 =
00237 dir_max*dir_max + dir_mid*dir_mid + dir_min*dir_min;
00238 if ( check1 != 5 ) {
00239 cout << " sum dir*dir should be 5 not " << check1 << endl;
00240 exit(-1);
00241 }
00242
00243 int cmax2 = 2*cmax;
00244 int cmid2 = 2*cmid;
00245 int cmin2 = 2*cmin;
00246 int chi_mid = cmid2 - cmax;
00247 int chi_min = cmin2 - cmax;
00248
00249
00250
00251
00252 int nlinks = 2*(ext1+ext2+ext3+ext_prop);
00253
00254
00255 int *path = new int[nlinks];
00256 int ipath = 0;
00257
00258
00259 for (int i = 1; i <= cmax; i++) {
00260 path[ipath] = dir_orth[dir_max];
00261 ipath++;
00262 if (chi_mid >= 0) {
00263 chi_mid -= cmax2;
00264 path[ipath] = dir_orth[dir_mid];
00265 ipath++;
00266 }
00267 if (chi_min >= 0) {
00268 chi_min -= cmax2;
00269 path[ipath] = dir_orth[dir_min];
00270 ipath++;
00271 }
00272 chi_mid += cmid2;
00273 chi_min += cmin2;
00274 }
00275
00276
00277 for (int i = 0; i < ext_prop; i++) {
00278 path[ipath] = prop_dir;
00279 ipath++;
00280 }
00281
00282
00283
00284
00285
00286
00287 int qq_path = ext1 + ext2 + ext3;
00288 int inv_path = qq_path - 1;
00289 for (int i = 0; i < qq_path; i++) {
00290 path[ipath] = path[inv_path] + 4;
00291 ipath++;
00292 inv_path--;
00293 }
00294
00295
00296 for (int i = 0; i < ext_prop; i++) {
00297 path[ipath] = prop_dir + 4;
00298 ipath++;
00299 }
00300
00301
00302 if (ipath != nlinks) {
00303 cout << "illegal path !!!" << endl;
00304 cout << "ipath = " << ipath << endl;
00305 cout << "nlinks = " << nlinks << endl;
00306 exit(-1);
00307 }
00308
00309
00310
00311
00312
00313 int x[4]={0,0,0,0};
00314 Matrix LOOP;
00315
00316 Complex pot=0.;
00317
00318 int isite = 0;
00319 for(x[0]=0;x[0]<GJP.XnodeSites();x[0]++)
00320 for(x[1]=0;x[1]<GJP.YnodeSites();x[1]++)
00321 for(x[2]=0;x[2]<GJP.ZnodeSites();x[2]++)
00322 for(x[3]=0;x[3]<GJP.TnodeSites();x[3]++){
00323
00324 LOOP.ZeroMatrix();
00325 lat.PathOrdProdPlus(LOOP, x, path, nlinks);
00326 pot += LOOP.Tr();
00327 isite++;
00328
00329 }
00330
00331
00332
00333
00334
00335 Wloop[iloop] = pot;
00336 int tmp_sep[4] = {-1,-1,-1,-1};
00337 tmp_sep[dir_orth[0]] = ext1;
00338 tmp_sep[dir_orth[1]] = ext2;
00339 tmp_sep[dir_orth[2]] = ext3;
00340 qq_sep0[iloop] = tmp_sep[0];
00341 qq_sep1[iloop] = tmp_sep[1];
00342 qq_sep2[iloop] = tmp_sep[2];
00343 qq_sep3[iloop] = tmp_sep[3];
00344 qq_sep4[iloop] = ext_prop;
00345 qq_sep5[iloop] = r2;
00346 iloop++;
00347
00348
00349 delete [] path;
00350
00351 }
00352 }
00353 }
00354 }
00355
00356 }
00357
00358 if (iloop != num_loop ) {
00359 cout << "something is wrong about loop counting" << endl;
00360 cout << "iloop = " << iloop << endl;
00361 cout << "num_loop = " << num_loop << endl;
00362 exit(-1);
00363 }
00364
00365
00366 char wfname[100];
00367 sprintf(wfname, "Wloop%04dsme%03d.dat", sweep/1000, sweep%1000);
00368 FILE *fp= Fopen(wfname, "w");
00369
00370
00371 Fprintf(fp, "# max_X= %d max_Y= %d max_Z= %d max_T= %d \n",
00372 max_X, max_Y, max_Z, max_T);
00373 Fprintf(fp, "# sweep= %d prop_dir= %d num_loop= %d\n",
00374 sweep/1000, prop_dir, num_loop);
00375 Fprintf(fp, "# smear= %d \n", sweep%1000);
00376 Fprintf(fp, "# x y z t prop pot_real pot_imag\n");
00377
00378 for (int i = 0; i < num_loop; i++){
00379 Complex W = Wloop[i];
00380 pot_real = real(W);
00381 pot_imag = imag(W);
00382 glb_sum(&pot_real) ;
00383 glb_sum(&pot_imag) ;
00384
00385
00386
00387 pot_real *= aniso_factor*norm_fac;
00388 pot_imag *= aniso_factor*norm_fac;
00389
00390 Fprintf(fp," %d %d %d %d %d %e %e \n",
00391
00392
00393 qq_sep0[i],qq_sep1[i],qq_sep2[i],qq_sep3[i],
00394 qq_sep4[i], pot_real, pot_imag);
00395
00396
00397
00398 }
00399
00400 Fclose(fp);
00401
00402
00403 delete[] Wloop;
00404
00405 delete[] qq_sep0;
00406 delete[] qq_sep1;
00407 delete[] qq_sep2;
00408 delete[] qq_sep3;
00409 delete[] qq_sep4;
00410 delete[] qq_sep5;
00411
00412 }
00413 CPS_END_NAMESPACE