00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00014 void set_cold(gauge_field &U) {
00015 begin_function("set_cold");
00016 mdp << "Creating a cold gauge configuration" << '\n';
00017 register site x(U.lattice());
00018 int mu;
00019 forallsites(x)
00020 for(mu=0; mu<U.ndim; mu++)
00021 U(x,mu)=mdp_identity(U.nc);
00022 U.update();
00023 end_function("set_cold");
00024 }
00025
00027 void set_hot(gauge_field &U) {
00028 begin_function("set_hot");
00029 mdp << "Creating a hot gauge configuration" << '\n';
00030 register site x(U.lattice());
00031 int mu;
00032 forallsites(x)
00033 for(mu=0; mu<U.ndim; mu++)
00034 U(x,mu)=U.lattice().random(x).SU(U.nc);
00035 U.update();
00036 end_function("set_hot");
00037 }
00038
00040 void check_unitarity(gauge_field &U, double precision=PRECISION) {
00041 begin_function("check_unitarity");
00042 site x(U.lattice());
00043 int mu;
00044 mdp_int how_many=0;
00045 for(x.idx=0; x.idx<U.lattice().nvol; x.idx++)
00046 for(mu=0; mu<U.ndim; mu++)
00047 if(max(inv(U(x,mu))-hermitian(U(x,mu)))>precision) how_many++;
00048 mdp.add(how_many);
00049 mdp << "Non unitary links found=" << how_many << '\n';
00050 end_function("check_unitarity");
00051 }
00052
00054 mdp_real average_plaquette(gauge_field &U,int mu,int nu) {
00055 double tmp=0;
00056 site x(U.lattice());
00057
00058 forallsites(x) {
00059 tmp+=real(trace(plaquette(U,x,mu,nu)));
00060 }
00061 mdp.add(tmp);
00062 return tmp/(U.lattice().nvol_gl*U.nc);
00063 }
00064
00066 mdp_real average_plaquette(gauge_field &U) {
00067 double tmp=0;
00068 mdp_site x(U.lattice());
00069
00070 int mu,nu;
00071 forallsites(x) {
00072 for(mu=0; mu<U.ndim-1; mu++)
00073 for(nu=mu+1; nu<U.ndim; nu++)
00074 tmp+=real(trace(plaquette(U,x,mu,nu)));
00075 }
00076 mdp.add(tmp);
00077 return 2.0*tmp/(U.ndim*(U.ndim-1)*U.lattice().nvol_gl*U.nc);
00078 }
00079
00081 void compute_em_field(gauge_field &U) {
00082 int nc=U.nc;
00083 site x(U.lattice());
00084
00085 U.em.deallocate_memory();
00086 U.em.allocate_em_field(U.lattice(), U.nc);
00087 mdp_matrix A(nc,nc);
00088 mdp_matrix b1(nc,nc), b2(nc,nc);
00089
00090
00091
00092
00093 int mu,nu;
00094 forallsites(x)
00095 for(mu=0; mu<U.ndim-1; mu++)
00096 for(nu=mu+1; nu<U.ndim; nu++) {
00097
00098 A=
00099 U(x,mu)*U(x+mu,nu)*hermitian(U(x,nu)*U(x+nu,mu))+
00100 hermitian(U(x-nu,nu))*U(x-nu,mu)*
00101 U((x-nu)+mu,nu)*hermitian(U(x,mu))+
00102 hermitian(U((x-mu)-nu,nu)*U(x-mu,mu))*U((x-mu)-nu,mu)*U(x-nu,nu)+
00103 U(x,nu)*hermitian(U(x-mu,nu)*U((x+nu)-mu,mu))*U(x-mu,mu);
00104
00105 U.em(x,mu,nu)=((mdp_real) 0.125)*(A-hermitian(A));
00106
00107 }
00108 U.em.update();
00109 }
00110
00111
00112
00113
00114
00115
00116
00126 void compute_long_links(gauge_field &U, gauge_field &V, int length=2) {
00127 if((&(U.lattice())!=&(V.lattice())) || (U.nc!=V.nc) || (U.ndim!=V.ndim))
00128 error("fermiqcd_gauge_auxiliary_functions/compute_long_links: U and V are not compatible lattices");
00129 if(V.lattice().next_next<length)
00130 error("fermiqcd_gauge_auxiliary_functions/compute_long_links: next_next is not big enough");
00131
00132 U.long_links.deallocate_memory();
00133 U.long_links.allocate_mdp_nmatrix_field(V.lattice(),U.ndim, U.nc, U.nc);
00134 site x(U.lattice());
00135 int mu;
00136 if(length==2)
00137 forallsites(x)
00138 for(mu=0; mu<V.ndim; mu++)
00139 U.long_links(x,mu)=V(x,mu)*V(x+mu,mu);
00140 if(length==3)
00141 forallsites(x)
00142 for(mu=0; mu<V.ndim; mu++)
00143 U.long_links(x,mu)=V(x,mu)*V(x+mu,mu)*V((x+mu)+mu,mu);
00144 U.long_links.update();
00145 }
00146
00147
00148
00149
00150
00151
00152
00161 void set_antiperiodic_phases(gauge_field &U, int mu=0, int check=true) {
00162 begin_function("set_antiperiodic_phases");
00163 site x(U.lattice());
00164 int i,j;
00165 if(check)
00166 mdp << "Setting antiperiodic boundary conditions on mu=" << mu << '\n';
00167 else
00168 mdp << "Removing antiperiodic boundary conditions on mu=" << mu << '\n';
00169 forallsites(x)
00170 if(x(mu)==U.lattice().size(mu)-1) {
00171 for(i=0; i<U.nc; i++)
00172 for(j=0; j<U.nc; j++)
00173 U(x,mu,i,j)*=-1;
00174 }
00175 end_function("set_antiperiodic_phases");
00176 }
00177
00178
00181 mdp_matrix project_SU(mdp_matrix M, int nstep=1) {
00182 int i,j,k,l,step,nc=M.rowmax();
00183 mdp_real e0,e1,e2,e3,dk,d;
00184 mdp_complex dc,u0,u1,u2,u3;
00185 mdp_matrix B(nc,nc);
00186 mdp_matrix C(nc,nc);
00187 mdp_matrix S(nc,nc);
00188
00189 C=M;
00190
00191
00192
00193 for(i=0; i<nc; i++) {
00194 for(j=0; j<i; j++) {
00195 dc=0;
00196 for(k=0; k<nc; k++)
00197 dc+=conj(C(k,j))*C(k,i);
00198 for(k=0; k<nc; k++)
00199 C(k,i)-=dc*C(k,j);
00200 }
00201 d=0;
00202 for(k=0; k<nc; k++)
00203 d+=pow((double)abs(C(k,i)),(double)2.0);
00204 d=sqrt(d);
00205 for(k=0; k<nc; k++)
00206 C(k,i)/=d;
00207 }
00208
00209
00210
00211 for(i=0; i<nc; i++)
00212 for(j=0; j<nc; j++)
00213 for(k=0; k<nc; k++)
00214 B(i,j)+=conj(M(k,i))*C(k,j);
00215 for(step=0; step<nstep; step++) {
00216 for(i=0; i<nc-1; i++)
00217 for(j=i+1; j<nc; j++) {
00218 e0=real(B(i,i))+real(B(j,j));
00219 e1=imag(B(i,j))+imag(B(j,i));
00220 e2=real(B(i,j))-real(B(j,i));
00221 e3=imag(B(i,i))-imag(B(j,j));
00222 dk=sqrt(e0*e0+e1*e1+e2*e2+e3*e3);
00223 u0=mdp_complex(e0,-e3)/dk;
00224 u1=mdp_complex(e2,-e1)/dk;
00225 u2=mdp_complex(-e2,-e1)/dk;
00226 u3=mdp_complex(e0,e3)/dk;
00227
00228 for(k=0; k<nc; k++) {
00229 S(k,i)=C(k,i)*u0+C(k,j)*u1;
00230 S(k,j)=C(k,i)*u2+C(k,j)*u3;
00231 }
00232 if((i==nc-2) && (j==nc-1))
00233 for(k=0; k<nc; k++)
00234 for(l=0; l<nc-2; l++)
00235 S(k,l)=C(k,l);
00236 if((i!=nc-2) || (j!=nc-1) || (step!=nstep-1))
00237 for(k=0; k<nc; k++) {
00238 C(k,i)=B(k,i)*u0+B(k,j)*u1;
00239 C(k,j)=B(k,i)*u2+B(k,j)*u3;
00240 B(k,i)=C(k,i);
00241 B(k,j)=C(k,j);
00242 C(k,i)=S(k,i);
00243 C(k,j)=S(k,j);
00244 }
00245 }
00246 }
00247 return S;
00248 }
00249
00261 mdp_complex average_path(gauge_field &U, int length, int d[][2]) {
00262 mdp_matrix_field psi1(U.lattice(),U.nc,U.nc);
00263 mdp_matrix_field psi2(U.lattice(),U.nc,U.nc);
00264 mdp_site x(U.lattice());
00265 mdp_complex sum=0;
00266 for(int i=0; i<length; i++) {
00267 if(i==0)
00268 forallsites(x)
00269 psi1(x)=U(x,d[i][0],d[i][1]);
00270 else
00271 forallsites(x)
00272 psi1(x)=psi1(x)*U(x,d[i][0],d[i][1]);
00273 if(i<length-1) {
00274 psi1.update();
00275 if(d[i][0]==+1)
00276 forallsites(x) psi2(x)=psi1(x+d[i][1]);
00277 else if(d[i][0]==-1)
00278 forallsites(x) psi2(x)=psi1(x-d[i][1]);
00279 psi1=psi2;
00280 }
00281 }
00282 forallsites(x) sum+=trace(psi1(x));
00283 return sum/(U.lattice().nvol_gl*U.nc);
00284 }
00285
00298 mdp_matrix build_path(gauge_field &U, site x, int length, int d[][2]) {
00299 int nc=U.nc;
00300 site y(U.lattice());
00301 mdp_matrix tmp(nc,nc);
00302 tmp=U(x,d[0][0],d[0][1]);
00303 if(d[0][0]<0) y=x-d[0][1];
00304 else y=x+d[0][1];
00305 for(int i=1; i<length; i++) {
00306 tmp=tmp*U(y,d[i][0],d[i][1]);
00307 if(d[i][0]<0) y=y-d[i][1];
00308 else y=y+d[i][1];
00309 }
00310 return tmp;
00311 }
00312
00313 void copy_path(int length, int d[][2], int c[][2]) {
00314 for(int i=0; i<length; i++) {
00315 c[i][0]=d[i][0];
00316 c[i][1]=d[i][1];
00317 }
00318 }
00319
00320 void invert_path(int mu, int length, int d[][2]) {
00321 for(int i=0; i<length; i++)
00322 if(d[i][1]==mu) d[i][0]*=-1;
00323 }
00324
00325 void rotate_path(int angle, int mu, int nu, int length, int d[][2]) {
00326 angle=(angle+360)% 360;
00327 if(angle==90)
00328 for(int i=0; i<length; i++) {
00329 if(d[i][1]==mu) d[i][1]=nu;
00330 if(d[i][1]==nu) { d[i][0]*=-1; d[i][1]=mu;}
00331 }
00332 if(angle==180)
00333 for(int i=0; i<length; i++) {
00334 if(d[i][1]==mu) d[i][0]*=-1;
00335 if(d[i][1]==nu) d[i][0]*=-1;
00336 }
00337 if(angle==270)
00338 for(int i=0; i<length; i++) {
00339 if(d[i][1]==mu) {d[i][0]*=-1; d[i][1]=nu; }
00340 if(d[i][1]==nu) d[i][1]=mu;
00341 }
00342 }
00343