calc-SiAgSi-Qabs.py 5.7 KB

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