From c31575c922abadbf29bceb830f5c0e07c397f1c4 Mon Sep 17 00:00:00 2001 From: Giovanni La Mura <giovanni.lamura@inaf.it> Date: Fri, 10 Nov 2023 13:51:38 +0100 Subject: [PATCH] Enable configuration of clusters of spheres --- src/include/Configuration.h | 19 ++++++++++++-- src/libnptm/Configuration.cpp | 48 +++++++++++++++++++++++------------ 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/src/include/Configuration.h b/src/include/Configuration.h index fdc36184..12e3d779 100644 --- a/src/include/Configuration.h +++ b/src/include/Configuration.h @@ -64,13 +64,22 @@ public: * fields and their polarization properties. */ class GeometryConfiguration { - //! Temporary work-around to allow sphere() peeking in. + //! Temporary work-around to allow cluster() and sphere() peeking in. + friend void cluster(); friend void sphere(); protected: //! \brief Number of spherical components. int number_of_spheres; //! \brief Maximum expansion order of angular momentum. int l_max; + //! \brief QUESTION: definition? + int li; + //! \brief QUESTION: definition? + int le; + //! \brief QUESTION: definition? + int mxndm; + //! \brief QUESTION: definition? + int iavm; //! \brief Incident field polarization status (0 - linear, 1 - circular). int in_pol; //! \brief Number of transition points. QUESTION: correct? @@ -124,6 +133,10 @@ public: * for incident angles, 0 if determined by incidence and observation, =1 * accross z-axis for incidence and observation, >1 across z-axis as a * function of incidence angles for fixed scattering). + * \param li: `int` + * \param le: `int` + * \param mxndm: `int` + * \param iavm: `int` * \param x: `double*` Vector of spherical components X coordinates. * \param y: `double*` Vector of spherical components Y coordinates. * \param z: `double*` Vector of spherical components Z coordinates. @@ -143,6 +156,7 @@ public: */ GeometryConfiguration( int nsph, int lm, int in_pol, int npnt, int npntts, int meridional_type, + int li, int le, int mxndm, int iavm, double *x, double *y, double *z, double in_th_start, double in_th_step, double in_th_end, double sc_th_start, double sc_th_step, double sc_th_end, @@ -176,7 +190,8 @@ public: * data to describe the scatterer properties. */ class ScattererConfiguration { - //! Temporary work-around to allow sphere() peeking in. + //! Temporary work-around to allow cluster() and sphere() peeking in. + friend void cluster(); friend void sphere(); protected: //! \brief Matrix of dielectric parameters with size [NON_TRANS_LAYERS x N_SPHERES x LAYERS]. diff --git a/src/libnptm/Configuration.cpp b/src/libnptm/Configuration.cpp index 6bb02bdd..2e9a81fc 100644 --- a/src/libnptm/Configuration.cpp +++ b/src/libnptm/Configuration.cpp @@ -12,7 +12,8 @@ using namespace std; GeometryConfiguration::GeometryConfiguration( - int nsph, int lm, int _in_pol, int _npnt, int _npntts, int isam, + int _nsph, int _lm, int _in_pol, int _npnt, int _npntts, int _isam, + int _li, int _le, int _mxndm, int _iavm, double *x, double *y, double *z, double in_th_start, double in_th_step, double in_th_end, double sc_th_start, double sc_th_step, double sc_th_end, @@ -20,12 +21,16 @@ GeometryConfiguration::GeometryConfiguration( double sc_ph_start, double sc_ph_step, double sc_ph_end, int _jwtm ) { - number_of_spheres = nsph; - l_max = lm; + number_of_spheres = _nsph; + l_max = _lm; in_pol = _in_pol; npnt = _npnt; npntts = _npntts; - meridional_type = isam; + meridional_type = _isam; + li = _li; + le = _le; + mxndm = _mxndm; + iavm = _iavm; in_theta_start = in_th_start; in_theta_step = in_th_step; in_theta_end = in_th_end; @@ -59,22 +64,32 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(string file_name) { } catch (exception &ex) { throw OpenConfigurationFileException(file_name); } - int nsph, lm, _in_pol, _npnt, _npntts, isam; - sscanf( - file_lines[last_read_line++].c_str(), - " %d %d %d %d %d %d", - &nsph, &lm, &_in_pol, &_npnt, &_npntts, &isam - ); + int _nsph = 0, _lm = 0, _in_pol = 0, _npnt = 0, _npntts = 0, _isam = 0; + int _li = 0, _le = 0, _mxndm = 0, _iavm = 0; + sscanf(file_lines[last_read_line].c_str(), " %d", &_nsph); + if (_nsph == 1) { + sscanf( + file_lines[last_read_line++].c_str(), + " %*d %d %d %d %d %d", + &_lm, &_in_pol, &_npnt, &_npntts, &_isam + ); + } else { + sscanf( + file_lines[last_read_line++].c_str(), + " %*d %d %d %d %d %d %d %d %d", + &_li, &_le, &_mxndm, &_in_pol, &_npnt, &_npntts, &_iavm, &_isam + ); + } double *x, *y, *z; - x = new double[nsph]; - y = new double[nsph]; - z = new double[nsph]; - if (nsph == 1) { + x = new double[_nsph]; + y = new double[_nsph]; + z = new double[_nsph]; + if (_nsph == 1) { x[0] = 0.0; y[0] = 0.0; z[0] = 0.0; } else { - for (int i = 0; i < nsph; i++) { + for (int i = 0; i < _nsph; i++) { double sph_x, sph_y, sph_z; int sph_x_exp, sph_y_exp, sph_z_exp; sscanf( @@ -126,7 +141,8 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(string file_name) { int _jwtm; sscanf(file_lines[last_read_line++].c_str(), " %d", &_jwtm); GeometryConfiguration *conf = new GeometryConfiguration( - nsph, lm, _in_pol, _npnt, _npntts, isam, + _nsph, _lm, _in_pol, _npnt, _npntts, _isam, + _li, _le, _mxndm, _iavm, x, y, z, in_th_start, in_th_step, in_th_end, sc_th_start, sc_th_step, sc_th_end, -- GitLab