#include "gtest/gtest.h" #include "../src/nmie-basic.hpp" #include "../src/nmie-nearfield.hpp" #include "test_cases.hpp" TEST(RunFieldCalculationPolar, HandlesInput) { nmie::MultiLayerMie nmie; EXPECT_THROW(nmie.RunFieldCalculationPolar(0), std::invalid_argument); EXPECT_THROW(nmie.RunFieldCalculationPolar(1,1,10,5), std::invalid_argument); double r = 60; // double r = 1500; nmie.SetLayersSize({r/2, r}); nmie.SetLayersIndex({ {1.33,0}, {1.33,0}}); nmie.RunMieCalculation(); nmie.RunFieldCalculationPolar(1, 1, 0.5145*r, r*0.5148, 0, 3.14, 0, 0, true, 1); EXPECT_EQ(1, nmie.GetMaxTerms()); EXPECT_FALSE(nmie.GetFieldConvergence()); auto Eabs = nmie.GetFieldEabs(); EXPECT_TRUE(std::isnan(static_cast(Eabs[0]))); } //#ifndef MULTI_PRECISION TEST(BulkSphere, HandlesInput) { nmie::MultiLayerMie nmie; for (const auto &data : parameters_bulk_sphere) { auto x = std::get<0>(data); auto m = std::get<1>(data); nmie.SetLayersSize({x}); nmie.SetLayersIndex({m}); nmie.SetMaxTerms(-1); // nmie.RunMieCalculation(); // std::cout<<" test case: "<(data)<<" Qsca="<(nmie.PI_), 0, static_cast(nmie.PI_),true, -1); auto Eabs = nmie.GetFieldEabs(); for (auto &E:Eabs) E=nmie::pow2(E); // print(Eabs) EXPECT_TRUE(nmie.GetFieldConvergence())<<"Outside test for x="<(data)<(nmie.PI_), 0, static_cast(nmie.PI_),true, -1); EXPECT_TRUE(nmie.GetFieldConvergence())<<"Inside test for x="<(data)<