|
@@ -0,0 +1,277 @@
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+import scattnlay
|
|
|
+from scattnlay import fieldnlay
|
|
|
+from scattnlay import scattnlay
|
|
|
+import numpy as np
|
|
|
+import cmath
|
|
|
+from fieldplot import GetFlow3D
|
|
|
+from fieldplot import GetField
|
|
|
+
|
|
|
+
|
|
|
+def SetXM(design):
|
|
|
+ """ design value:
|
|
|
+ 1: AgSi - a1
|
|
|
+ 2: SiAgSi - a1, b1
|
|
|
+ 3: SiAgSi - a1, b2
|
|
|
+ """
|
|
|
+ epsilon_Si = 18.4631066585 + 0.6259727805j
|
|
|
+ epsilon_Ag = -8.5014154589 + 0.7585845411j
|
|
|
+ index_Si = np.sqrt(epsilon_Si)
|
|
|
+ index_Ag = np.sqrt(epsilon_Ag)
|
|
|
+ isSiAgSi=True
|
|
|
+ isBulk = False
|
|
|
+ if design==1:
|
|
|
+
|
|
|
+ isSiAgSi=False
|
|
|
+ WL=500
|
|
|
+ core_width = 0.0
|
|
|
+ inner_width = 31.93
|
|
|
+ outer_width = 4.06
|
|
|
+ elif design==2:
|
|
|
+
|
|
|
+ WL=500
|
|
|
+ core_width = 29.44
|
|
|
+ inner_width = 10.33
|
|
|
+ outer_width = 22.73
|
|
|
+ elif design == 3:
|
|
|
+
|
|
|
+ WL=500
|
|
|
+ core_width = 5.27
|
|
|
+ inner_width = 8.22
|
|
|
+ outer_width = 67.91
|
|
|
+ elif design==4:
|
|
|
+ WL=800
|
|
|
+ epsilon_Si = 13.64 + 0.047j
|
|
|
+ epsilon_Ag = -28.05 + 1.525j
|
|
|
+ core_width = 17.74
|
|
|
+ inner_width = 23.31
|
|
|
+ outer_width = 22.95
|
|
|
+ elif design==5:
|
|
|
+ WL=354
|
|
|
+ core_r = WL/20.0
|
|
|
+ epsilon_Ag = -2.0 + 0.28j
|
|
|
+ index_Ag = np.sqrt(epsilon_Ag)
|
|
|
+ x = np.ones((1), dtype = np.float64)
|
|
|
+ x[0] = 2.0*np.pi*core_r/WL
|
|
|
+ m = np.ones((1), dtype = np.complex128)
|
|
|
+ m[0] = index_Ag
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return x, m, WL
|
|
|
+
|
|
|
+
|
|
|
+ core_r = core_width
|
|
|
+ inner_r = core_r+inner_width
|
|
|
+ outer_r = inner_r+outer_width
|
|
|
+
|
|
|
+ nm = 1.0
|
|
|
+ if isSiAgSi:
|
|
|
+ x = np.ones((3), dtype = np.float64)
|
|
|
+ x[0] = 2.0*np.pi*core_r/WL
|
|
|
+ x[1] = 2.0*np.pi*inner_r/WL
|
|
|
+ x[2] = 2.0*np.pi*outer_r/WL
|
|
|
+ m = np.ones((3), dtype = np.complex128)
|
|
|
+ m[0] = index_Si/nm
|
|
|
+ m[1] = index_Ag/nm
|
|
|
+
|
|
|
+ m[2] = index_Si/nm
|
|
|
+ else:
|
|
|
+
|
|
|
+ x = np.ones((2), dtype = np.float64)
|
|
|
+ x[0] = 2.0*np.pi*inner_r/WL
|
|
|
+ x[1] = 2.0*np.pi*outer_r/WL
|
|
|
+ m = np.ones((2), dtype = np.complex128)
|
|
|
+ m[0] = index_Ag/nm
|
|
|
+ m[1] = index_Si/nm
|
|
|
+ return x, m, WL
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+design = 5
|
|
|
+x, m, WL = SetXM(design)
|
|
|
+
|
|
|
+
|
|
|
+WL_units='nm'
|
|
|
+comment='P-SiAgSi-flow'
|
|
|
+comment='bulk-P-Ag-flow'
|
|
|
+print "x =", x
|
|
|
+print "m =", m
|
|
|
+npts = 101
|
|
|
+factor=2.2
|
|
|
+flow_total = 3
|
|
|
+
|
|
|
+crossplane='XZ'
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+Ec, Hc, P, coordX, coordZ = GetField(crossplane, npts, factor, x, m)
|
|
|
+
|
|
|
+Er = np.absolute(Ec)
|
|
|
+Hr = np.absolute(Hc)
|
|
|
+
|
|
|
+Eabs = np.sqrt(Er[ :, 0]**2 + Er[ :, 1]**2 + Er[ :, 2]**2)
|
|
|
+Eangle = np.angle(Ec[ :, 0])/np.pi*180
|
|
|
+Habs= np.sqrt(Hr[ :, 0]**2 + Hr[ :, 1]**2 + Hr[ :, 2]**2)
|
|
|
+Hangle = np.angle(Hc[ :, 1])/np.pi*180
|
|
|
+
|
|
|
+try:
|
|
|
+ import matplotlib.pyplot as plt
|
|
|
+ from matplotlib import cm
|
|
|
+ from matplotlib.colors import LogNorm
|
|
|
+
|
|
|
+ Eabs_data = np.resize(P, (npts, npts)).T
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ fig, ax = plt.subplots(1,1)
|
|
|
+
|
|
|
+ scale_x = np.linspace(min(coordX)*WL/2.0/np.pi, max(coordX)*WL/2.0/np.pi, npts)
|
|
|
+ scale_z = np.linspace(min(coordZ)*WL/2.0/np.pi, max(coordZ)*WL/2.0/np.pi, npts)
|
|
|
+
|
|
|
+
|
|
|
+ min_tick = np.amin(Eabs_data[~np.isnan(Eabs_data)])
|
|
|
+ max_tick = np.amax(Eabs_data[~np.isnan(Eabs_data)])
|
|
|
+ scale_ticks = np.linspace(min_tick, max_tick, 6)
|
|
|
+
|
|
|
+
|
|
|
+ ax.set_title('Pabs')
|
|
|
+ cax = ax.imshow(Eabs_data, interpolation = 'nearest', cmap = cm.jet,
|
|
|
+ origin = 'lower'
|
|
|
+ , vmin = min_tick, vmax = max_tick
|
|
|
+ , extent = (min(scale_x), max(scale_x), min(scale_z), max(scale_z))
|
|
|
+
|
|
|
+ )
|
|
|
+ ax.axis("image")
|
|
|
+
|
|
|
+
|
|
|
+ cbar = fig.colorbar(cax, ticks = [a for a in scale_ticks])
|
|
|
+ cbar.ax.set_yticklabels(['%5.3g' % (a) for a in scale_ticks])
|
|
|
+ pos = list(cbar.ax.get_position().bounds)
|
|
|
+
|
|
|
+ if crossplane=='XZ':
|
|
|
+ plt.xlabel('Z, '+WL_units)
|
|
|
+ plt.ylabel('X, '+WL_units)
|
|
|
+ elif crossplane=='YZ':
|
|
|
+ plt.xlabel('Z, '+WL_units)
|
|
|
+ plt.ylabel('Y, '+WL_units)
|
|
|
+ elif crossplane=='XY':
|
|
|
+ plt.xlabel('Y, '+WL_units)
|
|
|
+ plt.ylabel('X, '+WL_units)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ from matplotlib import patches
|
|
|
+ from matplotlib.path import Path
|
|
|
+ for xx in x:
|
|
|
+ r= xx*WL/2.0/np.pi
|
|
|
+ s1 = patches.Arc((0, 0), 2.0*r, 2.0*r, angle=0.0, zorder=1.8,
|
|
|
+ theta1=0.0, theta2=360.0, linewidth=1, color='black')
|
|
|
+ ax.add_patch(s1)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (crossplane=='XZ' or crossplane=='YZ') and flow_total>0:
|
|
|
+
|
|
|
+ from matplotlib.path import Path
|
|
|
+ scanSP = np.linspace(-factor*x[-1], factor*x[-1], npts)
|
|
|
+ min_SP = -factor*x[-1]
|
|
|
+ step_SP = 2.0*factor*x[-1]/(flow_total-1)
|
|
|
+ x0, y0, z0 = 0, 0, 0
|
|
|
+ max_length=factor*x[-1]*15
|
|
|
+
|
|
|
+ max_angle = np.pi/200
|
|
|
+
|
|
|
+ for flow in range(0,flow_total):
|
|
|
+ if crossplane=='XZ':
|
|
|
+
|
|
|
+ x0 = min_SP + flow*step_SP
|
|
|
+ z0 = min_SP
|
|
|
+
|
|
|
+ elif crossplane=='YZ':
|
|
|
+
|
|
|
+ y0 = min_SP + flow*step_SP
|
|
|
+ z0 = min_SP
|
|
|
+
|
|
|
+ flow_xSP, flow_ySP, flow_zSP = GetFlow3D(x0, y0, z0, max_length, max_angle, x, m)
|
|
|
+ if crossplane=='XZ':
|
|
|
+ flow_z_plot = flow_zSP*WL/2.0/np.pi
|
|
|
+ flow_f_plot = flow_xSP*WL/2.0/np.pi
|
|
|
+ elif crossplane=='YZ':
|
|
|
+ flow_z_plot = flow_zSP*WL/2.0/np.pi
|
|
|
+ flow_f_plot = flow_ySP*WL/2.0/np.pi
|
|
|
+
|
|
|
+ verts = np.vstack((flow_z_plot, flow_f_plot)).transpose().tolist()
|
|
|
+ codes = [Path.LINETO]*len(verts)
|
|
|
+ codes[0] = Path.MOVETO
|
|
|
+ path = Path(verts, codes)
|
|
|
+
|
|
|
+ patch = patches.PathPatch(path, facecolor='none', lw=1, edgecolor='white',zorder = 1.9)
|
|
|
+ ax.add_patch(patch)
|
|
|
+ ax.plot(flow_z_plot, flow_f_plot, 'x',ms=2, mew=0.1, linewidth=0.5, color='k', fillstyle='none')
|
|
|
+
|
|
|
+ plt.savefig(comment+"-R"+str(int(round(x[-1]*WL/2.0/np.pi)))+"-"+crossplane+".svg")
|
|
|
+ plt.draw()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ plt.clf()
|
|
|
+ plt.close()
|
|
|
+finally:
|
|
|
+ terms, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2 = scattnlay(np.array([x]),
|
|
|
+ np.array([m]))
|
|
|
+ print("Qabs = "+str(Qabs));
|
|
|
+
|
|
|
+
|
|
|
+
|