DENNIS SULLIVAN
时间:03-31
整理:3721RD
点击:
Hi.
i have a problem in FDTD 3D programme in free space with dipole antena.exaclty in T=60 i dont get the same resulte with SULLIVAN book.
In T=30 T=40 and T=50 it's ok.
can you help me please.
%%%%%%%%%%%%%%%Fundamental constants%%%%%%%%%%%%%%%%%%%%%%%%%%
clear
c=3e8; % speed of light in free space
mu0=4.0*pi*1.0e-7; % permeability of free space
eps0=1.0/(c*c*mu0); % permittivity of free space
%%%%%%%%%%Grid parameters%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Nx=40; %number of grid cells in x-direction
Ny=40; %number of grid cells in y-direction
Nz=40; %number of grid cells in z-direction
Dx=1.0e-2; %space increment of square lattice in x direction
%Dx=5.0e-3; %space increment of square lattice in x direction
Dy=Dx; %space increment of square lattice in y direction
Dt=Dx/(2*c); %time step
itmax=60; %total number of time steps
%%%%%%%%%%%%%%%source position%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
is=Nx/2;
js=Ny/2;
ks=Nz/2;
%%%%%%%%%%%Material parameters%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
epsr=1.0;
mur=1.0;
sig=0.0;
ro=0.0;
%%%%%%%%%%%%Updating coefficients%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
caex(1:Nx,1:Ny,1:Nz)=(1.0-(Dt*sig)/(2.0*eps0*epsr))/(1.0+(Dt*sig)/(2.0*eps0*epsr));
cbex(1:Nx,1:Ny+1,1:Nz)=(Dt/(eps0*epsr*Dx))/(1.0+(Dt*sig)/(2.0*eps0*epsr));
caey(1:Nx,1:Ny,1:Nz)=(1.0-(Dt*sig)/(2.0*eps0*epsr))/(1.0+(Dt*sig)/(2.0*eps0*epsr));
cbey(1:Nx,1:Ny,1:Nz)=(Dt/(eps0*epsr*Dx))/(1.0+(Dt*sig)/(2.0*eps0*epsr));
caez(1:Nx,1:Ny,1:Nz)=(1.0-(Dt*sig)/(2.0*eps0*epsr))/(1.0+(Dt*sig)/(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...
hy(2:Nx-1,2:Ny-1,1:Nz)-hy(1:Nx-2,2:Ny-1,1:Nz));
ez(is,js,ks)=s(t);
hx(1:Nx,1:Ny,1:Nz)=dahx(1:Nx,1:Ny,1:Nz).*hx(1:Nx,1 :Ny,1:Nz)+...
dbhx(1:Nx,1:Ny,1:Nz).*(ey(1:Nx,1:Ny,2:Nz+1)-ey(1:Nx,1:Ny,1:Nz)+...
ez(1:Nx,1:Ny,1:Nz)-ez(1:Nx,2:Ny+1,1:Nz));
hy(1:Nx,1:Ny,1:Nz)=dahy(1:Nx,1:Ny,1:Nz).*hy(1:Nx,1 :Ny,1:Nz)+...
dbhy(1:Nx,1:Ny,1:Nz).*(ex(1:Nx,1:Ny,1:Nz)-ex(1:Nx,1:Ny,2:Nz+1)+...
ez(2:Nx+1,1:Ny,1:Nz)-ez(1:Nx,1:Ny,1:Nz));
hz(1:Nx,1:Ny,1:Nz)=dahz(1:Nx,1:Ny,1:Nz).*hz(1:Nx,1 :Ny,1:Nz)+...
dbhz(1:Nx,1:Ny,1:Nz).*(ex(1:Nx,2:Ny+1,1:Nz)-ex(1:Nx,1:Ny,1:Nz)+...
ey(1:Nx,1:Ny,1:Nz)-ey(2:Nx+1,1:Ny,1:Nz));
%%%%%%%%%%%%%%Update magnetic fields%%%%%%%%%%%%%%%%%%%%%%%%%%
%************************************************* **********************
% END TIME-STEPPING LOOP
%************************************************* **********************
end
surf(ez(1:Nx,1:Ny,ks))[img][/img][img][/img]
tanks a lot.
i have a problem in FDTD 3D programme in free space with dipole antena.exaclty in T=60 i dont get the same resulte with SULLIVAN book.
In T=30 T=40 and T=50 it's ok.
can you help me please.
%%%%%%%%%%%%%%%Fundamental constants%%%%%%%%%%%%%%%%%%%%%%%%%%
clear
c=3e8; % speed of light in free space
mu0=4.0*pi*1.0e-7; % permeability of free space
eps0=1.0/(c*c*mu0); % permittivity of free space
%%%%%%%%%%Grid parameters%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Nx=40; %number of grid cells in x-direction
Ny=40; %number of grid cells in y-direction
Nz=40; %number of grid cells in z-direction
Dx=1.0e-2; %space increment of square lattice in x direction
%Dx=5.0e-3; %space increment of square lattice in x direction
Dy=Dx; %space increment of square lattice in y direction
Dt=Dx/(2*c); %time step
itmax=60; %total number of time steps
%%%%%%%%%%%%%%%source position%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
is=Nx/2;
js=Ny/2;
ks=Nz/2;
%%%%%%%%%%%Material parameters%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
epsr=1.0;
mur=1.0;
sig=0.0;
ro=0.0;
%%%%%%%%%%%%Updating coefficients%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
caex(1:Nx,1:Ny,1:Nz)=(1.0-(Dt*sig)/(2.0*eps0*epsr))/(1.0+(Dt*sig)/(2.0*eps0*epsr));
cbex(1:Nx,1:Ny+1,1:Nz)=(Dt/(eps0*epsr*Dx))/(1.0+(Dt*sig)/(2.0*eps0*epsr));
caey(1:Nx,1:Ny,1:Nz)=(1.0-(Dt*sig)/(2.0*eps0*epsr))/(1.0+(Dt*sig)/(2.0*eps0*epsr));
cbey(1:Nx,1:Ny,1:Nz)=(Dt/(eps0*epsr*Dx))/(1.0+(Dt*sig)/(2.0*eps0*epsr));
caez(1:Nx,1:Ny,1:Nz)=(1.0-(Dt*sig)/(2.0*eps0*epsr))/(1.0+(Dt*sig)/(2.0*eps0*epsr));
cbez(1:Nx,1:Ny,1:Nz)=(Dt/(eps0*epsr*Dx))/(1.0+(Dt*sig)/(2.0*eps0*epsr));
dahx(1:Nx,1:Ny,1:Nz)=(1.0-(Dt*ro)/(2.0*mu0*mur))/(1.0+(Dt*ro)/(2.0*mu0*mur));
dbhx(1:Nx,1:Ny,1:Nz)=(Dt/(mu0*mur*Dx))/(1.0+(Dt*ro)/(2.0*mu0*mur));
dahy(1:Nx,1:Ny,1:Nz)=(1.0-(Dt*ro)/(2.0*mu0*mur))/(1.0+(Dt*ro)/(2.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,1:Nz).*hy(1:Nx,1 :Ny,1:Nz)+...
dbhy(1:Nx,1:Ny,1:Nz).*(ex(1:Nx,1:Ny,1:Nz)-ex(1:Nx,1:Ny,2:Nz+1)+...
ez(2:Nx+1,1:Ny,1:Nz)-ez(1:Nx,1:Ny,1:Nz));
hz(1:Nx,1:Ny,1:Nz)=dahz(1:Nx,1:Ny,1:Nz).*hz(1:Nx,1 :Ny,1:Nz)+...
dbhz(1:Nx,1:Ny,1:Nz).*(ex(1:Nx,2:Ny+1,1:Nz)-ex(1:Nx,1:Ny,1:Nz)+...
ey(1:Nx,1:Ny,1:Nz)-ey(2:Nx+1,1:Ny,1:Nz));
%%%%%%%%%%%%%%Update magnetic fields%%%%%%%%%%%%%%%%%%%%%%%%%%
%************************************************* **********************
% END TIME-STEPPING LOOP
%************************************************* **********************
end
surf(ez(1:Nx,1:Ny,ks))[img][/img][img][/img]
tanks a lot.