From 18e399ca6d14f1e9a8d42ee0e20e205f62ea4cc3 Mon Sep 17 00:00:00 2001
From: Giovanni La Mura <giovanni.lamura@inaf.it>
Date: Fri, 8 Nov 2024 12:12:41 +0100
Subject: [PATCH] Use ParticleDescriptor in SPHERE

---
 src/include/sph_subs.h   | 36 ++++++++++++++++++------------------
 src/libnptm/sph_subs.cpp | 18 +++++++++---------
 src/sphere/sphere.cpp    |  2 +-
 3 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/include/sph_subs.h b/src/include/sph_subs.h
index bfcf4a72..0ae5b280 100644
--- a/src/include/sph_subs.h
+++ b/src/include/sph_subs.h
@@ -38,11 +38,11 @@
  * \param zpv: `double ****` Geometrical asymmetry parameter coefficients matrix.
  * \param li: `int` Maximum field expansion order.
  * \param nsph: `int` Number of spheres.
- * \param c1: `C1 *` Pointer to a `C1` data structure.
+ * \param c1: `ParticleDescriptor *` Pointer to a `ParticleDescriptor` data structure.
  * \param sqk: `double`
  * \param gaps: `double *` Geometrical asymmetry parameter-corrected cross-section.
  */
-void aps(double ****zpv, int li, int nsph, C1 *c1, double sqk, double *gaps);
+void aps(double ****zpv, int li, int nsph, ParticleDescriptor *c1, double sqk, double *gaps);
 
 /*! \brief Complex Bessel Function.
  *
@@ -88,10 +88,10 @@ double cg1(int lmpml, int mu, int l, int m);
  * \param i: `int`
  * \param ic: `int`
  * \param vk: `double`
- * \param c1: `C1 *` Pointer to `C1` data structure.
+ * \param c1: `ParticleDescriptor *` Pointer to `ParticleDescriptor` data structure.
  * \param c2: `C2 *` Pointer to `C2` data structure.
  */
-void diel(int npntmo, int ns, int i, int ic, double vk, C1 *c1, C2 *c2);
+void diel(int npntmo, int ns, int i, int ic, double vk, ParticleDescriptor *c1, C2 *c2);
 
 /*! \brief Compute Mie scattering coefficients.
  *
@@ -107,7 +107,7 @@ void diel(int npntmo, int ns, int i, int ic, double vk, C1 *c1, C2 *c2);
  * \param vk: `double` Wave number in scale units.
  * \param exdc: `double` External medium dielectric constant.
  * \param exri: `double` External medium refractive index.
- * \param c1: `C1 *` Pointer to a `C1` data structure.
+ * \param c1: `ParticleDescriptor *` Pointer to a `ParticleDescriptor` data structure.
  * \param c2: `C2 *` Pointer to a `C2` data structure.
  * \param jer: `int &` Reference to integer error code variable.
  * \param lcalc: `int &` Reference to integer variable recording the maximum expansion order accounted for.
@@ -116,7 +116,7 @@ void diel(int npntmo, int ns, int i, int ic, double vk, C1 *c1, C2 *c2);
  */
 void dme(
 	 int li, int i, int npnt, int npntts, double vk, double exdc, double exri,
-	 C1 *c1, C2 *c2, int &jer, int &lcalc, dcomplex &arg, int last_conf=0
+	 ParticleDescriptor *c1, C2 *c2, int &jer, int &lcalc, dcomplex &arg, int last_conf=0
 );
 
 /*! \brief Bessel function calculation control parameters.
@@ -189,11 +189,11 @@ void orunve(double *u1, double *u2, double *u3, int iorth, double torth);
  * \param inpol: `int` Incident field polarization type (0 - linear; 1 - circular).
  * \param lw: `int`
  * \param isq: `int`
- * \param c1: `C1 *` Pointer to a `C1` data structure.
+ * \param c1: `ParticleDescriptor *` Pointer to a `ParticleDescriptor` data structure.
  */
 void pwma(
 	  double *up, double *un, dcomplex *ylm, int inpol, int lw,
-	  int isq, C1 *c1
+	  int isq, ParticleDescriptor *c1
 );
 
 /*! \brief Compute radiation torques on a single sphere in Cartesian coordinates.
@@ -205,14 +205,14 @@ void pwma(
  * \param inpol: `int` Incident polarization type (0 - linear; 1 - circular)
  * \param li: `int` Maximum field expansion order.
  * \param nsph: `int` Number of spheres.
- * \param c1: `C1 *` Pointer to `C1` data structure.
+ * \param c1: `ParticleDescriptor *` Pointer to `ParticleDescriptor` data structure.
  * \param tqse: `double **`
  * \param tqspe: `complex double **`
  * \param tqss: `double **`
  * \param tqsps: `complex double **`
  */
 void rabas(
-	   int inpol, int li, int nsph, C1 *c1, double **tqse, dcomplex **tqspe,
+	   int inpol, int li, int nsph, ParticleDescriptor *c1, double **tqse, dcomplex **tqspe,
 	   double **tqss, dcomplex **tqsps
 );
 
@@ -308,9 +308,9 @@ void sphar(
  * \param lm: `int` Maximum field expansion order.
  * \param vk: `double` Wave number in scale units.
  * \param exri: `double` External medium refractive index.
- * \param c1: `C1 *` Pointer to a `C1` data structure.
+ * \param c1: `ParticleDescriptor *` Pointer to a `ParticleDescriptor` data structure.
  */
-void sscr0(dcomplex &tfsas, int nsph, int lm, double vk, double exri, C1 *c1);
+void sscr0(dcomplex &tfsas, int nsph, int lm, double vk, double exri, ParticleDescriptor *c1);
 
 /*! \brief C++ Compute the scattering amplitude and the scattered field intensity.
  *
@@ -321,9 +321,9 @@ void sscr0(dcomplex &tfsas, int nsph, int lm, double vk, double exri, C1 *c1);
  * \param lm: `int` Maximum field expansion order.
  * \param vk: `double` Wave number in scale units.
  * \param exri: `double` External medium refractive index.
- * \param c1: `C1 *` Pointer to a `C1` data structure.
+ * \param c1: `ParticleDescriptor *` Pointer to a `ParticleDescriptor` data structure.
  */
-void sscr2(int nsph, int lm, double vk, double exri, C1 *c1);
+void sscr2(int nsph, int lm, double vk, double exri, ParticleDescriptor *c1);
 
 /*! \brief Determine the geometrical asymmetry parameter coefficients.
  *
@@ -409,12 +409,12 @@ void upvsp(
  * \param u: `double *`
  * \param up: `double *`
  * \param un: `double *`
- * \param c1: `C1 *` Pointer to a `C1` data structure.
+ * \param c1: `ParticleDescriptor *` Pointer to a `ParticleDescriptor` data structure.
  */
 void wmamp(
 	   int iis, double cost, double sint, double cosp, double sinp, int inpol,
 	   int lm, int idot, int nsph, double *arg, double *u, double *up,
-	   double *un, C1 *c1
+	   double *un, ParticleDescriptor *c1
 );
 
 /*! \brief Compute the scattering plane-referred geometrical asymmetry parameter coefficients.
@@ -445,13 +445,13 @@ void wmamp(
  * \param nsph: `int` Number opf spheres.
  * \param argi: `double *`
  * \param args: `double *`
- * \param c1: `C1 *` Pointer to a `C1` data structure.
+ * \param c1: `ParticleDescriptor *` Pointer to a `ParticleDescriptor` data structure.
  */
 void wmasp(
 	   double cost, double sint, double cosp, double sinp, double costs, double sints,
 	   double cosps, double sinps, double *u, double *up, double *un, double *us,
 	   double *ups, double *uns, int isq, int ibf, int inpol, int lm, int idot,
-	   int nsph, double *argi, double *args, C1 *c1
+	   int nsph, double *argi, double *args, ParticleDescriptor *c1
 );
 
 #endif /* SRC_INCLUDE_SPH_SUBS_H_ */
diff --git a/src/libnptm/sph_subs.cpp b/src/libnptm/sph_subs.cpp
index 046c280d..d24a0fb6 100644
--- a/src/libnptm/sph_subs.cpp
+++ b/src/libnptm/sph_subs.cpp
@@ -34,7 +34,7 @@
 #include "../include/sph_subs.h"
 #endif
 
-void aps(double ****zpv, int li, int nsph, C1 *c1, double sqk, double *gaps) {
+void aps(double ****zpv, int li, int nsph, ParticleDescriptor *c1, double sqk, double *gaps) {
   dcomplex cc0 = 0.0 + 0.0 * I;
   dcomplex summ, sume, suem, suee, sum;
   double half_pi = acos(0.0);
@@ -197,7 +197,7 @@ double cg1(int lmpml, int mu, int l, int m) {
   return result;
 }
 
-void diel(int npntmo, int ns, int i, int ic, double vk, C1 *c1, C2 *c2) {
+void diel(int npntmo, int ns, int i, int ic, double vk, ParticleDescriptor *c1, C2 *c2) {
   const double dif = c1->rc[i - 1][ns] - c1->rc[i - 1][ns - 1];
   const double half_step = 0.5 * dif / npntmo;
   double rr = c1->rc[i - 1][ns - 1];
@@ -218,7 +218,7 @@ void diel(int npntmo, int ns, int i, int ic, double vk, C1 *c1, C2 *c2) {
 
 void dme(
 	 int li, int i, int npnt, int npntts, double vk, double exdc, double exri,
-	 C1 *c1, C2 *c2, int &jer, int &lcalc, dcomplex &arg, int last_conf
+	 ParticleDescriptor *c1, C2 *c2, int &jer, int &lcalc, dcomplex &arg, int last_conf
 ) {
   const int lipo = li + 1;
   const int lipt = li + 2;
@@ -497,7 +497,7 @@ void orunve(double *u1, double *u2, double *u3, int iorth, double torth) {
 
 void pwma(
 	  double *up, double *un, dcomplex *ylm, int inpol, int lw,
-	  int isq, C1 *c1
+	  int isq, ParticleDescriptor *c1
 ) {
   const double four_pi = 8.0 * acos(0.0);
   int is = isq;
@@ -575,7 +575,7 @@ void pwma(
 }
 
 void rabas(
-	   int inpol, int li, int nsph, C1 *c1, double **tqse, dcomplex **tqspe,
+	   int inpol, int li, int nsph, ParticleDescriptor *c1, double **tqse, dcomplex **tqspe,
 	   double **tqss, dcomplex **tqsps
 ) {
   dcomplex cc0 = 0.0 + 0.0 * I;
@@ -894,7 +894,7 @@ void sphar(
   goto label40;
 }
 
-void sscr0(dcomplex &tfsas, int nsph, int lm, double vk, double exri, C1 *c1) {
+void sscr0(dcomplex &tfsas, int nsph, int lm, double vk, double exri, ParticleDescriptor *c1) {
   dcomplex sum21, rm, re, csam;
   const dcomplex cc0 = 0.0 + 0.0 * I;
   const double exdc = exri * exri;
@@ -935,7 +935,7 @@ void sscr0(dcomplex &tfsas, int nsph, int lm, double vk, double exri, C1 *c1) {
   }
 }
 
-void sscr2(int nsph, int lm, double vk, double exri, C1 *c1) {
+void sscr2(int nsph, int lm, double vk, double exri, ParticleDescriptor *c1) {
   dcomplex s11, s21, s12, s22, rm, re, csam, cc;
   const dcomplex cc0 = 0.0 + 0.0 * I;
   double ccs = 1.0 / (vk * vk);
@@ -1121,7 +1121,7 @@ void upvsp(
 void wmamp(
 	   int iis, double cost, double sint, double cosp, double sinp, int inpol,
 	   int lm, int idot, int nsph, double *arg, double *u, double *up,
-	   double *un, C1 *c1
+	   double *un, ParticleDescriptor *c1
 ) {
   const int ylm_size = (lm + 1) * (lm + 1) + 1;
   dcomplex *ylm = new dcomplex[ylm_size];
@@ -1150,7 +1150,7 @@ void wmasp(
 	   double cost, double sint, double cosp, double sinp, double costs, double sints,
 	   double cosps, double sinps, double *u, double *up, double *un, double *us,
 	   double *ups, double *uns, int isq, int ibf, int inpol, int lm, int idot,
-	   int nsph, double *argi, double *args, C1 *c1
+	   int nsph, double *argi, double *args, ParticleDescriptor *c1
 ) {
   const int ylm_size = (lm + 1) * (lm + 1) + 1;
   dcomplex *ylm = new dcomplex[ylm_size];
diff --git a/src/sphere/sphere.cpp b/src/sphere/sphere.cpp
index c0e789ff..e90fcae8 100644
--- a/src/sphere/sphere.cpp
+++ b/src/sphere/sphere.cpp
@@ -129,7 +129,7 @@ void sphere(const string& config_file, const string& data_file, const string& ou
     double cfmp, cfsp, sfmp, sfsp;
     int jw;
     int l_max = gconf->l_max;
-    C1 *c1 = new C1(gconf, sconf);
+    ParticleDescriptor *c1 = new ParticleDescriptorSphere(gconf, sconf);
     int npnt = gconf->npnt;
     int npntts = gconf->npntts;
     int in_pol = gconf->in_pol;
-- 
GitLab