首页 > 代码库 > FDFD一维

FDFD一维

一维FDTD程序如下

https://wenku.baidu.com/view/699d2b5b4b35eefdc8d333cf.html

function FDTDonedimensionpipei(L,d,T) %version1.0  终端匹配  
%FDTDonedimensionpipei(6,0.18,0.5e-9) 
t0=3*T; 
c=3e8;  
u=4*pi*1e-7;
e=8.8541878e-12; 
dz=T*c/10; 
Nz=fix(L/dz); 
dt=dz/2/c;  
Ex=zeros(1,Nz+1); 
B=zeros(1,Nz+1); 
Hy=zeros(1,Nz); 
Nt=2*Nz; 
for n=0:Nt     
    t=n*dt;      
    F=exp(-(t-t0).^2./T^2);     
    Ex(1)=F;     
    for k=1:Nz          
        Hy(k)=Hy(k)+dt./u.*(Ex(k)-Ex(k+1))./dz;     
    end      
    for k=1:Nz-1          
        Ex(k+1)=Ex(k+1)+dt./e.*(Hy(k)-Hy(k+1))./dz;     
    end      
    Ex(1)=B(2)+(c*dt-dz)./(c*dt+dz).*(Ex(2)-B(1));      
    Ex(Nz+1)=B(Nz)+(c*dt-dz)./(c*dt+dz).*(Ex(Nz)-B(Nz+1));     
    Vref1=d.*Ex(Nz-300);     
    Vref2=d.*Ex(Nz-100);     
    plot(t,Vref1,s);     
    hold on;      
    plot(t,Vref2,rx);     
    hold on;     
    B=Ex; 
end

 

FDFD一维