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;