test-negative-epsilon.cc 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * @file test-negative-epsilon.cc
  3. * @author Konstantin Ladutenko <kostyfisik at gmail (.) com>
  4. * @date Mon Mar 9 13:21:37 2015
  5. *
  6. * @brief test negative epsilon case
  7. *
  8. // This file is part of scattnlay //
  9. // //
  10. // This program is free software: you can redistribute it and/or modify //
  11. // it under the terms of the GNU General Public License as published by //
  12. // the Free Software Foundation, either version 3 of the License, or //
  13. // (at your option) any later version. //
  14. // //
  15. // This program is distributed in the hope that it will be useful, //
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of //
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
  18. // GNU General Public License for more details. //
  19. // //
  20. // The only additional remark is that we expect that all publications //
  21. // describing work using this software, or all commercial products //
  22. // using it, cite the following reference: //
  23. // [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by //
  24. // a multilayered sphere," Computer Physics Communications, //
  25. // vol. 180, Nov. 2009, pp. 2348-2354. //
  26. // //
  27. // You should have received a copy of the GNU General Public License //
  28. // along with this program. If not, see <http://www.gnu.org/licenses/>. //
  29. *
  30. */
  31. #include "nmie.h"
  32. #include <stdio.h>
  33. template<class T> inline T pow2(const T value) {return value*value;};
  34. const double PI=3.14159265358979323846;
  35. int main(int argc, char *argv[]) {
  36. try {
  37. double lambda_work_ = 3.75; // cm
  38. double a_ = 0.75*lambda_work_; // 2.8125 cm - size of PEC core
  39. double min_index_ = 1e-11;
  40. nmie::MultiLayerMie multi_layer_mie;
  41. // Only PEC target
  42. multi_layer_mie.SetTargetPEC(a_);
  43. multi_layer_mie.SetWavelength(lambda_work_);
  44. multi_layer_mie.RunMieCalculations();
  45. double PEC_Qsca = multi_layer_mie.GetQsca();
  46. double PEC_r = multi_layer_mie.GetTotalRadius();
  47. double PEC_RCS = PEC_Qsca*PI*pow2(PEC_r);
  48. // PEC target covered with with air layer
  49. multi_layer_mie.SetCoatingWidth({0.1});
  50. multi_layer_mie.SetCoatingIndex({{1.0,0.0}});
  51. multi_layer_mie.RunMieCalculations();
  52. double Qsca1 = multi_layer_mie.GetQsca();
  53. double total_r1 = multi_layer_mie.GetTotalRadius();
  54. double initial_RCS1 = Qsca1*PI*pow2(total_r1);
  55. printf("RCS = %g cm^2 with (r=%g) and RCS=%g cm^2 without (r=%g)air coating.\n",
  56. initial_RCS1, total_r1,
  57. PEC_RCS, PEC_r);
  58. //multi_layer_mie.SetMaxTermsNumber(150);
  59. // Bi-layer, inner layer = lossless metall.
  60. std::vector<std::complex<double>> cindex;
  61. cindex.clear();
  62. double n=min_index_;
  63. double k=std::sqrt(0.29);
  64. cindex.push_back(std::complex<double>(n, k));
  65. n=std::sqrt(24.6);
  66. k=min_index_;
  67. cindex.push_back(std::complex<double>(n, k));
  68. multi_layer_mie.SetCoatingWidth({0.1,0.1});
  69. multi_layer_mie.SetCoatingIndex(cindex);
  70. multi_layer_mie.RunMieCalculations();
  71. double Qsca = multi_layer_mie.GetQsca();
  72. double total_r = multi_layer_mie.GetTotalRadius();
  73. double initial_RCS = Qsca*PI*pow2(total_r);
  74. printf("RCS=%g for bi-layer coating (total R=%g).\n", initial_RCS,total_r);
  75. n=1.0;
  76. k=min_index_;
  77. cindex.push_back(std::complex<double>(n, k));
  78. multi_layer_mie.SetCoatingWidth({0.1,0.1,0.1});
  79. multi_layer_mie.SetCoatingIndex(cindex);
  80. multi_layer_mie.RunMieCalculations();
  81. Qsca = multi_layer_mie.GetQsca();
  82. total_r = multi_layer_mie.GetTotalRadius();
  83. initial_RCS = Qsca*PI*pow2(total_r);
  84. printf("RCS=%g for bi-layer+air coating (total R=%g).\n", initial_RCS,total_r);
  85. } catch( const std::invalid_argument& ia ) {
  86. // Will catch if multi_layer_mie fails or other errors.
  87. std::cerr << "Invalid argument: " << ia.what() << std::endl;
  88. return -1;
  89. }
  90. return 0;
  91. }