#ifndef SRC_NMIE_APPLIED_HPP_ #define SRC_NMIE_APPLIED_HPP_ //**********************************************************************************// // Copyright (C) 2009-2018 Ovidio Pena // // Copyright (C) 2013-2018 Konstantin Ladutenko // // // // This file is part of scattnlay // // // // This program is free software: you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation, either version 3 of the License, or // // (at your option) any later version. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // The only additional remark is that we expect that all publications // // describing work using this software, or all commercial products // // using it, cite at least one of the following references: // // [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by // // a multilayered sphere," Computer Physics Communications, // // vol. 180, Nov. 2009, pp. 2348-2354. // // [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie // // calculation of electromagnetic near-field for a multilayered // // sphere," Computer Physics Communications, vol. 214, May 2017, // // pp. 225-230. // // // // You should have received a copy of the GNU General Public License // // along with this program. If not, see . // //**********************************************************************************// #include #include #include #include #include #include "nmie.hpp" #include "nmie-basic.hpp" #include "nmie-nearfield.hpp" #include #include namespace nmie { int nMieApplied(const unsigned int L, const int pl, std::vector &x, std::vector >& m, const unsigned int nTheta, std::vector& Theta, const int nmax, double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo, std::vector >& S1, std::vector >& S2); int nMieApplied(const unsigned int L, std::vector& x, std::vector >& m, const unsigned int nTheta, std::vector& Theta, double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo, std::vector >& S1, std::vector >& S2); int nMieApplied(const unsigned int L, const int pl, std::vector& x, std::vector >& m, const unsigned int nTheta, std::vector& Theta, double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo, std::vector >& S1, std::vector >& S2); int nMieApplied(const unsigned int L, std::vector& x, std::vector >& m, const unsigned int nTheta, std::vector& Theta, const int nmax, double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo, std::vector >& S1, std::vector >& S2); template class MultiLayerMieApplied : public MultiLayerMie { // Will throw for any error! public: void RunMieCalculation(); void RunFieldCalculationPolar(const int outer_arc_points, const int radius_points, const double from_Rho, const double to_Rho, const double from_Theta, const double to_Theta, const double from_Phi, const double to_Phi, const int isIgnoreAvailableNmax); emscripten::val GetFieldEabs(); void GetFailed(); long iformat = 0; bool output = true; void prn(FloatType var) { do { if (!output) break; ++iformat; printf("%23.13e",var); if (iformat%4 == 0) printf("\n"); } while (false); } // Set parameters in applied units void SetWavelength(FloatType wavelength) { this->MultiLayerMie::MarkUncalculated(); wavelength_ = wavelength;}; // It is possible to set only a multilayer target to run calculaitons. // For many runs it can be convenient to separate target and coating layers. // Per layer void AddTargetLayer(FloatType layer_width, std::complex layer_index); void AddTargetLayerReIm(FloatType layer_width, FloatType re_layer_index, FloatType im_layer_index); void AddCoatingLayer(FloatType layer_width, std::complex layer_index); // For all layers void SetTargetWidth(std::vector width); void SetTargetIndex(std::vector< std::complex > index); void SetTargetPEC(FloatType radius); void SetCoatingWidth(std::vector width); void SetCoatingIndex(std::vector< std::complex > index); void SetFieldPoints(std::vector< std::array > coords); //Set parameters in size parameter units void SetWidthSP(const std::vector& width); void SetIndexSP(const std::vector< std::complex >& index); void SetFieldPointsSP(const std::vector< std::vector >& coords_sp); // Set common parameters void SetModeNmaxAndType(int mode_n, int mode_type) { this->MultiLayerMie::SetModeNmaxAndType(mode_n, mode_type);}; void SetAnglesForPattern(FloatType from_angle, FloatType to_angle, int samples); std::vector GetAngles(); void ClearTarget(); void ClearCoating(); void ClearLayers(); void ClearAllDesign(); //Layers + SP + index_ // Applied units requests FloatType GetTotalRadius(); FloatType GetTargetRadius(); FloatType GetCoatingWidth(); std::vector GetTargetLayersWidth(); std::vector< std::complex > GetTargetLayersIndex(); std::vector GetCoatingLayersWidth(); std::vector< std::complex > GetCoatingLayersIndex(); std::vector< std::vector > GetFieldPoints(); std::vector< std::vector > GetSpectra(FloatType from_WL, FloatType to_WL, int samples); // ext, sca, abs, bk FloatType GetRCSext(); FloatType GetRCSsca(); FloatType GetRCSabs(); FloatType GetRCSbk(); std::vector GetPatternEk(); std::vector GetPatternHk(); std::vector GetPatternUnpolarized(); // Dimensionless FloatType GetQsca(){ return this->MultiLayerMie::GetQsca();}; FloatType GetQabs(){ return this->MultiLayerMie::GetQabs();}; FloatType GetQext(){ return this->MultiLayerMie::GetQext();}; // Size parameter units std::vector GetLayerWidthSP(); // Same as to get target and coating index std::vector< std::complex > GetLayerIndex(); std::vector< std::array > GetFieldPointsSP(); // Do we need normalize field to size parameter? /* std::vector > > GetFieldESP(); */ /* std::vector > > GetFieldHSP(); */ std::vector< std::array > GetSpectraSP(FloatType from_SP, FloatType to_SP, int samples); // WL,ext, sca, abs, bk std::vector GetPatternEkSP(); std::vector GetPatternHkSP(); std::vector GetPatternUnpolarizedSP(); void GetExpanCoeffs (std::vector< std::vector > >& aln, std::vector< std::vector > >& bln, std::vector< std::vector > >& cln, std::vector< std::vector > >& dln); // Output results (data file + python script to plot it with matplotlib) void PlotSpectra(); void PlotSpectraSP(); void PlotField(); void PlotFieldSP(); void PlotPattern(); void PlotPatternSP(); private: void ConvertToSP(); void GenerateSizeParameter(); void GenerateIndex(); void InitMieCalculations(); void sbesjh(std::complex z, std::vector >& jn, std::vector >& jnp, std::vector >& h1n, std::vector >& h1np); void sphericalBessel(std::complex z, std::vector >& bj, std::vector >& by, std::vector >& bd); std::complex calcD1confra(int N, const std::complex z); FloatType wavelength_ = 1.0; FloatType total_radius_ = 0.0; /// Width and index for each layer of the structure std::vector target_width_, coating_width_; std::vector< std::complex > target_index_, coating_index_; std::vector< std::vector > coords_sp_; }; // end of class MultiLayerMie } // end of namespace nmie #endif // SRC_NMIE_APPLIED_HPP