Browse Source

compiles and runs (incorrect, but without run time errors)

Konstantin Ladutenko 2 years ago
parent
commit
9bc1761386
4 changed files with 34 additions and 32 deletions
  1. 23 23
      src/mesomie.hpp
  2. 4 4
      src/nmie.hpp
  3. 3 1
      tests/CMakeLists.txt
  4. 4 4
      tests/test_bulk_sphere.cc

+ 23 - 23
src/mesomie.hpp

@@ -63,12 +63,12 @@ void MesoMie<FloatType>::calc_ab(int nmax,
                                  FloatType R,
                                  FloatType R,
                                  FloatType xd,
                                  FloatType xd,
                                  FloatType xm,
                                  FloatType xm,
-                                 FloatType eps_d,
-                                 FloatType eps_m,
-                                 FloatType d_parallel,
-                                 FloatType d_perp) {
-  an_.resize(nmax, static_cast<FloatType>(0.0));
-  bn_.resize(nmax, static_cast<FloatType>(0.0));
+                                 std::complex<FloatType> eps_d,
+                                 std::complex<FloatType> eps_m,
+                                 std::complex<FloatType> d_parallel,
+                                 std::complex<FloatType> d_perp) {
+  an_.resize(nmax + 1, static_cast<FloatType>(0.0));
+  bn_.resize(nmax + 1, static_cast<FloatType>(0.0));
   std::vector<std::complex<FloatType>>      //
   std::vector<std::complex<FloatType>>      //
       D1_xd(nmax + 1), D3_xd(nmax + 1),     //
       D1_xd(nmax + 1), D3_xd(nmax + 1),     //
       D1_xm(nmax + 1), D3_xm(nmax + 1),     //
       D1_xm(nmax + 1), D3_xm(nmax + 1),     //
@@ -80,24 +80,24 @@ void MesoMie<FloatType>::calc_ab(int nmax,
 
 
   for (int n = 1; n <= nmax; n++) {
   for (int n = 1; n <= nmax; n++) {
     an_[n] = Psi_xd[n] *
     an_[n] = Psi_xd[n] *
-             (                                                       //
-                 eps_m * xd * D1_xd[n] - eps_d * xm * D1_xm[n] +     //
-                 (eps_m - eps_d) *                                   //
-                     (                                               //
-                         n * (n + 1) * d_perp +                      //
-                         xd * D1_xd[n] * xm * D1_xm[n] * d_parallel  //
-                         ) /                                         //
-                     R                                               //
-                 ) /                                                 //
+             (                                                           //
+                 eps_m * xd * D1_xd[n] - eps_d * xm * D1_xm[n] +         //
+                 (eps_m - eps_d) *                                       //
+                     (                                                   //
+                         static_cast<FloatType>(n * (n + 1)) * d_perp +  //
+                         xd * D1_xd[n] * xm * D1_xm[n] * d_parallel      //
+                         ) /                                             //
+                     R                                                   //
+                 ) /                                                     //
              Zeta_xd[n] *
              Zeta_xd[n] *
-             (                                                       //
-                 eps_m * xd * D3_xd[n] - eps_d * xm * D1_xm[n] +     //
-                 (eps_m - eps_d) *                                   //
-                     (                                               //
-                         n * (n + 1) * d_perp +                      //
-                         xd * D3_xd[n] * xm * D1_xm[n] * d_parallel  //
-                         ) /                                         //
-                     R                                               //
+             (                                                           //
+                 eps_m * xd * D3_xd[n] - eps_d * xm * D1_xm[n] +         //
+                 (eps_m - eps_d) *                                       //
+                     (                                                   //
+                         static_cast<FloatType>(n * (n + 1)) * d_perp +  //
+                         xd * D3_xd[n] * xm * D1_xm[n] * d_parallel      //
+                         ) /                                             //
+                     R                                                   //
              );
              );
     bn_[n] = Psi_xd[n] *
     bn_[n] = Psi_xd[n] *
              (                                         //
              (                                         //

+ 4 - 4
src/nmie.hpp

@@ -541,10 +541,10 @@ class MesoMie {
                FloatType R,
                FloatType R,
                FloatType xd,
                FloatType xd,
                FloatType xm,
                FloatType xm,
-               FloatType eps_d,
-               FloatType eps_m,
-               FloatType d_parallel,
-               FloatType d_perp);
+               std::complex<FloatType> eps_d,
+               std::complex<FloatType> eps_m,
+               std::complex<FloatType> d_parallel,
+               std::complex<FloatType> d_perp);
 };  // end of class MesoMie
 };  // end of class MesoMie
 
 
 }  // end of namespace nmie
 }  // end of namespace nmie

+ 3 - 1
tests/CMakeLists.txt

@@ -27,7 +27,9 @@ target_link_libraries("test_Riccati_Bessel_logarithmic_derivative" ${LIBS})
 add_test(NAME "test_Riccati_Bessel_logarithmic_derivative"
 add_test(NAME "test_Riccati_Bessel_logarithmic_derivative"
         COMMAND "test_Riccati_Bessel_logarithmic_derivative")
         COMMAND "test_Riccati_Bessel_logarithmic_derivative")
 
 
-
+#TODO remove -Wno
+set_source_files_properties(test_bulk_sphere.cc
+        PROPERTIES COMPILE_FLAGS "-Wno-overflow -Wno-unused-parameter")
 add_executable("test_bulk_sphere" test_bulk_sphere.cc)
 add_executable("test_bulk_sphere" test_bulk_sphere.cc)
 target_link_libraries("test_bulk_sphere" ${LIBS})
 target_link_libraries("test_bulk_sphere" ${LIBS})
 add_test(NAME "test_bulk_sphere"
 add_test(NAME "test_bulk_sphere"

+ 4 - 4
tests/test_bulk_sphere.cc

@@ -95,11 +95,11 @@ TEST(BulkSphere, MesoMie) {
     nmie.calcScattCoeffs();
     nmie.calcScattCoeffs();
     auto an_nmie = nmie.GetAn();
     auto an_nmie = nmie.GetAn();
     int nmax = an_nmie.size();
     int nmax = an_nmie.size();
-    mesomie.calc_ab(nmax + 2, 1, 1, x, 1, std::sqrt(m).real(), 0, 0);
-    // auto an_meso = mesomie.GetAn();
+    mesomie.calc_ab(nmax + 2, 1, 2, x, {1, 0}, std::sqrt(m), {0, 0}, {0, 0});
+    auto an_meso = mesomie.GetAn();
     for (int n = 0; n < nmax; n++) {
     for (int n = 0; n < nmax; n++) {
-      if (an_nmie[n].real() > 0.1)
-        std::cout << an_nmie[n] << std::endl;
+      if (an_meso[n + 1].real() > 0.1)
+        std::cout << an_nmie[n] << ' ' << an_meso[n + 1] << std::endl;
     }
     }
 
 
     // double Qext = static_cast<double>(nmie.GetQext());
     // double Qext = static_cast<double>(nmie.GetQext());