00001 #include<config.h>
00002 CPS_START_NAMESPACE
00008
00009
00010
00011
00012
00013
00014
00015 CPS_END_NAMESPACE
00016 #include <stdlib.h>
00017 #include <util/qcdio.h>
00018 #include <util/mom.h>
00019 CPS_START_NAMESPACE
00020
00021 CPS_END_NAMESPACE
00022 #include <util/gjp.h>
00023 #include <util/smalloc.h>
00024 #include <util/verbose.h>
00025 #include <util/error.h>
00026 CPS_START_NAMESPACE
00027
00028 Mom MOM;
00029
00030
00031
00032
00033 Mom::Mom()
00034 {
00035 cname = "Mom";
00036 char *fname = "Mom(MomArg*)";
00037 VRB.Func(cname,fname);
00038 }
00039
00040
00041
00042 Mom::~Mom() {
00043 char *fname = "~Mom()";
00044 VRB.Func(cname,fname);
00045
00046
00047 VRB.Sfree(cname,fname, "mom_fact", mom_fact);
00048 sfree(mom_fact);
00049 }
00050
00051
00052
00053
00054
00059
00060 void Mom::Init(MomArg *arg)
00061 {
00062 char *fname = "Init()";
00063 VRB.Func(cname,fname);
00064
00065 PI = 3.14159265358979323846;
00066
00067
00068
00069 if(arg == 0)
00070 ERR.Pointer(cname,fname, "arg");
00071 mom_arg = arg;
00072
00073 no_of_mom = mom_arg->no_of_momenta;
00074 deg = mom_arg->deg;
00075 max_p1 = mom_arg->max_p1;
00076 max_p2 = mom_arg->max_p2;
00077 max_p3 = mom_arg->max_p3;
00078
00079 int mom_fact_size = no_of_mom*GJP.VolNodeSites();
00080
00081 mom_fact = (Complex *) smalloc(mom_fact_size * sizeof(Complex));
00082 if(mom_fact == 0)
00083 ERR.Pointer(cname,fname, "mom_fact");
00084 VRB.Smalloc(cname,fname, "mom_fact", mom_fact, mom_fact_size * sizeof(Complex));
00085
00086
00087 nx[0] = GJP.XnodeSites();
00088 nx[1] = GJP.YnodeSites();
00089 nx[2] = GJP.ZnodeSites();
00090 nx[3] = GJP.TnodeSites();
00091
00092
00093 glb_L[0] = GJP.XnodeSites()*GJP.Xnodes();
00094 glb_L[1] = GJP.YnodeSites()*GJP.Ynodes();
00095 glb_L[2] = GJP.ZnodeSites()*GJP.Znodes();
00096 glb_L[3] = GJP.TnodeSites()*GJP.Tnodes();
00097
00098
00099 glb_sour_center[0] = (mom_arg->src_end[0] + mom_arg->src_begin[0])/2;
00100 glb_sour_center[1] = (mom_arg->src_end[1] + mom_arg->src_begin[1])/2;
00101 glb_sour_center[2] = (mom_arg->src_end[2] + mom_arg->src_begin[2])/2;
00102 glb_sour_center[3] = (mom_arg->src_end[3] + mom_arg->src_begin[3])/2;
00103
00104
00105 dir = mom_arg->dir;
00106
00107 i = (mom_arg->dir + 1)%4;
00108 j = (mom_arg->dir + 2)%4;
00109 k = (mom_arg->dir + 3)%4;
00110
00111 }
00112
00113
00114
00115
00123
00124 void Mom::run()
00125 {
00126 char *fname = "run()";
00127 VRB.Func(cname,fname);
00128
00129 int s[4];
00130 int glb[4];
00131 int n[4];
00132 n[dir]=0;
00133 Float mom[4];
00134
00135 if (deg && ( (max_p1 < max_p2) || (max_p2 < max_p3) ) ) {
00136 ERR.General(cname, fname, "mom_deg requires ordered momenta %d %d %d \n", max_p1,max_p2,max_p3) ;
00137 }
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 int imom=0;
00149 for (int p1=0; p1<= max_p1; p1++){
00150 for (int p2=0; p2<= max_p2; p2++){
00151 if (p2>p1 && deg) continue;
00152 for (int p3=0; p3<= max_p3; p3++){
00153 if (p3>p2 && deg) continue;
00154
00155 n[i]=p1; n[j]=p2; n[k]=p3;
00156
00157
00158 for (int mu=0; mu<4; mu++) mom[mu] = 2.*PI*n[mu]/glb_L[mu];
00159
00160
00161
00162 for (s[dir] = 0; s[dir] < nx[dir]; s[dir]++) {
00163 for (s[i] = 0; s[i] < nx[i]; s[i]++) {
00164 for (s[j] = 0; s[j] < nx[j]; s[j]++) {
00165 for (s[k] = 0; s[k] < nx[k]; s[k]++) {
00166
00167
00168 glb[0] = s[0] + GJP.XnodeSites()*GJP.XnodeCoor();
00169 glb[1] = s[1] + GJP.YnodeSites()*GJP.YnodeCoor();
00170 glb[2] = s[2] + GJP.ZnodeSites()*GJP.ZnodeCoor();
00171 glb[3] = s[3] + GJP.TnodeSites()*GJP.TnodeCoor();
00172
00173 int x[4];
00174
00175 for (int mu=0; mu<4; mu++) x[mu] = glb[mu]-glb_sour_center[mu];
00176
00177
00178 int offset = imom + s[0]*no_of_mom + s[1]*no_of_mom*nx[0] + s[2]*no_of_mom*nx[0]*nx[1] + s[3]*no_of_mom*nx[0]*nx[1]*nx[2];
00179
00180
00181 Float alpha[3];
00182 alpha[0] = x[i]*mom[i] + x[j]*mom[j] + x[k]*mom[k];
00183
00184
00185
00186 if (deg) {
00187
00188
00189
00190
00191
00192 alpha[1] = x[i]*mom[j] + x[j]*mom[k] + x[k]*mom[i];
00193 alpha[2] = x[i]*mom[k] + x[j]*mom[i] + x[k]*mom[j];
00194
00195
00196 mom_fact[offset].real( ( cos(alpha[0])+cos(alpha[1])+cos(alpha[2]))/3.0 );
00197 mom_fact[offset].imag( (-sin(alpha[0])-sin(alpha[1])-sin(alpha[2]))/3.0 );
00198
00199 } else {
00200
00201
00202 mom_fact[offset].real( cos(alpha[0]) );
00203 mom_fact[offset].imag( -sin(alpha[0]) );
00204 }
00205
00206 }
00207 }
00208 }
00209 }
00210
00211 imom++;
00212
00213 }
00214 }
00215 }
00216
00217 if (no_of_mom != imom)
00218 ERR.General(cname, fname, "conflict between imom=%d and no_of_mom = %d",imom,no_of_mom);
00219
00220
00221
00222
00223
00224
00225
00226 }
00227
00228
00229
00230
00231
00240
00241 Complex Mom::fact(int imom, int *s)
00242 {
00243 char *fname = "fact()";
00244 VRB.Func(cname,fname);
00245
00246 int offset = imom + s[0]*no_of_mom + s[1]*no_of_mom*nx[0] + s[2]*no_of_mom*nx[0]*nx[1] + s[3]*no_of_mom*nx[0]*nx[1]*nx[2];
00247
00248 return mom_fact[offset];
00249
00250
00251 }
00252
00253 CPS_END_NAMESPACE