diff --git a/src/include/Configuration.h b/src/include/Configuration.h index 67666c6bfa18a0e8c161cc2eaf9c1baf9b2b9b9f..4235f56d9d42cb4849380282f66b90871b5bf1cb 100644 --- a/src/include/Configuration.h +++ b/src/include/Configuration.h @@ -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 diff --git a/src/libnptm/Configuration.cpp b/src/libnptm/Configuration.cpp index 68e076630b26c5eb8bb91b2a1dcd5d8b392392d5..2aa61343aaf91e99294d2d786c72ddae2f290c5b 100644 --- a/src/libnptm/Configuration.cpp +++ b/src/libnptm/Configuration.cpp @@ -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");