calc-SiAgSi-Qabs.py 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. from polarplot import polarplot
  39. ###############################################################################
  40. def SetXM(design):
  41. """ design value:
  42. 1: AgSi - a1
  43. 2: SiAgSi - a1, b1
  44. 3: SiAgSi - a1, b2
  45. """
  46. epsilon_Si = 18.4631066585 + 0.6259727805j
  47. epsilon_Ag = -8.5014154589 + 0.7585845411j
  48. index_Si = np.sqrt(epsilon_Si)
  49. index_Ag = np.sqrt(epsilon_Ag)
  50. isSiAgSi=True
  51. isBulk = False
  52. if design==1:
  53. #36 5.62055 0 31.93 4.06 49 5.62055 500
  54. isSiAgSi=False
  55. WL=500 #nm
  56. core_width = 0.0 #nm Si
  57. inner_width = 31.93 #nm Ag
  58. outer_width = 4.06 #nm Si
  59. elif design==2:
  60. #62.5 4.48866 29.44 10.33 22.73 0 4.48866 500
  61. WL=500 #nm
  62. core_width = 29.44 #nm Si
  63. inner_width = 10.33 #nm Ag
  64. outer_width = 22.73 #nm Si
  65. elif design == 3:
  66. #81.4 3.14156 5.27 8.22 67.91 0 3.14156 500
  67. WL=500 #nm
  68. core_width = 5.27 #nm Si
  69. inner_width = 8.22 #nm Ag
  70. outer_width = 67.91 #nm Si
  71. elif design==4:
  72. WL=800 #nm
  73. epsilon_Si = 13.64 + 0.047j
  74. epsilon_Ag = -28.05 + 1.525j
  75. core_width = 17.74 #nm Si
  76. inner_width = 23.31 #nm Ag
  77. outer_width = 22.95 #nm Si
  78. elif design==5:
  79. WL=354 #nm
  80. core_r = WL/20.0
  81. epsilon_Ag = -2.0 + 0.28j #original
  82. index_Ag = np.sqrt(epsilon_Ag)
  83. x = np.ones((1), dtype = np.float64)
  84. x[0] = 2.0*np.pi*core_r/WL
  85. m = np.ones((1), dtype = np.complex128)
  86. m[0] = index_Ag
  87. # x = np.ones((2), dtype = np.float64)
  88. # x[0] = 2.0*np.pi*core_r/WL/4.0*3.0
  89. # x[1] = 2.0*np.pi*core_r/WL
  90. # m = np.ones((2), dtype = np.complex128)
  91. # m[0] = index_Ag
  92. # m[1] = index_Ag
  93. return x, m, WL
  94. elif design==6:
  95. # WL=1052 #nm
  96. # core_r = 140.0
  97. # #core_r = 190.0
  98. # core_r = 204.2
  99. # epsilon_Si = 12.7294053067+0.000835315166667j
  100. # index_Si = np.sqrt(epsilon_Si)
  101. #WL=455
  102. WL=456.33
  103. core_r = 90
  104. index_Si = 4.615+0.131j
  105. x = np.ones((1), dtype = np.float64)
  106. x[0] = 2.0*np.pi*core_r/WL
  107. m = np.ones((1), dtype = np.complex128)
  108. m[0] = index_Si
  109. # x = np.ones((2), dtype = np.float64)
  110. # x[0] = 2.0*np.pi*core_r/WL/4.0*3.0
  111. # x[1] = 2.0*np.pi*core_r/WL
  112. # m = np.ones((2), dtype = np.complex128)
  113. # m[0] = index_Ag
  114. # m[1] = index_Ag
  115. return x, m, WL
  116. core_r = core_width
  117. inner_r = core_r+inner_width
  118. outer_r = inner_r+outer_width
  119. nm = 1.0
  120. if isSiAgSi:
  121. x = np.ones((3), dtype = np.float64)
  122. x[0] = 2.0*np.pi*core_r/WL
  123. x[1] = 2.0*np.pi*inner_r/WL
  124. x[2] = 2.0*np.pi*outer_r/WL
  125. m = np.ones((3), dtype = np.complex128)
  126. m[0] = index_Si/nm
  127. m[1] = index_Ag/nm
  128. # m[0, 1] = index_Si/nm
  129. m[2] = index_Si/nm
  130. else:
  131. # bilayer
  132. x = np.ones((2), dtype = np.float64)
  133. x[0] = 2.0*np.pi*inner_r/WL
  134. x[1] = 2.0*np.pi*outer_r/WL
  135. m = np.ones((2), dtype = np.complex128)
  136. m[0] = index_Ag/nm
  137. m[1] = index_Si/nm
  138. return x, m, WL
  139. ###############################################################################
  140. #design = 1 #AgSi
  141. #design = 2
  142. #design = 3
  143. # design = 4 # WL=800
  144. # comment='SiAgSi-flow'
  145. #design = 5 # Bulk Ag
  146. # comment='bulk-Ag-flow'
  147. design = 6 # WL=800
  148. comment='Si-flow'
  149. x, m, WL = SetXM(design)
  150. WL_units='nm'
  151. print( "x =", x[-1])
  152. print( "m =", m)
  153. npts = 151
  154. factor=1.1
  155. #flow_total = 39
  156. #flow_total = 21
  157. flow_total = 0
  158. crossplane='XZ'
  159. #crossplane='XYZ'
  160. #crossplane='YZ'
  161. #crossplane='XY'
  162. # Options to plot: Eabs, Habs, Pabs, angleEx, angleHy
  163. field_to_plot='Eabs'
  164. #field_to_plot='angleEx'
  165. #field_to_plot='Pabs'
  166. import matplotlib.pyplot as plt
  167. fig, axs = plt.subplots(1,1)#, sharey=True, sharex=True)
  168. fig.tight_layout()
  169. fieldplot(fig, axs, x,m, WL, comment, WL_units, crossplane, field_to_plot, npts, factor, flow_total,
  170. subplot_label=' ',is_flow_extend=False,
  171. #inner_only = True
  172. )
  173. fig.subplots_adjust(hspace=0.3, wspace=-0.1)
  174. plt.savefig(comment+"-R"+str(int(round(x[-1]*WL/2.0/np.pi)))+"-"+crossplane+"-"
  175. +field_to_plot+".pdf",pad_inches=0.02, bbox_inches='tight')
  176. plt.draw()
  177. # plt.show()
  178. plt.clf()
  179. plt.close()
  180. polarplot(x,m,comment+"-R"+str(int(round(x[-1]*WL/2.0/np.pi)))+"-"+crossplane+"-"
  181. +field_to_plot+"-polar.pdf")