《一维等离子体FDTD的Matlab源代码(两种方法).doc》由会员分享,可在线阅读,更多相关《一维等离子体FDTD的Matlab源代码(两种方法).doc(23页珍藏版)》请在金锄头文库上搜索。
1、一维等离子体FDTD的Matlab源代码(两种方法)% 1=V-V % *$g-:ILRuZ %1D% oCz/HQoBk % k9L;!TH1K % D1xh %初始化 QVgl(;lX clear; 3yK!-Wp( % utV_ W& %系统参数 uwGcxOgg, TimeT=3000;%迭代次数 qITg%t KE=2000;%网格树木 p4Z(+Aa kc=450;%源的位置 f3y=Wxk kpstart=500;%等离子体开始位置 |2A:eI8 kpstop=1000;%等离子体终止位置 LDQgC*% % A#E ;lm %物理参数 V !wj c0=3e8;%真空中波速
2、3Jn ; zdelta=1e-9;%网格大小 #GFro0$ dt=zdelta/(2*c0);%时间间隔 ) )Za&S* f=900e12;%Gause脉冲的载频 C*hokqqP d=3e-15%脉冲底座宽度 .e-#yET t0=2.25/f;%脉冲中心时间 uXiNj &Be u0=57e12%碰撞频率 m&SNz= fpe=2000e12;%等离子体频率 K (|dl: wpe=2*pi*fpe;%等离子体圆频率 m4Zk,1m.| epsz=1/(4*pi*9*109); % 真空介电常数 $/ ,tSm mu=1/(c02*epsz);%磁常数 ;9#KeA _ ex_low
3、_m1=0; yt2PU_), ex_low_m2=0; CvdNk ex_high_m1=0; 8 FhdN ex_high_m2=0; v r:=K a0=2*u0/dt+(2/dt)2; hf8ZEW9 a1=-8/(dt)2; +H2Qk4XFB a2=-2*u0/dt+(2/dt)2; 2t,zLwBdnJ b0=wpe2+2*u0/dt+(2/dt)2; *lbJL Ex2=Ex; WjjBYKzF % L.WljNo %开始计算 MZI for T=1:TimeT L_s:l9!r %保存前一时间的电磁场 #o2hibq Ex_Pre=Ex; o? $.fhD Hy_Pre=Hy
4、; bYPKh %中间差分计算Dx 8sCv|cn for i=2:KE O| hpXkV Dx(i)=Dx(i)-(dt/zdelta)*(Hy(i)-Hy(i-1); cFWcxD Dx(kc)=cos(2*pi*f*T*dt)*exp(-4*pi*(T*dt-t0)/d)2); 1!gbTeVlY dGG %计算电场Ex w+ LAS for i=1:kpstart-1 09Cez0 Ex(i)=Dx(i)/epsz; tNX|U:Y* end DDH:)=;z for i=kpstop+1:KE Um54fU Ex(i)=Dx(i)/epsz; _f:W?$ho end J9r|gJ(
5、 Dx3=Dx2; C 6AUNRpl Dx2=Dx1; w*JGUk Dx1=Dx; =3 for i=kpstart:kpstop FG*rtCr Ex(i)=(1/b0)*(a0*Dx1(i)+a1*Dx2(i)+a2*Dx3(i)-b1*Ex1(i)-b2*Ex2(i); )TH# 1 end Em&6! Ex2=Ex1; CkIzWd Ex1=Ex; vOpK Np Sx3=Sx2; kq,ucU%p Sx2=Sx1; dKe_Q0 Ex(1)=ex_low_m2; RtIh-Z.9 ex_low_m2=ex_low_m1; 4u5-7TZ ex_low_m1=Ex(2); HqT#
6、$rv DG:Z=LuJr Ex(KE)=ex_high_m2; 76h ,xi ex_high_m2=ex_high_m1; SmSH2m- ex_high_m1=Ex(KE-1); X=fYWjH, %计算磁场 O*)VhwpK for i=1:KE-1 XBu-( Hy(i)=Hy(i)-(dt/(mu*zdelta)*(Ex(i+1)-Ex(i); GM f A, end *kDCliL plot(Ex); )g#T9tx2D grid on; CxOob1 pause(0.01); :hk5 . end% FDTD Main Function Jobs to Workers %*%
7、3-D FDTD code with PEC boundaries%*% This MATLAB M-file implements the finite-difference time-domain% solution of Maxwells curl equations over a three-dimensional% Cartesian space lattice comprised of uniform cubic grid cells.% % To illustrate the algorithm, an air-filled rectangular cavity % resona
8、tor is modeled. The length, width, and height of the % cavity are X cm (x-direction), Y cm (y-direction), and % Z 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 %