calc-SiAgSi-Qabs.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #!/usr/bin/env python
  2. # -*- coding: UTF-8 -*-
  3. #
  4. # Copyright (C) 2009-2015 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
  5. #
  6. # This file is part of python-scattnlay
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # The only additional remark is that we expect that all publications
  19. # describing work using this software, or all commercial products
  20. # using it, cite the following reference:
  21. # [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by
  22. # a multilayered sphere," Computer Physics Communications,
  23. # vol. 180, Nov. 2009, pp. 2348-2354.
  24. #
  25. # You should have received a copy of the GNU General Public License
  26. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. # This test case calculates the electric field in the
  28. # E-k plane, for an spherical Si-Ag-Si nanoparticle.
  29. import scattnlay
  30. from scattnlay import fieldnlay
  31. from scattnlay import scattnlay
  32. import numpy as np
  33. import cmath
  34. # from fieldplot import GetFlow3D
  35. # from fieldplot import GetField
  36. from fieldplot import fieldplot
  37. ###############################################################################
  38. def SetXM(design):
  39. """ design value:
  40. 1: AgSi - a1
  41. 2: SiAgSi - a1, b1
  42. 3: SiAgSi - a1, b2
  43. """
  44. epsilon_Si = 18.4631066585 + 0.6259727805j
  45. epsilon_Ag = -8.5014154589 + 0.7585845411j
  46. index_Si = np.sqrt(epsilon_Si)
  47. index_Ag = np.sqrt(epsilon_Ag)
  48. isSiAgSi=True
  49. isBulk = False
  50. if design==1:
  51. #36 5.62055 0 31.93 4.06 49 5.62055 500
  52. isSiAgSi=False
  53. WL=500 #nm
  54. core_width = 0.0 #nm Si
  55. inner_width = 31.93 #nm Ag
  56. outer_width = 4.06 #nm Si
  57. elif design==2:
  58. #62.5 4.48866 29.44 10.33 22.73 0 4.48866 500
  59. WL=500 #nm
  60. core_width = 29.44 #nm Si
  61. inner_width = 10.33 #nm Ag
  62. outer_width = 22.73 #nm Si
  63. elif design == 3:
  64. #81.4 3.14156 5.27 8.22 67.91 0 3.14156 500
  65. WL=500 #nm
  66. core_width = 5.27 #nm Si
  67. inner_width = 8.22 #nm Ag
  68. outer_width = 67.91 #nm Si
  69. elif design==4:
  70. WL=800 #nm
  71. epsilon_Si = 13.64 + 0.047j
  72. epsilon_Ag = -28.05 + 1.525j
  73. core_width = 17.74 #nm Si
  74. inner_width = 23.31 #nm Ag
  75. outer_width = 22.95 #nm Si
  76. elif design==5:
  77. WL=354 #nm
  78. core_r = WL/20.0
  79. epsilon_Ag = -2.0 + 0.28j #original
  80. index_Ag = np.sqrt(epsilon_Ag)
  81. x = np.ones((1), dtype = np.float64)
  82. x[0] = 2.0*np.pi*core_r/WL
  83. m = np.ones((1), dtype = np.complex128)
  84. m[0] = index_Ag
  85. # x = np.ones((2), dtype = np.float64)
  86. # x[0] = 2.0*np.pi*core_r/WL/4.0*3.0
  87. # x[1] = 2.0*np.pi*core_r/WL
  88. # m = np.ones((2), dtype = np.complex128)
  89. # m[0] = index_Ag
  90. # m[1] = index_Ag
  91. return x, m, WL
  92. core_r = core_width
  93. inner_r = core_r+inner_width
  94. outer_r = inner_r+outer_width
  95. nm = 1.0
  96. if isSiAgSi:
  97. x = np.ones((3), dtype = np.float64)
  98. x[0] = 2.0*np.pi*core_r/WL
  99. x[1] = 2.0*np.pi*inner_r/WL
  100. x[2] = 2.0*np.pi*outer_r/WL
  101. m = np.ones((3), dtype = np.complex128)
  102. m[0] = index_Si/nm
  103. m[1] = index_Ag/nm
  104. # m[0, 1] = index_Si/nm
  105. m[2] = index_Si/nm
  106. else:
  107. # bilayer
  108. x = np.ones((2), dtype = np.float64)
  109. x[0] = 2.0*np.pi*inner_r/WL
  110. x[1] = 2.0*np.pi*outer_r/WL
  111. m = np.ones((2), dtype = np.complex128)
  112. m[0] = index_Ag/nm
  113. m[1] = index_Si/nm
  114. return x, m, WL
  115. ###############################################################################
  116. #design = 1 #AgSi
  117. design = 2
  118. #design = 3
  119. #design = 4 # WL=800
  120. comment='SiAgSi-flow'
  121. #design = 5 # Bulk Ag
  122. # comment='bulk-Ag-flow'
  123. x, m, WL = SetXM(design)
  124. WL_units='nm'
  125. print "x =", x
  126. print "m =", m
  127. npts = 501
  128. factor=2.1
  129. flow_total = 39
  130. #flow_total = 21
  131. #flow_total = 0
  132. crossplane='XZ'
  133. #crossplane='YZ'
  134. #crossplane='XY'
  135. # Options to plot: Eabs, Habs, Pabs, angleEx, angleHy
  136. field_to_plot='Pabs'
  137. #field_to_plot='angleEx'
  138. fieldplot(x,m, WL, comment, WL_units, crossplane, field_to_plot, npts, factor, flow_total)