Переглянути джерело

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

Konstantin Ladutenko 9 роки тому
батько
коміт
1658e8ab72
8 змінених файлів з 37 додано та 30 видалено
  1. 1 1
      Makefile
  2. 1 1
      PKG-INFO
  3. 1 1
      debian/changelog
  4. 6 0
      examples/field-nanoshell.py
  5. 1 1
      setup.py
  6. 1 1
      setup_cython.py
  7. 10 10
      src/nmie.cc
  8. 16 15
      src/nmie.h

+ 1 - 1
Makefile

@@ -2,7 +2,7 @@ PYTHON=`which python`
 CYTHON=`which cython`
 DESTDIR=/
 PROJECT=python-scattnlay
-VERSION=2.0.0
+VERSION=2.0
 BUILDIR=$(CURDIR)/debian/$(PROJECT)
 SRCDIR=$(CURDIR)/src
 

+ 1 - 1
PKG-INFO

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

+ 1 - 1
debian/changelog

@@ -1,4 +1,4 @@
-python-scattnlay (2.0.0-1) trusty; urgency=low
+python-scattnlay (2.0-1) trusty; urgency=low
 
   * Updated for Utopic Unicorn
 

+ 6 - 0
examples/field-nanoshell.py

@@ -35,6 +35,7 @@
 
 from scattnlay import fieldnlay
 import numpy as np
+import time
 
 n1 = 1.53413
 n2 = 0.565838 + 7.23262j
@@ -62,8 +63,13 @@ coordZ = np.zeros(npts*npts, dtype = np.float64)
 
 coord = np.vstack((coordX, coordY, coordZ)).transpose()
 
+start_time = time.time()
+
 terms, E, H = fieldnlay(x, m, coord)
 
+elapsed_time = time.time() - start_time
+print "Time: ", elapsed_time
+
 Er = np.absolute(E)
 
 # |E|/|Eo|

+ 1 - 1
setup.py

@@ -26,7 +26,7 @@
 #    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.0.0'
+__version__ = '2.0'
 __title__ = 'Calculation of the scattering of EM radiation by a multilayered sphere'
 __mod__ = 'python-scattnlay'
 __author__ = 'Ovidio Peña Rodríguez'

+ 1 - 1
setup_cython.py

@@ -26,7 +26,7 @@
 #    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.0.0'
+__version__ = '2.0'
 __title__ = 'Calculation of the scattering of EM radiation by a multilayered sphere'
 __mod__ = 'python-scattnlay'
 __author__ = 'Ovidio Peña Rodríguez'

+ 10 - 10
src/nmie.cc

@@ -78,8 +78,8 @@ namespace nmie {
         throw std::invalid_argument("Declared number of layers do not fit x and m!");
     try {
       MultiLayerMie ml_mie;
-      ml_mie.SetAllLayersSize(x);
-      ml_mie.SetAllLayersIndex(m);
+      ml_mie.SetLayersSize(x);
+      ml_mie.SetLayersIndex(m);
       ml_mie.SetPECLayer(pl);
       ml_mie.SetMaxTerms(nmax);
 
@@ -135,8 +135,8 @@ namespace nmie {
         throw std::invalid_argument("Declared number of sample for Theta is not correct!");
     try {
       MultiLayerMie ml_mie;
-      ml_mie.SetAllLayersSize(x);
-      ml_mie.SetAllLayersIndex(m);
+      ml_mie.SetLayersSize(x);
+      ml_mie.SetLayersIndex(m);
       ml_mie.SetAngles(Theta);
       ml_mie.SetPECLayer(pl);
       ml_mie.SetMaxTerms(nmax);
@@ -299,8 +299,8 @@ namespace nmie {
     try {
       MultiLayerMie ml_mie;
       ml_mie.SetPECLayer(pl);
-      ml_mie.SetAllLayersSize(x);
-      ml_mie.SetAllLayersIndex(m);
+      ml_mie.SetLayersSize(x);
+      ml_mie.SetLayersIndex(m);
       ml_mie.SetFieldCoords({Xp_vec, Yp_vec, Zp_vec});
       ml_mie.RunFieldCalculation();
       E = ml_mie.GetFieldE();
@@ -419,7 +419,7 @@ namespace nmie {
   // ********************************************************************** //
   // Modify size of all layers                                             //
   // ********************************************************************** //
-  void MultiLayerMie::SetAllLayersSize(const std::vector<double>& layer_size) {
+  void MultiLayerMie::SetLayersSize(const std::vector<double>& layer_size) {
     MarkUncalculated();
     size_param_.clear();
     double prev_layer_size = 0.0;
@@ -438,7 +438,7 @@ namespace nmie {
   // ********************************************************************** //
   // Modify refractive index of all layers                                  //
   // ********************************************************************** //
-  void MultiLayerMie::SetAllLayersIndex(const std::vector< std::complex<double> >& index) {
+  void MultiLayerMie::SetLayersIndex(const std::vector< std::complex<double> >& index) {
     MarkUncalculated();
     refractive_index_ = index;
   }
@@ -457,7 +457,7 @@ namespace nmie {
 
 
   // ********************************************************************** //
-  // ********************************************************************** //
+  // Modify index of PEC layer                                              //
   // ********************************************************************** //
   void MultiLayerMie::SetPECLayer(int layer_position) {
     MarkUncalculated();
@@ -477,7 +477,7 @@ namespace nmie {
 
 
   // ********************************************************************** //
-  // ********************************************************************** //
+  // Get total size parameter of particle                                   //
   // ********************************************************************** //
   double MultiLayerMie::GetSizeParameter() {
     if (size_param_.size() > 0)

+ 16 - 15
src/nmie.h

@@ -27,7 +27,7 @@
 //    along with this program.  If not, see <http://www.gnu.org/licenses/>.         //
 //**********************************************************************************//
 
-#define VERSION "2.0.0"
+#define VERSION "2.0"
 #include <array>
 #include <complex>
 #include <cstdlib>
@@ -70,21 +70,15 @@ namespace nmie {
     std::vector<std::complex<double> > GetBn(){return bn_;};
 
     // Problem definition
-    // Add new layer
-    void AddNewLayer(double layer_size, std::complex<double> layer_index);
-    // Modify width of the layer
-    void SetLayerSize(std::vector<double> layer_size, int layer_position = 0);
-    // Modify refractive index of the layer
-    void SetLayerIndex(std::vector< std::complex<double> > layer_index, int layer_position = 0);
     // Modify size of all layers
-    void SetAllLayersSize(const std::vector<double>& layer_size);
+    void SetLayersSize(const std::vector<double>& layer_size);
     // Modify refractive index of all layers
-    void SetAllLayersIndex(const std::vector< std::complex<double> >& index);
+    void SetLayersIndex(const std::vector< std::complex<double> >& index);
     // Modify scattering (theta) angles
     void SetAngles(const std::vector<double>& angles);
     // Modify coordinates for field calculation
     void SetFieldCoords(const std::vector< std::vector<double> >& coords);
-    // Modify PEC layer
+    // Modify index of PEC layer
     void SetPECLayer(int layer_position = 0);
 
     // Set a fixed value for the maximun number of terms
@@ -97,12 +91,19 @@ namespace nmie {
     void ClearLayers();
     void MarkUncalculated();
 
-    // Applied units requests
+    // Read parameters
+    // Get total size parameter of particle
     double GetSizeParameter();
-    double GetLayerWidth(int layer_position = 0);
-    std::vector<double> GetLayersSize();
-    std::vector<std::complex<double> > GetLayersIndex();
-    std::vector<std::array<double, 3> > GetFieldCoords();
+    // Returns size of all layers
+    std::vector<double> GetLayersSize(){return size_param_;};
+    // Returns refractive index of all layers
+    std::vector<std::complex<double> > GetLayersIndex(){return refractive_index_;};
+    // Returns scattering (theta) angles
+    std::vector<double> GetAngles(){return theta_;};
+    // Returns coordinates used for field calculation
+    std::vector<std::vector<double> > GetFieldCoords(){return coords_;};
+    // Returns index of PEC layer
+    int GetPECLayer(){return PEC_layer_position_;};
 
     std::vector<std::vector< std::complex<double> > > GetFieldE(){return E_;};   // {X[], Y[], Z[]}
     std::vector<std::vector< std::complex<double> > > GetFieldH(){return H_;};