test-surf-integral.cc 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //**********************************************************************************//
  2. // Copyright (C) 2009-2016 Ovidio Pena <ovidio@bytesfall.com> //
  3. // Copyright (C) 2013-2016 Konstantin Ladutenko <kostyfisik@gmail.com> //
  4. // //
  5. // This file is part of scattnlay //
  6. // //
  7. // This program is free software: you can redistribute it and/or modify //
  8. // it under the terms of the GNU General Public License as published by //
  9. // the Free Software Foundation, either version 3 of the License, or //
  10. // (at your option) any later version. //
  11. // //
  12. // This program is distributed in the hope that it will be useful, //
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of //
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
  15. // GNU General Public License for more details. //
  16. // //
  17. // The only additional remark is that we expect that all publications //
  18. // describing work using this software, or all commercial products //
  19. // using it, cite the following reference: //
  20. // [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by //
  21. // a multilayered sphere," Computer Physics Communications, //
  22. // vol. 180, Nov. 2009, pp. 2348-2354. //
  23. // //
  24. // You should have received a copy of the GNU General Public License //
  25. // along with this program. If not, see <http://www.gnu.org/licenses/>. //
  26. //**********************************************************************************//
  27. // This program evaluates forces acting on the nanoparticle under irradiaton.
  28. #include <complex>
  29. #include <cstdio>
  30. #include <string>
  31. #include <iostream>
  32. #include "../src/shell-generator.hpp"
  33. int main(int argc, char *argv[]) {
  34. try {
  35. shell_generator::ShellGenerator shell;
  36. shell.Init();
  37. shell.Refine();
  38. //shell.Refine();
  39. //shell.Refine();
  40. double scale = 1.9; //Integration sphere radius.
  41. double shift = 1.1; //Shift of the charge relative to the sphere center.
  42. double charge = 11.0; //Coulomb charge.
  43. shell.Rescale(scale);
  44. shell.PrintVerts();
  45. auto points = shell.GetVertices();
  46. double charge_s = shell.IntegrateGaussSimple(charge, shift);
  47. std::cout << "Accuracy ( 1==ideal ): " << charge_s/charge << std::endl;
  48. } catch( const std::invalid_argument& ia ) {
  49. // Will catch if multi_layer_mie fails or other errors.
  50. std::cerr << "Invalid argument: " << ia.what() << std::endl;
  51. return -1;
  52. }
  53. return 0;
  54. }