123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- do { \
- if (! (condition)) { \
- std::cerr << "Assertion `"
- << " line " << __LINE__ << ": " << message << std::endl; \
- std::exit(EXIT_FAILURE); \
- } \
- } while (false)
- namespace nmie {
- int nMie_wrapper(int L, std::vector<double>& x, std::vector<std::complex<double> >& m, int nTheta, std::vector<double>& Theta, double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo, std::vector<std::complex<double> >& S1, std::vector<std::complex<double> >& S2);
- int nField(const int L, const int pl, const std::vector<double>& x, const std::vector<std::complex<double> >& m, const int nmax, const int ncoord, const std::vector<double>& Xp, const std::vector<double>& Yp, const std::vector<double>& Zp, std::vector<std::vector<std::complex<double> > >& E, std::vector<std::vector<std::complex<double> > >& H);
- class MultiLayerMie {
-
-
- public:
- void GetFailed();
- long iformat = 0;
- bool output = true;
- void prn(double var) {
- do {
- if (!output) break;
- ++iformat;
- printf("%23.13e",var);
- if (iformat%4 == 0) printf("\n");
- } while (false);
- }
-
- void SetWavelength(double wavelength) {wavelength_ = wavelength;};
-
-
-
- void AddTargetLayer(double layer_width, std::complex<double> layer_index);
- void AddCoatingLayer(double layer_width, std::complex<double> layer_index);
-
- void SetTargetWidth(std::vector<double> width);
- void SetTargetIndex(std::vector< std::complex<double> > index);
- void SetTargetPEC(double radius);
- void SetCoatingWidth(std::vector<double> width);
- void SetCoatingIndex(std::vector< std::complex<double> > index);
- void SetFieldPoints(std::vector< std::array<double,3> > coords);
-
- void SetWidthSP(const std::vector<double>& width);
- void SetIndexSP(const std::vector< std::complex<double> >& index);
- void SetFieldPointsSP(const std::vector< std::vector<double> >& coords_sp);
-
- void SetAnglesForPattern(double from_angle, double to_angle, int samples);
- void SetAngles(const std::vector<double>& angles);
- std::vector<double> GetAngles();
- void SetPEC(int layer_position = 0);
-
- void SetMaxTermsNumber(int nmax);
- int GetMaxTermsUsed() {return nmax_used_;};
-
- void ClearTarget();
- void ClearCoating();
- void ClearLayers();
- void ClearAllDesign();
-
- double GetTotalRadius();
- double GetTargetRadius();
- double GetCoatingWidth();
- std::vector<double> GetTargetLayersWidth();
- std::vector< std::complex<double> > GetTargetLayersIndex();
- std::vector<double> GetCoatingLayersWidth();
- std::vector< std::complex<double> > GetCoatingLayersIndex();
- std::vector< std::vector<double> > GetFieldPoints();
- std::vector<std::vector< std::complex<double> > >
- GetFieldE(){return E_field_;};
- std::vector<std::vector< std::complex<double> > >
- GetFieldH(){return H_field_;};
- std::vector< std::vector<double> > GetSpectra(double from_WL, double to_WL, int samples);
- double GetRCSext();
- double GetRCSsca();
- double GetRCSabs();
- double GetRCSbk();
- std::vector<double> GetPatternEk();
- std::vector<double> GetPatternHk();
- std::vector<double> GetPatternUnpolarized();
-
- std::vector<double> GetLayerWidthSP();
-
- std::vector< std::complex<double> > GetLayerIndex();
- std::vector< std::array<double,3> > GetFieldPointsSP();
-
-
-
- std::vector< std::array<double,5> > GetSpectraSP(double from_SP, double to_SP, int samples);
- double GetQext();
- double GetQsca();
- double GetQabs();
- double GetQbk();
- double GetQpr();
- std::vector<double> GetQsca_channel();
- std::vector<double> GetQabs_channel();
- std::vector<double> GetQsca_channel_normalized();
- std::vector<double> GetQabs_channel_normalized();
- std::vector<std::complex<double> > GetAn(){return an_;};
- std::vector<std::complex<double> > GetBn(){return bn_;};
- double GetAsymmetryFactor();
- double GetAlbedo();
- std::vector<std::complex<double> > GetS1();
- std::vector<std::complex<double> > GetS2();
- std::vector<double> GetPatternEkSP();
- std::vector<double> GetPatternHkSP();
- std::vector<double> GetPatternUnpolarizedSP();
-
-
- void RunMieCalculations();
- void RunFieldCalculations();
-
- void PlotSpectra();
- void PlotSpectraSP();
- void PlotField();
- void PlotFieldSP();
- void PlotPattern();
- void PlotPatternSP();
- private:
- void ConvertToSP();
- void GenerateSizeParameter();
- void GenerateIndex();
- void InitMieCalculations();
- void Nstop();
- void Nmax(int first_layer);
- void sbesjh(std::complex<double> z, std::vector<std::complex<double> >& jn,
- std::vector<std::complex<double> >& jnp, std::vector<std::complex<double> >& h1n,
- std::vector<std::complex<double> >& h1np);
- void sphericalBessel(std::complex<double> z, std::vector<std::complex<double> >& bj,
- std::vector<std::complex<double> >& by, std::vector<std::complex<double> >& bd);
- std::complex<double> calc_an(int n, double XL, std::complex<double> Ha, std::complex<double> mL,
- std::complex<double> PsiXL, std::complex<double> ZetaXL,
- std::complex<double> PsiXLM1, std::complex<double> ZetaXLM1);
- std::complex<double> calc_bn(int n, double XL, std::complex<double> Hb, std::complex<double> mL,
- std::complex<double> PsiXL, std::complex<double> ZetaXL,
- std::complex<double> PsiXLM1, std::complex<double> ZetaXLM1);
- std::complex<double> calc_S1(int n, std::complex<double> an, std::complex<double> bn,
- double Pi, double Tau);
- std::complex<double> calc_S2(int n, std::complex<double> an, std::complex<double> bn,
- double Pi, double Tau);
- void calcPsiZeta(std::complex<double> x,
- std::vector<std::complex<double> > D1,
- std::vector<std::complex<double> > D3,
- std::vector<std::complex<double> >& Psi,
- std::vector<std::complex<double> >& Zeta);
- std::complex<double> calcD1confra(int N, const std::complex<double> z);
- void calcD1D3(std::complex<double> z,
- std::vector<std::complex<double> >& D1,
- std::vector<std::complex<double> >& D3);
- void calcSinglePiTau(const double& costheta, std::vector<double>& Pi,
- std::vector<double>& Tau);
- void calcAllPiTau(std::vector< std::vector<double> >& Pi,
- std::vector< std::vector<double> >& Tau);
- void ExtScattCoeffs(std::vector<std::complex<double> >& an, std::vector<std::complex<double> >& bn);
- void IntScattCoeffs();
- void IntScattCoeffsInit();
- void fieldExt(const double Rho, const double Phi, const double Theta, const std::vector<double>& Pi, const std::vector<double>& Tau, std::vector<std::complex<double> >& E, std::vector<std::complex<double> >& H);
- void fieldInt(const double Rho, const double Phi, const double Theta, const std::vector<double>& Pi, const std::vector<double>& Tau, std::vector<std::complex<double> >& E, std::vector<std::complex<double> >& H);
-
- bool areIntCoeffsCalc_ = false;
- bool areExtCoeffsCalc_ = false;
- bool isMieCalculated_ = false;
- double wavelength_ = 1.0;
- double total_radius_ = 0.0;
-
- std::vector<double> target_width_, coating_width_;
- std::vector< std::complex<double> > target_index_, coating_index_;
-
- std::vector<double> size_parameter_;
-
- std::vector< std::complex<double> > index_;
-
- std::vector<double> theta_;
-
- int PEC_layer_position_ = -1;
-
-
- int nmax_ = -1;
- int nmax_used_ = -1;
- int nmax_preset_ = -1;
-
- std::vector<std::complex<double> > an_, bn_;
- std::vector< std::vector<double> > coords_sp_;
-
-
-
-
- std::vector< std::vector<std::complex<double> > > al_n_, bl_n_, cl_n_, dl_n_;
-
- double Qsca_ = 0.0, Qext_ = 0.0, Qabs_ = 0.0, Qbk_ = 0.0, Qpr_ = 0.0, asymmetry_factor_ = 0.0, albedo_ = 0.0;
- std::vector<std::vector< std::complex<double> > > E_field_, H_field_;
-
- std::vector<double> Qsca_ch_, Qext_ch_, Qabs_ch_, Qbk_ch_, Qpr_ch_;
- std::vector<double> Qsca_ch_norm_, Qext_ch_norm_, Qabs_ch_norm_, Qbk_ch_norm_, Qpr_ch_norm_;
- std::vector<std::complex<double> > S1_, S2_;
-
- const double PI_=3.14159265358979323846;
-
- double const cc_ = 2.99792458e8;
-
- double const mu_ = 4.0*PI_*1.0e-7;
-
- std::vector<std::complex<double> > PsiZeta_;
- };
- }
|