suppFig5.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/usr/bin/env python3
  2. # -*- coding: UTF-8 -*-
  3. from matplotlib import pyplot as plt
  4. import cmath
  5. from scattnlay import mesomie, mie
  6. import numpy as np
  7. import scipy.io
  8. min_lim = 0.4
  9. max_lim = 0.75
  10. # mat = scipy.io.loadmat('d-parameters/rs=4.mat')
  11. # omega_ratio = mat['omegav'][0]
  12. # d_perp = mat['dperp'][0]*10
  13. from_disk = np.loadtxt('rs4-d_perp_interpolated.txt')
  14. omega_ratio = from_disk[0, :]
  15. d_perp = from_disk[1, :] + 1j*from_disk[2, :]
  16. c = 299792458 # m/s
  17. h_reduced = 6.5821e-16 # eV s
  18. omega_p = 5.9 # eV
  19. gamma = 0.1 # eV
  20. eps_d = 1
  21. def eps_m(omega):
  22. return 1 - omega_p * omega_p / (omega*omega + 1j*omega*gamma)
  23. Rs = [2.5, 5, 10, 25]
  24. y_min = [1e-2, 1e-2, 1e-1, 1e-1]
  25. y_max = [1e1, 1e1, 5e1, 5e1]
  26. # for om_rat in omega_ratio:
  27. for fig in range(len(Rs)):
  28. R = Rs[fig]
  29. Qext = []
  30. Qext_mie = []
  31. om_rat_plot = []
  32. for i in range(len(omega_ratio)):
  33. om_rat = omega_ratio[i]
  34. if om_rat < min_lim or om_rat > max_lim:
  35. continue
  36. omega = om_rat*omega_p
  37. m = cmath.sqrt(eps_m(omega))
  38. x = (omega/c) * R * 1e-9/h_reduced
  39. mesomie.calc_ab(R*10, # R in angstrem
  40. x, # xd
  41. x * m, # xm
  42. 1, # eps_d
  43. m * m, # eps_m
  44. 0, # d_parallel
  45. d_perp[i]) # d_perp
  46. mesomie.calc_Q()
  47. mie.SetLayersSize(x)
  48. mie.SetLayersIndex(m)
  49. mie.RunMieCalculation()
  50. Qext.append(mesomie.GetQext())
  51. Qext_mie.append(mie.GetQext())
  52. # print(x, m, Qext[-1] - mie.GetQext())
  53. om_rat_plot.append(om_rat)
  54. # print(Qext)
  55. plt.figure(fig)
  56. plt.plot(om_rat_plot, Qext_mie, label='classic', color='gray', lw=4)
  57. plt.plot(om_rat_plot, Qext, label='non-classic', color='red', lw=4)
  58. plt.legend()
  59. plt.yscale('log')
  60. plt.xlim((0.4, 0.75))
  61. plt.ylim((y_min[fig], y_max[fig]))
  62. plt.title("R="+str(R))
  63. plt.show()