nmie-wrapper.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef SRC_NMIE_NMIE_WRAPPER_H_
  2. #define SRC_NMIE_NMIE_WRAPPER_H_
  3. ///
  4. /// @file nmie-wrapper.h
  5. /// @author Ladutenko Konstantin <kostyfisik at gmail (.) com>
  6. /// @date Tue Sep 3 00:40:47 2013
  7. /// @copyright 2013 Ladutenko Konstantin
  8. ///
  9. /// nmie-wrapper is free software: you can redistribute it and/or modify
  10. /// it under the terms of the GNU General Public License as published by
  11. /// the Free Software Foundation, either version 3 of the License, or
  12. /// (at your option) any later version.
  13. ///
  14. /// nmie-wrapper is distributed in the hope that it will be useful,
  15. /// but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. /// GNU General Public License for more details.
  18. ///
  19. /// You should have received a copy of the GNU General Public License
  20. /// along with nmie-wrapper. If not, see <http://www.gnu.org/licenses/>.
  21. ///
  22. /// nmie-wrapper uses nmie.c from scattnlay by Ovidio Pena
  23. /// <ovidio@bytesfall.com> as a linked library. He has an additional condition to
  24. /// his library:
  25. // The only additional condition is that we expect that all publications //
  26. // describing work using this software , or all commercial products //
  27. // using it, cite the following reference: //
  28. // [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by //
  29. // a multilayered sphere," Computer Physics Communications, //
  30. // vol. 180, Nov. 2009, pp. 2348-2354. //
  31. ///
  32. /// @brief Wrapper class around nMie function for ease of use
  33. ///
  34. ///
  35. #include <complex>
  36. #include <cstdlib>
  37. #include <iostream>
  38. #include <vector>
  39. #ifndef NDEBUG
  40. # define ASSERT(condition, message) \
  41. do { \
  42. if (! (condition)) { \
  43. std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
  44. << " line " << __LINE__ << ": " << message << std::endl; \
  45. std::exit(EXIT_FAILURE); \
  46. } \
  47. } while (false)
  48. #else
  49. # define ASSERT(condition, message) do { } while (false)
  50. #endif
  51. namespace nmie {
  52. class MultiLayerMie {
  53. public:
  54. void SetWavelength(double wavelength) {wavelength_ = wavelength;};
  55. void SetSizeParameter(std::vector<double> size_parameter);
  56. void SetIndex(std::vector< std::complex<double> > index);
  57. void RunMie(double *Qext, double *Qsca, double *Qabs, double *Qbk);
  58. std::vector< std::vector<double> > GetSpectra(double from_WL, double to_WL,
  59. int samples);
  60. /// Disabled functions or unused untill the end of C++ conversion
  61. double GetTotalRadius();
  62. private:
  63. /// Size parameter for each layer.
  64. std::vector<double> size_parameter_;
  65. /// Complex index value for each layer.
  66. std::vector< std::complex<double> > index_;
  67. const double PI=3.14159265358979323846;
  68. /// Disabled functions or unused untill the end of C++ conversion
  69. void GenerateSizeParameter();
  70. double wavelength_ = 1.0;
  71. double total_radius_ = 0.0;
  72. }; // end of class MultiLayerMie
  73. } // end of namespace nmie
  74. #endif // SRC_NMIE_NMIE_WRAPPER_H_