示例#1
0
int
random_evolve (double sys[], const double t)
     /** Versió bona, suposo.  */
     /* Seguint arXiv:cond-mat/9707147, actualitza la part
      * estocàstica segons \dot x = x_D + h^(1/2) * noise.
      */
{
  gsl_rng * rng = random_generator_get_generator ("random_evolve");
  double delta_t_ = t - t_ant;
  double sqrt_h = sqrt(RATIO * delta_t_);

  dimensions * dim = sys_dimensions_handle ();
  double xl = dim -> x_phys_min;
  double xr = dim -> x_phys_max;
  
  int i = 0;
  for (i = 0; i < phys_size; i++) {
    double x = sys[i];
    if ((xl < x) && (x < xr)) {
      double ran_x = gsl_ran_gaussian (rng, 1.);
      double ran_y = gsl_ran_gaussian (rng, 1.);
      sys[i] = sys[i] + sqrt_h * ran_x;
      sys[index_y(i)] = sys[index_y(i)] + sqrt_h * ran_y;
    }
  }

  t_ant = t;
  
  return 0;
}
示例#2
0
double
r2_ab_couette (const int a, const int b, const double sys[])
{
  dimensions *dim = sys_initial_dimensions_handle ();
  double y_max = dim->y_max;
  double y_min = dim->y_min;

  double x = sys[a] - sys[b];

  double ya = sys[index_y(a)];
  double yb = sys[index_y(b)];

  double yb_imatge = yb;
  y_min = y_min - delta_y / 2.;
  y_max = y_max + delta_y / 2.;

  if (yb > y_max)
    yb_imatge = y_min + (yb - y_max);
  else if (yb < y_min)
    yb_imatge = y_max - (y_min - yb);

  double y = ya - yb_imatge;

  return x*x + y*y;
}
int
data_stress_molecular_print (FILE * pfile, const sys_info_t * p_sys_info,
			     const int snap, const double t)
{
/*1    2    3   4  5  6   7   8   9  10  11  12  13  14  15  16  */
/*snap t e_str xx xy yy Lxx Lxy Lyy Rxx Rxy Ryy fxL fyL fxR fyR  */

  fprintf (pfile, "mol " 
	   "%d %.5e %.5e " 
	   "%.5e %.5e %.5e "  // mean
	   "%.5e %.5e %.5e "  // L
	   "%.5e %.5e %.5e "  // R
	   "%.5e %.5e %.5e %.5e\n", // forces

	   snap, t, e_strain,
 
	   mean_stress[index_xx(0)],
	   mean_stress[index_xy(0)], 
	   mean_stress[index_yy(0)],

	   mean_stress_L[index_xx(0)],
	   mean_stress_L[index_xy(0)],
	   mean_stress_L[index_yy(0)],

	   mean_stress_R[index_xx(0)],
	   mean_stress_R[index_xy(0)],
	   mean_stress_R[index_yy(0)],

	   forca_L[index_x(0)], forca_L[index_y(0)],
	   forca_R[index_x(0)], forca_R[index_y(0)]);

  return 0;
}
示例#4
0
int
bottom_reflexive_force (double t, const double sys[], 
			double f[], void *params)
{
  dimensions *dim = sys_initial_dimensions_handle ();
  double y_min = dim -> y_phys_min;
  
  y_min = y_min + dist_a * range_factor / 2.;
  int i;
  for (i = 0; i < phys_size; i++)
    {
      if (sys[index_y(i)] < y_min)
	{
	  if (f[index_y(i)] < 0.)
	    {
	      f[index_y(i)] = - f[index_y(i)];
	      /* de fet, l'exponencial aquella ja
	       * era impenetrable, no sé perquè ho
	       * he tocat! Ara no recordo com coi
	       * era! :(  */
	    }
	}
    }

  return 0;
}
示例#5
0
double
r2_ab_default (const int a, const int b, const double sys[])
{
  double x = sys[a] - sys[b];
  double y = sys[index_y(a)] - sys[index_y(b)];

  return x*x + y*y;
}
示例#6
0
int
right_y (double t, const double sys[],
	double f[], void *params)
{
  int i;
  for (i = sys_paret_R_init (); i < sys_paret_R_fin (); i++)
    f[index_y(i)] = f[index_y(i)] + V;
  return 0;
}
示例#7
0
int
inicia_cristall_paret_commensurada_amb_y (void)
{
  double * sys = sys_handle ();

  double delta_x = dist_a * sqrt(3.) / 2.;
  double delta_y = dist_a;

  double y_min = -ny_extra * delta_y;
  double y_minR = y_min;
  double x_min = -nx_paret * delta_x;
  double x_max = NX * delta_x;

  int paretLi = sys_paret_L_init ();
  int paretRi = sys_paret_R_init ();

  if (nx_paret % 2 == 1)
      y_min = y_min - delta_y / 2.;

  int i;
  int j;
  for (i = 0; i < nx_paret; i++)
    {
      for (j = 0; j < ny_paret; j++)
	{
	  if (i % 2 == 0)
	    {
	      double x = x_min + i * delta_x;
	      double y = y_min + j * delta_y;
	      double yr = y_minR + j * delta_y;
	      int indexL = i + nx_paret * j + paretLi;
	      int indexR = i + nx_paret * j + paretRi;
	      sys[indexL] = x;
	      sys[index_y(indexL)] = y;
	      sys[indexR] = x + x_max - x_min;
	      sys[index_y(indexR)] = yr;
	    }
	  else
	    {
	      double x = x_min + i * delta_x;
	      double y = y_min + j * delta_y + delta_y / 2.;
	      double yr = y_minR + j * delta_y + delta_y / 2.;
	      int indexL = i + paretLi + nx_paret * j;
	      int indexR = i + paretRi + nx_paret * j;
	      sys[indexL] = x;
	      sys[index_y(indexL)] = y;
	      sys[indexR] = x + x_max - x_min;
	      sys[index_y(indexR)] = yr;
	    }
	}
    }
  
  return 0;
}
示例#8
0
int
inicia_cristall_paret_commensurada_amb_x (void)
{
  double * sys = sys_handle ();

  double delta_x = dist_a;
  double delta_y = dist_a * sqrt(3.) / 2.;

  double y_min = -ny_extra * delta_y;
  double x_min = -nx_paret * delta_x;

  double x = x_min;
  double y = y_min;
  int index;
  for (index = sys_paret_L_init (); index < sys_paret_L_fin (); index++)
    {
      if (index % nx_paret == 0)
	{
	  x = x_min;
	  y = y + delta_y;
	}
      sys[index] = x;
      sys[index_y(index)] = y;
      if (index / nx_paret % 2 == 0)
	sys[index] = sys[index] + delta_x / 2.;

      x = x + delta_x;
    }

  double x_max = NX * delta_x;
  x = x_max;
  y = y_min;
  for (index = sys_paret_R_init (); index < sys_paret_R_fin (); index++)
    {
      if (index % nx_paret == 0)
	{
	  x = x_max;
	  y = y + delta_y;
	}
      sys[index] = x;
      sys[index_y(index)] = y;
      if (index / nx_paret % 2 == 0)
	sys[index] = sys[index] + delta_x / 2.;

      x = x + delta_x;
    }
  
  return 0;
}
示例#9
0
void Grid::putItem( GridItemPtr item)
{
    const vec2 & location = item->getPos();
    Cell& cell = cellRef( index_x( location.x ), index_y( location.y ) );
    cell.add( item );
    numItems += 1;
}
示例#10
0
void Grid::removeItem( GridItemPtr item)
{
    const vec2 & location = item->getPos();
    Cell& cell = cellRef( index_x( location.x ), index_y( location.y ) );
    cell.remove( item );
    numItems -= 1;
}
示例#11
0
int
historia_stress_writer (FILE * pfile, const double * sys,
			const sys_info_t * p_sys_info)
     /* implementacio de writer_funcp_t  **/
{
  static const char * new_line = "\n";
  static const char * particle_delim = ":";

  /* historia stressos:       i    x    y   xx   xy   yy  **/
  const char * format_file = "%d %.5e %.5e %.5e %.5e %.5e";
  int phys_size = p_sys_info->phys_size;
  int i;
  fprintf (pfile, particle_delim);
  for (i = 0; i < phys_size; i++)
    {
      fprintf (pfile, format_file,
	       i,                           // 1. i
	       sys[index_x(i)],             // 2. x
	       sys[index_y(i)],             // 3. y
	       stress_tensor[index_xx(i)] - mean_stress[index_xx(0)],  // 4. xx
	       stress_tensor[index_xy(i)] - mean_stress[index_xy(0)],  // 5. xy
	       stress_tensor[index_yy(i)] - mean_stress[index_yy(0)]); // 6. yy
      fprintf (pfile, particle_delim);
    }
  fprintf (pfile, new_line);  
  
  return 0;
}
void
readIndexSetFromFile(IndexSet<Index2D> &Lambda, string filename)
{
    std::ifstream infile (filename.c_str());
    if (infile.is_open()) {
        cerr << "   Indexset file is open." << endl;
    }
    else {
        cerr << "   Indexset file " << filename.c_str()  << " is not open." << endl;
    }

	int t1,t2;
    int j1,j2;
    long k1,k2;
    T coeff;

    while(!infile.eof()) {

    	infile >> t1 >> j1 >> k1 >> t2 >> j2 >> k2 >> coeff;

        if (t1 == 1 && t2 == 1) {
            Index1D index_x(j1,k1,XWavelet);
            Index1D index_y(j2,k2,XWavelet);
            Lambda.insert(Index2D(index_x,index_y));
        }
        else if (t1 == 1 && t2 == 0) {
            Index1D index_x(j1,k1,XWavelet);
            Index1D index_y(j2,k2,XBSpline);
            Lambda.insert(Index2D(index_x,index_y));
        }
        else if (t1 == 0 && t2 == 1) {
            Index1D index_x(j1,k1,XBSpline);
            Index1D index_y(j2,k2,XWavelet);
            Lambda.insert(Index2D(index_x,index_y));
        }
        else if (t1 == 0 && t2 == 0) {
            Index1D index_x(j1,k1,XBSpline);
            Index1D index_y(j2,k2,XBSpline);
            Lambda.insert(Index2D(index_x,index_y));
        }
        else {
            std::cerr << "Could not read file." << std::endl;
            exit(1); return;
        }
    }
}
示例#13
0
int
boundary_resolve_couette (void)
     /* Resol els conflictes deguts a que partícules surtin per
      * la part superior o inferior i hagin de passar-se a la seva
      * imatge periòdica.  */
{
  dimensions *dim = sys_initial_dimensions_handle ();
  double y_max = dim -> y_max; // initial_dimensions -> y_max;
  double y_min = dim -> y_min; // initial_dimensions -> y_min;

  y_min = y_min - delta_y / 2.; // ups, ja estava bé, crec.
  y_max = y_max + delta_y / 2.;

  double *sys = sys_handle ();

  int i;
  for (i = 0; i < sys_size; i++)
    {
      double y = sys[index_y(i)];

      double y_new = y;
      if (y > y_max)
	{
	  y_new = y_min + (y - y_max);
/* 	  fprintf(stderr,"pbc_up_down: %d %f %f\t%f %f\n", */
/* 		  i,y,y_new,y_max,y_min); */
	}
      if (y < y_min)
	{
	  y_new = y_max - (y_min - y);
/* 	  fprintf(stderr,"pbc_down_up: %d %f %f\t%f %f\n", */
/* 		  i,y,y_new,y_max,y_min); */
	}

      sys[index_y(i)] = y_new;
    }

  return 0;
}
示例#14
0
int
inicia_cristall_sistema_orientat_y (void)
{
  double * sys = sys_handle ();

  double delta_x = dist_a * sqrt(3.) / 2.;
  double delta_y = dist_a;

  int i;
  int j;

  for (i = 0; i < NX; i++)
    {
      for (j = 0; j < NY; j++)
	{
	  if (i % 2 == 0)
	    {
	      double x = i * delta_x;
	      double y = j * delta_y;
	      int index = i + NX * j;
	      sys[index] = x;
	      sys[index_y(index)] = y;
	    }
	  else
	    {
	      double x = i * delta_x;
	      double y = j * delta_y + delta_y / 2.;
	      int index = i + NX * j;
	      sys[index] = x;
	      sys[index_y(index)] = y;
	    }
	}
    }

  return 0;
}
示例#15
0
int
print_particles (FILE * pfile, const double * sys)
     /* Nota: en cas que es vulgui escriure en un altre format,
      * es pot sobreescriure aquest metode.  **/
{
  const char * particle_format = "%.5e %.5e";
  int i;
  fprintf (pfile, particle_delim);
  for (i = 0; i < sys_size; i++)
    {
      fprintf (pfile, particle_format, sys[i], sys[index_y(i)]);
      fprintf (pfile, particle_delim);
    }
  fprintf (pfile, new_line);
  
  return 0;
}
示例#16
0
int
inicia_cristall_add_random_perturbation_if_necessary (void)
{
  char *SIGMA_ = getenv ("SIGMA");
  if (SIGMA_ == 0)
    {
      log_to_logfile ("Cristall inicial perfecte. Sinó posar SIGMA != 0.",
		      __FILE__, __LINE__);
      return 0;
    }

  double SIGMA = strtod (SIGMA_, NULL);

  char log_SIGMA[100];
  sprintf (log_SIGMA, "SIGMA = %.5e, és la fracció [0,1) del delta_x(y)" \
	   " que es pertorben les posicions inicials.", SIGMA);
  log_to_logfile (log_SIGMA, __FILE__, __LINE__);

  double * sys = sys_handle ();
  gsl_rng * rng = random_generator_get_generator 
    ("inicia_cristall_add_random_perturbation");

  if (rng == 0) abort_no_random ();

  dimensions * dim = sys_initial_dimensions_handle ();
  int valid_new_x (double new_x)
    {
      return ((new_x > dim->x_min)&&(new_x < dim->x_max));
    }
  int valid_new_y (double new_y)
    {
      return 1;
    }
  int can_be_changed (int i, double new_x, double new_y)
    {
      int j;
      for (j = 0; j < i; j++)
	{
	  double x_j = sys[j];
	  double y_j = sys[index_y(j)];
	  double r2 = (new_x - x_j) * (new_x - x_j) 
	    + (new_y - y_j) * (new_y - y_j);
	  if (r2 < MINIMUM_APART * MINIMUM_APART) return 0;
	}
      return 1;
    }
示例#17
0
int
boundary_resolve_bottom_reflexive_up_free (void)
{
  dimensions *dim = sys_dimensions_handle ();
/*   double y_max = dim -> y_max; // initial_dimensions -> y_max; */
  double y_min = dim -> y_min; // initial_dimensions -> y_min;

  double *sys = sys_handle ();
  int i;
  for (i = 0; i < phys_size; i++)
    {
      double y = sys[index_y(i)];
      if (y < y_min)
	abort ();
    }

  return 0;
}
示例#18
0
int
data_stress_molecular_extract (const sys_info_t * p_sys_info,
			       const double * sys, const double * f,
			       const int snap, const double t)
{
  mean_stress[index_xx(0)] = 0.;
  mean_stress[index_xy(0)] = 0.;
  mean_stress[index_yy(0)] = 0.;

  mean_stress2[index_xx(0)] = 0.;
  mean_stress2[index_xy(0)] = 0.;
  mean_stress2[index_yy(0)] = 0.;

  mean_stress_L[index_xx(0)] = 0.;
  mean_stress_L[index_xy(0)] = 0.;
  mean_stress_L[index_yy(0)] = 0.;

  mean_stress2_L[index_xx(0)] = 0.;
  mean_stress2_L[index_xy(0)] = 0.;
  mean_stress2_L[index_yy(0)] = 0.;

  mean_stress_R[index_xx(0)] = 0.;
  mean_stress_R[index_xy(0)] = 0.;
  mean_stress_R[index_yy(0)] = 0.;

  mean_stress2_R[index_xx(0)] = 0.;
  mean_stress2_R[index_xy(0)] = 0.;
  mean_stress2_R[index_yy(0)] = 0.;

  forca_L[index_x(0)] = 0.;
  forca_L[index_y(0)] = 0.;
  forca_R[index_x(0)] = 0.;
  forca_R[index_y(0)] = 0.;

  int sys_size = p_sys_info->sys_size;
  int i;
  for (i = 0; i < sys_size; i++) 
    {
      stress_tensor[index_xx(i)] = 0.;
      stress_tensor[index_xy(i)] = 0.;
      stress_tensor[index_yy(i)] = 0.;
    }

  for (i = 0; i < sys_size; i++)
    {
      double x_i = sys[index_x(i)];
      double y_i = sys[index_y(i)];
      
      double s_xx_i = 0.;
      double s_xy_i = 0.;
      double s_yy_i = 0.;

      int jotes = 0;
      int j;
      for (j = 0; j < sys_size; j++)
	{
	  /* avoid self  */
	  if (i == j) continue;

	  double x_j = sys[index_x(j)];
	  double y_j = sys[index_y(j)];

	  /* La i es l'origen, la f actua sobre la j.  */
	  double x_ij = x_j - x_i;
	  double y_ij = y_j - y_i;
	  double r2_ij = x_ij * x_ij + y_ij * y_ij;

	  /* cut off  */
	  if (r2_ij > range2) continue;
	  
	  double f_x_ij = 0.;
	  double f_y_ij = 0.;
	  /* caluculo la forca  entre _i_ i _j_*/
	  double over_r2 = 1./r2_ij;
	  double over_r6 = over_r2 * over_r2 * over_r2;
	  double factor;
	  factor = 24. * over_r2 * over_r6 * (2 * over_r6 - 1);

	  f_x_ij = factor * x_ij;
	  f_y_ij = factor * y_ij;

	  s_xx_i = s_xx_i + f_x_ij * x_ij;
	  s_xy_i = s_xy_i + f_x_ij * y_ij;
	  s_yy_i = s_yy_i + f_y_ij * y_ij;

	  /* valors propis  */
/* 	  double suma = 0.5 * (s_xx_i + s_yy_i); */
/* 	  double resta = 0.5 * (s_xx_i - s_yy_i); */
/* 	  double arrel = sqrt (resta * resta + s_xy_i * s_xy_i); */

/* 	  double lambda_menys = suma - arrel; */
/* 	  double lambda_mes = suma + arrel; */

	  jotes++;
	}
      double norm = 1./ ((double) jotes);
      s_xx_i = norm * s_xx_i;
      s_xy_i = norm * s_xy_i;
      s_yy_i = norm * s_yy_i;

      stress_tensor[index_xx(i)] = s_xx_i;
      stress_tensor[index_xy(i)] = s_xy_i;
      stress_tensor[index_yy(i)] = s_yy_i;

      //      fprintf (stderr, "%d %f %f %f\n", i, s_xx_i, s_xy_i, s_yy_i);
    }

  /* calculo les mitjanes, que haurien de coincidir  */
  int phys_size = p_sys_info->phys_size;
  double norm = 1./ ((double) phys_size);
  for (i = 0; i < phys_size; i++)
    {
      double s_xx_i = stress_tensor[index_xx(i)];
      double s_xy_i = stress_tensor[index_xy(i)];
      double s_yy_i = stress_tensor[index_yy(i)];

      mean_stress[index_xx(0)] = mean_stress[index_xx(0)] + norm * s_xx_i;
      mean_stress[index_xy(0)] = mean_stress[index_xy(0)] + norm * s_xy_i;
      mean_stress[index_yy(0)] = mean_stress[index_yy(0)] + norm * s_yy_i;

      mean_stress2[index_xx(0)] = mean_stress2[index_xx(0)] 
	                        + norm * s_xx_i * s_xx_i;
      mean_stress[index_xy(0)] = mean_stress[index_xy(0)] 
                               + norm * s_xy_i * s_xy_i;
      mean_stress[index_yy(0)] = mean_stress[index_yy(0)] 
                               + norm * s_yy_i * s_yy_i;
    }

  /* e_strain  **/  
  double V = p_sys_info->V;
  double delta_x = p_sys_info->delta_x;
  int NX = p_sys_info->NX;
  double x_length_0 = (NX + 1) * delta_x;//(NX - 0.5) * delta_x;
  double vt = 2 * V * t;
  e_strain = vt / x_length_0;

  int paret_size = p_sys_info->paret_size;
  norm = 1. / ((double) paret_size);
  int NY = p_sys_info->NY;
  double delta_y = p_sys_info->delta_y;
  double norm_f = 1. / (delta_y * ((double) NY));
  //  fprintf (stdout, "norm: %f\n", norm_f);
  //forca total, no normalitzem / ((double) NY);
  /* paretL  */
  for (i = phys_size; i < phys_size + paret_size; i++)
    {
      double xx = stress_tensor[index_xx(i)];
      double xy = stress_tensor[index_xy(i)];
      double yy = stress_tensor[index_yy(i)];

      mean_stress_L[index_xx(0)] = mean_stress_L[index_xx(0)] + norm * xx;
      mean_stress_L[index_xy(0)] = mean_stress_L[index_xy(0)] + norm * xy;
      mean_stress_L[index_yy(0)] = mean_stress_L[index_yy(0)] + norm * yy;

      mean_stress2_L[index_xx(0)] = mean_stress2_L[index_xx(0)] 
	                          + norm * xx * xx;
      mean_stress2_L[index_xy(0)] = mean_stress2_L[index_xy(0)] 
                                  + norm * xy * xy;
      mean_stress2_L[index_yy(0)] = mean_stress2_L[index_yy(0)] 
                                  + norm * yy * yy;

      forca_L[index_x(0)] = forca_L[index_x(0)] + norm_f * f[index_x(i)];
      forca_L[index_y(0)] = forca_L[index_y(0)] + norm_f * f[index_y(i)];
    }

  norm = 1. / ((double) paret_size);
  //  norm_f = 1.; // forca total, no normalitzem / ((double) NY);
  /* paretR */
  for (i = phys_size + paret_size; i < phys_size + 2 * paret_size; i++)
    {
      double xx = stress_tensor[index_xx(i)];
      double xy = stress_tensor[index_xy(i)];
      double yy = stress_tensor[index_yy(i)];

      mean_stress_R[index_xx(0)] = mean_stress_R[index_xx(0)] + norm * xx;
      mean_stress_R[index_xy(0)] = mean_stress_R[index_xy(0)] + norm * xy;
      mean_stress_R[index_yy(0)] = mean_stress_R[index_yy(0)] + norm * yy;

      mean_stress2_R[index_xx(0)] = mean_stress2_R[index_xx(0)] 
	                          + norm * xx * xx;
      mean_stress2_R[index_xy(0)] = mean_stress2_R[index_xy(0)] 
                                  + norm * xy * xy;
      mean_stress2_R[index_yy(0)] = mean_stress2_R[index_yy(0)] 
                                  + norm * yy * yy;

      forca_R[index_x(0)] = forca_R[index_x(0)] + norm_f * f[index_x(i)];
      forca_R[index_y(0)] = forca_R[index_y(0)] + norm_f * f[index_y(i)];
    }

  if (historia_stress_b) 
    dr_writer_write_frame (stress_history_pfile, sys,
			   p_sys_info, snap, t);

  return 0;
}
示例#19
0
int
data_energy_extract (const sys_info_t * p_sys_info,
		     const double * sys, const double * f,
		     const int snap, const double t)
{
  energy_energy = 0.;
  energy_energy2 = 0.;
  dW_per_particle = 0.;
  dW = 0.;
  sum_modul_per_particle = 0.;
  sum_modul = 0.;

  int phys_size = p_sys_info->phys_size;
  double norm = 1. / ((double) phys_size);
  int i;
  int sys_size = p_sys_info->sys_size;
  for (i = 0; i < phys_size; i++)
  //for (i = 0; i < sys_size; i++)
    {
      double x_i = sys[index_x(i)];
      double y_i = sys[index_y(i)];

      double e_i = 0.;

      double fx_i = f[index_x(i)];
      double fy_i = f[index_y(i)];
      double vx_i = f[index_x(i)];
      double vy_i = f[index_y(i)];
      double dW_i = fx_i * vx_i + fy_i * vy_i; // v and f are the same, but...
      double mod_v_i = sqrt(vx_i * vx_i + vy_i * vy_i);

      int j;
      //for (j = 0; j < phys_size; j++)
      for (j = 0; j < sys_size; j++)
	{
	  /* avoid self  */
	  if (j == i) continue;

	  double x_j = sys[index_x(j)];
	  double y_j = sys[index_y(j)];
	  double r2 = (x_j - x_i) * (x_j - x_i) + (y_j - y_i) * (y_j - y_i);
	  double over_r2 = 1. / r2;
	  double over_r6 = over_r2 * over_r2 * over_r2;
	  double over_r12 = over_r6 * over_r6;
	  double e_ij = 4 * (over_r12 - over_r6);
	  e_i = e_i + e_ij;
	}

      // el 0.5 \sum_{i<j} = 0.5 \sum_{ij} !!!!!!!!!!!!!!
      energy_energy = energy_energy + 0.5 * e_i;
      energy_energy2 = energy_energy2 + 0.5 * e_i * e_i; //??? el 0.5 no ho sé
      dW_per_particle = dW_per_particle + norm * dW_i;
      dW = dW + dW_i;
      sum_modul_per_particle = sum_modul_per_particle + norm * mod_v_i;
      sum_modul = sum_modul + mod_v_i;
    }

  /* e_strain  **/
  double V = p_sys_info->V;
  double delta_x = p_sys_info->delta_x;
  int NX = p_sys_info->NX;
  double x_length_0 = (NX + 1) * delta_x;//(NX - 0.5) * delta_x;
  double vt = 2 * V * t;
  e_strain = vt / x_length_0;

  return 0;
}