123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- import scattnlay
- from scattnlay import fieldnlay
- import numpy as np
- epsilon_Si = 2.0 + 0.047j
- epsilon_Ag = -2.0 + 1.525j
- index_Si = np.sqrt(epsilon_Si)
- index_Ag = np.sqrt(epsilon_Ag)
- index_Si = 3.69410 + 0.0065435j
- index_Ag = 0.18599 + 4.9886j
- WL=800
- core_width = 17.74
- inner_width = 23.31
- outer_width = 22.95
- core_r = core_width
- inner_r = core_r+inner_width
- outer_r = inner_r+outer_width
- nm = 1.0
- x = np.ones((1, 3), dtype = np.float64)
- x[0, 0] = 2.0*np.pi*core_r/WL
- x[0, 1] = 2.0*np.pi*inner_r/WL
- x[0, 2] = 2.0*np.pi*outer_r/WL
- m = np.ones((1, 3), dtype = np.complex128)
- m[0, 0] = index_Si/nm
- m[0, 1] = index_Si/nm
- m[0, 2] = index_Ag/nm
- print "x =", x
- print "m =", m
- npts = 1001
- scan = np.linspace(-4.0*x[0, 2], 4.0*x[0, 2], npts)
- coord = np.zeros((npts, 3), dtype = np.float64)
- coord[:, 0] = scan
- terms, E, H = fieldnlay(x, m, coord)
- Er = np.absolute(E)
- Eh = np.sqrt(Er[0, :, 0]**2 + Er[0, :, 1]**2 + Er[0, :, 2]**2)
- result = np.vstack((scan, Eh)).transpose()
- try:
- import matplotlib.pyplot as plt
- fig = plt.figure()
- ax = fig.add_subplot(111)
- ax.errorbar(result[:, 0], result[:, 1], fmt = 'r', label = 'X axis')
- ax.legend()
- plt.xlabel('X')
- plt.ylabel('|E|/|Eo|')
- plt.draw()
- plt.show()
- finally:
- np.savetxt("lfield.txt", result, fmt = "%.5f")
- print result
|