Browse Source

add a test for large bable spectrum (disabled, as it is failing now)

Konstantin Ladutenko 3 years ago
parent
commit
f4a76c989e
2 changed files with 35 additions and 0 deletions
  1. 1 0
      tests/test_bulk_sphere.cc
  2. 34 0
      tests/test_near_field.cc

+ 1 - 0
tests/test_bulk_sphere.cc

@@ -28,6 +28,7 @@ TEST(BulkSphere, ArgPi) {
 }
 #endif
 
+//TEST(BulkSphere, DISABLED_HandlesInput) {
 TEST(BulkSphere, HandlesInput) {
   nmie::MultiLayerMie<nmie::FloatType> nmie;
   // A list of tests for a bulk sphere from

+ 34 - 0
tests/test_near_field.cc

@@ -55,6 +55,40 @@ TEST(RunFieldCalculationCartesian, HandlesInput) {
 
 }
 
+TEST(LargeBubbleSpectrum, DISABLED_HandlesInput) {
+//TEST(LargeBubbleSpectrum, HandlesInput) { // TODO fix fail...
+  nmie::MultiLayerMie<nmie::FloatType> nmie;
+  nmie::FloatType core_r  = 2*nmie.PI_*100;
+  nmie::FloatType shell_r = 2*nmie.PI_*(100+0.1);
+  nmie.SetLayersIndex({ {1,0}, {1.33,0}});
+  double central_WL = 0.7007;
+  double relative_distance = 1e-10;
+  double dWL = central_WL*relative_distance;
+  std::vector<double> Qsca(5);
+  for (int i = 0; i < 5; ++i) {
+    auto WL = static_cast<nmie::FloatType>(central_WL +(i - 2)*dWL);
+    nmie.SetLayersSize({core_r/WL, shell_r/WL});
+    nmie.RunMieCalculation();
+    Qsca[i] = static_cast<double>(nmie.GetQsca());
+    std::cout<<"Qsca["<<i<<"]="<<Qsca[i]<<std::endl;
+  }
+
+  {
+    // Eabs points are located near the sphere outer border
+    //
+    //    0   1   2   3   4
+    //    ------- WL ------>
+    // distance between points (0) and (4) is 5*relative_distance*central_WL, initial
+    // value used for the test was 5*1e-10*0.7007, so we expect good linear dependence
+    // for points from 0 to 4. In the asserts we check, that the slope doesn't
+    // change too fast inside the curve.
+    using std::abs;
+    EXPECT_TRUE(
+        ( abs(Qsca[0] - Qsca[1]) + abs(Qsca[3] - Qsca[4]) ) >= abs(Qsca[1] - Qsca[2])
+    );
+  }
+}
+
 //TEST(RunFieldCalculationPolar, DISABLED_HandlesInput) {
 TEST(RunFieldCalculationPolar, HandlesInput) {
   nmie::MultiLayerMie<nmie::FloatType> nmie;