calc-size-averaged-Qext.py 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #!/usr/bin/env python3
  2. # -*- coding: UTF-8 -*-
  3. #
  4. # Copyright (C) 2021 Konstantin Ladutenko <kostyfisik@gmail.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. from scattnlay import mie
  28. import matplotlib.pyplot as plt
  29. import numpy as np
  30. from optical_constants import read_refractive_index_from_yaml as get_index
  31. def gauss(x, mu, sigma):
  32. return 1/(sigma * np.sqrt(2 * np.pi)) * np.exp( - (x - mu)**2 / (2 * sigma**2))
  33. # fill_factor = 0.8
  34. from_WL = 300
  35. to_WL = 1100
  36. WL_points= 100
  37. WLs = np.linspace(from_WL, to_WL, WL_points)
  38. r_points = 200
  39. from_r = 40/2.
  40. to_r =80/2.
  41. all_r = np.linspace(from_r, to_r, r_points)
  42. r_mean = 58.3/2.
  43. r_std = 6.3/2.
  44. # from_r = 1.
  45. # to_r =15.
  46. # all_r = np.linspace(from_r, to_r, r_points)
  47. # r_mean = 6
  48. # r_std = 2
  49. core_r = 30
  50. inner_shell_h = 8
  51. outer_shell_h = 10
  52. host_media = 1.33
  53. r_weights = gauss(all_r, r_mean,r_std)/len(all_r)
  54. plt.plot(all_r, r_weights )
  55. plt.xlabel("R, nm")
  56. plt.ylabel("amount")
  57. index_SiO2 = get_index("refractiveindex_info/SiO2-Gao.yml", WLs, units='nm')
  58. # index_Au = get_index("refractiveindex_info/Au-McPeak.yml", WLs, units='nm')
  59. index_Au = get_index("refractiveindex_info/Au-Johnson.yml", WLs, units='nm')
  60. index_TiO2 = get_index("refractiveindex_info/TiO2-Sarkar.yml", WLs, units='nm')
  61. # index_TiO2[:,1] += 0.5j
  62. # index_Au[:,1] = index_Au[:,1]* fill_factor + (1-fill_factor)
  63. # print("Au index before correction, max = ", np.max(np.imag(index_Au[:,1])))
  64. # # Taking into account gold free electrons damping
  65. # # contributed by surface scattering and bulk dumping
  66. # # See eq 1 in [1] -> doi: https://doi.org/10.1186/s11671-018-2670-7
  67. # eps_exp = index_Au[:,1]**2
  68. # c=299792458 # speed of light
  69. # h= 4.135667516e-15 # eV*s, Planck constant
  70. # w = h*c/(WLs*1e-9) # eV, frequency
  71. # w_p =8.55 # eV, gold plasmon frequency
  72. # g_b = 18.4e-3 # eV, bulk dumping
  73. # v_f = 1.4e6 # m/s, Fermi velocity of electrons in gold
  74. # A = 1.33 # fit parameter for 16 nm gold shell, see Table 2 in [1]
  75. # L_b = (4.*((core_r+inner_shell_h)**3 - core_r**3)/
  76. # (3.*((core_r+inner_shell_h)**2 + core_r**2)))
  77. # # g_s = v_f/L_b # eq 2 in [1]
  78. # g_s = h*A*v_f/(inner_shell_h*1e-9) # eq 4 in [1]
  79. # # g_b *= 0.2
  80. # # g_s *= 0.5
  81. # eps_Au = (eps_exp
  82. # +
  83. # w_p**2 / ( w * (w + 1j*g_b) )
  84. # -
  85. # w_p**2 / ( w * (w + 1j*(g_b+g_s)) )
  86. # )
  87. # index_Au[:,1] = np.sqrt(eps_Au)
  88. index_Au[:,1] += 1.6j
  89. # print(f"L_b={L_b}")
  90. # # print(w)
  91. # print(f"g_s={g_s}, g_b={g_b} ")
  92. # print("Au index after, max = ", np.max(np.imag(index_Au[:,1])))
  93. x = np.ones((3), dtype = np.float64)
  94. m = np.ones((3), dtype = np.complex128)
  95. Qext_core_shell = np.zeros(len(WLs))
  96. Qext_3l = np.zeros(len(WLs))
  97. for i in range(len(WLs)):
  98. WL = WLs[i]
  99. for j in range(len(all_r)):
  100. core_r = all_r[j]
  101. # inner_shell_h = all_r[j]
  102. weight = r_weights[j]
  103. # print(core_r)
  104. x = host_media*2.0*np.pi/WL*np.array([core_r,
  105. core_r+inner_shell_h,
  106. core_r+inner_shell_h+outer_shell_h])
  107. m = np.array([index_SiO2[i][1], index_Au[i][1],
  108. index_TiO2[i][1]]
  109. )/host_media
  110. # print(x, m)
  111. mie.SetLayersSize(x)
  112. mie.SetLayersIndex(m)
  113. mie.RunMieCalculation()
  114. Qext_3l[i] += mie.GetQext()*weight
  115. x = host_media*2.0*np.pi/WL*np.array([core_r,
  116. core_r+inner_shell_h])
  117. m = np.array([index_SiO2[i][1], index_Au[i][1]])/host_media
  118. mie.SetLayersSize(x)
  119. mie.SetLayersIndex(m)
  120. mie.RunMieCalculation()
  121. Qext_core_shell[i] += mie.GetQext()*weight
  122. fig, axs2 = plt.subplots(1,1)#, sharey=True, sharex=True)
  123. axs2.plot(WLs, Qext_3l, color="purple")
  124. axs2.plot(WLs, Qext_core_shell, color="lime")
  125. axs2.set_xlabel("WL, nm")
  126. axs2.set_ylabel("Extinction, a.u.")
  127. # axs2 = axs.twinx()
  128. # axs2.plot(np.array(core_r_vec)*2,an_vec[:,0],"b.",lw=0.8, markersize=1.9,label="$a_0$")
  129. # axs2.plot(np.array(core_r_vec)*2,bn_vec[:,0],"b-", markersize=1.9,label="$b_0$")
  130. # axs2.plot(np.array(core_r_vec)*2,an_vec[:,1],"g.",lw=0.8, markersize=1.9,label="$a_1$")
  131. # axs2.plot(np.array(core_r_vec)*2,bn_vec[:,1],"g-", markersize=1.9,label="$b_1$")
  132. # axs2.legend(loc="upper right")
  133. # axs2.tick_params('y', colors='black')
  134. # axs2.set_ylim(0,1)
  135. # axs2.set_ylabel("Mie",color="black")
  136. plt.savefig("spectra.pdf",pad_inches=0.02, bbox_inches='tight')
  137. plt.show()
  138. plt.clf()
  139. plt.close()