py_nmie.cc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //**********************************************************************************//
  2. // Copyright (C) 2009-2015 Ovidio Pena <ovidio@bytesfall.com> //
  3. // //
  4. // This file is part of scattnlay //
  5. // //
  6. // This program is free software: you can redistribute it and/or modify //
  7. // it under the terms of the GNU General Public License as published by //
  8. // the Free Software Foundation, either version 3 of the License, or //
  9. // (at your option) any later version. //
  10. // //
  11. // This program is distributed in the hope that it will be useful, //
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of //
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
  14. // GNU General Public License for more details. //
  15. // //
  16. // The only additional remark is that we expect that all publications //
  17. // describing work using this software, or all commercial products //
  18. // using it, cite the following reference: //
  19. // [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by //
  20. // a multilayered sphere," Computer Physics Communications, //
  21. // vol. 180, Nov. 2009, pp. 2348-2354. //
  22. // //
  23. // You should have received a copy of the GNU General Public License //
  24. // along with this program. If not, see <http://www.gnu.org/licenses/>. //
  25. //**********************************************************************************//
  26. #include <stdlib.h>
  27. #include <stdio.h>
  28. #include "ucomplex.h"
  29. #include "nmie.h"
  30. #include "py_nmie.h"
  31. //Same as nMieScatt but only uses doubles (useful for python)
  32. int nfMieScatt(int L, int pl, double x[], double mr[], double mi[], int nTheta, double Theta[], int n_max, double *Qext, double *Qsca, double *Qabs, double *Qbk, double *Qpr, double *g, double *Albedo, double S1r[], double S1i[], double S2r[], double S2i[]){
  33. int i, result;
  34. complex m[L], S1[nTheta], S2[nTheta];
  35. for (i = 0; i < L; i++) {
  36. m[i].r = mr[i];
  37. m[i].i = mi[i];
  38. }
  39. result = nMieScatt(L, pl, x, m, nTheta, Theta, n_max, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2);
  40. for (i = 0; i < nTheta; i++) {
  41. S1r[i] = S1[i].r;
  42. S1i[i] = S1[i].i;
  43. S2r[i] = S2[i].r;
  44. S2i[i] = S2[i].i;
  45. }
  46. return result;
  47. }
  48. int nfMieField(int L, int pl, double x[], double mr[], double mi[], int n_max, int nCoords, double Xp[], double Yp[], double Zp[], double Er[], double Ei[], double Hr[], double Hi[]){
  49. int i, result;
  50. complex m[L], E[nCoords], H[nCoords];
  51. for (i = 0; i < L; i++) {
  52. m[i].r = mr[i];
  53. m[i].i = mi[i];
  54. }
  55. result = nMieField(L, pl, x, m, n_max, nCoords, Xp, Yp, Zp, E, H);
  56. for (i = 0; i < nCoords; i++) {
  57. Er[i] = E[i].r;
  58. Ei[i] = E[i].i;
  59. Hr[i] = H[i].r;
  60. Hi[i] = H[i].i;
  61. }
  62. return result;
  63. }