FDTD算法的Matlab程序_第1頁
FDTD算法的Matlab程序_第2頁
FDTD算法的Matlab程序_第3頁
FDTD算法的Matlab程序_第4頁
FDTD算法的Matlab程序_第5頁
已閱讀5頁,還剩1頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

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-573

2、9 :s zkh? % |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 pl

4、anes 9, % These PEC boundaries form the outer lossless walls of the cavity. A6z.MdYZ % a&qdp % The cavity is excited by an additive current source oriented x 9 a % along the z-direction. The source waveform is a differentiated Qj1%wWG % Gaussian pulse given by #K!jh)y % J(t)=-J0*(t-t0)*exp(-(t-t0)2/

5、tau2), dMjeF % where tau=50 ps. The FWHM spectral bandwidth of this zero-dc- eYoc(bG(+ % content pulse is approximately 7 GHz. The grid resolution Gs|a$ V|o % (dx = 2 mm) was chosen to provide at least 10 samples per j1;0kb? % wavelength up through 15 GHz. jqjj2 9 % _XV , p % To execute this M-file,

6、 type fdtd3D at the MATLAB prompt. g(sR ? % This M-file displays the FDTD-computed Ez fields at every other Wt!;Y,1 s % time step, and records those frames in a movie matrix, M, which i WGGnGS % is played at the end of the simulation using the movie command. WTt /y6 % j+/EG*/ %* cMy?& _3f/lG?&- clea

7、r EOqV5$+ czWUD %* ov!L8 9u % Fundamental constants Tgq,tR %* _bGV d +eb!fi cc=2.e8; %speed of light in free space Di_K muz=4.0*pi*1.0e-7; %permeability of free space lPHeO+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

8、+1; gB#$mq, jb=je+1; D#&N? kb=ke+1; iW B1dp YJrZ is=26; %location of z-directed current source +xtRY js=13; %location of z-directed current source LaiUf_W#X XW kobs=5; El6?ml 47XQZ-4 dx=0.002; %space increment of cubic lattice jZ3 dt=dx/(2.0*cc); %time step N XzgI SuW_6 nmax=500; %total number of ti

9、me steps # 1,(I ghiFIACMO %* 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/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

10、-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 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

11、#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 xAyjA6 |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

12、 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-;| 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 X2zI

13、Fm %* _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: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)

14、; ()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); d 8z9_C- IQB%v5 ez(2:ie,2:je,1:ke)=ca*ez(2:ie,2:je,1:ke)+. fMg+X cb*(hx(2:ie,1:je-1,1:ke)-hx(2:ie,2:je,1:ke)+. r+n hm9 hy(2:ie,2:je,1:ke

15、)-hy(1:ie-1,2:je,1:ke); h_7Dn rgu7g ez(is,js,1:ke)=ez(is,js,1:ke)+. pJETM srcconst*(n-ndelay)*exp(-(n-ndelay)2/tau2); -PH qD j, % 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)

16、-ez(2:ie,2:jb,1:ke); 2o-Ie/d m_1BB$lyP2 hy(1:ie,2:je,1:ke)=hy(1: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:i

17、e,1:je,2:ke)-ey(2:ib,1:je,2:ke); =%V(n7= FY.my8 %* 6vQCghI % Visualize 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*ip

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論