save_plasmon_data.lsf 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. ?dirname;
  39. format long;
  40. z_arr = [5, 20];
  41. for(x=1:10) {
  42. for (media=1:2){
  43. if (media == 1){shift_sign = 1;} else {shift_sign = -1;}
  44. for(i=1:length(z_arr)){
  45. zshift_all = z_arr(i);
  46. monitor_name = "mon_x"+num2str(x)+"mkm_media"+num2str(media)+"_zshift"+num2str(zshift_all)+"nm";
  47. select(monitor_name);
  48. if (haveresult(monitor_name) == 1){
  49. E = getresult(monitor_name, "E");
  50. H = getresult(monitor_name, "H");
  51. len = length(E.lambda);
  52. #Save to file
  53. fname = dirname+slash+monitor_name+".txt";
  54. if (fileexists(fname)){rm(fname);}
  55. write(fname,"lambda, dip.power, Ex, Ey, Ez, Hx, Hy, Hz, n_Au");
  56. for (i=1:len){
  57. str = num2str(E.lambda(i))
  58. +", "+num2str(dipolepower(E.f(i)))
  59. +", "+num2str(E.Ex(i))
  60. +", "+num2str(E.Ey(i))
  61. +", "+num2str(E.Ez(i))
  62. +", "+num2str(H.Hx(i))
  63. +", "+num2str(H.Hy(i))
  64. +", "+num2str(H.Hz(i))
  65. +", "+num2str(n_fdtd(i))
  66. ;
  67. write(fname,str);
  68. }
  69. }
  70. }
  71. }
  72. }
  73. cd(curdir);
  74. redrawon;