Kaynağa Gözat

Merge branch 'master' of github.com:ovidiopr/scattnlay

Konstantin Ladutenko 6 yıl önce
ebeveyn
işleme
9b1ee9ce27

+ 7 - 3
COPYING

@@ -1,5 +1,5 @@
-    Copyright (C) 2009-2017 Ovidio Peña <ovidio@bytesfall.com>
-    Copyright (C) 2013-2017 Konstantin Ladutenko <kostyfisik@gmail.com>
+    Copyright (C) 2009-2018 Ovidio Peña <ovidio@bytesfall.com>
+    Copyright (C) 2013-2018 Konstantin Ladutenko <kostyfisik@gmail.com>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -13,10 +13,14 @@
 
     The only additional remark is that we expect that all publications
     describing work using this software, or all commercial products
-    using it, cite the following reference:
+    using it, cite at least one of the following references:
     [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
         a multilayered sphere," Computer Physics Communications,
         vol. 180, Nov. 2009, pp. 2348-2354.
+    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+        calculation of electromagnetic near-field for a multilayered
+        sphere," Computer Physics Communications, vol. 214, May 2017,
+        pp. 225-230.
 
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.

+ 19 - 13
Makefile

@@ -2,10 +2,11 @@ PYTHON=`which python`
 CYTHON=`which cython`
 DESTDIR=/
 PROJECT=python-scattnlay
-VERSION=2.1
+VERSION=2.2
 BUILDIR=$(CURDIR)/debian/$(PROJECT)
 SRCDIR=$(CURDIR)/src
 MULTIPREC=100
+CXX_NMIE_HEADERS=$(SRCDIR)/nmie.hpp $(SRCDIR)/nmie-impl.hpp $(SRCDIR)/nmie-precision.hpp
 
 all:
 	@echo "make source - Create source package for Python extension"
@@ -22,13 +23,13 @@ all:
 source:
 	$(PYTHON) setup.py sdist $(COMPILE) --dist-dir=../
 
-cython: scattnlay.pyx
+cython: $(SRCDIR)/scattnlay.pyx
     # create c++ code for double precision module
-	$(CYTHON) --cplus scattnlay.pyx -o $(SRCDIR)/scattnlay.cpp
+	$(CYTHON) --cplus $(SRCDIR)/scattnlay.pyx -o $(SRCDIR)/scattnlay.cpp
 	# create c++ code for MP module
-	ln -s scattnlay.pyx scattnlay_mp.pyx
-	$(CYTHON) --cplus scattnlay_mp.pyx -o $(SRCDIR)/scattnlay_mp.cpp
-	rm scattnlay_mp.pyx
+	ln -s $(SRCDIR)/scattnlay.pyx $(SRCDIR)/scattnlay_mp.pyx
+	$(CYTHON) --cplus $(SRCDIR)/scattnlay_mp.pyx -o $(SRCDIR)/scattnlay_mp.cpp
+	rm $(SRCDIR)/scattnlay_mp.pyx
 
 python_ext: $(SRCDIR)/nmie.cc $(SRCDIR)/py_nmie.cc $(SRCDIR)/scattnlay.cpp $(SRCDIR)/scattnlay_mp.cpp
 	$(PYTHON) setup.py build_ext --inplace
@@ -50,13 +51,18 @@ builddeb:
 	# build the package
 	dpkg-buildpackage -i -I -rfakeroot
 
-standalone: $(SRCDIR)/farfield.cc $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc
-    # create standalone programs with DP
-	c++ -DNDEBUG -O2 -Wall -std=c++11 $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc  -lm -o ../scattnlay
-	c++ -DNDEBUG -O2 -Wall -std=c++11 $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc  -lm -o ../fieldnlay
-	# create standalone programs with MP
-	c++ -DNDEBUG -DMULTI_PRECISION=$(MULTIPREC) -O2 -Wall -std=c++11 $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc  -lm -o ../scattnlay-mp
-	c++ -DNDEBUG -DMULTI_PRECISION=$(MULTIPREC) -O2 -Wall -std=c++11 $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc  -lm -o ../fieldnlay-mp
+standalone: scattnlay fieldnlay scattnlay-mp fieldnlay-mp
+
+# standalone programs with DP
+scattnlay: $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc $(CXX_NMIE_HEADERS)
+	$(CXX) -DNDEBUG -O2 -Wall -std=c++11 $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc  -lm -o scattnlay $(CXXFLAGS) $(LDFLAGS)
+fieldnlay: $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc $(CXX_NMIE_HEADERS)
+	$(CXX) -DNDEBUG -O2 -Wall -std=c++11 $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc  -lm -o fieldnlay $(CXXFLAGS) $(LDFLAGS)
+# standalone programs with MP
+scattnlay-mp: $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc $(CXX_NMIE_HEADERS)
+	$(CXX) -DNDEBUG -DMULTI_PRECISION=$(MULTIPREC) -O2 -Wall -std=c++11 $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc  -lm -o scattnlay-mp $(CXXFLAGS) $(LDFLAGS)
+fieldnlay-mp: $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc $(CXX_NMIE_HEADERS)
+	$(CXX) -DNDEBUG -DMULTI_PRECISION=$(MULTIPREC) -O2 -Wall -std=c++11 $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc  -lm -o fieldnlay-mp $(CXXFLAGS) $(LDFLAGS)
 
 clean:
 	$(PYTHON) setup.py clean

+ 1 - 1
PKG-INFO

@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: python-scattnlay
-Version: 2.1
+Version: 2.2
 Summary: Calculation of the scattering of EM radiation by a multilayered sphere
 Home-page: http://scattering.sourceforge.net/
 Author: Ovidio Peña Rodríguez

+ 33 - 19
README.md

@@ -1,6 +1,6 @@
 ![output example](/doc/OutputExample.png)
 **Output example:** Field distribution inside layered Si\Ag\Si sphere
-and Poynting vector distribution in Ag sphere with poweflow lines
+and Poynting vector distribution in Ag sphere with powerflow lines
 calculated with Scattnlay (scripts  field-SiAgSi-flow.py and
 field-Ag-flow.py from example section as [revision](https://github.com/ovidiopr/scattnlay/commit/57c7261705a5776f78420c1f486e929517d5f584) ).
 
@@ -75,6 +75,10 @@ and then you simply install the package:
 ``` bash
 sudo apt-get install python-scattnlay
 ```
+You can also install it from PyPi via
+```bash
+sudo pip install python-scattnlay
+```
 
 Use:
 ----
@@ -125,7 +129,7 @@ Scattnlay "Hello world!" example:
 
 ```C++
     try {
-      nmie::MultiLayerMieApplied<double> multi_layer_mie;  
+      nmie::MultiLayerMieApplied<double> multi_layer_mie; 
       multi_layer_mie.AddTargetLayer(core_width, index_Si);
       multi_layer_mie.AddTargetLayer(inner_width, index_Ag);
       multi_layer_mie.AddTargetLayer(outer_width, index_Si);
@@ -148,31 +152,41 @@ The complete `example-minimal.cc` and a bit more complicated
 multiple precision (just include `-DMULTI_PRECISION=200` to use 200
 digits for calculations). 
 
-Papers
-------
+Related papers
+--------------
+
+1. O. Peña and U. Pal, "Scattering of electromagnetic radiation by a
+   multilayered sphere," Comput. Phys. Commun. 180, 2348-2354 (2009).
+   http://dx.doi.org/10.1016/j.cpc.2009.07.010
 
-1. "Scattering of electromagnetic radiation by a multilayered sphere"
-   O. Pena and U. Pal,  Computer Physics Communications, vol. 180,
-   Nov. 2009, pp. 2348-2354. http://dx.doi.org/10.1016/j.cpc.2009.07.010
+2. K. Ladutenko, O. Peña-Rodríguez, I. Melchakova, I. Yagupov and P. Belov,
+   "Reduction of scattering using thin all-dielectric shells designed by
+   stochastic optimizer," J. Appl. Phys. 116, 184508 (2014).
+   http://dx.doi.org/10.1063/1.4900529
 
-2. "Reduction of scattering using thin all-dielectric shells designed by stochastic optimizer"
-   Konstantin Ladutenko, Ovidio Peña-Rodríguez, Irina Melchakova, Ilya
-   Yagupov, and Pavel Belov  J. Appl. Phys., vol. 116, pp. 184508,
-   2014 http://dx.doi.org/10.1063/1.4900529
+3. K. Ladutenko, P. Belov, O. Peña-Rodríguez, A. Mirzaei, A. Miroshnichenko
+   and I. Shadrivov, "Superabsorption of light by nanoparticles,"
+   Nanoscale 7, 18897-18901 (2015).
+   http://dx.doi.org/10.1039/C5NR05468K
 
-3. "Superabsorption of light by nanoparticles" Konstantin Ladutenko,
-   Pavel Belov, Ovidio Peña-Rodríguez, Ali Mirzaei, Andrey
-   E. Miroshnichenko and Ilya V. Shadrivov  Nanoscale, 2015,7,
-   18897-18901 http://dx.doi.org/10.1039/C5NR05468K
+4. K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie calculation
+   of electromagnetic near-field for a multilayered sphere,"
+   Comp. Phys. Comm. 214, 225-230 (2017).
+   http://dx.doi.org/j.cpc.2017.01.017
 
 Acknowledgment
 --------------
 
 We expect that all publications describing work using this software,
-or all commercial products using it, cite the following reference:
-> O. Pena and U. Pal, "Scattering of electromagnetic radiation
-> by a multilayered sphere," Computer Physics Communications,
-> vol. 180, Nov. 2009, pp. 2348-2354.
+or all commercial products using it, cite at least one of the following references:
+> [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation
+>     by a multilayered sphere," Computer Physics Communications,
+>     vol. 180, Nov. 2009, pp. 2348-2354.
+>
+> [2] K. Ladutenko, U. Pal, A. Rivera and O. Peña-Rodríguez, "Mie calculation
+>     of electromagnetic near-field for a multilayered sphere,"
+>     Computer Physics Communications, vol. 214, May 2017, pp. 225-230.
+
 
 License
 -------

+ 5 - 0
debian/changelog

@@ -1,3 +1,8 @@
+python-scattnlay (2.2.0-1) xenial; urgency=low
+
+  * Updated for Xenial Xerus (2.2.0-1)
+ -- Ovidio Peña Rodríguez <ovidio@bytesfall.com>  Thu, 19 Feb 2017 11:44:00 +0100
+
 python-scattnlay (2.1.0-1) xenial; urgency=low
 
   * Updated for Xenial Xerus (2.1.0-1)

+ 7 - 2
debian/copyright

@@ -1,5 +1,5 @@
 This package was debianized by Ovidio Peña Rodríguez
- on Wed, 16 Jan 2017 20:13:44 +0200.
+ on Wed, 19 Feb 2018 11:50:00 +0100.
 
 It was downloaded from https://github.com/ovidiopr/scattnlay
 
@@ -9,7 +9,8 @@ Upstream Author:
 
 Copyright:
 
-    Copyright (C) 2009-2017 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+    Copyright (C) 2009-2018 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+    Copyright (C) 2013-2018 Konstantin Ladutenko <kostyfisik@gmail.com>
 
 License:
 
@@ -29,6 +30,10 @@ License:
     [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
         a multilayered sphere," Computer Physics Communications,
         vol. 180, Nov. 2009, pp. 2348-2354.
+    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+        calculation of electromagnetic near-field for a multilayered
+        sphere," Computer Physics Communications, vol. 214, May 2017,
+        pp. 225-230.
 
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.

+ 1 - 1
debian/watch

@@ -1,2 +1,2 @@
 version=3
-http://sourceforge.net/scattering/python-scattering-(+.+)\.tar\.gz
+https://github.com/ovidiopr/scattnlay/archive/v2\.2\.0\.tar\.gz

+ 85 - 0
examples/optical_force.py

@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+#
+#    Copyright (C) 2009-2017 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+#    Copyright (C) 2013-2017 Konstantin Ladutenko <kostyfisik@gmail.com>
+#
+#    This file is part of scattnlay
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    The only additional remark is that we expect that all publications
+#    describing work using this software, or all commercial products
+#    using it, cite at least one of the following references:
+#    [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
+#        a multilayered sphere," Computer Physics Communications,
+#        vol. 180, Nov. 2009, pp. 2348-2354.
+#    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+#        calculation of electromagnetic near-field for a multilayered
+#        sphere," Computer Physics Communications, vol. 214, May 2017,
+#        pp. 225-230.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This test case calculates the optical force over a silver nanoparticle,
+# as a function of the irradiance and the radius.
+
+from scattnlay import scattnlay
+import numpy as np
+from scipy.constants import pi, c
+
+radius = np.linspace(0.5, 180.0, 360)
+nAg = np.sqrt(-4.0 + 0.7j)
+wl = 400.0
+
+x = np.ones((len(radius), 1), dtype = np.float64)
+x[:, 0] = 2.0*pi*radius/wl
+
+m = np.ones((len(radius), 1), dtype = np.complex128)
+m[:, 0] *= nAg
+
+terms, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2 = scattnlay(x, m)
+F = pi*Qpr*radius*radius/c/1e9
+
+result = np.vstack((radius, 1e11*F, 1e13*F, 1e15*F)).transpose()
+
+try:
+    import matplotlib.pyplot as plt
+
+    plt.figure(1)
+    plt.subplot(311)
+    plt.plot(radius, 1e11*F, 'k', label = '10$^{11}$ W/m$^2$')
+    plt.plot(radius, 1e13*F, 'b', label = '10$^{13}$ W/m$^2$')
+    plt.plot(radius, 1e15*F, 'g', label = '10$^{15}$ W/m$^2$')
+    plt.ylabel('F (nN)')
+    plt.legend(loc = 4)
+    ax = plt.gca()
+    ax.set_yscale('log')
+
+    plt.subplot(312)
+    plt.plot(radius, g, 'r', label = 'g')
+    plt.ylabel('g')
+
+    plt.subplot(313)
+    plt.plot(radius, Qext, 'k', label = 'Q$_{ext}$')
+    plt.plot(radius, Qsca, 'b', label = 'Q$_{sca}$')
+    plt.plot(radius, Qpr, 'g', label = 'Q$_{pr}$')
+    plt.ylabel('Q')
+    plt.legend()
+
+    plt.xlabel('R (nm)')
+    
+    plt.show()
+finally:
+    #np.savetxt("test_force.txt", result, fmt = "%.5e")
+    print result
+

+ 2 - 0
setup.cfg

@@ -0,0 +1,2 @@
+[metadata]
+description-file = README.md

+ 13 - 7
setup.py

@@ -1,10 +1,10 @@
 #!/usr/bin/env python
 # -*- coding: UTF-8 -*-
 #
-#    Copyright (C) 2009-2017 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
-#    Copyright (C) 2013-2017 Konstantin Ladutenko <kostyfisik@gmail.com>
+#    Copyright (C) 2009-2018 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+#    Copyright (C) 2013-2018 Konstantin Ladutenko <kostyfisik@gmail.com>
 #
-#    This file is part of python-scattnlay
+#    This file is part of scattnlay
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -18,20 +18,25 @@
 #
 #    The only additional remark is that we expect that all publications
 #    describing work using this software, or all commercial products
-#    using it, cite the following reference:
-#    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by
+#    using it, cite at least one of the following references:
+#    [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
 #        a multilayered sphere," Computer Physics Communications,
 #        vol. 180, Nov. 2009, pp. 2348-2354.
+#    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+#        calculation of electromagnetic near-field for a multilayered
+#        sphere," Computer Physics Communications, vol. 214, May 2017,
+#        pp. 225-230.
 #
 #    You should have received a copy of the GNU General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-__version__ = '2.1'
+__version__ = '2.2'
 __title__ = 'Calculation of the scattering of EM radiation by a multilayered sphere'
 __mod__ = 'python-scattnlay'
 __author__ = 'Ovidio Peña Rodríguez'
 __email__ = 'ovidio@bytesfall.com'
-__url__ = 'http://scattering.sourceforge.net/'
+__url__ = 'https://github.com/ovidiopr/scattnlay'
+__download_url__ = 'https://github.com/ovidiopr/scattnlay/archive/v2.2.0.tar.gz'
 
 from distutils.core import setup
 from distutils.extension import Extension
@@ -51,6 +56,7 @@ O. Pena, U. Pal, Comput. Phys. Commun. 180 (2009) 2348-2354.""",
       maintainer_email = __email__,
       keywords = ['Mie scattering', 'Multilayered sphere', 'Efficiency factors', 'Cross-sections'],
       url = __url__,
+      download_url = __download_url__,
       license = 'GPL',
       platforms = 'any',
       ext_modules = [Extension("scattnlay",

+ 74 - 0
setup_pb11.py

@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+#
+#    Copyright (C) 2009-2018 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+#    Copyright (C) 2013-2018 Konstantin Ladutenko <kostyfisik@gmail.com>
+#
+#    This file is part of scattnlay
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    The only additional remark is that we expect that all publications
+#    describing work using this software, or all commercial products
+#    using it, cite at least one of the following references:
+#    [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
+#        a multilayered sphere," Computer Physics Communications,
+#        vol. 180, Nov. 2009, pp. 2348-2354.
+#    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+#        calculation of electromagnetic near-field for a multilayered
+#        sphere," Computer Physics Communications, vol. 214, May 2017,
+#        pp. 225-230.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+__version__ = '2.2'
+__title__ = 'Calculation of the scattering of EM radiation by a multilayered sphere'
+__mod__ = 'python-scattnlay'
+__author__ = 'Ovidio Peña Rodríguez'
+__email__ = 'ovidio@bytesfall.com'
+__url__ = 'https://github.com/ovidiopr/scattnlay'
+__download_url__ = 'https://github.com/ovidiopr/scattnlay/archive/v2.2.0.tar.gz'
+
+from distutils.core import setup
+from distutils.extension import Extension
+import numpy as np
+import pybind11 as pb
+
+setup(name = __mod__,
+      version = __version__,
+      description = __title__,
+      long_description="""The Python version of scattnlay, a computer implementation of the algorithm for the calculation of electromagnetic \
+radiation scattering by a multilayered sphere developed by Yang. It has been shown that the program is effective, \
+resulting in very accurate values of scattering efficiencies for a wide range of size parameters, which is a \
+considerable improvement over previous implementations of similar algorithms. For details see: \
+O. Pena, U. Pal, Comput. Phys. Commun. 180 (2009) 2348-2354.""",
+      author = __author__,
+      author_email = __email__,
+      maintainer = __author__,
+      maintainer_email = __email__,
+      keywords = ['Mie scattering', 'Multilayered sphere', 'Efficiency factors', 'Cross-sections'],
+      url = __url__,
+      download_url = __download_url__,
+      license = 'GPL',
+      platforms = 'any',
+      ext_modules = [Extension("scattnlay",
+                               ["src/nmie.cc", "src/pb11_nmie.cc", "src/pb11_wrapper.cc"],
+                               language = "c++",
+                               include_dirs = [np.get_include(), pb.get_include(True)], 
+                               extra_compile_args=['-std=c++11']),
+                     Extension("scattnlay_mp",
+                               ["src/nmie.cc", "src/pb11_nmie.cc", "src/pb11_wrapper_mp.cc"],
+                               language = "c++",
+                               include_dirs = [np.get_include(), pb.get_include(True)], 
+                               extra_compile_args=['-std=c++11', '-DMULTI_PRECISION=100'])]
+)
+

+ 7 - 3
src/farfield.cc

@@ -1,6 +1,6 @@
 //**********************************************************************************//
-//    Copyright (C) 2009-2015  Ovidio Pena <ovidio@bytesfall.com>                   //
-//    Copyright (C) 2013-2015  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
 //                                                                                  //
 //    This file is part of scattnlay                                                //
 //                                                                                  //
@@ -16,10 +16,14 @@
 //                                                                                  //
 //    The only additional remark is that we expect that all publications            //
 //    describing work using this software, or all commercial products               //
-//    using it, cite the following reference:                                       //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 //    You should have received a copy of the GNU General Public License             //
 //    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //

+ 10 - 6
src/nearfield.cc

@@ -1,6 +1,6 @@
 //**********************************************************************************//
-//    Copyright (C) 2009-2015  Ovidio Pena <ovidio@bytesfall.com>                   //
-//    Copyright (C) 2013-2015  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
 //                                                                                  //
 //    This file is part of scattnlay                                                //
 //                                                                                  //
@@ -16,10 +16,14 @@
 //                                                                                  //
 //    The only additional remark is that we expect that all publications            //
 //    describing work using this software, or all commercial products               //
-//    using it, cite the following reference:                                       //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 //    You should have received a copy of the GNU General Public License             //
 //    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //
@@ -230,9 +234,9 @@ int main(int argc, char *argv[]) {
     for (int i = 0; i < nx; i++) {
       for (int j = 0; j < ny; j++) {
         for (int k = 0; k < nz; k++) {
-          Xp[i*ny + j*nz + k] = xi + (double)i*dx;
-          Yp[i*ny + j*nz + k] = yi + (double)j*dy;
-          Zp[i*ny + j*nz + k] = zi + (double)k*dz;
+          Xp[i*ny*nz + j*nz + k] = xi + (double)i*dx;
+          Yp[i*ny*nz + j*nz + k] = yi + (double)j*dy;
+          Zp[i*ny*nz + j*nz + k] = zi + (double)k*dz;
         }
       }
     }

+ 30 - 28
src/nmie-applied-impl.hpp

@@ -1,36 +1,38 @@
 #ifndef SRC_NMIE_APPLIED_IMPL_HPP_
 #define SRC_NMIE_APPLIED_IMPL_HPP_
-///
-/// @file   nmie-applied-impl.hpp
-/// @author Ladutenko Konstantin <kostyfisik at gmail (.) com>
-/// @date   Tue Sep  3 00:38:27 2013
-/// @copyright 2013-2016 Ladutenko Konstantin
-///
-/// nmie is free software: you can redistribute it and/or modify
-/// it under the terms of the GNU General Public License as published by
-/// the Free Software Foundation, either version 3 of the License, or
-/// (at your option) any later version.
-///
-/// nmie-wrapper is distributed in the hope that it will be useful,
-/// but WITHOUT ANY WARRANTY; without even the implied warranty of
-/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-/// GNU General Public License for more details.
-///
-/// You should have received a copy of the GNU General Public License
-/// along with nmie-wrapper.  If not, see <http://www.gnu.org/licenses/>.
-///
-/// nmie uses nmie.c from scattnlay by Ovidio Pena
-/// <ovidio@bytesfall.com> . He has an additional condition to 
-/// his library:
-//    The only additional condition is that we expect that all publications         //
-//    describing  work using this software , or all commercial products             //
-//    using it, cite the following reference:                                       //
+//**********************************************************************************//
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//                                                                                  //
+//    This file is part of scattnlay                                                //
+//                                                                                  //
+//    This program is free software: you can redistribute it and/or modify          //
+//    it under the terms of the GNU General Public License as published by          //
+//    the Free Software Foundation, either version 3 of the License, or             //
+//    (at your option) any later version.                                           //
+//                                                                                  //
+//    This program is distributed in the hope that it will be useful,               //
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of                //
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 //
+//    GNU General Public License for more details.                                  //
+//                                                                                  //
+//    The only additional remark is that we expect that all publications            //
+//    describing work using this software, or all commercial products               //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
-///
-/// @brief  Wrapper class around nMie function for ease of use
-///
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
+//                                                                                  //
+//    You should have received a copy of the GNU General Public License             //
+//    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //
+//                                                                                  //
+//    @brief  Wrapper class around nMie function for ease of use                    //
+//                                                                                  //
+//**********************************************************************************//
 #include "nmie-applied.hpp"
 #include "nmie-precision.hpp"
 #include <array>

+ 30 - 28
src/nmie-applied.cc

@@ -1,34 +1,36 @@
-///
-/// @file   nmie-applied.cc
-/// @author Ladutenko Konstantin <kostyfisik at gmail (.) com>
-/// @date   Tue Sep  3 00:38:27 2013
-/// @copyright 2013,2014,2015 Ladutenko Konstantin
-///
-/// nmie is free software: you can redistribute it and/or modify
-/// it under the terms of the GNU General Public License as published by
-/// the Free Software Foundation, either version 3 of the License, or
-/// (at your option) any later version.
-///
-/// nmie-wrapper is distributed in the hope that it will be useful,
-/// but WITHOUT ANY WARRANTY; without even the implied warranty of
-/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-/// GNU General Public License for more details.
-///
-/// You should have received a copy of the GNU General Public License
-/// along with nmie-wrapper.  If not, see <http://www.gnu.org/licenses/>.
-///
-/// nmie uses nmie.c from scattnlay by Ovidio Pena
-/// <ovidio@bytesfall.com> . He has an additional condition to 
-/// his library:
-//    The only additional condition is that we expect that all publications         //
-//    describing  work using this software , or all commercial products             //
-//    using it, cite the following reference:                                       //
+//**********************************************************************************//
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//                                                                                  //
+//    This file is part of scattnlay                                                //
+//                                                                                  //
+//    This program is free software: you can redistribute it and/or modify          //
+//    it under the terms of the GNU General Public License as published by          //
+//    the Free Software Foundation, either version 3 of the License, or             //
+//    (at your option) any later version.                                           //
+//                                                                                  //
+//    This program is distributed in the hope that it will be useful,               //
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of                //
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 //
+//    GNU General Public License for more details.                                  //
+//                                                                                  //
+//    The only additional remark is that we expect that all publications            //
+//    describing work using this software, or all commercial products               //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
-///
-/// @brief  Wrapper class around nMie function for ease of use
-///
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
+//                                                                                  //
+//    You should have received a copy of the GNU General Public License             //
+//    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //
+//                                                                                  //
+//    @brief  Wrapper class around nMie function for ease of use                    //
+//                                                                                  //
+//**********************************************************************************//
 #include "nmie-applied.hpp"
 #include "nmie-applied-impl.hpp"
 #include "nmie-precision.hpp"

+ 7 - 3
src/nmie-applied.hpp

@@ -1,8 +1,8 @@
 #ifndef SRC_NMIE_APPLIED_HPP_
 #define SRC_NMIE_APPLIED_HPP_
 //**********************************************************************************//
-//    Copyright (C) 2009-2016  Ovidio Pena <ovidio@bytesfall.com>                   //
-//    Copyright (C) 2013-2016  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
 //                                                                                  //
 //    This file is part of scattnlay                                                //
 //                                                                                  //
@@ -18,10 +18,14 @@
 //                                                                                  //
 //    The only additional remark is that we expect that all publications            //
 //    describing work using this software, or all commercial products               //
-//    using it, cite the following reference:                                       //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 //    You should have received a copy of the GNU General Public License             //
 //    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //

+ 25 - 21
src/nmie-impl.hpp

@@ -1,8 +1,8 @@
 #ifndef SRC_NMIE_IMPL_HPP_
 #define SRC_NMIE_IMPL_HPP_
 //**********************************************************************************//
-//    Copyright (C) 2009-2016  Ovidio Pena <ovidio@bytesfall.com>                   //
-//    Copyright (C) 2013-2016  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
 //                                                                                  //
 //    This file is part of scattnlay                                                //
 //                                                                                  //
@@ -18,10 +18,14 @@
 //                                                                                  //
 //    The only additional remark is that we expect that all publications            //
 //    describing work using this software, or all commercial products               //
-//    using it, cite the following reference:                                       //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 //    You should have received a copy of the GNU General Public License             //
 //    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //
@@ -36,6 +40,10 @@
 //    [2] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [3] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 // Hereinafter all equations numbers refer to [2]                                   //
 //**********************************************************************************//
@@ -86,9 +94,7 @@ namespace nmie {
     std::vector<std::complex<ToFloatType> > new_x;
     for (auto element : x) {
       new_x.push_back(std::complex<ToFloatType>(static_cast<ToFloatType>(element.real()),
-						static_cast<ToFloatType>(element.imag())
-						)
-		      );
+                                                static_cast<ToFloatType>(element.imag()) ) );
     }
     return new_x;
   }
@@ -100,10 +106,8 @@ namespace nmie {
     for (auto y : x) {
       new_y.clear();
       for (auto element : y) {
-	new_y.push_back(std::complex<ToFloatType>(static_cast<ToFloatType>(element.real()),
-						static_cast<ToFloatType>(element.imag())
-						  )
-			);
+        new_y.push_back(std::complex<ToFloatType>(static_cast<ToFloatType>(element.real()),
+                                                  static_cast<ToFloatType>(element.imag()) ) );
       }
       new_x.push_back(new_y);
     }
@@ -383,8 +387,8 @@ namespace nmie {
     std::complex<FloatType> Num = (Ha/mL + n/XL)*PsiXL - PsiXLM1;
     std::complex<FloatType> Denom = (Ha/mL + n/XL)*ZetaXL - ZetaXLM1;
     // std::cout<< std::setprecision(100)
-    // 	     << "Ql "	<< PsiXL
-    // 	     <<std::endl;
+    //          << "Ql "        << PsiXL
+    //          << std::endl;
 
 
     return Num/Denom;
@@ -459,7 +463,7 @@ namespace nmie {
 
     // Upward recurrence for PsiZeta and D3 - equations (18a) - (18d)
     PsiZeta_[0] = static_cast<FloatType>(0.5)*(static_cast<FloatType>(1.0) - std::complex<FloatType>(nmm::cos(2.0*z.real()), nmm::sin(2.0*z.real()))
-		       *static_cast<FloatType>(nmm::exp(-2.0*z.imag())));
+                 *static_cast<FloatType>(nmm::exp(-2.0*z.imag())));
     D3[0] = std::complex<FloatType>(0.0, 1.0);
 
     for (int n = 1; n <= nmax_; n++) {
@@ -693,7 +697,7 @@ namespace nmie {
       //*************************************************//
       // Upward recurrence for Q - equations (19a) and (19b)
       Num = std::complex<FloatType>(nmm::exp(-2.0*(z1.imag() - z2.imag())), 0.0)
-	*std::complex<FloatType>(nmm::cos(-2.0*z2.real()) - nmm::exp(-2.0*z2.imag()), nmm::sin(-2.0*z2.real()));
+      *std::complex<FloatType>(nmm::cos(-2.0*z2.real()) - nmm::exp(-2.0*z2.imag()), nmm::sin(-2.0*z2.real()));
       Denom = std::complex<FloatType>(nmm::cos(-2.0*z1.real()) - nmm::exp(-2.0*z1.imag()), nmm::sin(-2.0*z1.real()));
       Q[l][0] = Num/Denom;
 
@@ -976,17 +980,17 @@ namespace nmie {
       if (cabs(aln_[0][n]) < 1e-10) aln_[0][n] = 0.0;
       else {
         //throw std::invalid_argument("Unstable calculation of aln_[0][n]!");
-	std::cout<< std::setprecision(100)
-		 << "Warning: Potentially unstable calculation of aln[0]["
-		 << n << "] = "<< aln_[0][n] <<std::endl;
+        std::cout<< std::setprecision(100)
+                 << "Warning: Potentially unstable calculation of aln[0]["
+                 << n << "] = "<< aln_[0][n] <<std::endl;
         aln_[0][n] = 0.0;
       }
       if (cabs(bln_[0][n]) < 1e-10) bln_[0][n] = 0.0;
       else {
         //throw std::invalid_argument("Unstable calculation of bln_[0][n]!");
-	std::cout<< std::setprecision(100)
-		 << "Warning: Potentially unstable calculation of bln[0]["
-		 << n << "] = "<< bln_[0][n] <<std::endl;
+        std::cout<< std::setprecision(100)
+                 << "Warning: Potentially unstable calculation of bln[0]["
+                 << n << "] = "<< bln_[0][n] <<std::endl;
         bln_[0][n] = 0.0;
       }
     }
@@ -1057,7 +1061,7 @@ namespace nmie {
 
       // Total field in the lth layer: eqs. (1) and (2) in Yang, Appl. Opt., 42 (2003) 1710-1720
       std::complex<FloatType> En = ipow[n1 % 4]
-	*static_cast<FloatType>((rn + rn + 1.0)/(rn*rn + rn));
+      *static_cast<FloatType>((rn + rn + 1.0)/(rn*rn + rn));
       for (int i = 0; i < 3; i++) {
         // electric field E [V m - 1] = EF*E0
         E[i] += En*(cln_[l][n]*M1o1n[i] - c_i*dln_[l][n]*N1e1n[i]

+ 7 - 3
src/nmie-precision.hpp

@@ -1,8 +1,8 @@
 #ifndef SRC_NMIE_PRECISION_H_
 #define SRC_NMIE_PRECISION_H_
 //**********************************************************************************//
-//    Copyright (C) 2009-2015  Ovidio Pena <ovidio@bytesfall.com>                   //
-//    Copyright (C) 2013-2015  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
 //                                                                                  //
 //    This file is part of scattnlay                                                //
 //                                                                                  //
@@ -18,10 +18,14 @@
 //                                                                                  //
 //    The only additional remark is that we expect that all publications            //
 //    describing work using this software, or all commercial products               //
-//    using it, cite the following reference:                                       //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 //    You should have received a copy of the GNU General Public License             //
 //    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //

+ 33 - 9
src/nmie.cc

@@ -1,6 +1,6 @@
 //**********************************************************************************//
-//    Copyright (C) 2009-2015  Ovidio Pena <ovidio@bytesfall.com>                   //
-//    Copyright (C) 2013-2015  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
 //                                                                                  //
 //    This file is part of scattnlay                                                //
 //                                                                                  //
@@ -16,10 +16,14 @@
 //                                                                                  //
 //    The only additional remark is that we expect that all publications            //
 //    describing work using this software, or all commercial products               //
-//    using it, cite the following reference:                                       //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 //    You should have received a copy of the GNU General Public License             //
 //    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //
@@ -34,6 +38,10 @@
 //    [2] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [3] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 // Hereinafter all equations numbers refer to [2]                                   //
 //**********************************************************************************//
@@ -70,7 +78,8 @@ namespace nmie {
   // Return value:                                                                    //
   //   Number of multipolar expansion terms used for the calculations                 //
   //**********************************************************************************//
-  int ScattCoeffs(const unsigned int L, const int pl, std::vector<double>& x, std::vector<std::complex<double> >& m, const int nmax, std::vector<std::complex<double> >& an, std::vector<std::complex<double> >& bn) {
+  int ScattCoeffs(const unsigned int L, const int pl, std::vector<double>& x, std::vector<std::complex<double> >& m,
+                  const int nmax, std::vector<std::complex<double> >& an, std::vector<std::complex<double> >& bn) {
 
     if (x.size() != L || m.size() != L)
         throw std::invalid_argument("Declared number of layers do not fit x and m!");
@@ -125,7 +134,10 @@ namespace nmie {
   // Return value:                                                                    //
   //   Number of multipolar expansion terms used for the calculations                 //
   //**********************************************************************************//
-  int nMie(const unsigned int L, const int pl, std::vector<double>& x, std::vector<std::complex<double> >& m, const unsigned int nTheta, std::vector<double>& Theta, const int nmax, double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo, std::vector<std::complex<double> >& S1, std::vector<std::complex<double> >& S2) {
+  int nMie(const unsigned int L, const int pl, std::vector<double>& x, std::vector<std::complex<double> >& m,
+           const unsigned int nTheta, std::vector<double>& Theta, const int nmax,
+           double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo,
+           std::vector<std::complex<double> >& S1, std::vector<std::complex<double> >& S2) {
 
     if (x.size() != L || m.size() != L)
         throw std::invalid_argument("Declared number of layers do not fit x and m!");
@@ -195,7 +207,10 @@ namespace nmie {
   // Return value:                                                                    //
   //   Number of multipolar expansion terms used for the calculations                 //
   //**********************************************************************************//
-  int nMie(const unsigned int L, std::vector<double>& x, std::vector<std::complex<double> >& m, const unsigned int nTheta, std::vector<double>& Theta, double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo, std::vector<std::complex<double> >& S1, std::vector<std::complex<double> >& S2) {
+  int nMie(const unsigned int L, std::vector<double>& x, std::vector<std::complex<double> >& m,
+           const unsigned int nTheta, std::vector<double>& Theta,
+           double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo,
+           std::vector<std::complex<double> >& S1, std::vector<std::complex<double> >& S2) {
     return nmie::nMie(L, -1, x, m, nTheta, Theta, -1, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2);
   }
 
@@ -227,7 +242,10 @@ namespace nmie {
   // Return value:                                                                    //
   //   Number of multipolar expansion terms used for the calculations                 //
   //**********************************************************************************//
-  int nMie(const unsigned int L, const int pl, std::vector<double>& x, std::vector<std::complex<double> >& m, const unsigned int nTheta, std::vector<double>& Theta, double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo, std::vector<std::complex<double> >& S1, std::vector<std::complex<double> >& S2) {
+  int nMie(const unsigned int L, const int pl, std::vector<double>& x, std::vector<std::complex<double> >& m,
+           const unsigned int nTheta, std::vector<double>& Theta,
+           double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo,
+           std::vector<std::complex<double> >& S1, std::vector<std::complex<double> >& S2) {
     return nmie::nMie(L, pl, x, m, nTheta, Theta, -1, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2);
   }
 
@@ -261,7 +279,10 @@ namespace nmie {
   // Return value:                                                                    //
   //   Number of multipolar expansion terms used for the calculations                 //
   //**********************************************************************************//
-  int nMie(const unsigned int L, std::vector<double>& x, std::vector<std::complex<double> >& m, const unsigned int nTheta, std::vector<double>& Theta, const int nmax, double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo, std::vector<std::complex<double> >& S1, std::vector<std::complex<double> >& S2) {
+  int nMie(const unsigned int L, std::vector<double>& x, std::vector<std::complex<double> >& m,
+           const unsigned int nTheta, std::vector<double>& Theta, const int nmax,
+           double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo,
+           std::vector<std::complex<double> >& S1, std::vector<std::complex<double> >& S2) {
     return nmie::nMie(L, -1, x, m, nTheta, Theta, nmax, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2);
   }
 
@@ -288,7 +309,10 @@ namespace nmie {
   // Return value:                                                                    //
   //   Number of multipolar expansion terms used for the calculations                 //
   //**********************************************************************************//
-  int nField(const unsigned int L, const int pl, const std::vector<double>& x, const std::vector<std::complex<double> >& m, const int nmax, const unsigned int ncoord, const std::vector<double>& Xp_vec, const std::vector<double>& Yp_vec, const std::vector<double>& Zp_vec, std::vector<std::vector<std::complex<double> > >& E, std::vector<std::vector<std::complex<double> > >& H) {
+  int nField(const unsigned int L, const int pl, const std::vector<double>& x, const std::vector<std::complex<double> >& m,
+             const int nmax, const unsigned int ncoord,
+             const std::vector<double>& Xp_vec, const std::vector<double>& Yp_vec, const std::vector<double>& Zp_vec,
+             std::vector<std::vector<std::complex<double> > >& E, std::vector<std::vector<std::complex<double> > >& H) {
     if (x.size() != L || m.size() != L)
       throw std::invalid_argument("Declared number of layers do not fit x and m!");
     if (Xp_vec.size() != ncoord || Yp_vec.size() != ncoord || Zp_vec.size() != ncoord

+ 8 - 4
src/nmie.hpp

@@ -1,8 +1,8 @@
 #ifndef SRC_NMIE_HPP_
 #define SRC_NMIE_HPP_
 //**********************************************************************************//
-//    Copyright (C) 2009-2016  Ovidio Pena <ovidio@bytesfall.com>                   //
-//    Copyright (C) 2013-2016  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
 //                                                                                  //
 //    This file is part of scattnlay                                                //
 //                                                                                  //
@@ -18,16 +18,20 @@
 //                                                                                  //
 //    The only additional remark is that we expect that all publications            //
 //    describing work using this software, or all commercial products               //
-//    using it, cite the following reference:                                       //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 //    You should have received a copy of the GNU General Public License             //
 //    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //
 //**********************************************************************************//
 
-#define VERSION "2.0"
+#define VERSION "2.2"
 #include <array>
 #include <complex>
 #include <cstdlib>

+ 203 - 0
src/pb11_nmie.cc

@@ -0,0 +1,203 @@
+//**********************************************************************************//
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//                                                                                  //
+//    This file is part of scattnlay                                                //
+//                                                                                  //
+//    This program is free software: you can redistribute it and/or modify          //
+//    it under the terms of the GNU General Public License as published by          //
+//    the Free Software Foundation, either version 3 of the License, or             //
+//    (at your option) any later version.                                           //
+//                                                                                  //
+//    This program is distributed in the hope that it will be useful,               //
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of                //
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 //
+//    GNU General Public License for more details.                                  //
+//                                                                                  //
+//    The only additional remark is that we expect that all publications            //
+//    describing work using this software, or all commercial products               //
+//    using it, cite at least one of the following references:                      //
+//    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
+//        a multilayered sphere," Computer Physics Communications,                  //
+//        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
+//                                                                                  //
+//    You should have received a copy of the GNU General Public License             //
+//    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //
+//**********************************************************************************//
+
+#include <complex>
+#include <vector>
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/numpy.h>
+#include <pybind11/complex.h>
+#include <pybind11/stl.h>
+#include "nmie.hpp"
+
+
+namespace py = pybind11;
+
+
+py::tuple scattcoeffs(py::array_t<double, py::array::c_style | py::array::forcecast> x,
+                      py::array_t<std::complex<double>, py::array::c_style | py::array::forcecast> m,
+                      int nmax, int pl)
+{
+  if (x.ndim() != 2)
+    throw std::runtime_error("The size parameter (x) should be 2-D NumPy array.");
+  if (m.ndim() != 2)
+    throw std::runtime_error("The relative refractive index (m) should be 2-D NumPy array.");
+
+
+  std::complex<float> c_zero(0.0, 0.0);
+
+  int num_wvlght = x.shape(0);
+  int num_layers = x.shape(1);
+
+  // allocate std::vector (to pass to the C++ function)
+  std::vector<std::vector<double> > x_cpp(x.size());
+  std::vector<std::vector<std::complex<double> > > m_cpp(m.size());
+
+  // copy py::array -> std::vector
+  std::memcpy(x_cpp.data(), x.data(), x.size()*sizeof(double));
+  std::memcpy(m_cpp.data(), m.data(), m.size()*sizeof(std::complex<double>));
+
+  // create std::vector (to get return from the C++ function)
+  std::vector<int> terms(num_wvlght);
+  std::vector<std::vector<std::complex<double> > > an, bn;
+  an.resize(num_wvlght);
+  bn.resize(num_wvlght);
+  
+  ssize_t max_terms = 0;
+  for (ssize_t i = 0; i < num_wvlght; i++) {
+    terms[i] = nmie::ScattCoeffs(num_layers, pl, x_cpp[i], m_cpp[i], nmax, an[i], bn[i]);
+
+    if (terms[i] > max_terms)
+      max_terms = terms[i];
+  }
+
+  for (ssize_t i = 0; i < num_wvlght; i++) {
+    an[i].resize(max_terms);
+    bn[i].resize(max_terms);
+
+    for (ssize_t j = terms[i]; j < max_terms; j++) {
+      an[i][j] = c_zero;
+      bn[i][j] = c_zero;
+    }
+  }
+
+  return py::make_tuple(terms, an, bn);
+
+}
+
+py::tuple scattnlay(py::array_t<double, py::array::c_style | py::array::forcecast> x,
+                    py::array_t<std::complex<double>, py::array::c_style | py::array::forcecast> m,
+                    py::array_t<double, py::array::c_style | py::array::forcecast> theta,
+                    int nmax, int pl)
+{
+  if (x.ndim() != 2)
+    throw std::runtime_error("The size parameter (x) should be 2-D NumPy array.");
+  if (m.ndim() != 2)
+    throw std::runtime_error("The relative refractive index (m) should be 2-D NumPy array.");
+  if (theta.ndim() != 1)
+    throw std::runtime_error("The scattering angles (theta) should be 1-D NumPy array.");
+
+  int num_wvlght = x.shape(0);
+  int num_layers = x.shape(1);
+  int num_angles = theta.shape(0);
+
+  // allocate std::vector (to pass to the C++ function)
+  std::vector<std::vector<double> > x_cpp(x.size());
+  std::vector<std::vector<std::complex<double> > > m_cpp(m.size());
+  std::vector<double> theta_cpp(theta.size());
+
+  // copy py::array -> std::vector
+  std::memcpy(x_cpp.data(), x.data(), x.size()*sizeof(double));
+  std::memcpy(m_cpp.data(), m.data(), m.size()*sizeof(std::complex<double>));
+  std::memcpy(theta_cpp.data(), theta.data(), theta.size()*sizeof(double));
+
+
+  // create std::vector (to get return from the C++ function)
+  std::vector<int> terms(num_wvlght);
+  std::vector<std::vector<std::complex<double> > > S1, S2;
+  S1.resize(num_wvlght);
+  S2.resize(num_wvlght);
+
+  std::vector<double> Qext(num_wvlght);
+  std::vector<double> Qsca(num_wvlght);
+  std::vector<double> Qabs(num_wvlght);
+  std::vector<double> Qbk(num_wvlght);
+  std::vector<double> Qpr(num_wvlght);
+  std::vector<double> g(num_wvlght);
+  std::vector<double> Albedo(num_wvlght);
+  
+  for (ssize_t i = 0; i < num_wvlght; i++) {
+    S1[i].resize(num_angles);
+    S2[i].resize(num_angles);
+
+    terms[i] = nmie::nMie(num_layers, pl, x_cpp[i], m_cpp[i], num_angles, theta_cpp, nmax,
+                          &Qext[i], &Qsca[i], &Qabs[i], &Qbk[i], &Qpr[i], &g[i], &Albedo[i],
+                          S1[i], S2[i]);
+  }
+
+  return py::make_tuple(terms, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2);
+}
+
+py::tuple fieldnlay(py::array_t<double, py::array::c_style | py::array::forcecast> x,
+                    py::array_t<std::complex<double>, py::array::c_style | py::array::forcecast> m,
+                    py::array_t<double, py::array::c_style | py::array::forcecast> coords,
+                    int nmax, int pl)
+{
+  if (x.ndim() != 2)
+    throw std::runtime_error("The size parameter (x) should be 2-D NumPy array.");
+  if (m.ndim() != 2)
+    throw std::runtime_error("The relative refractive index (m) should be 2-D NumPy array.");
+  if (coords.ndim() != 2)
+    throw std::runtime_error("The coordinates should be 2-D NumPy array.");
+
+
+  int num_wvlght = x.shape(0);
+  int num_layers = x.shape(1);
+  int num_points = coords.shape(0);
+
+  // allocate std::vector (to pass to the C++ function)
+  std::vector<std::vector<double> > x_cpp(x.size());
+  std::vector<std::vector<std::complex<double> > > m_cpp(m.size());
+  std::vector<double> Xc(coords.size()/3);
+  std::vector<double> Yc(coords.size()/3);
+  std::vector<double> Zc(coords.size()/3);
+
+  // copy py::array -> std::vector
+  std::memcpy(x_cpp.data(), x.data(), x.size()*sizeof(double));
+  std::memcpy(m_cpp.data(), m.data(), m.size()*sizeof(std::complex<double>));
+  std::memcpy(Xc.data(), coords.data(), coords.size()*sizeof(double)/3);
+  std::memcpy(Yc.data(), coords.data() + coords.size()*sizeof(double)/3, coords.size()*sizeof(double)/3);
+  std::memcpy(Zc.data(), coords.data() + 2*coords.size()*sizeof(double)/3, coords.size()*sizeof(double)/3);
+
+
+  // create std::vector (to get return from the C++ function)
+  std::vector<int> terms(num_wvlght);
+  std::vector<std::vector<std::vector<std::complex<double> > > > E, H;
+  E.resize(num_wvlght);
+  H.resize(num_wvlght);
+
+  for (ssize_t i = 0; i < num_wvlght; i++) {
+    E[i].resize(num_points);
+    H[i].resize(num_points);
+
+    for (int j = 0; j < 3; j++) {
+      E[i][j].resize(3);
+      H[i][j].resize(3);
+    }
+
+    terms[i] = nmie::nField(num_layers, pl, x_cpp[i], m_cpp[i], nmax, num_points, Xc, Yc, Zc, E[i], H[i]);
+  }
+
+  return py::make_tuple(terms, E, H);
+}
+

+ 56 - 0
src/pb11_nmie.hpp

@@ -0,0 +1,56 @@
+//**********************************************************************************//
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//                                                                                  //
+//    This file is part of scattnlay                                                //
+//                                                                                  //
+//    This program is free software: you can redistribute it and/or modify          //
+//    it under the terms of the GNU General Public License as published by          //
+//    the Free Software Foundation, either version 3 of the License, or             //
+//    (at your option) any later version.                                           //
+//                                                                                  //
+//    This program is distributed in the hope that it will be useful,               //
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of                //
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 //
+//    GNU General Public License for more details.                                  //
+//                                                                                  //
+//    The only additional remark is that we expect that all publications            //
+//    describing work using this software, or all commercial products               //
+//    using it, cite at least one of the following references:                      //
+//    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
+//        a multilayered sphere," Computer Physics Communications,                  //
+//        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
+//                                                                                  //
+//    You should have received a copy of the GNU General Public License             //
+//    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //
+//**********************************************************************************//
+
+#include <complex>
+#include <vector>
+#include <pybind11/pybind11.h>
+#include <pybind11/numpy.h>
+
+
+namespace py = pybind11;
+
+
+py::tuple scattcoeffs(py::array_t<double, py::array::c_style | py::array::forcecast> x,
+                      py::array_t<std::complex<double>, py::array::c_style | py::array::forcecast> m,
+                      int nmax, int pl);
+
+
+py::tuple scattnlay(py::array_t<double, py::array::c_style | py::array::forcecast> x,
+                    py::array_t<std::complex<double>, py::array::c_style | py::array::forcecast> m,
+                    py::array_t<double, py::array::c_style | py::array::forcecast> theta,
+                    int nmax, int pl);
+
+
+py::tuple fieldnlay(py::array_t<double, py::array::c_style | py::array::forcecast> x,
+                    py::array_t<std::complex<double>, py::array::c_style | py::array::forcecast> m,
+                    py::array_t<double, py::array::c_style | py::array::forcecast> coords,
+                    int nmax, int pl);
+

+ 22 - 0
src/pb11_wrapper.cc

@@ -0,0 +1,22 @@
+#include <pybind11/pybind11.h>
+#include "pb11_nmie.hpp"
+
+namespace py = pybind11;
+
+// wrap as Python module
+PYBIND11_MODULE(scattnlay, m)
+{
+  m.doc() = "The Python version of scattnlay";
+
+  m.def("scattcoeffs", &scattcoeffs,
+        "Calculate the scattering coefficients, required to calculate both the near- and far-field parameters.",
+        py::arg("x"), py::arg("m"), py::arg("nmax") = -1, py::arg("pl") = -1);
+
+  m.def("scattnlay", &scattnlay,
+        "Calculate the scattering parameters and amplitudes.",
+        py::arg("x"), py::arg("m"), py::arg("theta") = py::array_t<double>(0), py::arg("nmax") = -1, py::arg("pl") = -1);
+
+  m.def("fieldnlay", &fieldnlay,
+        "Calculate the complex electric and magnetic field in the surroundings and inside the particle.",
+        py::arg("x"), py::arg("m"), py::arg("coords"), py::arg("nmax") = -1, py::arg("pl") = -1);
+}

+ 22 - 0
src/pb11_wrapper_mp.cc

@@ -0,0 +1,22 @@
+#include <pybind11/pybind11.h>
+#include "pb11_nmie.hpp"
+
+namespace py = pybind11;
+
+// wrap as Python module
+PYBIND11_MODULE(scattnlay_mp, m)
+{
+  m.doc() = "The Python version of scattnlay";
+
+  m.def("scattcoeffs", &scattcoeffs,
+        "Calculate the scattering coefficients, required to calculate both the near- and far-field parameters.",
+        py::arg("x"), py::arg("m"), py::arg("nmax") = -1, py::arg("pl") = -1);
+
+  m.def("scattnlay", &scattnlay,
+        "Calculate the scattering parameters and amplitudes.",
+        py::arg("x"), py::arg("m"), py::arg("theta") = py::array_t<double>(0), py::arg("nmax") = -1, py::arg("pl") = -1);
+
+  m.def("fieldnlay", &fieldnlay,
+        "Calculate the complex electric and magnetic field in the surroundings and inside the particle.",
+        py::arg("x"), py::arg("m"), py::arg("coords"), py::arg("nmax") = -1, py::arg("pl") = -1);
+}

+ 7 - 3
src/py_nmie.cc

@@ -1,6 +1,6 @@
 //**********************************************************************************//
-//    Copyright (C) 2009-2015  Ovidio Pena <ovidio@bytesfall.com>                   //
-//    Copyright (C) 2013-2015  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
 //                                                                                  //
 //    This file is part of scattnlay                                                //
 //                                                                                  //
@@ -16,10 +16,14 @@
 //                                                                                  //
 //    The only additional remark is that we expect that all publications            //
 //    describing work using this software, or all commercial products               //
-//    using it, cite the following reference:                                       //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 //    You should have received a copy of the GNU General Public License             //
 //    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //

+ 7 - 3
src/py_nmie.h

@@ -1,6 +1,6 @@
 //**********************************************************************************//
-//    Copyright (C) 2009-2015  Ovidio Pena <ovidio@bytesfall.com>                   //
-//    Copyright (C) 2013-2015  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
 //                                                                                  //
 //    This file is part of scattnlay                                                //
 //                                                                                  //
@@ -16,10 +16,14 @@
 //                                                                                  //
 //    The only additional remark is that we expect that all publications            //
 //    describing work using this software, or all commercial products               //
-//    using it, cite the following reference:                                       //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 //    You should have received a copy of the GNU General Public License             //
 //    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //

Dosya farkı çok büyük olduğundan ihmal edildi
+ 161 - 161
src/scattnlay.cpp


+ 70 - 5
scattnlay.pyx → src/scattnlay.pyx

@@ -1,7 +1,7 @@
-#    Copyright (C) 2009-2017 Ovidio Pena <ovidio@bytesfall.com>
-#    Copyright (C) 2013-2017 Konstantin Ladutenko <kostyfisik@gmail.com>
+#    Copyright (C) 2009-2018 Ovidio Pena <ovidio@bytesfall.com>
+#    Copyright (C) 2013-2018 Konstantin Ladutenko <kostyfisik@gmail.com>
 #
-#    This file is part of python-scattnlay
+#    This file is part of scattnlay
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -15,10 +15,14 @@
 #
 #    The only additional remark is that we expect that all publications
 #    describing work using this software, or all commercial products
-#    using it, cite the following reference:
-#    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by
+#    using it, cite at least one of the following references:
+#    [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
 #        a multilayered sphere," Computer Physics Communications,
 #        vol. 180, Nov. 2009, pp. 2348-2354.
+#    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+#        calculation of electromagnetic near-field for a multilayered
+#        sphere," Computer Physics Communications, vol. 214, May 2017,
+#        pp. 225-230.
 #
 #    You should have received a copy of the GNU General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
@@ -47,6 +51,24 @@ cdef extern from "py_nmie.h":
     cdef int nField(int L, int pl, vector[double] x, vector[complex] m, int nmax, int nCoords, vector[double] Xp, vector[double] Yp, vector[double] Zp, double Erx[], double Ery[], double Erz[], double Eix[], double Eiy[], double Eiz[], double Hrx[], double Hry[], double Hrz[], double Hix[], double Hiy[], double Hiz[])
 
 def scattcoeffs(np.ndarray[np.float64_t, ndim = 2] x, np.ndarray[np.complex128_t, ndim = 2] m, np.int_t nmax, np.int_t pl = -1):
+    """
+    scattcoeffs(x, m[, nmax, pl])
+
+    Calculate the scattering coefficients required to calculate both the
+    near- and far-field parameters.
+
+        x: Size parameters (2D ndarray)
+        m: Relative refractive indices (2D ndarray)
+        nmax: Maximum number of multipolar expansion terms to be used for the
+              calculations. Only use it if you know what you are doing, otherwise
+              set this parameter to -1 and the function will calculate it.
+        pl: Index of PEC layer. If there is none just send -1
+
+    Returns: (terms, an, bn)
+    with
+        terms: Number of multipolar expansion terms used for the calculations
+        an, bn: Complex scattering coefficients
+    """
     cdef Py_ssize_t i
 
     cdef np.ndarray[np.int_t, ndim = 1] terms = np.zeros(x.shape[0], dtype = np.int)
@@ -73,6 +95,31 @@ def scattcoeffs(np.ndarray[np.float64_t, ndim = 2] x, np.ndarray[np.complex128_t
     return terms, an, bn
 
 def scattnlay(np.ndarray[np.float64_t, ndim = 2] x, np.ndarray[np.complex128_t, ndim = 2] m, np.ndarray[np.float64_t, ndim = 1] theta = np.zeros(0, dtype = np.float64), np.int_t nmax = -1, np.int_t pl = -1):
+    """
+    scattnlay(x, m[, theta, nmax, pl])
+
+    Calculate the actual scattering parameters and amplitudes.
+
+        x: Size parameters (2D ndarray)
+        m: Relative refractive indices (2D ndarray)
+        theta: Scattering angles where the scattering amplitudes will be
+               calculated (optional, 1D ndarray)
+        nmax: Maximum number of multipolar expansion terms to be used for the
+              calculations. Only use it if you know what you are doing.
+        pl: Index of PEC layer.
+
+    Returns: (terms, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2)
+    with
+        terms: Number of multipolar expansion terms used for the calculations
+        Qext: Efficiency factor for extinction
+        Qsca: Efficiency factor for scattering
+        Qabs: Efficiency factor for absorption (Qabs = Qext - Qsca)
+        Qbk: Efficiency factor for backscattering
+        Qpr: Efficiency factor for the radiation pressure
+        g: Asymmetry factor (g = (Qext-Qpr)/Qsca)
+        Albedo: Single scattering albedo (Albedo = Qsca/Qext)
+        S1, S2: Complex scattering amplitudes
+    """
     cdef Py_ssize_t i
 
     cdef np.ndarray[np.int_t, ndim = 1] terms = np.zeros(x.shape[0], dtype = np.int)
@@ -107,6 +154,24 @@ def scattnlay(np.ndarray[np.float64_t, ndim = 2] x, np.ndarray[np.complex128_t,
     return terms, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2
 
 def fieldnlay(np.ndarray[np.float64_t, ndim = 2] x, np.ndarray[np.complex128_t, ndim = 2] m, np.ndarray[np.float64_t, ndim = 2] coords, np.int_t nmax = -1, np.int_t pl = -1):
+    """
+    fieldnlay(x, m, coords[, theta, nmax, pl])
+
+    Calculate the actual scattering parameters and amplitudes.
+
+        x: Size parameters (2D ndarray)
+        m: Relative refractive indices (2D ndarray)
+        coords: Array containing all coordinates where the complex electric
+                and magnetic fields will be calculated (2D ndarray)
+        nmax: Maximum number of multipolar expansion terms to be used for the
+              calculations. Only use it if you know what you are doing.
+        pl: Index of PEC layer.
+
+    Returns: (terms, E, H)
+    with
+        terms: Number of multipolar expansion terms used for the calculations
+        E, H: Complex electric and magnetic field at the provided coordinates
+    """
     cdef Py_ssize_t i
 
     cdef np.ndarray[np.int_t, ndim = 1] terms = np.zeros(x.shape[0], dtype = np.int)

Dosya farkı çok büyük olduğundan ihmal edildi
+ 161 - 161
src/scattnlay_mp.cpp


+ 7 - 3
src/shell-generator.cc

@@ -1,6 +1,6 @@
 //**********************************************************************************//
-//    Copyright (C) 2009-2016  Ovidio Pena <ovidio@bytesfall.com>                   //
-//    Copyright (C) 2013-2016  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
 //                                                                                  //
 //    This file is part of scattnlay                                                //
 //                                                                                  //
@@ -16,10 +16,14 @@
 //                                                                                  //
 //    The only additional remark is that we expect that all publications            //
 //    describing work using this software, or all commercial products               //
-//    using it, cite the following reference:                                       //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 //    You should have received a copy of the GNU General Public License             //
 //    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //

+ 7 - 3
src/shell-generator.hpp

@@ -1,8 +1,8 @@
 #ifndef SRC_SHELL_GENERATOR_H_
 #define SRC_SHELL_GENERATOR_H_
 //**********************************************************************************//
-//    Copyright (C) 2009-2016  Ovidio Pena <ovidio@bytesfall.com>                   //
-//    Copyright (C) 2013-2016  Konstantin Ladutenko <kostyfisik@gmail.com>          //
+//    Copyright (C) 2009-2018  Ovidio Pena <ovidio@bytesfall.com>                   //
+//    Copyright (C) 2013-2018  Konstantin Ladutenko <kostyfisik@gmail.com>          //
 //                                                                                  //
 //    This file is part of scattnlay                                                //
 //                                                                                  //
@@ -18,10 +18,14 @@
 //                                                                                  //
 //    The only additional remark is that we expect that all publications            //
 //    describing work using this software, or all commercial products               //
-//    using it, cite the following reference:                                       //
+//    using it, cite at least one of the following references:                      //
 //    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by           //
 //        a multilayered sphere," Computer Physics Communications,                  //
 //        vol. 180, Nov. 2009, pp. 2348-2354.                                       //
+//    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie              //
+//        calculation of electromagnetic near-field for a multilayered              //
+//        sphere," Computer Physics Communications, vol. 214, May 2017,             //
+//        pp. 225-230.                                                              //
 //                                                                                  //
 //    You should have received a copy of the GNU General Public License             //
 //    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //

+ 7 - 3
tests/python/scattPEC.py

@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: UTF-8 -*-
 #
-#    Copyright (C) 2009-2015 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+#    Copyright (C) 2009-2017 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
 #
 #    This file is part of python-scattnlay
 #
@@ -17,10 +17,14 @@
 #
 #    The only additional remark is that we expect that all publications
 #    describing work using this software, or all commercial products
-#    using it, cite the following reference:
-#    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by
+#    using it, cite at least one of the following references:
+#    [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
 #        a multilayered sphere," Computer Physics Communications,
 #        vol. 180, Nov. 2009, pp. 2348-2354.
+#    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+#        calculation of electromagnetic near-field for a multilayered
+#        sphere," Computer Physics Communications, vol. 214, May 2017,
+#        pp. 225-230.
 #
 #    You should have received a copy of the GNU General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.

+ 30 - 0
tests/python/scattSiO2.py

@@ -1,4 +1,34 @@
 #!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+#
+#    Copyright (C) 2009-2017 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+#    Copyright (C) 2013-2017 Konstantin Ladutenko <kostyfisik@gmail.com>
+#
+#    This file is part of scattnlay
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    The only additional remark is that we expect that all publications
+#    describing work using this software, or all commercial products
+#    using it, cite at least one of the following references:
+#    [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
+#        a multilayered sphere," Computer Physics Communications,
+#        vol. 180, Nov. 2009, pp. 2348-2354.
+#    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+#        calculation of electromagnetic near-field for a multilayered
+#        sphere," Computer Physics Communications, vol. 214, May 2017,
+#        pp. 225-230.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # This test case calculates the differential scattering
 # cross section for different x values of a SiO2 sphere

+ 8 - 4
tests/python/test01-wrapper.py

@@ -1,9 +1,9 @@
 #!/usr/bin/env python
 # -*- coding: UTF-8 -*-
 #
-#    Copyright (C) 2009-2015 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+#    Copyright (C) 2009-2017 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
 #
-#    This file is part of python-scattnlay
+#    This file is part of scattnlay
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -17,10 +17,14 @@
 #
 #    The only additional remark is that we expect that all publications
 #    describing work using this software, or all commercial products
-#    using it, cite the following reference:
-#    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by
+#    using it, cite at least one of the following references:
+#    [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
 #        a multilayered sphere," Computer Physics Communications,
 #        vol. 180, Nov. 2009, pp. 2348-2354.
+#    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+#        calculation of electromagnetic near-field for a multilayered
+#        sphere," Computer Physics Communications, vol. 214, May 2017,
+#        pp. 225-230.
 #
 #    You should have received a copy of the GNU General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.

+ 7 - 3
tests/python/test01.py

@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: UTF-8 -*-
 #
-#    Copyright (C) 2009-2015 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+#    Copyright (C) 2009-2017 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
 #
 #    This file is part of python-scattnlay
 #
@@ -17,10 +17,14 @@
 #
 #    The only additional remark is that we expect that all publications
 #    describing work using this software, or all commercial products
-#    using it, cite the following reference:
-#    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by
+#    using it, cite at least one of the following references:
+#    [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
 #        a multilayered sphere," Computer Physics Communications,
 #        vol. 180, Nov. 2009, pp. 2348-2354.
+#    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+#        calculation of electromagnetic near-field for a multilayered
+#        sphere," Computer Physics Communications, vol. 214, May 2017,
+#        pp. 225-230.
 #
 #    You should have received a copy of the GNU General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.

+ 8 - 4
tests/python/test02.py

@@ -1,9 +1,9 @@
 #!/usr/bin/env python
 # -*- coding: UTF-8 -*-
 #
-#    Copyright (C) 2009-2015 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+#    Copyright (C) 2009-2017 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
 #
-#    This file is part of python-scattnlay
+#    This file is part of scattnlay
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -17,10 +17,14 @@
 #
 #    The only additional remark is that we expect that all publications
 #    describing work using this software, or all commercial products
-#    using it, cite the following reference:
-#    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by
+#    using it, cite at least one of the following references:
+#    [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
 #        a multilayered sphere," Computer Physics Communications,
 #        vol. 180, Nov. 2009, pp. 2348-2354.
+#    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+#        calculation of electromagnetic near-field for a multilayered
+#        sphere," Computer Physics Communications, vol. 214, May 2017,
+#        pp. 225-230.
 #
 #    You should have received a copy of the GNU General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.

+ 8 - 4
tests/python/test04.py

@@ -1,9 +1,9 @@
 #!/usr/bin/env python
 # -*- coding: UTF-8 -*-
 #
-#    Copyright (C) 2009-2015 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+#    Copyright (C) 2009-2017 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
 #
-#    This file is part of python-scattnlay
+#    This file is part of scattnlay
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -17,10 +17,14 @@
 #
 #    The only additional remark is that we expect that all publications
 #    describing work using this software, or all commercial products
-#    using it, cite the following reference:
-#    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by
+#    using it, cite at least one of the following references:
+#    [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
 #        a multilayered sphere," Computer Physics Communications,
 #        vol. 180, Nov. 2009, pp. 2348-2354.
+#    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+#        calculation of electromagnetic near-field for a multilayered
+#        sphere," Computer Physics Communications, vol. 214, May 2017,
+#        pp. 225-230.
 #
 #    You should have received a copy of the GNU General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.

+ 8 - 4
tests/python/test04_field.py

@@ -1,9 +1,9 @@
 #!/usr/bin/env python
 # -*- coding: UTF-8 -*-
 #
-#    Copyright (C) 2009-2015 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+#    Copyright (C) 2009-2017 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
 #
-#    This file is part of python-scattnlay
+#    This file is part of scattnlay
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -17,10 +17,14 @@
 #
 #    The only additional remark is that we expect that all publications
 #    describing work using this software, or all commercial products
-#    using it, cite the following reference:
-#    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by
+#    using it, cite at least one of the following references:
+#    [1] O. Peña and U. Pal, "Scattering of electromagnetic radiation by
 #        a multilayered sphere," Computer Physics Communications,
 #        vol. 180, Nov. 2009, pp. 2348-2354.
+#    [2] K. Ladutenko, U. Pal, A. Rivera, and O. Peña-Rodríguez, "Mie
+#        calculation of electromagnetic near-field for a multilayered
+#        sphere," Computer Physics Communications, vol. 214, May 2017,
+#        pp. 225-230.
 #
 #    You should have received a copy of the GNU General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor