1、c0=3e8;%真空中波速 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#
2、KeA _ ex_low_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; hf8ZEW9a1=-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? $.fh
3、D Hy_Pre=Hy; 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 _f:W?$ho end J9r|gJ( Dx3=Dx2
4、; 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 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#$rv DG:Z=LuJr Ex(
5、KE)=ex_high_m2; 76h ,xi ex_high_m2=ex_high_m1; SmSH2m- ex_high_m1=Ex(KE-1); X=fYWjH, %计算磁场 O*)VhwpK 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 %*% 3-D FDTD code with PEC bound
6、aries% 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 % resonator is modeled. The length, wi
7、dth, 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,
8、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/tau2),
9、 % where tau=50 ps. The FWHM 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
10、 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.function Ex,Ey,Ez=FDTD3D_Main(handles)global SimRunStop% if isdir(C:MATLAB7workcavityfigures)% mkdir % end% Grid Partitionp.ip = g
11、et(handles.XdirPar,Value);p.jp = get(handles.YdirPar,p.PN = get(handles.PartNo,% Grid Dimensonsie = get(handles.xslider, %number of grid cells in x-directionje = get(handles.yslider, %number of grid cells in y-directionke = get(handles.zslider, %number of grid cells in z-directionib=ie+1;jb=je+1;kb=
12、ke+1;% All Domains Fields Ini.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);% Fundamental constantsparam.cc=2.99792458e8; %speed of light in free spaceparam.muz=4.0*pi*1.0e-7; %permeability of free spaceparam.epsz = 1.0/(param.cc*pa
13、ram.cc*param.muz); %permittivity of free space% Grid parametersparam.is = get(handles.xsource, %location of z-directed current sourceparam.js = get(handles.ysource,param.kobs = floor(ke/2); %Surface of observationparam.dx = get(handles.CellSize,; %space increment of cubic latticeparam.dt = param.dx/
14、(2.0*param.cc); %time stepparam.nmax = get(handles.TimeStep, %total number of time steps% Differentiated Gaussian pulse excitationparam.rtau=get(handles.tau,)*100e-12;param.tau=param.rtau/param.dt;param.ndelay=3*param.tau;param.Amp = get(handles.sourceamp,)*10e11;param.srcconst=-param.dt*param.Amp;%
15、 Material parametersparam.eps= get(handles.epsilon,param.sig= get(handles.sigma,% Updating coefficientsparam.ca=(1.0-(param.dt*param.sig)/(2.0*param.epsz*param.eps)/(1.0+(param.dt*param.sig)/(2.0*param.epsz*param.eps);param.cb=(param.dt/param.epsz/param.eps/param.dx)/(1.0+(param.dt*param.sig)/(2.0*p
16、aram.epsz*param.eps);param.da=1.0;param.db=param.dt/param.muz/param.dx;% Calling FDTD Algorithmex=zeros(ib,jb,kb);ey=zeros(ib,jb,kb);ez=zeros(ib,jb,kb);hx=zeros(ib,jb,kb);hy=zeros(ib,jb,kb);hz=zeros(ib,jb,kb);X,Y,Z = meshgrid(1:ib,1:jb,1:kb); % Grid coordinatesPsim = zeros(param.nmax,1);Panl = zeros
17、(param.nmax,1);if (p.ip = 1)&(p.jp = 0) x = ceil(ie/p.PN) param.a = 1:x-1:ie-x; param.b = x+1:ie; param.c = 1,1; param.d = je,je; m2 = 1; for n=1:1:param.nmax for m1=1:p.PN ex,ey,ez=Efields(param,handles,ex,ey,ez,hx,hy,hz,ie,je,ke,ib,jb,kb,n,m1,m2,p); hx,hy,hz = Hfields(param,hx,hy,hz,ex,ey,ez,ie,je
18、,ke,ib,jb,kb,n,m1,m2,p); end Psim(n),Panl(n) = Cavity_Power(param,handles,ex,ey,ez,n); field_viz(param,handles,ex,ey,ez,X,Y,Z,n,Psim,Panl,p); Dyn_FFT pause(0.01);elseif (p.ip = 0)&(p.jp = 1) y = ceil(je/p.PN); param.c = 1:y-1:je-y; param.d = y+1:je; param.a = 1,1; param.b = ie,ie; m1 = 1; for m2=1: end field_viz(param,handles,ex,ey,ez,X,Y,Z,n,Psim,Panl
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1