12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- import scattnlay
- from scattnlay import scattnlay,scattcoeffs,fieldnlay
- import matplotlib.pyplot as plt
- import numpy as np
- import cmath
- import example
- from_WL = 400
- to_WL = 800
- WL_points= 400
- WLs = np.linspace(from_WL, to_WL, WL_points)
- index_NP = 1.5
- x = np.ones((1), dtype = np.float64)
- m = np.ones((1), dtype = np.complex128)
- core_r = 450
- 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(Qsca)
- terms, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2 = example.scattnlay(
- np.array(x), np.array(m))
- print(np.array([Qsca]))
- terms, an, bn = scattcoeffs(np.array([x]), np.array([m]),24)
- Qsca_vec.append(Qsca*np.pi*core_r**2*1e-5)
- 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()
|