波在匹配介质间的传播
1 %1D FDTD simulation with a simple absorbing boundary condition 2 % and a TFSF boundary between hy[49] and ez[50]. 3 % dielectric material located ez[100] 4 SIZE = 400; 5 LOSS = 0.01; 6 LOSS_LAYER =250; 7 ez = zeros(1,SIZE); 8 hy = zeros(1,SIZE-1); 9 ceze = zeros(1,SIZE); 10 cezh = zeros(1,SIZE); 11 chyh = zeros(1,SIZE-1); 12 chye = zeros(1,SIZE-1); 13 imp0=377.0; 14 maxTime = 10000; 15 % initialize update coefficient 16 for mm = 1 : 1 : SIZE -1 17 if mm < 100 18 ceze(mm) = 1.0; 19 cezh(mm) = imp0; 20 else if mm < LOSS_LAYER 21 ceze(mm) = 1.0; 22 cezh(mm) = imp0/9.0; 23 else 24 ceze(mm) = (1-LOSS)/(1+LOSS); 25 cezh(mm) = imp0 /9/(1+LOSS); 26 end 27 28 end 29 end 30 for mm = 1 : 1 : SIZE -1 31 if mm < LOSS_LAYER 32 chyh(mm) = 1.0; 33 chye(mm) = 1.0/imp0; 34 else 35 chyh(mm) = (1-LOSS)/(1+LOSS); 36 chye(mm) = 1.0/imp0/(1+LOSS); 37 38 end 39 end 40 for qTime = 0 : 1 : maxTime 41 % hy(SIZE)=hy(SIZE-1);% 42 43 % update magnetic field 44 for mm = 1 : 1 : SIZE -1 45 hy(mm) = hy(mm)*chyh(mm) + (ez(mm+1)- ez(mm))*chye(mm); 46 end 47 % correction for Hy adjacent to TFSF boundary */ 48 hy(50)=hy(50)-exp(-(qTime - 30)*(qTime - 30) / 100) / imp0; 49 50 figure(1); 51 subplot(211);t_hy = plot(hy); 52 title('Magnetic Field'); 53 54 % ABC 55 ez(1)=ez(2);% 56 % ez(SIZE)=ez(SIZE-1);% 57 58 for mm = 2 : 1 : SIZE-1 59 ez(mm) = ez(mm)*ceze(mm) + (hy(mm)- hy(mm-1))*cezh(mm); 60 end 61 % figure(2); 62 subplot(212); 63 t_ez = plot(ez); 64 title('Electric Field') 65 ez(51) = ez(51) + exp(-(qTime+0.5-(-0.5)-30.0)*(qTime+0.5-(-0.5)-30.0)/100.0); 66 67 % pause(0.01); 68 % % refreshdata(t_hy); 69 % refreshdata(t_ez); 70 % drawnow; 71 end
OPTIMISM, PASSION & HARDWORK