Exemplo n.º 1
0
extern void SourceMom4(srcdef src, spinor_dble *sd) {
	/*****************************************************************************
	 *
	 *                    4th-moment calculation
	 *
	 *      To calculate the 4th moment of the source the
	 *       sourceorigin is shifted to the point (0,0,0).
	 *    Only points for (x1, x2, x3)<(L1/2, L2/2, L3/2) holds
	 *	    are used because of the periodic boundary conditions.
	 *
	 *                       ++++++++++++++
	 *                       +            +
	 *                       +            +
	 *                   L/2 +++++++      +
	 *                       +     +      +
	 *                       +     +      +
	 *                 (0,0) ++++++++++++++
	 *                             L/2
	 *****************************************************************************/

	int my_rank, t, x, y, z, i, ix;
	int t_send[NPROC], x_send[NPROC], y_send[NPROC], z_send[NPROC];
	double S2x2_send[NPROC], S2_send[NPROC], F_send[NPROC];
	double F = 0, S2 = 0, S2x2 = 0, rmsradius = 0, r;
	spinor_dble *psi;
	char filename[300];
	FILE *out = NULL;

	MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);

	for (i = 0; i < NPROC; i++) {
		t_send[i] = 0;
		x_send[i] = 0;
		y_send[i] = 0;
		z_send[i] = 0;
		S2x2_send[i] = 0.0;
		S2_send[i] = 0.0;
		F_send[i] = 0.0;
	}

	/*
	if (my_rank == 0) {
		sprintf(filename, "/home/jaeger/baryon/source.dat");
		out = fopen(filename, "wb");
	}*/

	for (ix = 0; ix < VOLUME; ix++) {
		t = coords[ix].t;
		x = coords[ix].x;
		y = coords[ix].y;
		z = coords[ix].z;

		F = 0;
		psi = sd + ix;

		F = _vector_prod_re((*psi).c1, (*psi).c1) + _vector_prod_re((*psi).c2,
				(*psi).c2) + _vector_prod_re((*psi).c3, (*psi).c3)
				+ _vector_prod_re((*psi).c4, (*psi).c4);

		x -= src.pos[1];
		y -= src.pos[2];
		z -= src.pos[3];

		if (x < 0)
			x += NPROC1 * L1;
		if (y < 0)
			y += NPROC2 * L2;
		if (z < 0)
			z += NPROC3 * L3;

		if ((x <= (NPROC1 * L1 / 2)) && (y <= (NPROC2 * L2 / 2)) && (z
				<= (NPROC3 * L3 / 2))) {
			r = (x * x + y * y + z * z);
			S2x2 += r * r * F;
			S2 += F;
		}
		/*
		MPI_Gather(&t, 1, MPI_INT, t_send, 1, MPI_INT, 0, MPI_COMM_WORLD);
		MPI_Gather(&x, 1, MPI_INT, x_send, 1, MPI_INT, 0, MPI_COMM_WORLD);
		MPI_Gather(&y, 1, MPI_INT, y_send, 1, MPI_INT, 0, MPI_COMM_WORLD);
		MPI_Gather(&z, 1, MPI_INT, z_send, 1, MPI_INT, 0, MPI_COMM_WORLD);
		MPI_Gather(&F, 1, MPI_DOUBLE, F_send, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);

		if (my_rank == 0) {
			for (i = 0; i < NPROC; i++) {
				if ((t_send[i] == 0) && (z_send[i] == 11)) {

					fprintf(out, "%d \t %d \t %d \t %d \t %1.5e \n", t_send[i],
							x_send[i], y_send[i], z_send[i], F_send[i]);

				}

			}

		}*/

	}
	MPI_Gather(&S2x2, 1, MPI_DOUBLE, S2x2_send, 1, MPI_DOUBLE, 0,
			MPI_COMM_WORLD);
	MPI_Gather(&S2, 1, MPI_DOUBLE, S2_send, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);

	S2x2 = 0;
	S2 = 0;

	if (my_rank == 0) {
		for (i = 0; i < NPROC; i++) {
			S2x2 += S2x2_send[i];
			S2 += S2_send[i];
		}
	}
	rmsradius = sqrt(S2x2 / S2);

	if (my_rank == 0)
		message("the 4th moment of the source is %lf \n", rmsradius);
	/*
	if (my_rank == 0) {
		fclose(out);
	}*/
}
Exemplo n.º 2
0
su3 random_su3(void)
{
   double norm,fact;
   complex z;
   su3_vector z1,z2,z3;
   su3 u;

   /*
   z1=random_su3_vector();
   */
   z1=unif_su3_vector();


   for (;;)
   {
     /*
      z2=random_su3_vector();
     */
      z2=unif_su3_vector();

      z.re=_vector_prod_re(z1,z2);
      z.im=_vector_prod_im(z1,z2);

      _vector_project(z2,z,z1);

      norm=_vector_prod_re(z2,z2);
      norm=sqrt(norm);

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

   fact=1.0/norm;
   _vector_mul(z2,fact,z2);

   z3.c0.re= (z1.c1.re*z2.c2.re-z1.c1.im*z2.c2.im)
            -(z1.c2.re*z2.c1.re-z1.c2.im*z2.c1.im);
   z3.c0.im=-(z1.c1.re*z2.c2.im+z1.c1.im*z2.c2.re)
            +(z1.c2.re*z2.c1.im+z1.c2.im*z2.c1.re);

   z3.c1.re= (z1.c2.re*z2.c0.re-z1.c2.im*z2.c0.im)
            -(z1.c0.re*z2.c2.re-z1.c0.im*z2.c2.im);
   z3.c1.im=-(z1.c2.re*z2.c0.im+z1.c2.im*z2.c0.re)
            +(z1.c0.re*z2.c2.im+z1.c0.im*z2.c2.re);

   z3.c2.re= (z1.c0.re*z2.c1.re-z1.c0.im*z2.c1.im)
            -(z1.c1.re*z2.c0.re-z1.c1.im*z2.c0.im);
   z3.c2.im=-(z1.c0.re*z2.c1.im+z1.c0.im*z2.c1.re)
            +(z1.c1.re*z2.c0.im+z1.c1.im*z2.c0.re);

   u.c00=z1.c0;
   u.c01=z1.c1;
   u.c02=z1.c2;

   u.c10=z2.c0;
   u.c11=z2.c1;
   u.c12=z2.c2;

   u.c20=z3.c0;
   u.c21=z3.c1;
   u.c22=z3.c2;

   return(u);
}
Exemplo n.º 3
0
extern void SourceRadius(srcdef src, spinor_dble *sd) {
	/*****************************************************************************
	 *
	 *                    Radius calculation
	 *
	 *       To calculate the radius of the source the
	 *       sourceorigin is shifted to the point (0,0,0).
	 *       Only points for (x1, x2, x3)<(L1/2, L2/2, L3/2) hold
	 *	are used because of the periodic boundary conditions.
	 *
	 *                       ++++++++++++++
	 *                       +            +
	 *                       +            +
	 *                   L/2 +++++++      +
	 *                       +     +      +
	 *                       +     +      +
	 *                 (0,0) ++++++++++++++
	 *                             L/2
	 *****************************************************************************/

	int my_rank, t, x, y, z, i, ix;
	int x_send[NPROC], y_send[NPROC], z_send[NPROC];
	double S2x2_send[NPROC], S2_send[NPROC], F_send[NPROC];
	double F = 0, S2 = 0, S2x2 = 0, rmsradius = 0, r;
	spinor_dble *psi;

	MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);

	for (i = 0; i < NPROC; i++) {
		x_send[i] = 0;
		y_send[i] = 0;
		z_send[i] = 0;
		S2x2_send[i] = 0.0;
		S2_send[i] = 0.0;
		F_send[i] = 0.0;
	}

	for (ix = 0; ix < VOLUME; ix++) {
		t = coords[ix].t;
		x = coords[ix].x;
		y = coords[ix].y;
		z = coords[ix].z;

		F = 0;
		psi = sd + ix;

		F = _vector_prod_re((*psi).c1, (*psi).c1) + _vector_prod_re((*psi).c2,
				(*psi).c2) + _vector_prod_re((*psi).c3, (*psi).c3)
				+ _vector_prod_re((*psi).c4, (*psi).c4);

		x -= src.pos[1];
		y -= src.pos[2];
		z -= src.pos[3];

		if (x < 0)
			x += NPROC1 * L1;
		if (y < 0)
			y += NPROC2 * L2;
		if (z < 0)
			z += NPROC3 * L3;

		if ((x <= (NPROC1 * L1 / 2)) && (y <= (NPROC2 * L2 / 2)) && (z
				<= (NPROC3 * L3 / 2))) {
			r = (x * x + y * y + z * z);
			S2x2 += r * F;
			S2 += F;
		}

	}
	MPI_Gather(&S2x2, 1, MPI_DOUBLE, S2x2_send, 1, MPI_DOUBLE, 0,
			MPI_COMM_WORLD);
	MPI_Gather(&S2, 1, MPI_DOUBLE, S2_send, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);

	S2x2 = 0;
	S2 = 0;

	if (my_rank == 0) {
		for (i = 0; i < NPROC; i++) {
			S2x2 += S2x2_send[i];
			S2 += S2_send[i];
		}
	}
	rmsradius = sqrt(S2x2 / S2);

	if (my_rank == 0)
		message("the rms radius of the source is %lf \n", rmsradius);
}