Exemplo n.º 1
0
static void
edge_cases( struct resampled *effmass ,
	    const struct resampled *bootavg ,
	    const size_t j ,
	    const size_t NDATA )
{
  if( j == 0 ) {
    equate( &effmass[j] , bootavg[j+1] ) ;
    divide( &effmass[j] , bootavg[j] ) ;
    if( log_range( effmass[j] ) ) {
      zero_effmass( &effmass[j] , bootavg[j] ) ;
    } else {
      res_log( &effmass[j] ) ;
      mult_constant( &effmass[j] , -1.0 ) ;
    }
  } else if( j == NDATA - 1 ) {
    equate( &effmass[j] , bootavg[j] ) ;
    divide( &effmass[j] , bootavg[j-1] ) ;
    // just in case there is a sign flip
    if( log_range( effmass[j] ) ) {
      return zero_effmass( &effmass[j] , bootavg[j] ) ;
    } else {
      res_log( &effmass[j] ) ;
      mult_constant( &effmass[j] , -1.0 ) ;
    }
  }
  return ;
}
Exemplo n.º 2
0
static void
average_data( struct resampled *ave ,
	      const struct resampled *to_add ,
	      const int NDATA )
{
  size_t j ;
  for( j = 0 ; j < NDATA ; j++ ) {
    add( &ave[j] , to_add[j] ) ;
    mult_constant( &ave[j] , 0.5 ) ;
  }
}
Exemplo n.º 3
0
// tauvus computation
void
flavour_combination_eval( double **xavg ,
			  struct resampled **bootavg ,
			  struct mom_info **mominfo ,
			  struct input_params *INPARAMS ,
			  const int NSLICES ,
			  const int LT ,
			  const bool renormalise )
{
  printf( "\n--> Flavour combination evaluation <--\n" ) ;

  // tell us if we have given the wrong arguments
  if( NSLICES != 4 ) {
    printf( "Expected V (ss) VV(ls) A(ll) A(ls)\n" ) ;
    return ;
  }

  printf( "\n--> Converting to physical momenta <--\n" ) ;
  // OK, momentum first
  int j , i ;
  for( j = 0 ; j < NSLICES ; j++ ) {
    // ainverse multipliers
    const double aI  = INPARAMS -> quarks[j].ainverse ;
    const double aI2 = pow( INPARAMS -> quarks[j].ainverse , 2 ) ;
    const double aI4 = pow( INPARAMS -> quarks[j].ainverse , 4 ) ;
    const double aI6 = pow( INPARAMS -> quarks[j].ainverse , 6 ) ;

    #pragma omp parallel for private(i)
    for( i = 0 ; i < INPARAMS -> NDATA[j] ; i++ ) {

      // set to physical lattice spacing xavg[j][i] is now |p| in GeV!!
      xavg[j][i] = aI * sqrt( xavg[j][i] ) ;
      // and the moms
      mominfo[j][i].p2 *= aI2 ;
      mominfo[j][i].p4 *= aI4 ;
      mominfo[j][i].p6 *= aI6 ;

      // check for some consistency
      if( fabs( mominfo[j][i].p2 - xavg[j][i]*xavg[j][i] ) > 1E-12 ) {
	printf( "P2 Broken !! %e \n" , mominfo[j][i].p2 - xavg[j][i]*xavg[j][i] ) ;
	exit(1) ;
      } 
    }
  }

  // multiply by Z_V
  printf( "\n--> Renormalising <--\n" ) ;

  char str[ 256 ] ;
  sprintf( str , "m%g_m%g.dat" , INPARAMS -> quarks[1].ml , INPARAMS -> quarks[1].ms ) ;

  FILE *file = fopen( str , "w" ) ;

  // so the idea is to form all contributions into bootavg[0]
  const double ZV = INPARAMS -> quarks[0].ZV ;

  fprintf( file , "ZV :: %f\n" , INPARAMS -> quarks[0].ZV ) ;
  fprintf( file , "a^{-1} :: %f GeV\n" , INPARAMS -> quarks[0].ainverse ) ;
  fprintf( file , "Combination :: ( ss - ls )_V + ( ll - ls )_A (0+1) \n" ) ;
  fprintf( file , "q [GeV]        Pi(q^2)             Err\n" ) ;

  printf( "Renormalising with %f \n" , ZV ) ;

  // form flavour breaking combination
  for( j = 0 ; j < INPARAMS->NDATA[0] ; j++ ) {

    // form V(0+1) -(ss-ls) put in index 0
    subtract( &bootavg[0][j] , bootavg[1][j] ) ;

    // form A (0+1)-(ll-ls)  and put in index 2
    subtract( &bootavg[2][j] , bootavg[3][j] ) ;

    // and compute the flavour breaking difference
    add( &bootavg[0][j] , bootavg[2][j] ) ;

    // and then renormalise
    mult_constant( &bootavg[0][j] , ZV ) ;

    fprintf( file , "%f %1.12E %1.12E \n" , xavg[0][j] , bootavg[0][j].avg , bootavg[0][j].err ) ;
  }

  // plot only the flavour breaking difference
  struct resampled *fitparams = fit_data_plot_data( (const struct resampled**)bootavg , 
						    (const double**)xavg , 
						    (const struct mom_info **)mominfo ,
						    *INPARAMS , 1 , LT ) ;
  
  fclose( file ) ;
  free( fitparams ) ;

  return ;
}
Exemplo n.º 4
0
// tetra computation
void
tetra_eval( double **xavg ,
	    struct resampled **bootavg ,
	    struct mom_info **mominfo ,
	    struct mom_info *moms ,
	    struct input_params *INPARAMS ,
	    const int NSLICES ,
	    const int LT )
{
  // Diquark-Diquark is in Slice #0 and Dimeson is in #1
  // Vector Meson is in #2
  // Pseudoscalar Meson is in #3
  size_t j ;
#ifdef COMPUTE_BINDING
  if( NSLICES == 4 ) {
    // take product of vector and pseudoscalar put into 2
    for( j = 0 ; j < INPARAMS -> NDATA[2] ; j++ ) {
      mult( &bootavg[2][j] , bootavg[3][j] ) ;
      mult_constant( &bootavg[2][j] , -1 ) ;
    }
  } else if( NSLICES == 8 ) {
    // take product of vector and pseudoscalar
    for( j = 0 ; j < INPARAMS -> NDATA[2] ; j++ ) {
      mult( &bootavg[2][j] , bootavg[3][j] ) ;
      mult_constant( &bootavg[2][j] , -1 ) ;
      
      mult( &bootavg[6][j] , bootavg[7][j] ) ;
      mult_constant( &bootavg[6][j] , -1 ) ;
    }

    // backwards data needs to b time flipped
    flip_data( bootavg[3] , bootavg[4] , INPARAMS -> NDATA[4] ) ;
    flip_data( bootavg[4] , bootavg[5] , INPARAMS -> NDATA[4] ) ;
    flip_data( bootavg[5] , bootavg[6] , INPARAMS -> NDATA[4] ) ;

    // average the data
    average_data( bootavg[0] , bootavg[3] , INPARAMS -> NDATA[0] ) ;
    average_data( bootavg[1] , bootavg[4] , INPARAMS -> NDATA[0] ) ;
    average_data( bootavg[2] , bootavg[5] , INPARAMS -> NDATA[0] ) ;
  }

  for( j = 0 ; j < INPARAMS -> NDATA[2] ; j++ ) {
    // divide correlator #0 by this result
    divide( &bootavg[0][j] , bootavg[2][j] ) ;
    divide( &bootavg[1][j] , bootavg[2][j] ) ;
  }
  
  // evaluate the correlator now
  correlator_eval( xavg , bootavg , mominfo , moms , 
		   INPARAMS , 2 , LT ) ;
#else
  // take product of vector and pseudoscalar put into 2
  for( j = 0 ; j < INPARAMS -> NDATA[2] ; j++ ) {
    mult( &bootavg[2][j] , bootavg[3][j] ) ;
    mult_constant( &bootavg[2][j] , -1 ) ;
  }
  // evaluate the correlator now
  correlator_eval( xavg , bootavg , mominfo , moms , 
		   INPARAMS , 3 , LT ) ;
#endif

  return ;
}
Exemplo n.º 5
0
double* reconstruction(PSIRT* psirt)
{
	int i=0;
	//for(i=0;i<n_particulas;i++) printf("\r\nDONE\tPARTICLE #%d STATUS: %d",i,particles[i]->status);

	// ---
	// 1. AJUSTAR ESCOPO
	// O universo de particulas esta inicialmente entre -1 e +1.
	// Ajustar de acordo com o fator de escala.
	// ---
	for (i = 0; i < psirt->n_particles; i++) {
		if ((psirt->particles[i]->location->x > -RECONSTRUCTION_SCALE_FACTOR)
				&& (psirt->particles[i]->location->x < RECONSTRUCTION_SCALE_FACTOR)
				&& (psirt->particles[i]->location->y > -RECONSTRUCTION_SCALE_FACTOR)
				&& (psirt->particles[i]->location->y < RECONSTRUCTION_SCALE_FACTOR)) {
			psirt->particles[i]->location->x += RECONSTRUCTION_SCALE_FACTOR;
			psirt->particles[i]->location->y += RECONSTRUCTION_SCALE_FACTOR;
			psirt->particles[i]->location->x /= 2 * RECONSTRUCTION_SCALE_FACTOR;
			psirt->particles[i]->location->y /= 2 * RECONSTRUCTION_SCALE_FACTOR;
		}
	}
	// ---
	// 2. ESCALAR
	// Escalar particulas de acordo com resolucao.
	// ---
	Vector2D** scaled_particles = malloc(sizeof(Vector2D*) * psirt->n_particles);
	for (i = 0; i < psirt->n_particles; i++) {
		scaled_particles[i] = mult_constant(psirt->particles[i]->location, RES_X);
		//printf("\r\n ANTES: %f,%f \t DEPOIS: %f,%f",particles[i]->location->x, particles[i]->location->y,scaled_particles[i]->x,scaled_particles[i]->y  );
	}
	// ---
	// 3. CALCULAR INTENSIDADE DE CADA PIXEL
	// Para cada pixel, medir a distancia entre seu centro
	// e cada particula presente no sistema.
	// ---
	double *pixel_intensity = malloc(sizeof(double) * RES_X * RES_Y);
	for (i = 0; i < RES_X * RES_Y; i++) pixel_intensity[i] = 0.0;

	Vector2D* pixel = new_vector(0.0, 0.0);

	int pix_x = 0, pix_y = 0, part = 0;
	double iter_intensity = 0.0;
	for (pix_x = 0; pix_x < RES_X; pix_x++) {
		for (pix_y = 0; pix_y < RES_Y; pix_y++) {
			// atualiza pixel atual (centro: bias +0.5, +0.5)
			set_vector(pixel, pix_x + 0.5, pix_y + 0.5);

			int particula = -1;

			// distancia para cada particula
			for (part = 0; part < psirt->n_particles; part++) {
				if (psirt->particles[part]->status != DEAD) {


					// formato: x + ( y*RES_X )
					double distance = vector_vector_distance(pixel,
							scaled_particles[part]);


					//!!!!!!!!!!!!!!!!!
//					if (particula == -1) particula = part;
//
//					else if (part != particula)
//					{
//						if ( (scaled_particles[part]->x > scaled_particles[particula]->x)
//								&
//								( (fabs(scaled_particles[part]->y - scaled_particles[particula]->y ) <= TRAJ_PART_THRESHOLD*RES_X ) ) )
//						{
//							printf("\r\nParticula fixa: [%d] (%f,%f)\t comparada com [%d] (%f,%f)\t DIST = %f",
//									particula, scaled_particles[particula]->x, scaled_particles[particula]->y,
//									part, scaled_particles[part]->x, scaled_particles[part]->y,
//									distance);
//						}
//					}



					if (distance > PARTICLE_SIZE) {
						distance = 0.0;
						iter_intensity = 0.0;
					} else {
						distance = ((PARTICLE_SIZE - distance) / PARTICLE_SIZE);
//						distance= distance/PARTICLE_SIZE;
//						distance = 1-distance;
						iter_intensity = distance; //TODO interf. destrutiva?
//						iter_intensity =
//								(iter_intensity > SATURATION) ? SATURATION : iter_intensity;
					}
					if (iter_intensity > 0)
						pixel_intensity[pix_x + (pix_y * RES_X)] +=
								iter_intensity;
				}
			}
		}
	}
	free(scaled_particles);
	free(pixel);
	double max = -1.0, min = 999999.0, delta = 0;
	for (i = 0; i < RES_X * RES_Y; i++) {
		if (pixel_intensity[i] > max) max = pixel_intensity[i];
		else if (pixel_intensity[i] < min) min = pixel_intensity[i];
		//			if (i%RES_X==0) printf("\r\n");
		//			printf("%f ",pixel_intensity[i]);
	}
	delta = max - min;
	// normalize
	for (i = 0; i < RES_X * RES_Y; i++) {
		pixel_intensity[i] -= min;
		pixel_intensity[i] /= delta;
	}
	return pixel_intensity;
}