//**********************************************************************************// // Copyright (C) 2009-2015 Ovidio Pena // // Copyright (C) 2013-2015 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 the following reference: // // [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by // // a multilayered sphere," Computer Physics Communications, // // vol. 180, Nov. 2009, pp. 2348-2354. // // // // You should have received a copy of the GNU General Public License // // along with this program. If not, see . // //**********************************************************************************// // This program returns expansion coefficents of Mie series #include #include #include #include "../src/nmie-applied.hpp" #include "../src/nmie-applied-impl.hpp" #include "../src/nmie-precision.hpp" #include "./read-spectra.h" // template inline T pow2(const T value) {return value*value;} int main(int argc, char *argv[]) { using namespace nmie ; try { read_spectra::ReadSpectra Si_index, Ag_index; read_spectra::ReadSpectra plot_core_index_, plot_TiN_; std::string core_filename("Si-int.txt"); //std::string core_filename("Ag.txt"); //std::string TiN_filename("TiN.txt"); std::string TiN_filename("Ag-int.txt"); //std::string TiN_filename("Si.txt"); std::string shell_filename(core_filename); nmie::MultiLayerMieApplied multi_layer_mie; const std::complex epsilon_Si(18.4631066585, 0.6259727805); const std::complex epsilon_Ag(-8.5014154589, 0.7585845411); const std::complex index_Si = std::sqrt(epsilon_Si); const std::complex index_Ag = std::sqrt(epsilon_Ag); double WL=500; //nm double core_width = 5.27; //nm Si double inner_width = 8.22; //nm Ag double outer_width = 67.91; //nm Si bool isSiAgSi = true; double delta_width = 25.0; //bool isSiAgSi = false; if (isSiAgSi) { core_width = 5.27; //nm Si inner_width = 8.22; //nm Ag outer_width = 67.91; //nm Si multi_layer_mie.AddTargetLayer(core_width, index_Si); multi_layer_mie.AddTargetLayer(inner_width, index_Ag); multi_layer_mie.AddTargetLayer(outer_width+delta_width, index_Si); } else { inner_width = 31.93; //nm Ag outer_width = 4.06; //nm Si multi_layer_mie.AddTargetLayer(inner_width, index_Ag); multi_layer_mie.AddTargetLayer(outer_width+delta_width, index_Si); } for (int dd = 0; dd<50; ++dd) { delta_width = dd; FILE *fp; std::string fname = "absorb-layered-spectra-d"+std::to_string(dd)+".dat"; fp = fopen(fname.c_str(), "w"); multi_layer_mie.SetWavelength(WL); multi_layer_mie.RunMieCalculation(); double Qabs = static_cast(multi_layer_mie.GetQabs()); printf("Qabs = %g\n", Qabs); std::vector< std::vector > > aln, bln, cln, dln; multi_layer_mie.GetExpanCoeffs(aln, bln, cln, dln); std::vector< std::vector > > d_aln = nmie::ConvertComplexVectorVector(aln); std::string str = std::string("#WL "); for (int l = 0; l& Si = Si_data[i].second; const std::complex& Ag = Ag_data[i].second; str+=std::to_string(WL); multi_layer_mie.ClearTarget(); if (isSiAgSi) { multi_layer_mie.AddTargetLayer(core_width, Si); multi_layer_mie.AddTargetLayer(inner_width, Ag); multi_layer_mie.AddTargetLayer(outer_width+delta_width, Si); } else { inner_width = 31.93; //nm Ag outer_width = 4.06; //nm Si multi_layer_mie.AddTargetLayer(inner_width, Ag); multi_layer_mie.AddTargetLayer(outer_width+delta_width, Si); } multi_layer_mie.SetWavelength(WL); multi_layer_mie.RunMieCalculation(); multi_layer_mie.GetQabs(); multi_layer_mie.GetExpanCoeffs(aln, bln, cln, dln); for (int l = 0; l(pow2(std::abs(aln[l][n]))+ pow2(std::abs(dln[l][n])))) + " " + std::to_string(static_cast(pow2(std::abs(bln[l][n])) + pow2(std::abs(cln[l][n])) )); // str+=" "+std::to_string(aln[l][n].real() - pow2(std::abs(aln[l][n])) // +dln[l][n].real() - pow2(std::abs(dln[l][n]))) // + " " // + std::to_string(bln[l][n].real() - pow2(std::abs(bln[l][n])) // +cln[l][n].real() - pow2(std::abs(cln[l][n])) ); } } str+="\n"; fprintf(fp, "%s", str.c_str()); str.clear(); } fclose(fp); } // WL = 500; // multi_layer_mie.SetWavelength(WL); // multi_layer_mie.RunMieCalculation(); // multi_layer_mie.GetQabs(); // multi_layer_mie.GetExpanCoeffs(aln, bln, cln, dln); // printf("\n Scattering"); // for (int l = 0; l