fdtd在matlab中的,MATLAB编程在FDTD算法中的应用

时域有限差分(FDTD)法是在 21 世纪 60 年代由 K. S.Yee 首先提出并用于求解电磁场散射问题,其主要思路是在空间轴和时间轴上对场量进行离散,并用中心差分代替偏微分,这就将麦克斯韦方程组转化为了差分方程,通过在时间轴和空间轴上采取蛙跳法(leapfrog)逐步推进地求解,最终求得在一定边值与初值条件下的空间场解。随着计算机技术的发展,FDTD 的应用越来越多,对于FDTD 算法的编程求解,最常用的程序语言有 VC 和FORTRUN,而 MATLAB 作为一种可视化效果好的软件,在 FDTD 计算中可视化程度较高,并具有能显示动态场效果的特点。文章采用 FDTD 法对高压开关柜内超高频电磁波的辐射和传播特性进行仿真,仿真中将对二维 TM 电磁波进行 FDTD 表达式的推导,并结合 FDTD 算法边界条件的特点,用 MATLAB 语言进行编程。 1 二维 TM 电磁波 FDTD 算法 1.1 算式推导 在自由空间中,对于二维 TM电磁波,,MAXWELL 的两个旋度方程可以分解为: 坠EZ 坠y =- μ0 坠Hx 坠t (1) 坠EZ 坠x =μ0 坠Hy 坠t (2) ε0 坠EZ 坠t = 坠Ey 坠x - 坠Hx 坠y (3) 构造二维 TM波 FDTD cell 如图 1 所示: 按照 FDTD 元胞对以上三式中的偏导用中心差商代替,分别可得: EZ(i,+j+ 1 2 ,n)- EZ(i,j- 1 2 ,n) △y =- μ0 Hx(i,+j+ 1 2 ,n+ 1 2 )- Hx(i,+j+ 1 2 ,n- 1 2 ) △t (4) EZ(i+ 1 2 ,j,n)- EZ(i- 1 2 ,j,n) △x =μ0 Hy(i+ 1 2 ,j,n+ 1 2 )- Hy(i+ 1 2 ,j,n- 1 2 ) △t (5) ε0 EZ(i,j,n+ 1 2 )- EZ(i,j,n- 1 2 ) △t = Hy(i+1,j,n+ 1 2 )- Hy(i,j,n+ 1 2 ) △x - Hx(i,j+1,n+ 1 2 )- Hy(i,j,n+ 1 2 ) △y (6) 由于方程中出现了半网格和半时间步,为了便于编程,可以将上面差分式改为如下 FDTD 算式: Hx(i,j,k+1)=Hx(i,j,k) - △t μ0△y [EZ(i,j+1,n)- EZ(i,j,n) ] (7) Hy(i,j,n+1)=Hy(i,j,n)+ △t μ0△x [EZ(i+1,j,n)- EZ(i,j,n) ] (8) Ez(i,j,n+1) =Ez(i,j,n)+ △t ε0 [Hy(i+1,j,n)- Hy(i,j,n) △x - Hx(i,j+1,n)- Hy(i,j,n) △y ] (9) 1.2 数值稳定性的条件 FDTD 方法是以一组有限差分方程来替代MAXWELL 旋度方程来进行数值计算的方法,在执行形如 FDTD 算法时,随着时间步长的增长,如何保证该算法的稳定性是一个重要问题。数值解是否稳定主要取决于时间步长 △t 与空间步长 △x、△y、△z 之间的关系。按照Courant 稳定性条件,FDTD 算法中空间和时间间隔应满足的关系为: MATLAB 编程在 FDTD 算法中的应用 宋登峰,蒋 荣 (河南理工大学 电气工程与自动化学院,河南 焦作 454003) 作者简介:宋登峰(1985-),男,河北晋州市人,在读硕士研究生,主要研究方向:自动化技术及设备。 摘 要:文章介绍了时域有限差分(FDTD) 法的基本原理,推导了二维 TM 波的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
%*********************************************************************** % 3-D FDTD code with PEC boundaries %*********************************************************************** % % Program author: Susan C. Hagness % Department of Electrical and Computer Engineering % University of Wisconsin-Madison % 1415 Engineering Drive % Madison, WI 53706-1691 % 608-265-5739 % hagness@engr.wisc.edu % % Date of this version: February 2000 % % This MATLAB M-file implements the finite-difference time-domain % solution of Maxwell's curl equations over a three-dimensional % Cartesian space lattice comprised of uniform cubic grid cells. % % To illustrate the algorithm, an air-filled rectangular cavity % resonator (充气矩形空腔谐振器) is modeled. The length, width, and height of the % cavity are 10.0 cm (x-direction), 4.8 cm (y-direction), and % 2.0 cm (z-direction), respectively. % % The computational domain is truncated using PEC boundary % conditions: % ex(i,j,k)=0 on the j=1, j=jb, k=1, and k=kb planes % ey(i,j,k)=0 on the i=1, i=ib, k=1, and k=kb planes % ez(i,j,k)=0 on the i=1, i=ib, j=1, and j=jb planes % These PEC boundaries form the outer lossless walls of the cavity. % % The cavity is excited by an additive current source oriented % along the z-direction. The source waveform is a differentiated % Gaussian pulse given by % J(t)=-J0*(t-t0)*exp(-(t-t0)^2/tau^2), % where tau=50 ps. The FWHM ( 半最大值全宽度(full width at half maximum)) % spectral bandwidth of this zero-dc- % content pulse is approximately 7 GHz. The grid resolution (分辨率) % (dx = 2 mm) was chosen to provide at least 10 samples per % wavelength up through 15 GHz. % % To execute this M-file, type "fdtd3D" at the MATLAB prompt. % This M-file displays the FDTD-computed Ez fields at every other % time step (第一个时间步), and records those frames in a movie matrix, M, which % is played at the end of the simulation using the "movie" command. % %*********************************************************************** clear %*********************************************************************** % Fundamental constants %*********************************************************************** cc=2.99792458e8; %speed of light in free space muz=4.0*pi*1.0e-7; %permeability of free space epsz=1.0/(cc*cc*muz); %permittivity of free space %*********************************************************************** % Grid parameters %*********************************************************************** ie=50; %number of grid cells in x-direction je=24; %number of grid cells in y-direction ke=10; %number of grid cells in z-direction ib=ie+1; jb=je+1; kb=ke+1; is=26; %location of z-directed current source js=13; %location of z-directed current source kobs=5; dx=0.002; %space increment of cubic lattice dt=dx/(2.0*cc); %time step nmax=500; %total number of time steps %*********************************************************************** % Differentiated Gaussian pulse excitation %*********************************************************************** rtau=50.0e-12; tau=rtau/dt; ndelay=3*tau; srcconst=-dt*3.0e+11; %*********************************************************************** % Material parameters %*********************************************************************** eps=1.0; %相对介电常数 epsz,真空介电常数 sig=0.0; %相对电阻率 %*********************************************************************** % Updating coefficients %*********************************************************************** ca=(1.0-(dt*sig)/(2.0*epsz*eps))/(1.0+(dt*sig)/(2.0*epsz*eps)); cb=(dt/epsz/eps/dx)/(1.0+(dt*sig)/(2.0*epsz*eps)); da=1.0; db=dt/muz/dx; %*********************************************************************** % Field arrays %*********************************************************************** ex=zeros(ie,jb,kb); ey=zeros(ib,je,kb); ez=zeros(ib,jb,ke); hx=zeros(ib,je,ke); hy=zeros(ie,jb,ke); hz=zeros(ie,je,kb); %*********************************************************************** % Movie initialization %*********************************************************************** tview(:,:)=ez(:,:,kobs); sview(:,:)=ez(:,js,:); subplot('position',[0.15 0.45 0.7 0.45]), pcolor(tview'); %shading flat; %caxis([-1.0 1.0]); %colorbar; %axis image; title(['Ez(i,j,k=5), time step = 0']); xlabel('i coordinate'); ylabel('j coordinate'); subplot('position',[0.15 0.10 0.7 0.25]), pcolor(sview'); %shading flat; %caxis([-1.0 1.0]); %colorbar; %axis image; title(['Ez(i,j=13,k), time step = 0']); xlabel('i coordinate'); ylabel('k coordinate'); rect=get(gcf,'Position'); rect(1:2)=[0 0]; M=moviein(nmax/2,gcf,rect); %*********************************************************************** % BEGIN TIME-STEPPING LOOP %*********************************************************************** for n=1:nmax %*********************************************************************** % Update electric fields %*********************************************************************** ex(1:ie,2:je,2:ke)=ca*ex(1:ie,2:je,2:ke)+... cb*(hz(1:ie,2:je,2:ke)-hz(1:ie,1:je-1,2:ke)+... hy(1:ie,2:je,1:ke-1)-hy(1:ie,2:je,2:ke)); ey(2:ie,1:je,2:ke)=ca*ey(2:ie,1:je,2:ke)+... cb*(hx(2:ie,1:je,2:ke)-hx(2:ie,1:je,1:ke-1)+... hz(1:ie-1,1:je,2:ke)-hz(2:ie,1:je,2:ke)); ez(2:ie,2:je,1:ke)=ca*ez(2:ie,2:je,1:ke)+... cb*(hx(2:ie,1:je-1,1:ke)-hx(2:ie,2:je,1:ke)+... hy(2:ie,2:je,1:ke)-hy(1:ie-1,2:je,1:ke)); ez(is,js,1:ke)=ez(is,js,1:ke)+... srcconst*(n-ndelay)*exp(-((n-ndelay)^2/tau^2)); % J(t)=-J0*(t-t0)*exp(-(t-t0)^2/tau^2) %*********************************************************************** % Update magnetic fields %*********************************************************************** hx(2:ie,1:je,1:ke)=hx(2:ie,1:je,1:ke)+... db*(ey(2:ie,1:je,2:kb)-ey(2:ie,1:je,1:ke)+... ez(2:ie,1:je,1:ke)-ez(2:ie,2:jb,1:ke)); hy(1:ie,2:je,1:ke)=hy(1:ie,2:je,1:ke)+... db*(ex(1:ie,2:je,1:ke)-ex(1:ie,2:je,2:kb)+... ez(2:ib,2:je,1:ke)-ez(1:ie,2:je,1:ke)); hz(1:ie,1:je,2:ke)=hz(1:ie,1:je,2:ke)+... db*(ex(1:ie,2:jb,2:ke)-ex(1:ie,1:je,2:ke)+... ey(1:ie,1:je,2:ke)-ey(2:ib,1:je,2:ke)); %*********************************************************************** % Visualize fields %*********************************************************************** if mod(n,2)==0; timestep=int2str(n); tview(:,:)=ez(:,:,kobs); sview(:,:)=ez(:,js,:); subplot('position',[0.15 0.45 0.7 0.45]), pcolor(tview'); % shading flat; % caxis([-1.0 1.0]); % colorbar; % axis image; title(['Ez(i,j,k=5), time step = ',timestep]); xlabel('i coordinate'); ylabel('j coordinate'); subplot('position',[0.15 0.10 0.7 0.25]), pcolor(sview'); % shading flat; % caxis([-1.0 1.0]); % colorbar; % axis image; title(['Ez(i,j=13,k), time step = ',timestep]); xlabel('i coordinate'); ylabel('k coordinate'); nn=n/2; M(:,nn)=getframe(gcf,rect); end; %*********************************************************************** % END TIME-STEPPING LOOP %*********************************************************************** end movie(gcf,M,0,10,rect);

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值