Browse Source

Fixed compilation of python extension. Calculation of an_bulk_, bn_bulk_ seems broken. Field calculation using these values gives an error.

Ovidio Peña Rodríguez 10 years ago
parent
commit
03967872ac
3 changed files with 12 additions and 14 deletions
  1. 10 12
      nmie.cc
  2. 1 1
      scattnlay.cpp
  3. 1 1
      setup.py

+ 10 - 12
nmie.cc

@@ -1314,7 +1314,7 @@ namespace nmie {
     // Calculate angular functions Pi and Tau
     calcPiTau(std::cos(Theta), Pi, Tau);
 
-    for (int n = nmax_ - 1; n >= 0; n--) {
+    for (int n = nmax_ - 2; n >= 0; n--) {
       int n1 = n + 1;
       double rn = static_cast<double>(n1);
 
@@ -1372,17 +1372,15 @@ namespace nmie {
   void MultiLayerMie::RunFieldCalculation() {
     // Calculate external scattering coefficients an_ and bn_
     ExternalScattCoeffs();
-    printf("an_\n");
-    for (auto a: an_) printf("%10.5er%+10.5ei  ",std::real(a), std::imag(a));
-    printf("\nbn_\n");
-    for (auto a: bn_) printf("%10.5er%+10.5ei  ",std::real(a), std::imag(a));
-
-    calc_an_bn_bulk(an_, bn_, size_param_.back(), refractive_index_.back());
-    printf("\nbulk an_\n");
-    for (auto a: an_) printf("%10.5er%+10.5ei  ",std::real(a), std::imag(a));
-    printf("\nbulk bn_\n");
-    for (auto a: bn_) printf("%10.5er%+10.5ei  ",std::real(a), std::imag(a));
-    printf("\nsize param: %g\n", size_param_.back());
+
+    std::vector<std::complex<double> > an1(nmax_), bn1(nmax_);
+
+    calc_an_bn_bulk(an1, bn1, size_param_.back(), refractive_index_.back());
+
+    for (int n = 0; n < nmax_; n++) {
+      printf("an_[%i] = %10.5er%+10.5ei;  an_bulk_[%i] = %10.5er%+10.5ei\n", n, std::real(an_[n]), std::imag(an_[n]), n, std::real(an1[n]), std::imag(an1[n]));
+      printf("bn_[%i] = %10.5er%+10.5ei;  bn_bulk_[%i] = %10.5er%+10.5ei\n", n, std::real(bn_[n]), std::imag(bn_[n]), n, std::real(bn1[n]), std::imag(bn1[n]));
+    }
 
     // Calculate internal scattering coefficients aln_,  bln_, cln_, and dln_
     InternalScattCoeffs();

+ 1 - 1
scattnlay.cpp

@@ -1,4 +1,4 @@
-/* Generated by Cython 0.20.1post0 (Debian 0.20.1+git90-g0e6e38e-1ubuntu2) on Tue Apr 14 15:24:18 2015 */
+/* Generated by Cython 0.20.1post0 (Debian 0.20.1+git90-g0e6e38e-1ubuntu2) on Wed Apr 15 19:02:11 2015 */
 
 #define PY_SSIZE_T_CLEAN
 #ifndef CYTHON_USE_PYLONG_INTERNALS

+ 1 - 1
setup.py

@@ -53,7 +53,7 @@ O. Pena, U. Pal, Comput. Phys. Commun. 180 (2009) 2348-2354.""",
       license = 'GPL',
       platforms = 'any',
       ext_modules = [Extension("scattnlay",
-                               ["nmie.cc", "py_nmie.cc", "scattnlay.cpp"],
+                               ["nmie.cc", "bessel.cc", "py_nmie.cc", "scattnlay.cpp"],
                                language = "c++",
                                include_dirs = [np.get_include()])], 
       extra_compile_args=['-std=c++11']