From df75e19c67c2a99bd6b47786d0307fe9a71be8cf Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Mon, 2 Jan 2012 18:42:34 -0500 Subject: Added code intended to demonstrate fast to slow switch behaviour --- .../fast_to_slow_switch/Makefile | 55 +++++++++++++++++ .../Nlevels_no_dopler_with_z_4wm.m | 66 ++++++++++++++++++++ .../fast_to_slow_switch/map2dat.m | 33 ++++++++++ .../plot_fields_propagation_I2.gp | 15 +++++ .../fast_to_slow_switch/pp_I2.m | 71 ++++++++++++++++++++++ 5 files changed, 240 insertions(+) create mode 100644 xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/Makefile create mode 100644 xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/Nlevels_no_dopler_with_z_4wm.m create mode 100644 xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/map2dat.m create mode 100644 xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/plot_fields_propagation_I2.gp create mode 100644 xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/pp_I2.m (limited to 'xmds2/Nlevels_with_doppler_with_z_4wm') diff --git a/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/Makefile b/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/Makefile new file mode 100644 index 0000000..e00cefd --- /dev/null +++ b/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/Makefile @@ -0,0 +1,55 @@ +### -*- make -*- +### This makefile can be used to build and run the XMDS examples + + +XSIL_FILES = Nlevels_with_doppler_with_z_4wm.xsil +M_FILES = $(patsubst %.xsil,%.m,$(XSIL_FILES)) +GNUPLOT_FILES = $(wildcard *.gp) + +XSIL2GRAPHICS = xsil2graphics + +# fast light +#PARAMS = --delta1=0 --delta2=0 --delta3=0 --E1o=3.0e7 --E2o=3.1e5 --E3o=3.0e7 --E4o=6.3e3 +PARAMS = --delta1=0 --delta2=0 --delta3=0 --E1o=1.9e7 --E2o=3.1e5 --E3o=3.8e7 --E4o=6.3e4 +# slow light EIT +#PARAMS = --delta1=0 --delta2=0 --delta3=0 --E1o=1.9e7 --E2o=3.1e5 --E3o=0 --E4o=0 + +all: $(XSIL_FILES) Nlevels_with_doppler_with_z_4wm.xsil $(M_FILES) plot png + +Nlevels_with_doppler_with_z_4wm.xsil: ../Nlevels_with_doppler_with_z_4wm.run + $< $(PARAMS) | grep "Time elapsed for simulation is:" > exact_analysis_execution_time.txt + +%.m: %.xsil + $(XSIL2GRAPHICS) $< + +plot: $(M_FILES) $(GNUPLOT_FILES) + octave pp_I2.m + gnuplot plot_fields_propagation_I2.gp + +clean: + rm -f $(CC_FILES) $(RUN_FILES) $(M_FILES) $(XSIL_FILES) *.wisdom.fftw3 *.dat octave-core *.wisdom *.pdf + rm -f $(pdf_targets) + rm -f $(eps_targets) + +real_clean: clean + rm -f $(png_targets) + +eps_targets = $(wildcard *.eps) +pdf_targets = $(eps_targets:%.eps=%.pdf) +png_targets = $(pdf_targets:%.pdf=%.png) + +pdf: $(pdf_targets) + +$(pdf_targets): %.pdf : %.eps + cat $< | ps2eps -B > __tt.eps + epspdf __tt.eps $@ + rm -f __tt.eps + #ps2eps -B $< | epspdf $< $@ + +png: pdf $(png_targets) + +$(png_targets): %.png : %.pdf + convert -density 300 $< $@ + +.PRECIOUS: %.run %.xsil %.m +.PHONY: all clean diff --git a/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/Nlevels_no_dopler_with_z_4wm.m b/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/Nlevels_no_dopler_with_z_4wm.m new file mode 100644 index 0000000..9c884dc --- /dev/null +++ b/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/Nlevels_no_dopler_with_z_4wm.m @@ -0,0 +1,66 @@ +fpDat = fopen('Nlevels_no_dopler_with_z_4wm_mg0.dat', 'r', 'ieee-le'); +if (fpDat < 0) + disp('Cannot open binary data file: Nlevels_no_dopler_with_z_4wm_mg0.dat') + return +end +z_1Len = fread(fpDat, 1, 'uint32'); +z_1 = zeros(1, z_1Len); +z_1(:) = fread(fpDat, z_1Len, 'double'); +t_1Len = fread(fpDat, 1, 'uint32'); +t_1 = zeros(1, t_1Len); +t_1(:) = fread(fpDat, t_1Len, 'double'); +I1_out_1Len = fread(fpDat, 1, 'uint32'); +I1_out_1 = fread(fpDat, [t_1Len, z_1Len], 'double'); +I2_out_1Len = fread(fpDat, 1, 'uint32'); +I2_out_1 = fread(fpDat, [t_1Len, z_1Len], 'double'); +I3_out_1Len = fread(fpDat, 1, 'uint32'); +I3_out_1 = fread(fpDat, [t_1Len, z_1Len], 'double'); +I4_out_1Len = fread(fpDat, 1, 'uint32'); +I4_out_1 = fread(fpDat, [t_1Len, z_1Len], 'double'); +fclose(fpDat); +clear fpDat z_1Len t_1Len I1_out_1Len I2_out_1Len I3_out_1Len I4_out_1Len +fpDat = fopen('Nlevels_no_dopler_with_z_4wm_mg1.dat', 'r', 'ieee-le'); +if (fpDat < 0) + disp('Cannot open binary data file: Nlevels_no_dopler_with_z_4wm_mg1.dat') + return +end +z_2Len = fread(fpDat, 1, 'uint32'); +z_2 = zeros(1, z_2Len); +z_2(:) = fread(fpDat, z_2Len, 'double'); +t_2Len = fread(fpDat, 1, 'uint32'); +t_2 = zeros(1, t_2Len); +t_2(:) = fread(fpDat, t_2Len, 'double'); +r11_out_2Len = fread(fpDat, 1, 'uint32'); +r11_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r22_out_2Len = fread(fpDat, 1, 'uint32'); +r22_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r33_out_2Len = fread(fpDat, 1, 'uint32'); +r33_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r44_out_2Len = fread(fpDat, 1, 'uint32'); +r44_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r12_re_out_2Len = fread(fpDat, 1, 'uint32'); +r12_re_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r12_im_out_2Len = fread(fpDat, 1, 'uint32'); +r12_im_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r13_re_out_2Len = fread(fpDat, 1, 'uint32'); +r13_re_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r13_im_out_2Len = fread(fpDat, 1, 'uint32'); +r13_im_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r14_re_out_2Len = fread(fpDat, 1, 'uint32'); +r14_re_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r14_im_out_2Len = fread(fpDat, 1, 'uint32'); +r14_im_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r23_re_out_2Len = fread(fpDat, 1, 'uint32'); +r23_re_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r23_im_out_2Len = fread(fpDat, 1, 'uint32'); +r23_im_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r24_re_out_2Len = fread(fpDat, 1, 'uint32'); +r24_re_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r24_im_out_2Len = fread(fpDat, 1, 'uint32'); +r24_im_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r34_re_out_2Len = fread(fpDat, 1, 'uint32'); +r34_re_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +r34_im_out_2Len = fread(fpDat, 1, 'uint32'); +r34_im_out_2 = fread(fpDat, [t_2Len, z_2Len], 'double'); +fclose(fpDat); +clear fpDat z_2Len t_2Len r11_out_2Len r22_out_2Len r33_out_2Len r44_out_2Len r12_re_out_2Len r12_im_out_2Len r13_re_out_2Len r13_im_out_2Len r14_re_out_2Len r14_im_out_2Len r23_re_out_2Len r23_im_out_2Len r24_re_out_2Len r24_im_out_2Len r34_re_out_2Len r34_im_out_2Len diff --git a/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/map2dat.m b/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/map2dat.m new file mode 100644 index 0000000..969b6dc --- /dev/null +++ b/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/map2dat.m @@ -0,0 +1,33 @@ +function map2dat(outfile, x,y,z, xskip, yskip) +% saves 3D data in suitable way to be drawn by gnuplot +% x,y - vectors of x,y values +% z map of z values as used by Octave/Matlab +% xskip, yskip - skip paprameters +% only every, xskip, yskip point will be written + + + +Nx=length(x); +Ny=length(y); +Nxs=Nx/xskip; +Nys=Ny/yskip; +points=zeros(1,3*Nxs*Nys); +%points=[]; +tic; +for i=1:Nxs + for k=1:Nys + %points=[points x(i*xskip) y(k*yskip) z(k*yskip,i*xskip)]; + points((i-1)*(Nys-1)*3+3*(k-1)+1) = x(i*xskip); + points((i-1)*(Nys-1)*3+3*(k-1)+2) = y(k*yskip); + points((i-1)*(Nys-1)*3+3*(k-1)+3) = z(k*yskip,i*xskip); + end +end +disp('=== points formation complete ==='); +toc +tic; +%points +fd = fopen(outfile, "wt"); +fprintf (fd, "%g %g %g\n", points); +fclose(fd); +disp('=== points saving complete ==='); +toc; diff --git a/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/plot_fields_propagation_I2.gp b/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/plot_fields_propagation_I2.gp new file mode 100644 index 0000000..77b4870 --- /dev/null +++ b/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/plot_fields_propagation_I2.gp @@ -0,0 +1,15 @@ +set terminal postscript portrait enhanced color solid size 5,3.5 +set output 'fields_propagation_I2.eps' +set dgrid3d 100,100 qnorm 4 +set pm3d map +#set contour +set hidden3d +set palette rgb 10,13,31 negative + + +set xlabel "z (cm)" +set ylabel "t ({/Symbol m}S)" +set zlabel "I_2 (1/S)" +set nokey +#set view map +splot [0:][-0.2:0.2] 'I2.dat' diff --git a/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/pp_I2.m b/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/pp_I2.m new file mode 100644 index 0000000..f0a2c11 --- /dev/null +++ b/xmds2/Nlevels_with_doppler_with_z_4wm/fast_to_slow_switch/pp_I2.m @@ -0,0 +1,71 @@ +Nlevels_with_doppler_with_z_4wm + +%% field propagation +z_1=z_1*100; % z in cm +t_1=t_1*1e6; % time now measured in uS +figure(1) +%set(gca,'fontsize',20); +imagesc(z_1, t_1, I2_out_1); colorbar +tmin=-0.4; +tmax= 0.4; +ylim([tmin,tmax],'manual'); +xlabel('z (cm)') +ylabel('t (uS)') +zlabel('I_2') +title('I_2') + +xskip=1; +yskip=10; +map2dat('I2.dat',z_1,t_1, I2_out_1, xskip, yskip); + + + +print('-color','-depsc2', '-tight', '-S200,120', 'fields_propagation_I2.eps') + + + +%% fields before and after the cell +figure(2) +%set(gca,'fontsize',30); +plot( ... + t_1,I2_out_1(:,1),'.-;before;', "linewidth", 4, ... + t_1,I2_out_1(:,end), '-;after;', "linewidth", 4 ... + ) +xlabel('t (uS)') +ylabel('I_2 (1/s)^2') +title('I_2 before and after cell') +legend('location', 'northeast'); + +[b, a]=butter(3, 0.05); +I2_out_after=I2_out_1(:,end); +I2_out_after_filtered=filtfilt(b,a,I2_out_after); +settling_time=0.01; %uS +t_good_indx=t_1> min(t_1 + settling_time); +[m,max_pos_before]=max(I2_out_1(t_good_indx,1) ); [m,max_pos_after]=max(I2_out_after_filtered(t_good_indx)); +delay_time=t_1(max_pos_after)-t_1(max_pos_before); +printf('Second field delay time = %f uS\n',delay_time); + +%set(gca,'fontsize',40); +%set (gcf,'paperposition',[0.5 0 2.5,1.5]); % IMPORTANT to shrink eps size for readable fonts +print('-color','-depsc2', '-tight','-S200,120', 'fields_before_after_cell_I2.eps') + +figure(4) +I2_max_in=max(I2_out_1(t_good_indx,1)); +I2_max_out=max(I2_out_1(t_good_indx,end)); +I2_in_norm=(I2_out_1(:,1))/I2_max_in; +I2_out_norm=(I2_out_1(:,end))/I2_max_out; +tmin=-.05; +tmax=.05; +indx=(t_1>=tmin & t_1<=tmax); % soom in in time to this region +plot( ... + t_1(indx),I2_in_norm(indx),'.-;before;', "linewidth", 4, ... + t_1(indx),I2_out_norm(indx), '-;after;', "linewidth", 4 ... + ) +legend('location', 'southeast'); +xlim([tmin,tmax],'manual'); +xlabel('t (uS)') +ylabel('I_2') +title('I_2 before and after cell normalized') +%set (gcf,'paperposition',[0.5 0 2.5,1.5]); % IMPORTANT to shrink eps size for readable fonts +print('-color','-depsc2', '-tight','-S200,120', 'probe_before_after_cell_I2_normalized.eps') + -- cgit v1.2.3