123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- #include <complex>
- #include "../src/mesomie.hpp"
- #include "../src/nmie-basic.hpp"
- #include "gtest/gtest.h"
- #ifndef MULTI_PRECISION
- TEST(BulkSphere, ArgPi) {
- std::vector<double> WLs{50, 80, 100, 200, 400};
- double host_index = 2.;
- double core_radius = 100.;
- double delta = 1e-5;
- nmie::MultiLayerMie<nmie::FloatType> nmie;
- nmie.SetLayersIndex({std::complex<double>(4, 0)});
- for (auto WL : WLs) {
- nmie.SetLayersSize(
- {2 * nmie::PI_ * host_index * core_radius / (WL + delta)});
- nmie.RunMieCalculation();
- double Qabs_p = std::abs(static_cast<double>(nmie.GetQabs()));
- nmie.SetLayersSize(
- {2 * nmie::PI_ * host_index * core_radius / (WL - delta)});
- nmie.RunMieCalculation();
- double Qabs_m = std::abs(static_cast<double>(nmie.GetQabs()));
- nmie.SetLayersSize({2 * nmie::PI_ * host_index * core_radius / (WL)});
- nmie.RunMieCalculation();
- double Qabs = std::abs(static_cast<double>(nmie.GetQabs()));
- EXPECT_GT(Qabs_p + Qabs_m, Qabs);
- }
- }
- #endif
- std::vector<std::tuple<double, std::complex<double>, double, double, char> >
- parameters_and_results{
-
-
-
-
-
-
-
-
-
-
-
- {100, {10, 10}, 2.071124, 1.836785, 'l'},
-
-
-
- };
- TEST(BulkSphere, DISABLED_HandlesInput) {
-
- nmie::MultiLayerMie<nmie::FloatType> nmie;
- for (const auto& data : parameters_and_results) {
- auto x = std::get<0>(data);
- auto m = std::get<1>(data);
-
- nmie.SetLayersSize({x});
- nmie.SetLayersIndex({m});
-
- nmie.RunMieCalculation();
- double Qext = static_cast<double>(nmie.GetQext());
- double Qsca = static_cast<double>(nmie.GetQsca());
- double Qext_Du = std::get<2>(data);
- double Qsca_Du = std::get<3>(data);
- EXPECT_FLOAT_EQ(Qext_Du, Qext)
- << "Extinction of the bulk sphere, test case:" << std::get<4>(data)
- << "\nnmax_ = " << nmie.GetMaxTerms();
- EXPECT_FLOAT_EQ(Qsca_Du, Qsca)
- << "Scattering of the bulk sphere, test case:" << std::get<4>(data);
- }
- }
- TEST(BulkSphere, MesoMie) {
- nmie::MultiLayerMie<nmie::FloatType> nmie;
- nmie::MesoMie<nmie::FloatType> mesomie;
- for (const auto& data : parameters_and_results) {
- auto x = std::get<0>(data);
- auto m = std::get<1>(data);
-
- nmie.SetLayersSize({x});
- nmie.SetLayersIndex({m});
-
- nmie.calcScattCoeffs();
- auto an_nmie = nmie.GetAn();
- int nmax = an_nmie.size();
- mesomie.calc_ab(nmax + 2,
- x,
- {x, 0},
- x * m,
- 1.0 / (x * m),
- m / x,
- {0, 0},
- {0, 0});
- auto an_meso = mesomie.GetAn();
- mesomie.calc_ab_classic(nmax + 2, x, m);
- auto an_meso_cl = mesomie.GetAnClassic();
- for (int n = 0; n < nmax && n < 200; n++) {
- std::cout << n << an_nmie[n] << ' ' << an_meso[n + 1] << ' '
- << an_meso_cl[n + 1] << std::endl;
- }
-
-
-
-
-
-
-
-
-
- }
- }
- int main(int argc, char** argv) {
- testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
- }
|