Browse Source

nmax preset value in now preserved

Konstantin Ladutenko 10 years ago
parent
commit
4721dfbfce
2 changed files with 8 additions and 1 deletions
  1. 4 1
      nmie.cc
  2. 4 0
      nmie.h

+ 4 - 1
nmie.cc

@@ -263,7 +263,7 @@ namespace nmie {
   // ********************************************************************** //
   // ********************************************************************** //
   void MultiLayerMie::SetMaxTermsNumber(int nmax) {
-    nmax_ = nmax;
+    nmax_preset_ = nmax;
   }
   // ********************************************************************** //
   // ********************************************************************** //
@@ -998,6 +998,7 @@ c    MM       + 1  and - 1, alternately
   //**********************************************************************************//
   void MultiLayerMie::RunMieCalculations() {
     ConvertToSP();
+    nmax_ = nmax_preset_;
     if (size_parameter_.size() != index_.size())
       throw std::invalid_argument("Each size parameter should have only one index!");
     if (size_parameter_.size() == 0)
@@ -1057,6 +1058,7 @@ c    MM       + 1  and - 1, alternately
     Qbk_ = (Qbktmp.real()*Qbktmp.real() + Qbktmp.imag()*Qbktmp.imag())/x2;    // Equation (33)
 
     isMieCalculated_ = true;
+    nmax_used_ = nmax_;
     //return nmax;
   }
   // ********************************************************************** //
@@ -1068,6 +1070,7 @@ c    MM       + 1  and - 1, alternately
   void MultiLayerMie::fieldExt(double Rho, double Phi, double Theta, std::vector<double> Pi, std::vector<double> Tau,
 			       std::vector<std::complex<double> > an, std::vector<std::complex<double> > bn,
 			       std::vector<std::complex<double> >& E, std::vector<std::complex<double> >& H)  {
+    
 
     double rn = 0.0;
     std::complex<double> zn, xxip, encap;

+ 4 - 0
nmie.h

@@ -99,7 +99,9 @@ namespace nmie {
     void SetAngles(const std::vector<double>& angles);
     std::vector<double> GetAngles();
     void SetPEC(int layer_position = 0);  // By default set PEC layer to be the first one
+    
     void SetMaxTermsNumber(int nmax);
+    int GetMaxTermsUsed() {return nmax_used_;};
     
     void ClearTarget();
     void ClearCoating();
@@ -219,6 +221,8 @@ namespace nmie {
     // Set nmax_ manualy with SetMaxTermsNumber(int nmax) or in ScattCoeffs(..)
     // with Nmax(int first_layer);
     int nmax_ = -1;
+    int nmax_used_ = -1;
+    int nmax_preset_ = -1;
     /// Store result
     double Qsca_ = 0.0, Qext_ = 0.0, Qabs_ = 0.0, Qbk_ = 0.0, Qpr_ = 0.0, asymmetry_factor_ = 0.0, albedo_ = 0.0;
     std::vector<std::complex<double> > S1_, S2_;