瀏覽代碼

refactor mode_n and mode_t

Konstantin Ladutenko 6 年之前
父節點
當前提交
17433beb39
共有 5 個文件被更改,包括 104 次插入38 次删除
  1. 7 8
      src/nmie-impl.hpp
  2. 4 1
      src/nmie.cc
  3. 3 3
      src/nmie.hpp
  4. 45 13
      src/scattnlay.cpp
  5. 45 13
      src/scattnlay_mp.cpp

+ 7 - 8
src/nmie-impl.hpp

@@ -828,6 +828,7 @@ namespace nmie {
     //      http://en.wikipedia.org/wiki/Loss_of_significance
     for (int i = nmax_ - 2; i >= 0; i--) {
       const int n = i + 1;
+      if (mode_n_ != Modes::kAll && n != mode_n_) continue;
       // Equation (27)
       Qext_ += (n + n + 1.0)*(an_[i].real() + bn_[i].real());
       // Equation (28)
@@ -1019,7 +1020,6 @@ namespace nmie {
   template <typename FloatType>
   void MultiLayerMie<FloatType>::calcFieldByComponents(const FloatType Rho,
                                 const FloatType Theta, const FloatType Phi,
-                                const int mode_n, const int mode_type,
                                 std::vector<std::complex<FloatType> >& E,
                                 std::vector<std::complex<FloatType> >& H)  {
 
@@ -1075,7 +1075,7 @@ namespace nmie {
       std::complex<FloatType> En = ipow[n1 % 4]
 	*static_cast<FloatType>((rn + rn + 1.0)/(rn*rn + rn));
       for (int i = 0; i < 3; i++) {
-        if (mode_n == Modes::kAll) {
+        if (mode_n_ == Modes::kAll) {
           // electric field E [V m - 1] = EF*E0
           E[i] += En*(      cln_[l][n]*M1o1n[i] - c_i*dln_[l][n]*N1e1n[i]
                       + c_i*aln_[l][n]*N3e1n[i] -     bln_[l][n]*M3o1n[i]);
@@ -1084,8 +1084,8 @@ namespace nmie {
                       + c_i*bln_[l][n]*N3o1n[i] +     aln_[l][n]*M3e1n[i]);
           continue;
         }
-        if (n1 == mode_n) {
-          if (mode_type == Modes::kElectric || mode_type == Modes::kAll) {
+        if (n1 == mode_n_) {
+          if (mode_type_ == Modes::kElectric || mode_type_ == Modes::kAll) {
             E[i] += En*( -c_i*dln_[l][n]*N1e1n[i]
                         + c_i*aln_[l][n]*N3e1n[i]);
 
@@ -1093,7 +1093,7 @@ namespace nmie {
                         +aln_[l][n]*M3e1n[i]);
             continue;
           }
-          if (mode_type == Modes::kMagnetic  || mode_type == Modes::kAll) {
+          if (mode_type_ == Modes::kMagnetic  || mode_type_ == Modes::kAll) {
             E[i] += En*(  cln_[l][n]*M1o1n[i]
                         - bln_[l][n]*M3o1n[i]);
 
@@ -1145,8 +1145,7 @@ namespace nmie {
   //   Number of multipolar expansion terms used for the calculations                 //
   //**********************************************************************************//
   template <typename FloatType>
-  void MultiLayerMie<FloatType>::RunFieldCalculation(
-                                const int mode_n, const int mode_type) {
+  void MultiLayerMie<FloatType>::RunFieldCalculation() {
     FloatType Rho, Theta, Phi;
 
     // Calculate scattering coefficients an_ and bn_
@@ -1194,7 +1193,7 @@ namespace nmie {
       std::vector<std::complex<FloatType> > Es(3), Hs(3);
 
       // Do the actual calculation of electric and magnetic field
-      calcFieldByComponents(Rho, Theta, Phi, mode_n, mode_type, Es, Hs);
+      calcFieldByComponents(Rho, Theta, Phi, Es, Hs);
       for (int sph_coord = 0; sph_coord<3; ++sph_coord) {
         Es_[point][sph_coord] = Es[sph_coord];
         Hs_[point][sph_coord] = Hs[sph_coord];

+ 4 - 1
src/nmie.cc

@@ -392,7 +392,10 @@ namespace nmie {
       ml_mie.SetFieldCoords({ConvertVector<FloatType>(Xp_vec),
 	    ConvertVector<FloatType>(Yp_vec),
 	    ConvertVector<FloatType>(Zp_vec) });
-      ml_mie.RunFieldCalculation(mode_n, mode_type);
+      
+      ml_mie.SetModeNmaxAndType(mode_n, mode_type);
+
+      ml_mie.RunFieldCalculation();
       E = ConvertComplexVectorVector<double>(ml_mie.GetFieldE());
       H = ConvertComplexVectorVector<double>(ml_mie.GetFieldH());
 

+ 3 - 3
src/nmie.hpp

@@ -95,7 +95,7 @@ namespace nmie {
     const double mu_ = 4.0*PI_*1.0e-7;
     // Run calculation
     void RunMieCalculation();
-    void RunFieldCalculation(const int mode_n=Modes::kAll, const int mode_type=Modes::kAll);
+    void RunFieldCalculation();
     void calcScattCoeffs();
     void calcExpanCoeffs();
 
@@ -202,8 +202,8 @@ namespace nmie {
                        std::vector<std::complex<FloatType> >& No1n, std::vector<std::complex<FloatType> >& Ne1n);
 
     void calcFieldByComponents(const FloatType Rho, const FloatType Theta, const FloatType Phi,
-                               const int mode_n, const int mode_type,
-                               std::vector<std::complex<FloatType> >& E, std::vector<std::complex<FloatType> >& H);
+                               std::vector<std::complex<FloatType> >& E,
+                               std::vector<std::complex<FloatType> >& H);
 
     bool isExpCoeffsCalc_ = false;
     bool isScaCoeffsCalc_ = false;

文件差異過大導致無法顯示
+ 45 - 13
src/scattnlay.cpp


文件差異過大導致無法顯示
+ 45 - 13
src/scattnlay_mp.cpp


部分文件因文件數量過多而無法顯示