bug1.cc 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //**********************************************************************************//
  2. // Copyright (C) 2009-2015 Ovidio Pena <ovidio@bytesfall.com> //
  3. // Copyright (C) 2013-2015 Konstantin Ladutenko <kostyfisik@gmail.com> //
  4. // //
  5. // This file is part of scattnlay //
  6. // //
  7. // This program is free software: you can redistribute it and/or modify //
  8. // it under the terms of the GNU General Public License as published by //
  9. // the Free Software Foundation, either version 3 of the License, or //
  10. // (at your option) any later version. //
  11. // //
  12. // This program is distributed in the hope that it will be useful, //
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of //
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
  15. // GNU General Public License for more details. //
  16. // //
  17. // The only additional remark is that we expect that all publications //
  18. // describing work using this software, or all commercial products //
  19. // using it, cite the following reference: //
  20. // [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by //
  21. // a multilayered sphere," Computer Physics Communications, //
  22. // vol. 180, Nov. 2009, pp. 2348-2354. //
  23. // //
  24. // You should have received a copy of the GNU General Public License //
  25. // along with this program. If not, see <http://www.gnu.org/licenses/>. //
  26. //**********************************************************************************//
  27. // This program evaluates absorption of a triple layered nanoparticle
  28. #include <complex>
  29. #include <cstdio>
  30. #include <string>
  31. #include "../src/nmie-applied.hpp"
  32. #include "../src/nmie-applied-impl.hpp"
  33. int main(int argc, char *argv[]) {
  34. try {
  35. nmie::MultiLayerMieApplied<double> multi_layer_mie;
  36. const std::complex<double> index_Si(4, 0.0);
  37. double delta = 1e-5;
  38. double core_r = 100.; //nm Si
  39. double host = 2.;
  40. double WL = 200.;
  41. multi_layer_mie.AddTargetLayer(core_r*host, index_Si/host);
  42. multi_layer_mie.SetWavelength(WL-delta);
  43. multi_layer_mie.RunMieCalculation();
  44. double Qabs = multi_layer_mie.GetQabs();
  45. printf("at WL = %g-(%g) the result is Qabs = %15.14g\n", WL, delta, Qabs);
  46. multi_layer_mie.SetWavelength(WL);
  47. multi_layer_mie.RunMieCalculation();
  48. Qabs = multi_layer_mie.GetQabs();
  49. printf("at WL = %g the result is Qabs = %15.14g\n", WL, Qabs);
  50. multi_layer_mie.SetWavelength(WL+delta);
  51. multi_layer_mie.RunMieCalculation();
  52. Qabs = multi_layer_mie.GetQabs();
  53. printf("at WL = %g+(%g) the result is Qabs = %15.14g\n", WL, delta, Qabs);
  54. } catch( const std::invalid_argument& ia ) {
  55. // Will catch if multi_layer_mie fails or other errors.
  56. std::cerr << "Invalid argument: " << ia.what() << std::endl;
  57. return -1;
  58. }
  59. return 0;
  60. }