fdtd算法的matlab程序,FDTD算法的Matlab程序

《FDTD算法的Matlab程序》由会员分享,可在线阅读,更多相关《FDTD算法的Matlab程序(6页珍藏版)》请在人人文库网上搜索。

1、* 5= T$h;O % 3-D FDTD code with PEC boundaries Iw?*y.z| %* H!4A& % r dCs % Program author: Susan C. Hagness B_?7+ % Department of Electrical and Computer Engineering &hrMpD6z6i % University of Wisconsin-Madison T/|nOu 5 % 1415 Engineering Drive 41P0)o % Madison, WI 53706-1691 9MH;=88q % 608-265-5739。

2、 :s zkh? % hagnessengr.wisc.edu |UA=? Xl % )_;l%& % Date of this version: February 2000 !$Ivro % yYSmmgrX0 % This MATLAB M-file implements the finite-difference time-domain (F$r$9S % solution of Maxwells curl equations over a three-dimensional $gN%X/n1 % Cartesian space lattice comprised of uniform 。

3、cubic grid cells. %hN(79:g % vq.o ;q / % To illustrate the algorithm, an air-filled rectangular cavity Gy+- % conditions: yUDoOVC0 % ex(i,j,k)=0 on the j=1, j=jb, k=1, and k=kb planes kyN) % ey(i,j,k)=0 on the i=1, i=ib, k=1, and k=kb planes 7Hv 6z#m % ez(i,j,k)=0 on the i=1, i=ib, j=1, and j=jb pla。

4、nes +M ?nR$a %* $:DhK % Grid parameters .7#04_aP %* jRjQDK_ka (?l ke=10; %number of grid cells in z-direction Aa%ks+1 s0Xihsw6 ib=ie+1; gB#$mq, jb=je+1; D#&N?ACMO %* dYJWQ;j.| F/PN1#T rtau=50.0e-12; |k _ jO tau=rtau/dt; y_8 8I:O ndelay=3*tau; /W/ =OPe srcconst=-dt*3.0e+11; mg*,_3q33 6546sU %* %Sfew/。

5、R0 % Material parameters qI PI!s %* C jsy1gA FU Ip eps=1.0; 3xhxE sig=0.0; 5R/!e(m r+;op_ %* :v&TQ % Updating coefficients iu2%S)w %* SS1-UbL qJ8V cb=(dt/epsz/eps/dx)/(1.0+(dt*sig)/(2.0*epsz*eps); ?k?7GN da=1.0; +dcB h Dq db=dt/muz/dx; #TM+Vd$ f JY %* -uXf?sTV % Field arrays ra/5D %* $014/IB fb.jXSR。

6、 ex=zeros(ie,jb,kb); eW, E)x: ey=zeros(ib,je,kb); bfcQ( m5 ez=zeros(ib,jb,ke); ul$k xc=N hx=zeros(ib,je,ke); W%5o87 hy=zeros(ie,jb,ke); q#B=PZNA hz=zeros(ie,je,kb); Z;Q2tT /F OSreS5bg %* +Ch2Lod % Movie initialization C.qN Bl* %* .n$c+ O0m_ tview(:,:)=ez(:,:,kobs); elF#$ sview(:,:)=ez(:,js,:); B xAy。

7、jA6 |5il5UP subplot(position,0.15 0.45 0.7 0.45),pcolor(tview); +_EE shading flat; mH:8_=(. *is(-1.0 1.0); 6roq 1= colorbar; ,GeW_!Q axis image; Ms shading flat; :3N6Ej *is(-1.0 1.0); ajCe&+ colorbar; %E8HLTEvl axis image; E | title(Ez(i,j=13,k), time step = 0); qWU59:d xlabel(i coordinate); 3qQU-;|。

8、 ylabel(k coordinate); zr 4JTS 9=J 3T66U rect=get(gcf,Position); qEH rect(1:2)=0 0; # uyAC$ )j QrD M=moviein(nmax/2,gcf,rect); DUmp6 X2zIFm %* _gfec4o % BEGIN TIME-STEPPING LOOP Z= LLL %* uF ;8B P_Pco for n=1:nmax rM4RibS 5Z(q|nn7P %* uG+eF % Update electric fields pf#R %* + jN)$Y3Ya x f)P ex(1:ie,2。

9、:je,2:ke)=ca*ex(1:ie,2:je,2:ke)+. J,IxRGi cb*(hz(1:ie,2:je,2:ke)-hz(1:ie,1:je-1,2:ke)+. Pk8(2fAYk hy(1:ie,2:je,1:ke-1)-hy(1:ie,2:je,2:ke); ()fYhk|W ? !#1 ey(2:ie,1:je,2:ke)=ca*ey(2:ie,1:je,2:ke)+. C?rb(m cb*(hx(2:ie,1:je,2:ke)-hx(2:ie,1:je,1:ke-1)+. 1 y7$N8Xo hz(1:ie-1,1:je,2:ke)-hz(2:ie,1:je,2:ke);。

10、 d 8z9_C- IQB%v5 ez(2:ie,2:je,1:ke)=ca*ez(2:ie,2:je,1:ke)+. fM, % Update magnetic fields o(5 ( bJ %* o n?8l?iQ ?;Ge/QU5 hx(2:ie,1:je,1:ke)=hx(2:ie,1:je,1:ke)+. ,:/3L db*(ey(2:ie,1:je,2:kb)-ey(2:ie,1:je,1:ke)+. .Ue1v*, ez(2:ie,1:je,1:ke)-ez(2:ie,2:jb,1:ke); 2o-Ie/d m_1BB$lyP2 hy(1:ie,2:je,1:ke)=hy(1:。

11、ie,2:je,1:ke)+. AqPQeNgz db*(ex(1:ie,2:je,1:ke)-ex(1:ie,2:je,2:kb)+. u:D,;) ez(2:ib,2:je,1:ke)-ez(1:ie,2:je,1:ke); Sf*b6lcC WT2eMK hz(1:ie,1:je,2:ke)=hz(1:ie,1:je,2:ke)+. QWV12t$v db*(ex(1:ie,2:jb,2:ke)-ex(1:ie,1:je,2:ke)+. z/Yrf ey(1:ie,1:je,2:ke)-ey(2:ib,1:je,2:ke); =%V(n7= FY.my8 %* 6vQCghI % Vis。

12、ualize fields gK8=A0c %* A7qKY-4B HYf if mod(n,2)=0; $Dm2:Dmt plRBfwN timestep=int2str(n); BB694 tview(:,:)=ez(:,:,kobs); :d ts sview(:,:)=ez(:,js,:); *+qlam4N vPDF+u subplot(position,0.15 0.45 0.7 0.45),pcolor(tview); u._B7R& shading flat; W/3,vf1 *is(-1.0 1.0); gxIGL-1M colorbar; 5*ipwA axis image; E*! title(Ez(i,j,k=5), time step = ,timestep); PdQ3;s Q;s Mu nn=n/2; 6Vu ovN2 M(:,nn)=getframe(gcf,rect); .4y* & =)sb_ end; $rWDZ0Z dW2 2v! %* nLOK1,4 % END TIME-STEPPING LOOP l=t/M= %* xkRS?Q g &Nh zEl1 end lXF7)H&T Uf|uFGb movie(gcf,M,0,10,rect); vQpbRR。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值