123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import sys
- sys.path.insert(0,'..')
- from scattnlay import scattnlay,scattcoeffs,fieldnlay, switch_to_double_precision, switch_to_multiple_precision
- import matplotlib.pyplot as plt
- import numpy as np
- import cmath
- switch_to_multiple_precision()
- from_WL = 400
- to_WL = 800
- WL_points= 100
- WLs = np.linspace(from_WL, to_WL, WL_points)
- index_NP = 1.5+0.3j
- x = np.ones((1), dtype = np.float64)
- m = np.ones((1), dtype = np.complex128)
- core_r = 45000
- Qsca_vec = []
- core_r_vec = []
- an_vec = []
- bn_vec = []
- for WL in WLs:
- x[0] = 2.0*np.pi*core_r/WL
- m[0] = index_NP
- terms, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2 = scattnlay(
- np.array(x), np.array(m))
- print(np.array([Qsca]))
- terms, an, bn = scattcoeffs(x, m,24)
-
- Qsca_vec.append(Qsca)
- core_r_vec.append(core_r)
- an_vec.append(np.abs(an)[0])
- bn_vec.append(np.abs(bn)[0])
- an_vec = np.array(an_vec)
- bn_vec = np.array(bn_vec)
- fig, axs2 = plt.subplots(1,1)
- axs2.plot(WLs, Qsca_vec, color="black")
- plt.savefig("spectra.pdf",pad_inches=0.02, bbox_inches='tight')
- plt.show()
- plt.clf()
- plt.close()
|