calc-SiAgSi-Qabs.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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.array([2.0*np.pi*core_r/WL], dtype = np.float64)
  83. m = np.array([index_Ag], dtype = np.complex128)
  84. return x, m, WL
  85. elif design==6:
  86. WL=1052 #nm
  87. core_r = 140.0
  88. #core_r = 190.0
  89. core_r = 204.2
  90. epsilon_Si = 12.7294053067+0.000835315166667j
  91. index_Si = np.sqrt(epsilon_Si)
  92. x = np.array([2.0*np.pi*core_r/WL], dtype = np.float64)
  93. m = np.array([index_Si], dtype = np.complex128)
  94. return x, m, WL
  95. core_r = core_width
  96. inner_r = core_r+inner_width
  97. outer_r = inner_r+outer_width
  98. nm = 1.0
  99. if isSiAgSi:
  100. x = 2.0*np.pi*np.array([core_r, inner_r, outer_r], dtype = np.float64)/WL
  101. m = np.array([index_Si, index_Ag, index_Si], dtype = np.complex128)/nm
  102. else:
  103. # bilayer
  104. x = 2.0*np.pi*np.array([inner_r, outer_r], dtype = np.float64)/WL
  105. m = np.array([index_Ag, index_Si], dtype = np.complex128)/nm
  106. return x, m, WL
  107. ###############################################################################
  108. #design = 1 #AgSi
  109. #design = 2
  110. #design = 3
  111. # design = 4 # WL=800
  112. # comment='SiAgSi-flow'
  113. #design = 5 # Bulk Ag
  114. # comment='bulk-Ag-flow'
  115. design = 6 # WL=800
  116. comment='Si-flow'
  117. x, m, WL = SetXM(design)
  118. WL_units='nm'
  119. print("x =", x)
  120. print("m =", m)
  121. npts = 501
  122. factor=2.1
  123. flow_total = 39
  124. #flow_total = 21
  125. #flow_total = 0
  126. #crossplane='XZ'
  127. crossplane='XYZ'
  128. #crossplane='YZ'
  129. #crossplane='XY'
  130. # Options to plot: Eabs, Habs, Pabs, angleEx, angleHy
  131. field_to_plot='Eabs'
  132. #field_to_plot='angleEx'
  133. #field_to_plot='Pabs'
  134. import matplotlib.pyplot as plt
  135. fig, axs = plt.subplots(1,1)#, sharey=True, sharex=True)
  136. fig.tight_layout()
  137. fieldplot(fig, axs, x, m, WL, comment, WL_units, crossplane, field_to_plot, npts, factor, flow_total,
  138. subplot_label=' ')
  139. fig.subplots_adjust(hspace=0.3, wspace=-0.1)
  140. plt.savefig(comment+"-R"+str(int(round(x[-1]*WL/2.0/np.pi)))+"-"+crossplane+"-"
  141. +field_to_plot+".pdf",pad_inches=0.02, bbox_inches='tight')
  142. plt.draw()
  143. # plt.show()
  144. plt.clf()
  145. plt.close()