Commit 17a04839 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Add configuration functions to estimate particle components size and particle size

parent 866f3376
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -290,7 +290,7 @@ protected:
  double *_radii_of_spheres;
  //! \brief Vector of sphere ID numbers, with size [N_SPHERES].
  int *_iog_vec;
  //! \brief Vector of layer numbers for every sphere, with size [N_SPHERES].
  //! \brief Vector of layer numbers for every sphere, with size [CONFIGURATIONS].
  int *_nshl_vec;
  //! \brief Vector of scale parameters, with size [N_SCALES].
  double *_scale_vec;
@@ -511,6 +511,12 @@ public:
   */
  int get_iog(int index) { return _iog_vec[index]; }
  
  /*! \brief Get the maximum radius of the sphere components.
   *
   * \return radius: `double` The radius of the largest sphere.
   */
  double get_max_radius();
  
  /*! \brief Get the number of layers for a given configuration.
   *
   * This is a specialized function to get the number of layers in a specific
@@ -521,6 +527,13 @@ public:
   */
  int get_nshl(int index) { return _nshl_vec[index]; }

  /*! \brief Get the radius of the smallest sphere containing the particle.
   *
   * \param gc: `GeometryConfiguration *` Pointer to a `GeometryConfiguration` instance.
   * \return radius: `double` The radius of the sphere containing the particle.
   */
  double get_particle_radius(GeometryConfiguration *gc);
  
  /*! \brief Get the radius of a sphere by its index.
   *
   * This is a specialized function to get the radius of a sphere through its
+34 −0
Original line number Diff line number Diff line
@@ -971,6 +971,40 @@ ScattererConfiguration* ScattererConfiguration::from_legacy(const std::string& f
  return conf;
}

double ScattererConfiguration::get_max_radius() {
  double result = 0.0;
  for (int ci = 0; ci < _configurations; ci++) {
    if (_radii_of_spheres[ci] > result)
      result = _radii_of_spheres[ci];
  }
  return result;
}

double ScattererConfiguration::get_particle_radius(GeometryConfiguration *gc) {
  double result = 0.0;
  if (_use_external_sphere) {
    result = _radii_of_spheres[0] * _rcf[0][_nshl_vec[0] - 1];
  } else {
    double x, y, z;
    int far_index = -1;
    double dist2, max_dist;
    double max_dist2 = 0.0;
    for (int si = 0; si < _number_of_spheres; si++) {
      x = gc->get_sph_x(si);
      y = gc->get_sph_y(si);
      z = gc->get_sph_z(si);
      dist2 = x * x + y * y + z * z;
      if (dist2 > max_dist2) {
	max_dist2 = dist2;
	far_index = si;
      }
    }
    max_dist = sqrt(max_dist2);
    result = max_dist + _radii_of_spheres[far_index];
  }
  return result;
}

void ScattererConfiguration::print() {
  int ies = (_use_external_sphere)? 1 : 0;
  printf("### CONFIGURATION DATA ###\n");