12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import sys
- sys.path.insert(0,'..')
- from scattnlay import scattnlay,scattcoeffs,fieldnlay, mie
- import matplotlib.pyplot as plt
- import numpy as np
- import cmath
- from_WL = 300
- to_WL = 1000
- WL_points= 1000
- WLs = np.linspace(from_WL, to_WL, WL_points)
- index_NP = 4+0.01j
- x = np.ones((1), dtype = np.float64)
- m = np.ones((1), dtype = np.complex128)
- core_r = 100
- Qsca_vec = []
- Qsca_mode_vec = []
- for WL in WLs:
- x[0] = 2.0*np.pi*core_r/WL
- m[0] = index_NP
- mie.SetLayersSize(x)
- mie.SetLayersIndex(m)
- mie.SetModeNmaxAndType(-1,-1)
- mie.RunMieCalculation()
- Qsca = mie.GetQsca()
- mie.SetModeNmaxAndType(1,0)
- mie.RunMieCalculation()
- Qsca_mode = mie.GetQsca()
- print(np.array([Qsca]))
- Qsca_vec.append(Qsca)
- Qsca_mode_vec.append(Qsca_mode)
- fig, axs2 = plt.subplots(1,1)
- axs2.plot(WLs, Qsca_vec, color="blue")
- axs2.plot(WLs, Qsca_mode_vec, color="red")
- plt.savefig("spectra.pdf",pad_inches=0.02, bbox_inches='tight')
- plt.show()
- plt.clf()
- plt.close()
|