Exemple #1
0
su3_vector random_su3_vector(void)
{
   int i;
   double v[6],norm,fact;
   su3_vector s;

   for (;;)
   {
      gauss_vector(v,6);
      norm=0.0;

      for (i=0;i<6;i++)
         norm+=v[i]*v[i];

      norm=sqrt(norm);

      if (1.0!=(1.0+norm))
         break;
   }

   fact=1.0/norm;
   s.c0.re=v[0]*fact;
   s.c0.im=v[1]*fact;
   s.c1.re=v[2]*fact;
   s.c1.im=v[3]*fact;
   s.c2.re=v[4]*fact;
   s.c2.im=v[5]*fact;

   return(s);
}
Exemple #2
0
/* Function provides a spinor field of length V with
   Gaussian distribution */
void random_spinor_field_lexic(spinor * const k) {
  int x, y, z, t, X, Y, Z, tt, id=0;
#ifdef MPI
  int rlxd_state[105];
#endif
  int coords[4];
  spinor *s;
  double v[24];

#ifdef MPI
  if(g_proc_id == 0) {
    rlxd_get(rlxd_state);
  }
  MPI_Bcast(rlxd_state, 105, MPI_INT, 0, MPI_COMM_WORLD);
  if(g_proc_id != 0) {
    rlxd_reset(rlxd_state);
  }
#endif
  for(t = 0; t < g_nproc_t*T; t++) {
    tt = t - g_proc_coords[0]*T;
    coords[0] = t / T;
    for(x = 0; x < g_nproc_x*LX; x++) {
      X = x - g_proc_coords[1]*LX; 
      coords[1] = x / LX;
      for(y = 0; y < g_nproc_y*LY; y++) {
	Y = y - g_proc_coords[2]*LY;
	coords[2] = y / LY;
	for(z = 0; z < g_nproc_z*LZ; z++) {
	  Z = z - g_proc_coords[3]*LZ;
	  coords[3] = z / LZ;
#ifdef MPI
	  MPI_Cart_rank(g_cart_grid, coords, &id);
#endif
	  if(g_cart_id == id) {
	    gauss_vector(v, 24);
	    s = k + g_ipt[tt][X][Y][Z];
	    memcpy(s, v, 24*sizeof(double));
	  }
	  else {
	    ranlxd(v,24);
	  }
	}
      }
    }
  }
  return;
}
void random_gauss_jacobi_field(su3_vector * const k, const int V)
{
int ix;
su3_vector *s;
double v[6];

 for (ix=0; ix<V ;ix++) {
     s=k+ix;
     gauss_vector(v,6);
     s->c0 = v[0] + v[1] * I;
     s->c1 = v[2] + v[3] * I;
     s->c2 = v[4] + v[5] * I;
 }
#ifdef TM_USE_MPI
 xchange_jacobi(k);
#endif
}
Exemple #4
0
void random_gauss_jacobi_field(su3_vector * const k, const int V)
{
int ix;
su3_vector *s;
double v[6];

 for (ix=0; ix<V ;ix++) {
     s=k+ix;
     gauss_vector(v,6);
     (*s).c0.re=v[0];
     (*s).c0.im=v[1];
     (*s).c1.re=v[2];
     (*s).c1.im=v[3];
     (*s).c2.re=v[4];
     (*s).c2.im=v[5];
 }
#ifdef MPI
 xchange_jacobi(k);
#endif
}
Exemple #5
0
void random_spinor_field(spinor * const k, const int V, const int repro) {

  int ix;
  int rlxd_state[105];
  spinor *s;
  double v[6];
#ifdef MPI
  int j=0;
#endif

  if(g_proc_id==0 && repro == 1) {
    for (ix = 0; ix < V; ix++) {
      s = k + ix;
      gauss_vector(v,6);
      (*s).s0.c0.re=v[0];
      (*s).s0.c0.im=v[1];
      (*s).s0.c1.re=v[2];
      (*s).s0.c1.im=v[3];
      (*s).s0.c2.re=v[4];
      (*s).s0.c2.im=v[5];
      gauss_vector(v,6);
      (*s).s1.c0.re=v[0];
      (*s).s1.c0.im=v[1];
      (*s).s1.c1.re=v[2];
      (*s).s1.c1.im=v[3];
      (*s).s1.c2.re=v[4];
      (*s).s1.c2.im=v[5];
      gauss_vector(v,6);
      (*s).s2.c0.re=v[0];
      (*s).s2.c0.im=v[1];
      (*s).s2.c1.re=v[2];
      (*s).s2.c1.im=v[3];
      (*s).s2.c2.re=v[4];
      (*s).s2.c2.im=v[5];
      gauss_vector(v,6);
      (*s).s3.c0.re=v[0];
      (*s).s3.c0.im=v[1];
      (*s).s3.c1.re=v[2];
      (*s).s3.c1.im=v[3];
      (*s).s3.c2.re=v[4];
      (*s).s3.c2.im=v[5];
    }
    /* send the state for the random-number generator to 1 */
    rlxd_get(rlxd_state);
#ifdef MPI
    if(g_nproc > 1) {
      MPI_Send(&rlxd_state[0], 105, MPI_INT, 1, 102, MPI_COMM_WORLD);
    }
#endif
  }
#ifdef MPI
  if(g_proc_id != 0 && repro == 1) {
    MPI_Recv(&rlxd_state[0], 105, MPI_INT, g_proc_id-1, 102, MPI_COMM_WORLD, &status);
    rlxd_reset(rlxd_state);
    for (ix=0;ix<V;ix++) {
      s = k + ix;
      gauss_vector(v,6);
      (*s).s0.c0.re=v[0];
      (*s).s0.c0.im=v[1];
      (*s).s0.c1.re=v[2];
      (*s).s0.c1.im=v[3];
      (*s).s0.c2.re=v[4];
      (*s).s0.c2.im=v[5];
      gauss_vector(v,6);
      (*s).s1.c0.re=v[0];
      (*s).s1.c0.im=v[1];
      (*s).s1.c1.re=v[2];
      (*s).s1.c1.im=v[3];
      (*s).s1.c2.re=v[4];
      (*s).s1.c2.im=v[5];
      gauss_vector(v,6);
      (*s).s2.c0.re=v[0];
      (*s).s2.c0.im=v[1];
      (*s).s2.c1.re=v[2];
      (*s).s2.c1.im=v[3];
      (*s).s2.c2.re=v[4];
      (*s).s2.c2.im=v[5];
      gauss_vector(v,6);
      (*s).s3.c0.re=v[0];
      (*s).s3.c0.im=v[1];
      (*s).s3.c1.re=v[2];
      (*s).s3.c1.im=v[3];
      (*s).s3.c2.re=v[4];
      (*s).s3.c2.im=v[5];
    }
    /* send the state fo the random-number generator to k+1 */
    
    j=g_proc_id+1;
    if(j==g_nproc){
      j=0;
    }
    rlxd_get(rlxd_state);
    MPI_Send(&rlxd_state[0], 105, MPI_INT, j, 102, MPI_COMM_WORLD);
  }
  if(g_nproc > 1 && g_proc_id==0 && repro == 1) {
    MPI_Recv(&rlxd_state[0], 105, MPI_INT, g_nproc-1, 102, MPI_COMM_WORLD, &status);
    rlxd_reset(rlxd_state);
  }
#endif
  if(repro != 1) {
    for (ix = 0; ix < V; ix++) {
      s = k + ix;
      gauss_vector(v,6);
      (*s).s0.c0.re=v[0];
      (*s).s0.c0.im=v[1];
      (*s).s0.c1.re=v[2];
      (*s).s0.c1.im=v[3];
      (*s).s0.c2.re=v[4];
      (*s).s0.c2.im=v[5];
      gauss_vector(v,6);
      (*s).s1.c0.re=v[0];
      (*s).s1.c0.im=v[1];
      (*s).s1.c1.re=v[2];
      (*s).s1.c1.im=v[3];
      (*s).s1.c2.re=v[4];
      (*s).s1.c2.im=v[5];
      gauss_vector(v,6);
      (*s).s2.c0.re=v[0];
      (*s).s2.c0.im=v[1];
      (*s).s2.c1.re=v[2];
      (*s).s2.c1.im=v[3];
      (*s).s2.c2.re=v[4];
      (*s).s2.c2.im=v[5];
      gauss_vector(v,6);
      (*s).s3.c0.re=v[0];
      (*s).s3.c0.im=v[1];
      (*s).s3.c1.re=v[2];
      (*s).s3.c1.im=v[3];
      (*s).s3.c2.re=v[4];
      (*s).s3.c2.im=v[5];
    }
  }
}
Exemple #6
0
/**************************************
 *
 * Initialises the momenta
 * with the gaussian distribution
 *
 **************************************/
double ini_momenta(const int repro) {
  
  su3adj *xm;
  int i, mu;
#ifdef MPI
  int k;
  int rlxd_state[105];
#endif
  static double y[8];
  static double tt,tr,ts,kc,ks,sum;
  
  if(repro == 1) {
    if(g_proc_id==0){
      kc=0.; 
      ks=0.;
      for(i=0;i<VOLUME;i++){ 
	for(mu=0;mu<4;mu++){
	  sum=0.;
	  xm=&moment[i][mu];
	  gauss_vector(y,8);
	  /* from the previous line we get exp(-y^2) distribution */
	  /* this means that <y^2> = sigma^2 = 1/2 */
	  /* in order to get <y^2> = 1 distribution ==> *sqrt(2) */
	  (*xm).d1=1.4142135623731*y[0];
	  (*xm).d2=1.4142135623731*y[1];
	  sum+=(*xm).d1*(*xm).d1+(*xm).d2*(*xm).d2;
	  (*xm).d3=1.4142135623731*y[2];
	  (*xm).d4=1.4142135623731*y[3];
	  sum+=(*xm).d3*(*xm).d3+(*xm).d4*(*xm).d4;
	  (*xm).d5=1.4142135623731*y[4];
	  (*xm).d6=1.4142135623731*y[5];
	  sum+=(*xm).d5*(*xm).d5+(*xm).d6*(*xm).d6;
	  (*xm).d7=1.4142135623731*y[6];
	  (*xm).d8=1.4142135623731*y[7];
	  sum+=(*xm).d7*(*xm).d7+(*xm).d8*(*xm).d8;
	  tr=sum+kc;
	  ts=tr+ks;
	  tt=ts-ks;
	  ks=ts;
	  kc=tr-tt;
	}
      }
#ifdef MPI
      /* send the state for the random-number generator to 1 */
      rlxd_get(rlxd_state);
      MPI_Send(&rlxd_state[0], 105, MPI_INT, 1, 101, MPI_COMM_WORLD);
#endif
    }
    
#ifdef MPI
    if(g_proc_id != 0){
      MPI_Recv(&rlxd_state[0], 105, MPI_INT, g_proc_id-1, 101, MPI_COMM_WORLD, &status);
      rlxd_reset(rlxd_state);
      kc=0.; ks=0.;
      for(i=0;i<VOLUME;i++){ 
	for(mu=0;mu<4;mu++){
	  sum=0.;
	  xm=&moment[i][mu];
	  gauss_vector(y,8);
	  (*xm).d1=1.4142135623731*y[0];
	  (*xm).d2=1.4142135623731*y[1];
	  sum+=(*xm).d1*(*xm).d1+(*xm).d2*(*xm).d2;
	  (*xm).d3=1.4142135623731*y[2];
	  (*xm).d4=1.4142135623731*y[3];
	  sum+=(*xm).d3*(*xm).d3+(*xm).d4*(*xm).d4;
	  (*xm).d5=1.4142135623731*y[4];
	  (*xm).d6=1.4142135623731*y[5];
	  sum+=(*xm).d5*(*xm).d5+(*xm).d6*(*xm).d6;
	  (*xm).d7=1.4142135623731*y[6];
	  (*xm).d8=1.4142135623731*y[7];
	  sum+=(*xm).d7*(*xm).d7+(*xm).d8*(*xm).d8;
	  tr=sum+kc;
	  ts=tr+ks;
	  tt=ts-ks;
	  ks=ts;
	  kc=tr-tt;
	}
      }
      /* send the state fo the random-number 
	 generator to next processor */
      
      k=g_proc_id+1; 
      if(k==g_nproc){ 
	k=0;
      }
      rlxd_get(rlxd_state);
      MPI_Send(&rlxd_state[0], 105, MPI_INT, k, 101, MPI_COMM_WORLD);
    }
#endif
    kc=0.5*(ks+kc);
    
#ifdef MPI
    if(g_proc_id == 0){
      MPI_Recv(&rlxd_state[0], 105, MPI_INT, g_nproc-1, 101, MPI_COMM_WORLD, &status);
      rlxd_reset(rlxd_state);
    }
#endif
  }
  else {
    kc=0.; 
    ks=0.;
    for(i=0;i<VOLUME;i++){ 
      for(mu=0;mu<4;mu++){
	sum=0.;
	xm=&moment[i][mu];
	gauss_vector(y,8);
	(*xm).d1=1.4142135623731*y[0];
	(*xm).d2=1.4142135623731*y[1];
	sum+=(*xm).d1*(*xm).d1+(*xm).d2*(*xm).d2;
	(*xm).d3=1.4142135623731*y[2];
	(*xm).d4=1.4142135623731*y[3];
	sum+=(*xm).d3*(*xm).d3+(*xm).d4*(*xm).d4;
	(*xm).d5=1.4142135623731*y[4];
	(*xm).d6=1.4142135623731*y[5];
	sum+=(*xm).d5*(*xm).d5+(*xm).d6*(*xm).d6;
	(*xm).d7=1.4142135623731*y[6];
	(*xm).d8=1.4142135623731*y[7];
	sum+=(*xm).d7*(*xm).d7+(*xm).d8*(*xm).d8;
	tr=sum+kc;
	ts=tr+ks;
	tt=ts-ks;
	ks=ts;
	kc=tr-tt;
      }
    }
    kc=0.5*(ks+kc);
    

  }
#ifdef MPI
  MPI_Allreduce(&kc, &ks, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
  return ks;
#endif
  return kc;
}