待续
1 %1D FDTD simulation with a simple absorbing boundary condition 2 % and a TFSF boundary between hy[49] and ez[50]. 3 SIZE = 500; 4 ez = zeros(1,SIZE); 5 hy = zeros(1,SIZE); 6 imp0=377.0; 7 maxTime = 10000; 8 9 for qTime = 0 : 1 : maxTime 10 hy(SIZE)=hy(SIZE-1);% 11 for mm = 1 : 1 : SIZE -1 12 hy(mm) = hy(mm) + (ez(mm+1)- ez(mm))/imp0; 13 end 14 % correction for Hy adjacent to TFSF boundary */ 15 hy(50)=hy(50)-exp(-(qTime - 30)*(qTime - 30) / 100) / imp0; 16 17 figure(1); t_hy = plot(hy); 18 title('Magnetic Field'); 19 ez(1)=ez(2);% 20 for mm = 2 : 1 : SIZE 21 ez(mm) = ez(mm) + (hy(mm)- hy(mm-1))*imp0; 22 end 23 figure(2); t_ez = plot(ez); 24 title('Electric Field') 25 ez(51) = ez(51) + exp(-(qTime+0.5-(-0.5)-30.0)*(qTime+0.5-(-0.5)-30.0)/100.0); 26 27 % pause(0.01); 28 % % refreshdata(t_hy); 29 % refreshdata(t_ez); 30 % drawnow; 31 end