save_plasmon_data.lsf 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. redrawoff;
  2. slash = "/";
  3. if (operatingsystem == "windows") {slash = "\\";}
  4. #########################################
  5. # Set constants
  6. mkm = 1e-6;
  7. groupscope("::model");
  8. select("FDTD");
  9. min_mesh_step=get("min mesh step");
  10. select("sub-Au");
  11. sub_Au_z_max = get("z max");
  12. #########################################
  13. # Create results dir if needed
  14. curdir = pwd;
  15. dirname_base = filebasename(currentfilename)+"."+fileextension(currentfilename)+".results";
  16. dirname = curdir+slash+dirname_base;
  17. files = splitstring(dir,endl);
  18. isCreated = false;
  19. for(i=1:length(files)) {
  20. if (files{i} == dirname_base) { isCreated = true;}
  21. }
  22. if (isCreated){ ?"output dir already exist";
  23. } else { system("mkdir "+dirname);}
  24. #########################################
  25. # Get FDTD material data
  26. groupscope("::model::mon");
  27. min_f = getglobalmonitor("minimum frequency");
  28. max_f = getglobalmonitor("maximum frequency");
  29. fpoints = getglobalmonitor("frequency points");
  30. fvec=linspace(min_f,max_f,fpoints);
  31. #Au_name = "Au (Gold) - Johnson and Christy Copy 2";
  32. Au_name = "Au-McPeak";
  33. n_fdtd=getfdtdindex(Au_name,fvec,min_f,max_f);
  34. n_fdtd;
  35. #########################################
  36. ?"Save data";
  37. cd(dirname);
  38. format long;
  39. z_arr = [5, 20, 200, 400, 600, 700];
  40. for(x=1:10) {
  41. for (media=1:2){
  42. if (media == 1){shift_sign = 1;} else {shift_sign = -1;}
  43. for(i=1:length(z_arr)){
  44. zshift_all = z_arr(i);
  45. monitor_name = "mon_x"+num2str(x)+"mkm_media"+num2str(media)+"_zshift"+num2str(zshift_all)+"nm";
  46. select(monitor_name);
  47. if (haveresult(monitor_name) == 1){
  48. E = getresult(monitor_name, "E");
  49. H = getresult(monitor_name, "H");
  50. len = length(E.lambda);
  51. #Save to file
  52. fname = dirname+slash+monitor_name+".txt";
  53. if (fileexists(fname)){rm(fname);}
  54. write(fname,"lambda, dip.power, Ex, Ey, Ez, Hx, Hy, Hz, n_Au");
  55. for (i=1:len){
  56. str = num2str(E.lambda(i))
  57. +", "+num2str(dipolepower(E.f(i)))
  58. +", "+num2str(E.Ex(i))
  59. +", "+num2str(E.Ey(i))
  60. +", "+num2str(E.Ez(i))
  61. +", "+num2str(H.Hx(i))
  62. +", "+num2str(H.Hy(i))
  63. +", "+num2str(H.Hz(i))
  64. +", "+num2str(n_fdtd(i))
  65. ;
  66. write(fname,str);
  67. }
  68. }
  69. }
  70. }
  71. }
  72. cd(curdir);
  73. redrawon;