Konstantin Ladutenko 7 vuotta sitten
vanhempi
commit
3ea8cfd07c
1 muutettua tiedostoa jossa 59 lisäystä ja 10 poistoa
  1. 59 10
      plasmon-modal-efficiency.py

+ 59 - 10
plasmon-modal-efficiency.py

@@ -1,17 +1,57 @@
 #!/usr/bin/env python3
 # -*- coding: UTF-8 -*-
-import numpy as np
+from scipy.special import hankel2 as H2n
 import matplotlib.pyplot as plt
+import numpy as np
 import os
-from scipy.special import hankel2 as H2n
+import scipy.io
+
 c = 299792458.0
 eps_0 = 8.854187817e-12 # F/m
 pi = np.pi
 verbose = 6
 # r of monitor
-r = 146.513e-9
+#r = 146.513e-9
+r = 800e-9
 #debug = True
 debug = False
+
+def read_data_mat(fname):
+    #data = "z, dip.power, Ex, Ey, Ez, Hx, Hy, Hz, n_Au"
+    #        0, 1        , 2 , 3 , 4 , 5 , 6 , 7 , 8   "
+    mat = scipy.io.loadmat(fname)
+    
+    lambd = np.reshape(mat["lambda"],(-1))
+    dippower = np.reshape(mat["dippower"],(-1))
+    z = np.reshape(mat["z"],(-1))
+    n_Au = np.reshape(mat["n_fdtd"],(-1))
+    onez = np.ones((len(z)))
+    data1 = {}
+    r1 = mat["mon1_E"][0,0][4][0,0]
+    E1 = mat["mon1_E"][0,0][0]
+    H1 = mat["mon1_H"][0,0][0]
+    data2 = {}
+    r2 = mat["mon2_E"][0,0][4][0,0]
+    E2 = mat["mon2_E"][0,0][0]
+    H2 = mat["mon2_H"][0,0][0]
+    for i in range(len(lambd)):
+        fdata = np.vstack(( z.astype(np.complex128), dippower[i]*onez.astype(np.complex128)
+                            ,E1[:,0,i], E1[:,1,i], E1[:,2,i]
+                            ,H1[:,0,i], H1[:,1,i], H1[:,2,i]
+                            ,n_Au[i]*onez.astype(np.complex128)
+        ))
+        data1[lambd[i]]=fdata
+        fdata = np.vstack(( z.astype(np.complex128), dippower[i]*onez.astype(np.complex128)
+                            ,E2[:,0,i], E2[:,1,i], E2[:,2,i]
+                            ,H2[:,0,i], H2[:,1,i], H2[:,2,i]
+                            ,n_Au[i]*onez.astype(np.complex128)
+        ))
+        data2[lambd[i]]=fdata
+        if debug: break
+
+    return ((r1,data1),(r2,data2))
+
+
 def read_data(dirname):
     data = {}
     WLs = []
@@ -202,11 +242,16 @@ def analyze(data,wl):
     
 file_ext="pdf"
 
+
 def main ():
+    #dirname="bigourdan-Au-sub-dipole-W.fsp.1D.monitor_1.results"
+    dirname="bigourdan-Au-sub-dipole-W-2mon.fsp.1D.monitor_2.results"
+    data = read_data(dirname)
+    filename = 'bigourdan-Au-sub-dipole-W-2mon.fsp.1D.mat'
+    data2 = read_data_mat(filename)
+    r,data = data2[0]
     if verbose > 5:
         print("r =",r)
-    dirname="bigourdan-Au-sub-dipole-W.fsp.1D.monitor_1.results"
-    data = read_data(dirname)
     WLs = []
     A2 = []
     for wl in data:
@@ -216,8 +261,12 @@ def main ():
         #print(WLs)
     WLs1 = np.array(WLs)
     A21 = np.array(A2)
-    dirname="bigourdan-Au-sub-Cyl-dipole-W.fsp.1D.monitor_1.results"
-    data = read_data(dirname)
+    # #dirname="bigourdan-Au-sub-Cyl-dipole-W.fsp.1D.monitor_1.results"
+    # dirname="bigourdan-Au-sub-Cyl-dipole-W-2mon.fsp.1D.monitor_2.results"
+    # data = read_data(dirname)
+    filename = 'bigourdan-Au-sub-Cyl-dipole-W-2mon.fsp.1D.mat'
+    data2 = read_data_mat(filename)
+    r,data = data2[0]
     WLs = []
     A2 = []
     for wl in data:
@@ -231,11 +280,11 @@ def main ():
     # data = np.vstack((WLs,A2))
     # print(np.sort(data))
     
-    plt.plot(WLs1*1e9, A21*275, linestyle='None', marker='o', color="black",label="x 275, no ant.")
-    plt.plot(WLs2*1e9, A22, linestyle='None', marker='*', color="red", label="with antena")
+    plt.plot(WLs1*1e9, A21*275, color="black",label="x 275, no ant.")
+    plt.plot(WLs2*1e9, A22, color="red", label="with antena")
     plt.legend()
     plt.xlabel(r'$\lambda$, nm')
-    plt.ylim(0,0.2)
+    plt.ylim(0,0.5)
     plt.ylabel(r'$|A_{sp}|^2$',labelpad=-1)
     #plt.title(dirname)
     plt.savefig(dirname+"_A2."+file_ext)