Konstantin Ladutenko 6 vuotta sitten
commit
6a18bc6f5b
4 muutettua tiedostoa jossa 173 lisäystä ja 0 poistoa
  1. 26 0
      add_plasmon_monitors.lsf
  2. 67 0
      efficiency-plasmon-plot.py
  3. 10 0
      main.lsf
  4. 70 0
      save_plasmon_data.lsf

+ 26 - 0
add_plasmon_monitors.lsf

@@ -0,0 +1,26 @@
+groupscope("::model");
+select("FDTD");
+min_mesh_step=get("min mesh step");
+select("sub-Au");
+sub_Au_z_max = get("z max");
+#remove old monitors
+groupscope("::model::mon");
+selectall;
+delete;
+#########################################
+mkm = 1e-6;
+for(x=1:10) {
+    for (media=1:2){
+        if (media == 1){shift_sign = 1;} else {shift_sign = -1;}
+        for(z_shift=1:2){
+            addpower;
+            zshift_all = z_shift*min_mesh_step;
+            set("name","mon_x"+num2str(x)+"mkm_media"+num2str(media)+"_zshift"
+                +num2str(zshift_all*1e9)+"nm");
+            set("monitor type",1);  # 1 = point, 2 = linear x, 3 = linear y, 4 = linear z, 5 = 2D x-normal, 6 = 2D y-normal, 7 = 2D z-normal, 8 = 3D
+            set("x",x*mkm);
+            set("y",0);
+            set("z",sub_Au_z_max + shift_sign*zshift_all);
+        }
+    }
+}

+ 67 - 0
efficiency-plasmon-plot.py

@@ -0,0 +1,67 @@
+#!/usr/bin/env python3
+# -*- coding: UTF-8 -*-
+import numpy as np
+import matplotlib.pyplot as plt
+file_ext="pdf"
+#dirname="Si-sphere-step2.5-dipole"
+
+#distance = [100,200,400,800,1200,1600,2000]
+#dirname="Si-sphere-step5-dipole-far"
+
+# distance = [1,2,3,4,5,6,7,8,9,10]
+# dirname="Si-sphere-step5-dipole-far-long"
+
+distance = [2,4,6,8,10,12,14,16,18,20,22]
+dirname="Si-sphere-step5-dipole-far-long22"
+
+data = []
+
+for i in distance:
+#    print(i, dirname+"/d%i.txt"%i)
+    data.append(
+        np.transpose(
+            np.loadtxt(dirname+"/r%i.txt"%i, delimiter=", ",skiprows=3)
+        )#[-2]
+    )
+
+
+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()
+
+WLs=[300,350,400,450,600,700,800]
+#WLs=[300,350,400,450,600,700]
+
+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)
+#    print(val,idx, " --> ", data[0][0,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'THz')
+plt.xlabel(r'Monitor R, $\mu$m')
+plt.ylabel(r'$Abs(E_x) \sqrt{R}$',labelpad=-5)
+# plt.title(' r = '+str(core_r))
+plt.savefig(dirname+"_WLs."+file_ext)
+plt.clf()
+plt.close()

+ 10 - 0
main.lsf

@@ -0,0 +1,10 @@
+clear;
+load("template-dipole-on-sphere-on-surf.fsp");
+status = layoutmode;
+if (status == 1) {
+    add_plasmon_monitors;
+} else {
+#    switchtolayout;
+    save_plasmon_data;
+}
+#newproject("current");

+ 70 - 0
save_plasmon_data.lsf

@@ -0,0 +1,70 @@
+redrawoff;
+slash = "/";
+if (operatingsystem == "windows") {slash = "\\";}
+#########################################
+# Set constants
+mkm = 1e-6;
+groupscope("::model");
+select("FDTD");
+min_mesh_step=get("min mesh step");
+select("sub-Au");
+sub_Au_z_max = get("z max");
+#########################################
+# Create results dir if needed
+curdir = pwd;
+dirname_base = filebasename(currentfilename)+"."+fileextension(currentfilename)+".results";
+dirname = curdir+slash+dirname_base;
+
+files = splitstring(dir,endl);
+isCreated = false;
+for(i=1:length(files)) {
+    if (files{i} == dirname_base) { isCreated = true;}
+}
+if (isCreated){ ?"output dir already exist";
+} else { system("mkdir "+dirname);}
+#########################################
+# Get FDTD material data
+groupscope("::model::mon");
+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";
+n_fdtd=getfdtdindex(Au_name,fvec,min_f,max_f);
+n_fdtd;
+#########################################
+?"Save data";
+cd(dirname);
+format long;
+for(x=1:10) {
+    for (media=1:2){
+        if (media == 1){shift_sign = 1;} else {shift_sign = -1;}
+        for(z_shift=1:2){
+            zshift_all = z_shift*min_mesh_step;
+            monitor_name = "mon_x"+num2str(x)+"mkm_media"+num2str(media)+"_zshift"+num2str(zshift_all*1e9)+"nm";
+            select(monitor_name);
+            E = getresult(monitor_name, "E");
+            H = getresult(monitor_name, "H");
+            len = length(E.lambda);
+            #Save to file
+            fname = dirname+slash+monitor_name+".txt";
+            if (fileexists(fname)){rm(fname);}
+            write(fname,"lambda, dip.power, Ex, Ey, Ez, Hx, Hy, Hz, n_Au");
+            for (i=1:len){
+                str = num2str(E.lambda(i))
+                +", "+num2str(dipolepower(E.f(i)))
+                +", "+num2str(E.Ex(i))
+                +", "+num2str(E.Ey(i))
+                +", "+num2str(E.Ez(i))
+                +", "+num2str(H.Hx(i))
+                +", "+num2str(H.Hy(i))
+                +", "+num2str(H.Hz(i))
+                +", "+num2str(n_fdtd(i))
+                ;
+                write(fname,str);
+            }
+        }
+    }
+}
+cd(curdir);
+redrawon;