Sfoglia il codice sorgente

lock file is autodeleted

Konstantin Ladutenko 7 anni fa
parent
commit
ebc9b36ea9
5 ha cambiato i file con 120 aggiunte e 4 eliminazioni
  1. 2 1
      create_hpc_bat.lsf
  2. 5 0
      hpc.bat
  3. 39 0
      mat_save.lsf
  4. 3 3
      rsync.sh
  5. 71 0
      save_1D_monitor.lsf

+ 2 - 1
create_hpc_bat.lsf

@@ -36,7 +36,8 @@ for(i=1:length(files)) {
                 write(fname,"IF EXIST \""+lockfile+"\" exit /b 1");
                 write(fname,"copy /y NUL "+lockfile+" >NUL");
                 write(fname,"\"C:\Program Files\Lumerical\FDTD\bin\fdtd-engine\" -t 32 "+files{i});
-                write(fname,"del "+lockfile);
+                write(fname,"echo del "+curdir+slash+lockfile);
+                write(fname,"del "+curdir+slash+lockfile);
                 write(fname,"exit /b 1");
                 break;
             }

+ 5 - 0
hpc.bat

@@ -6,18 +6,23 @@ 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
 
+echo Write hostname to temp folder file
 set host=%COMPUTERNAME%
 echo %host% > %TEMP%\hostname.txt
 
+echo Preinit exec.bat
 echo exit /b 1 > %host%exec.bat
 
 echo Before loop
 :loop
 REM random timeout 10 seconds
+    echo random wait
     set /a timeout=%RANDOM% * 11 / 32768
     start /wait timeout %timeout%
     echo %TEMP% > temppath.txt
+    echo execute Lumerical script
     "C:\Program Files\Lumerical\FDTD\bin\fdtd-solutions" -nw -run create_hpc_bat.lsf
+    echo Run local exec.bat                                
     call %host%exec.bat
 if !errorlevel! gtr 0 goto loop
 

+ 39 - 0
mat_save.lsf

@@ -0,0 +1,39 @@
+clear;
+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");
+#########################################
+# 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";
+Au_name = "Au-McPeak";
+n_fdtd=getfdtdindex(Au_name,fvec,min_f,max_f);
+#n_fdtd;
+#########################################
+format long;
+#z_arr = [5, 20];
+
+#########################################
+monitor_name = "monitor_1";
+mon1_E = getresult(monitor_name, "E");
+mon1_H = getresult(monitor_name, "H");
+monitor_name = "monitor_2";
+mon2_E = getresult(monitor_name, "E");
+mon2_H = getresult(monitor_name, "H");
+lambda = mon1_E.lambda;
+z = mon1_E.z;
+dippower = dipolepower(mon1_E.f);
+vacpower = sourcepower(mon1_E.f);
+name_base = filebasename(currentfilename)+"."+fileextension(currentfilename)+".1D.results";
+matlabsavelegacy(name_base);

+ 3 - 3
rsync.sh

@@ -21,13 +21,13 @@ 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
+#rsync -auz --progress --no-perms --no-owner --no-group --exclude .git --exclude docs --exclude build_docs --exclude *~ --exclude '*.lock' --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
+rsync -auz --progress --no-perms --no-owner --no-group --exclude .git --exclude docs --exclude build_docs --exclude *~ --exclude '*.lock' --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 '*.lock' --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

+ 71 - 0
save_1D_monitor.lsf

@@ -0,0 +1,71 @@
+clear;
+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
+monitor_name = "monitor_2";
+curdir = pwd;
+dirname_base = filebasename(currentfilename)+"."+fileextension(currentfilename)+".1D."+monitor_name+".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";
+Au_name = "Au-McPeak";
+n_fdtd=getfdtdindex(Au_name,fvec,min_f,max_f);
+#n_fdtd;
+#########################################
+?"Save data";
+cd(dirname);
+?dirname;
+format long;
+#z_arr = [5, 20];
+
+#########################################
+E = getresult(monitor_name, "E");
+H = getresult(monitor_name, "H");
+wl_len = length(E.lambda);
+z_len = length(E.z);
+for (j=1:wl_len){
+    #Save to file
+    fname = dirname+slash+"wl"+num2str(E.lambda(j))+".txt";
+    ?E.lambda(j);
+    if (fileexists(fname)){rm(fname);}
+    write(fname,"z, dip.power, Ex, Ey, Ez, Hx, Hy, Hz, n_Au");
+    for (i=1:z_len){        
+        str = num2str(E.z(i))
+        +", "+num2str(dipolepower(E.f(j)))
+        +", "+num2str(E.Ex(1,1,i,j))
+        +", "+num2str(E.Ey(1,1,i,j))
+        +", "+num2str(E.Ez(1,1,i,j))
+        +", "+num2str(H.Hx(1,1,i,j))
+        +", "+num2str(H.Hy(1,1,i,j))
+        +", "+num2str(H.Hz(1,1,i,j))
+        +", "+num2str(n_fdtd(j))
+        ;
+    write(fname,str);
+    }
+}
+cd(curdir);
+redrawon;