|
@@ -2,66 +2,135 @@
|
|
|
|
|
|
import numpy as np
|
|
|
import matplotlib.pyplot as plt
|
|
|
-file_ext="pdf"
|
|
|
-
|
|
|
+c = 299792458
|
|
|
+pi = np.pi
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+def read_data(dirname, distance, zshift):
|
|
|
+ media = [1,2]
|
|
|
+
|
|
|
+ data = []
|
|
|
+ data.append([])
|
|
|
+ for x in distance:
|
|
|
+ data.append([])
|
|
|
+ data[x].append([])
|
|
|
+ for m in media:
|
|
|
+ data[x].append([])
|
|
|
+ for z in zshift:
|
|
|
+ monitor_name = "mon_x"+str(x)+"mkm_media"+str(m)+"_zshift"+z+"nm"
|
|
|
+ data[x][m].append(
|
|
|
+ np.transpose(
|
|
|
+ np.genfromtxt(dirname+"/"+monitor_name+".txt", delimiter=", ",skip_header=1
|
|
|
+ ,dtype=None, encoding = None
|
|
|
+ , converters={0: lambda s: complex(s),
|
|
|
+ 1: lambda s: complex(s),
|
|
|
+ 2: lambda s: complex(s.replace('i', 'j')),
|
|
|
+ 3: lambda s: complex(s.replace('i', 'j')),
|
|
|
+ 4: lambda s: complex(s.replace('i', 'j')),
|
|
|
+ 5: lambda s: complex(s.replace('i', 'j')),
|
|
|
+ 6: lambda s: complex(s.replace('i', 'j')),
|
|
|
+ 7: lambda s: complex(s.replace('i', 'j')),
|
|
|
+ 8: lambda s: complex(s.replace('i', 'j'))
|
|
|
+ }
|
|
|
+ )
|
|
|
+ )
|
|
|
+ )
|
|
|
+ return data
|
|
|
|
|
|
-
|
|
|
-
|
|
|
|
|
|
-distance = [2,4,6,8,10,12,14,16,18,20,22]
|
|
|
-dirname="Si-sphere-step5-dipole-far-long22"
|
|
|
+def find_nearest(array,value):
|
|
|
+ idx = (np.abs(array-value)).argmin()
|
|
|
+ return array[idx],idx
|
|
|
|
|
|
-data = []
|
|
|
|
|
|
-for i in distance:
|
|
|
-
|
|
|
- data.append(
|
|
|
- np.transpose(
|
|
|
- np.loadtxt(dirname+"/r%i.txt"%i, delimiter=", ",skiprows=3)
|
|
|
- )
|
|
|
- )
|
|
|
+def get_WLs_idx(WLs, data):
|
|
|
+ dist = 1
|
|
|
+ mmedia = 1
|
|
|
+ shift = 1
|
|
|
+ WLs_idx = []
|
|
|
+ for wl in WLs:
|
|
|
+ val, idx = find_nearest(data[dist][mmedia][shift][0,:],wl*1e-9)
|
|
|
+ WLs_idx.append(idx)
|
|
|
+ return WLs_idx
|
|
|
|
|
|
|
|
|
-for i in range(len(distance)):
|
|
|
- R = distance[i]
|
|
|
- print(R)
|
|
|
- plt.semilogy(data[i][0,:], data[i][1,:]*np.sqrt(R))
|
|
|
-plt.xlabel(r'$\lambda$, nm')
|
|
|
-plt.ylabel(r'$Abs(E_x) \sqrt{R}$')
|
|
|
-plt.savefig(dirname+"_plot."+file_ext)
|
|
|
-plt.clf()
|
|
|
+def analyze(data, dist, z_vec, wl_idx):
|
|
|
+
|
|
|
+
|
|
|
+ data_in_air = np.array(data[dist][1])
|
|
|
+ data_in_gold = np.array(data[dist][2])
|
|
|
+ lambd = data_in_air[0][0,:]
|
|
|
+ omega = 2*pi*c/lambd
|
|
|
+
|
|
|
+ eps1 = complex(1)
|
|
|
+ n_Au = data_in_air[0][8,:]
|
|
|
+ eps2 = n_Au**2
|
|
|
|
|
|
-WLs=[300,350,400,450,600,700,800]
|
|
|
-
|
|
|
+ k_0 = omega/c
|
|
|
+ k_spp = k_0*np.sqrt(eps1*eps2/(eps1+eps2))
|
|
|
+ kappa1= np.sqrt(k_spp**2 - eps1*k_0**2)
|
|
|
+ kappa2= np.sqrt(k_spp**2 - eps2*k_0**2)
|
|
|
+
|
|
|
+ H1 = data_in_air[:,6,wl_idx]
|
|
|
+ H2 = data_in_gold[:,6,wl_idx]
|
|
|
+ for i in range(len(z_vec)):
|
|
|
+ z = z_vec[i]*1e-9
|
|
|
+ print("z =",z)
|
|
|
+ H1_0 = H1[i]/np.exp(-kappa1[wl_idx]*z)
|
|
|
+ H2_0 = H2[i]/np.exp(-kappa2[wl_idx]*z)
|
|
|
+ print("H0 air ",H1_0," from H1",H1[i])
|
|
|
+ print("H0 gold",H2_0," from H2",H2[i])
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+file_ext="png"
|
|
|
+dirname="template-dipole-on-sphere-on-surf-z.fsp.results"
|
|
|
+def main ():
|
|
|
+ distance = [1,2,3,4,5,6,7,8,9,10]
|
|
|
+ zshift = ["5","20","200","400","600"]
|
|
|
+ z_vec = [int(val) for val in zshift]
|
|
|
+
|
|
|
+ data = read_data(dirname, distance, zshift)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ WLs=[800]
|
|
|
+ WLs_idx = get_WLs_idx(WLs, data)
|
|
|
|
|
|
-def find_nearest(array,value):
|
|
|
- idx = (np.abs(array-value)).argmin()
|
|
|
- return array[idx],idx
|
|
|
|
|
|
-WLs_idx = []
|
|
|
-for wl in WLs:
|
|
|
- val, idx = find_nearest(data[0][0,:],wl/1000)
|
|
|
- WLs_idx.append(idx)
|
|
|
-
|
|
|
+ dist = 8
|
|
|
+ wl_idx = WLs_idx[0]
|
|
|
+
|
|
|
+ analyze(data, dist, z_vec, wl_idx)
|
|
|
|
|
|
|
|
|
-legend = []
|
|
|
-for i in range(len(WLs)):
|
|
|
- pl_data = []
|
|
|
- idx = WLs_idx[i]
|
|
|
- legend.append(str(WLs[i])+" nm")
|
|
|
- for point in range(len(distance)):
|
|
|
- R = distance[point]
|
|
|
- pl_data.append(data[point][1,idx]*np.sqrt(R))
|
|
|
- plt.semilogy(distance, pl_data,marker="o")
|
|
|
-plt.legend(legend)
|
|
|
-
|
|
|
-plt.xlabel(r'Monitor R, $\mu$m')
|
|
|
-plt.ylabel(r'$Abs(E_x) \sqrt{R}$',labelpad=-5)
|
|
|
-
|
|
|
-plt.savefig(dirname+"_WLs."+file_ext)
|
|
|
-plt.clf()
|
|
|
-plt.close()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+main()
|