Parcourir la source

new bach generator

Konstantin Ladutenko il y a 6 ans
Parent
commit
0445c73e89
6 fichiers modifiés avec 186 ajouts et 37 suppressions
  1. 24 0
      create_hpc_bat.lsf
  2. 97 35
      efficiency-plasmon-plot.py
  3. 28 0
      hpc.bat
  4. 2 1
      main.lsf
  5. 33 0
      rsync.sh
  6. 2 1
      save_plasmon_data.lsf

+ 24 - 0
create_hpc_bat.lsf

@@ -0,0 +1,24 @@
+clear;
+redrawoff;
+status = layoutmode;
+slash = "/";
+if (operatingsystem == "windows") {slash = "\\";}
+
+curdir = pwd;
+files = splitstring(dir,endl);
+isCreated = false;
+fname = curdir+slash+"exec.bat";
+if (fileexists(fname)){rm(fname);}
+
+for(i=1:length(files)) {
+    if(fileextension(files{i}) == "fsp") {
+        load(files{i});
+        status = layoutmode;
+        if (status == 1) {
+            write(fname,"\"C:\Program Files\Lumerical\FDTD\bin\fdtd-engine\" -t 32 "+files{i});
+            #add_plasmon_monitors;
+        }
+    }
+}
+redrawon;
+

+ 97 - 35
efficiency-plasmon-plot.py

@@ -4,7 +4,7 @@ import numpy as np
 import matplotlib.pyplot as plt
 c = 299792458
 pi = np.pi
-
+verbose = 6
 def read_data(dirname, distance, zshift):
     media = [1,2] # 1 - positive zshift, 2 - negative (need to add a minus sign for real shift).
     #min_mesh_step = 2.5 #nm
@@ -53,13 +53,51 @@ def get_WLs_idx(WLs, data):
     return WLs_idx
 
 
+def check_field_match(data_in_air, data_in_gold,wl_idx,z_vec,kappa1,kappa2,eps2): 
+    H1 = data_in_air[:,6,wl_idx]
+    H2 = data_in_gold[:,6,wl_idx]
+    E1 = data_in_air[:,4,wl_idx]
+    E2 = data_in_gold[:,4,wl_idx]
+    for i in range(len(z_vec)):
+        z = z_vec[i]*1e-9
+        if verbose > 8: print("z =",z)
+        H1_0 = H1[i]/np.exp(-kappa1[wl_idx]*z)
+        H2_0 = H2[i]/np.exp(-kappa2[wl_idx]*z)
+        E1_0 = E1[i]/np.exp(-kappa1[wl_idx]*z)
+        E2_0 = E2[i]/np.exp(-kappa2[wl_idx]*z)
+        E2_0e = E2[i]/np.exp(-kappa2[wl_idx]*z)*eps2[wl_idx]
+        if verbose > 8:
+            print("H0 air  (%5.4g %+5.4gj)"%(np.real(H1_0), np.imag(H1_0)),
+                  " from H1 (%5.4g %+5.4gj)"%(np.real(H1[i]), np.imag(H1[i])))
+            print("H0 gold (%5.4g %+5.4gj)"%(np.real(H2_0), np.imag(H2_0)),
+                  " from H2 (%5.4g %+5.4gj)"%(np.real(H2[i]), np.imag(H2[i])))
+            print("E0 air  (%5.4g %+5.4gj)"%(np.real(E1_0), np.imag(E1_0)),
+                  " from E1 (%5.4g %+5.4gj)"%(np.real(E1[i]), np.imag(E1[i])))
+            print("E0*eps2 (%5.4g %+5.4gj)"%(np.real(E2_0e), np.imag(E2_0e)),
+                  " from E2 (%5.4g %+5.4gj)"%(np.real(E2[i]), np.imag(E2[i])))
+            print("E0 gold (%5.4g %+5.4gj)"%(np.real(E2_0), np.imag(E2_0)))
+
+
 def analyze(data, dist, z_vec, wl_idx):
+    ''' dist in mkm!!!
+    '''
     #data = [dist][mmedia][shift] "lambda, dip.power, Ex, Ey, Ez, Hx, Hy, Hz, n_Au"
     #                              0     , 1        , 2 , 3 , 4 , 5 , 6 , 7 , 8   "
     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
+    dip_power = data_in_air[0][1,:]
+
+    Ex = data_in_air[0,2,0]
+    Ey = data_in_air[0,3,0]
+    Ez = data_in_air[0,4,0]
+    Hx = data_in_air[0,5,0]
+    Hy = data_in_air[0,6,0]
+    Hz = data_in_air[0,7,0]
+    E = np.array([Ex,Ey,Ez])
+    H = np.array([Hx,Hy,Hz])
+    print("S from full field",np.real(np.cross(E,np.conj(H))))
     
     eps1 = complex(1)
     n_Au = data_in_air[0][8,:]
@@ -70,45 +108,69 @@ def analyze(data, dist, z_vec, wl_idx):
     kappa1= np.sqrt(k_spp**2 - eps1*k_0**2)
     kappa2= np.sqrt(k_spp**2 - eps2*k_0**2)
 
-    # TODO def check_field_match(): 
-    H1 = data_in_air[:,6,wl_idx]
-    H2 = data_in_gold[:,6,wl_idx]
-    E1 = data_in_air[:,4,wl_idx]
-    E2 = data_in_gold[:,4,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)
-        E1_0 = E1[i]/np.exp(-kappa1[wl_idx]*z)
-        E2_0 = E2[i]/np.exp(-kappa2[wl_idx]*z)*eps2[wl_idx]
-        print("H0 air  (%5.4g %+5.4gj)"%(np.real(H1_0), np.imag(H1_0)),
-              " from H1 (%5.4g %+5.4gj)"%(np.real(H1[i]), np.imag(H1[i])))
-        print("H0 gold (%5.4g %+5.4gj)"%(np.real(H2_0), np.imag(H2_0)),
-              " from H2 (%5.4g %+5.4gj)"%(np.real(H2[i]), np.imag(H2[i])))
-        print("E0 air  (%5.4g %+5.4gj)"%(np.real(E1_0), np.imag(E1_0)),
-              " from E1 (%5.4g %+5.4gj)"%(np.real(E1[i]), np.imag(E1[i])))
-        print("E0*eps2 (%5.4g %+5.4gj)"%(np.real(E2_0), np.imag(E2_0)),
-              " from E2 (%5.4g %+5.4gj)"%(np.real(E2[i]), np.imag(E2[i])))
-    # H1_0 = H1/np.exp(-kappa1* 
-    # print(H1[0], H2[0],H1[0]- H2[0])
-    # pl_data = (np.absolute(data_gold[:,2,wl_idx]*np.sqrt(dist)))
-    # plt.semilogy(z_vec, pl_data,marker="o")
+    check_field_match(data_in_air, data_in_gold,wl_idx,z_vec,kappa1,kappa2,eps2)
+
+    H1 = data_in_air[:,6]
+    E1 = data_in_air[:,4]
+    
+    z = z_vec[0]*1e-9
+
+    if verbose > 5: print("Using data from air monitor at z =",z)
+    H1_0 = H1[0]/np.exp(-kappa1*z)
+    E1_0 = E1[0]/np.exp(-kappa1*z)
+    E2_0 = E1[0]/eps2
+    if verbose > 5: 
+        print("H0 air  (%5.4g %+5.4gj)"%(np.real(H1_0[wl_idx]), np.imag(H1_0[wl_idx])),
+              " from H1 (%5.4g %+5.4gj)"%(np.real(H1[0][wl_idx]), np.imag(H1[0][wl_idx])))
+        print("E0 air  (%5.4g %+5.4gj)"%(np.real(E1_0[wl_idx]), np.imag(E1_0[wl_idx])),
+              " from E1 (%5.4g %+5.4gj)"%(np.real(E1[0][wl_idx]), np.imag(E1[0][wl_idx])))
+        print("E0 gold (%5.4g %+5.4gj)"%(np.real(E2_0[wl_idx]), np.imag(E2_0[wl_idx])), " from E1")
+
+    R = dist*1e-6
+    print("R =",R)
+    #plasmon_power = 1.0/2.0 * np.real( E1[0] * np.conj(H1[0]))  # TODO check minus sign!!
+    plasmon_power = -1.0/2.0 * 2.0*np.pi*R * ( # TODO check minus sign!!
+        np.real( E1_0 * np.conj(H1_0) )
+            / (2.0 * np.real(kappa1))
+        +
+        np.real( E2_0 * np.conj(H1_0) )
+            / (2.0 * np.real(kappa2))        
+        )* np.exp( 2.0*np.imag(k_spp)*R )  # TODO check minus sign!!
+    #print(np.abs(plasmon_power/ dip_power))
+    eta0 = plasmon_power[0]/ dip_power[0] *100
+    ppw = plasmon_power[0]
+    print("\n")
+    print(dirname)
+    print("Power: plasmon %4.3g W of dipoles %4.3g W, efficiency %5.3g%%  from:"%(ppw, float(np.abs(dip_power[0])),float(np.abs( eta0))), ppw, eta0)
+    plt.plot(lambd*1e9, plasmon_power/ dip_power)
+    plt.ylim(0,1.0)
+
+    #plt.plot(lambd*1e9, np.real(eps2))
+    # plt.plot(lambd*1e9, np.real(k_spp))
+    # plt.plot(lambd*1e9, k_0)
+    #plt.semilogy(lambd*1e9, np.absolute(plasmon_power/ dip_power))
     # # legend = []
     # # legend.append(zshift[shift]+"@"+str(WLs[i])+" nm")
     # # plt.legend(legend)
     # # #plt.xlabel(r'THz')
-    # plt.xlabel(r'Z shift, nm')
-    # plt.ylabel(r'$Abs(E_x) \sqrt{R}$',labelpad=-5)
-    # # plt.title(' r = '+str(core_r))
-    # plt.savefig(dirname+"_z."+file_ext)
-    # plt.clf()
-    # plt.close()
+    plt.xlabel(r'$\lambda$, nm')
+    plt.ylabel(r'$P_{spp}/P_{dipole}$',labelpad=-5)
+    #plt.title(' R = '+str(core_r)+' nm')
+    plt.savefig(dirname+"_power_ratio."+file_ext)
+    plt.clf()
+    plt.close()
     
-file_ext="png"
-dirname="template-dipole-on-sphere-on-surf-z.fsp.results"
+file_ext="pdf"
+#dirname="template-dipole-on-sphere-on-surf-z.fsp.results"
+#dirname="Au-JC-R100-Au-JC.fsp.results"
+#dirname="Au-McPeak-R100-Si-Green.fsp.results"
+#dirname="Au-McPeak-R100-Au-McPeak.fsp.results"
+#dirname="Au-McPeak-R0.fsp.results"
+#dirname="Au-McPeak-R100-Si-Green-1500.fsp.results"
+#dirname="Au-McPeak-R100-Si-Green-1500-l.fsp.results"
+dirname="Au-McPeak-R50-Si-Green-1500-l.fsp.results"
 def main ():
-    distance = [1,2,3,4,5,6,7,8,9,10]
+    distance = [1,2,3,4,5,6,7,8,9,10] #mkm
     zshift = ["5","20","200","400","600"]
     z_vec = [int(val) for val in zshift]
 
@@ -116,7 +178,7 @@ def main ():
 
     #WLs=[300,350,400,450,600,700,800]
     #WLs=[600,700, 800, 450]
-    WLs=[600]#, 450]
+    WLs=[800]#, 450]
     WLs_idx = get_WLs_idx(WLs, data)
 
 

+ 28 - 0
hpc.bat

@@ -0,0 +1,28 @@
+@echo off
+REM run on hpc
+setlocal EnableDelayedExpansion
+set "startTime=%time: =0%"
+
+REM path %path%;
+REM"C:\Program Files\Lumerical\FDTD\bin\fdtd-engine" -t 32 template-dipole-on-sphere-on-surf-z.fsp
+"C:\Program Files\Lumerical\FDTD\bin\fdtd-solutions" -nw -run create_hpc_bat.lsf
+call exec.bat
+
+REM mpiexec -n 16 python Si_cylinder_on_Al2O3_substrate.py
+REM python Si_cylinder_on_Al2O3_substrate.py
+
+
+set "endTime=%time: =0%"
+
+
+
+rem Get elapsed time:
+set "end=!endTime:%time:~8,1%=%%100)*100+1!"  &  set "start=!startTime:%time:~8,1%=%%100)*100+1!"
+set /A "elap=((((10!end:%time:~2,1%=%%100)*60+1!%%100)-((((10!start:%time:~2,1%=%%100)*60+1!%%100)"
+
+rem Convert elapsed time to HH:MM:SS:CC format:
+set /A "cc=elap%%100+100,elap/=100,ss=elap%%60+100,elap/=60,mm=elap%%60+100,hh=elap/60+100"
+
+echo Start:    %startTime%
+echo End:      %endTime%
+echo Elapsed:  %hh:~1%%time:~2,1%%mm:~1%%time:~2,1%%ss:~1%%time:~8,1%%cc:~1%

+ 2 - 1
main.lsf

@@ -1,5 +1,5 @@
 clear;
-load("template-dipole-on-sphere-on-surf-z.fsp");
+#load("template-dipole-on-sphere-on-surf-z.fsp");
 status = layoutmode;
 if (status == 1) {
     add_plasmon_monitors;
@@ -8,3 +8,4 @@ if (status == 1) {
     save_plasmon_data;
 }
 #newproject("current");
+redrawon;

+ 33 - 0
rsync.sh

@@ -0,0 +1,33 @@
+#!/bin/bash
+#remote="/run/user/1000/gvfs/smb-share\:server\=192.168.5.18\,share\=hpc_d/k.ladutenko/0-tig-smuthi"
+#remote="/run/user/1000/gvfs/smb-share\:server\=192.168.5.30\,share\=users/z.ladutenko/0-tig-smuthi"
+echo $remote/setup.py
+mounted=`ls /run/user/1000/gvfs/ | wc -l`
+# if [ $mounted = 0 ]; then
+#     echo Mounting SMB share:
+gio mount smb://192.168.5.30/users
+gio mount smb://192.168.5.18/hpc_d
+#     echo Done!
+# fi
+
+if [ ! -f /run/user/1000/gvfs/smb-share\:server\=192.168.5.18\,share\=hpc_d/k.ladutenko/0-tig-smuthi/setup.py ]; then
+    echo "Mounting SMB share failed! If no other errors, you can try to mount it again."
+#    exit 1
+fi
+if [ ! -f /run/user/1000/gvfs/smb-share\:server\=192.168.5.30\,share\=users/z.ladutenko/0-tig-smuthi/setup.py ]; then
+    echo "Mounting SMB share failed! If no other errors, you can try to mount it again."
+#    exit 1
+fi
+
+# rsync -auz --progress --no-perms --no-owner --no-group --no-times --exclude .git --exclude docs --exclude build_docs --exclude *~ /home/tig/KOsty/Documents/Simulations/Belov/Bogdanov/T-matrix/smuthi/tig-smuthi/ $remote
+
+#rsync -auz --progress --no-perms --no-owner --no-group --exclude .git --exclude docs --exclude build_docs --exclude *~ --exclude *results* --exclude smuthi_nfmds_bin /home/tig/KOsty/Documents/Simulations/Belov/Bogdanov/dipole-on-surf/ /run/user/1000/gvfs/smb-share\:server\=192.168.5.30\,share\=users/z.ladutenko/dipole-on-surf
+echo Ok
+
+rsync -auz --progress --no-perms --no-owner --no-group --exclude .git --exclude docs --exclude build_docs --exclude *~ --exclude *results* /home/tig/KOsty/Documents/Simulations/Belov/Bogdanov/dipole-on-surf/ /run/user/1000/gvfs/smb-share\:server\=192.168.5.18\,share\=hpc_d/k.ladutenko/dipole-on-surf
+
+#gio mount smb://192.168.5.30/users
+#ls /run/user/1000/gvfs/smb-share\:server\=192.168.5.30\,share\=users/z.ladutenko/
+rsync -auz --progress --no-perms --no-owner --no-group --exclude .git --exclude docs --exclude build_docs --exclude *~ --exclude *results* /run/user/1000/gvfs/smb-share\:server\=192.168.5.18\,share\=hpc_d/k.ladutenko/dipole-on-surf/ /home/tig/KOsty/Documents/Simulations/Belov/Bogdanov/dipole-on-surf
+
+#rsync -auz --progress --no-perms --no-owner --no-group --exclude .git --exclude docs --exclude build_docs --exclude *~ --exclude *results* /run/user/1000/gvfs/smb-share\:server\=192.168.5.30\,share\=users/z.ladutenko/dipole-on-surf/ /home/tig/KOsty/Documents/Simulations/Belov/Bogdanov/dipole-on-surf

+ 2 - 1
save_plasmon_data.lsf

@@ -29,7 +29,8 @@ min_f = getglobalmonitor("minimum frequency");
 max_f = getglobalmonitor("maximum frequency");
 fpoints = getglobalmonitor("frequency points");
 fvec=linspace(min_f,max_f,fpoints);
-Au_name = "Au (Gold) - Johnson and Christy Copy 2";
+#Au_name = "Au (Gold) - Johnson and Christy Copy 2";
+Au_name = "Au-McPeak";
 n_fdtd=getfdtdindex(Au_name,fvec,min_f,max_f);
 n_fdtd;
 #########################################