1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- from scattnlay import fieldnlay, scattnlay, expansioncoeffs, scattcoeffs
- import cmath
- import matplotlib.pyplot as plt
- import numpy as np
- x = np.ones((1), dtype = np.float64)
- m = np.ones((1), dtype = np.complex128)
- WL=550
- core_r = 180
- index_NP = 4.0
- from_R = 120/2.0
- to_R = 240/2.0
- npts = 151
- ext = ".png"
- npts = 351
- comment='bulk-NP-WL'+str(WL)
- val_all = []
- all_R = np.linspace(from_R, to_R, npts)
- for core_r in all_R:
- 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]))
- terms, an, bn = scattcoeffs(np.array([x]), np.array([m]),terms)
- terms, aln, bln, cln, dln = expansioncoeffs(np.array([x]), np.array([m]), terms)
- order = 0
- val_all.append([
- np.abs(aln[0][-1][order]),np.abs(dln[0][0][order])
-
- ])
- val_all = np.array(val_all)
- fig, axs = plt.subplots(1,1)
- fig.tight_layout()
- fig.subplots_adjust(hspace=0.3, wspace=-0.1)
- all_R = all_R*2
- plt.plot(all_R, val_all[:,0],label="electric dipole, scatt.")
- plt.plot(all_R, val_all[:,1],label="electric dipole, internal")
- plt.legend()
- plt.ylim(0,4)
- plt.xlabel("D, nm")
- plt.ylabel("Mie coefficients")
- plt.savefig(comment+"-R"+str(int(round(x[-1]*WL/2.0/np.pi)))+ext,
- pad_inches=0.02, bbox_inches='tight')
- plt.clf()
- plt.close()
|