登 录
註 冊
论坛
微波仿真网
注册
登录论坛可查看更多信息
微波仿真论坛
>
时域有限差分法 FDTD
>
新手请教taflove书中的一维程序有些疑问
发帖
回复
1560
阅读
1
回复
[
求助
]
新手请教taflove书中的一维程序有些疑问
离线
wq_463
UID :20925
注册:
2008-11-06
登录:
2021-04-22
发帖:
227
等级:
仿真三级
0楼
发表于: 2008-12-15 10:29:28
%***********************************************************************
mE=%+:o.
% 1-D FDTD code with simple radiation boundary conditions
[1nfSW
%***********************************************************************
o-a\T
%
akATwSrU
% Program author: Susan C. Hagness
p{X?_ F
% Department of Electrical and Computer Engineering
w%~UuJ#i
% University of Wisconsin-Madison
*eL&fC
% 1415 Engineering Drive
\e+h">`WgX
% Madison, WI 53706-1691
PvF3a`&r
% 608-265-5739
bWWZGl9
% [url=mailto:hagness@engr.wisc.edu]hagness@engr.wisc.edu[/url]
x7J8z\b"O
%
>!sxX = <
% Date of this version: February 2000
]dIcW9a
%
{P')$f)
% This MATLAB M-file implements the finite-difference time-domain
Nk?eVJ)
% solution of Maxwell's curl equations over a one-dimensional space
N!!=9'fGF
% lattice comprised of uniform grid cells.
S9RH&/^H
%
i]x_W@h
% To illustrate the algorithm, a sinusoidal wave (1GHz) propagating
!xcLJ5^W
% in a nonpermeable lossy medium (epsr=1.0, sigma=5.0e-3 S/m) is
%])U (
% modeled. The simplified finite difference system for nonpermeable
"`g5iUHqUl
% media (discussed in Section 3.6.6 of the text) is implemented.97081162
|`eHUtjH
%
0"}qND
% The grid resolution (dx = 1.5 cm) is chosen to provide 20
f$1&)1W[
% samples per wavelength. The Courant factor S=c*dt/dx is set to
`&ufdn\j
% the stability limit: S=1. In 1-D, this is the "magic time step."
uaghB,i'n
%
uJ-Q]yQ
% The computational domain is truncated using the simplest radiation
K93L-K^J
% boundary condition for wave propagation in free space:
XX&4OV,^%D
%
U/}YpLgdD
% Ez(imax,n+1) = Ez(imax-1,n)
>vQ8~*xd
%
O{^8dwg
% To execute this M-file, type "fdtd1D" at the MATLAB prompt.
H j [!F%
% This M-file displays the FDTD-computed Ez and Hy fields at every
xnP@h
% time step, and records those frames in a movie matrix, M, which is
+*uaB
% played at the end of the simulation using the "movie" command.
USd7gOq(
%
M5 \flE2
%***********************************************************************
)hG4,0hv&
clear
f|f)Kys%5
%***********************************************************************
P^[eTR*?
% Fundamental constants
Qe4O N3X!
%***********************************************************************
v}\4/u
cc=2.99792458e8; %speed of light in free space
R&.mNji*
muz=4.0*pi*1.0e-7; %permeability of free space
&~=FXe0S
epsz=1.0/(cc*cc*muz); %permittivity of free space
g$f+X~Q
freq=1.0e+9; %frequency of source excitation
#mKF)W
lambda=cc/freq; %wavelength of source excitation
@n,V2`"
omega=2.0*pi*freq;
jRiXN%
%***********************************************************************
sU Er?TZ
% Grid parameters
{,aX|*1Ku~
%***********************************************************************
W_.WMbT
ie=200; %number of grid cells in x-direction
.fFXH
ib=ie+1;
.>#X *u
dx=lambda/20.0; %space increment of 1-D lattice
1A%0y)]
dt=dx/cc; %time step
)OHGg
omegadt=omega*dt;
{ooztC
nmax=round(12.0e-9/dt); %total number of time steps
/U26IbJ
%***********************************************************************
B SH2Kq
% Material parameters
/_SQKpic
%***********************************************************************
}TQa<;Q
eps=1.0;
@cB7tY*Ski
sig=5.0e-3;
z@I'Ryalyc
%***********************************************************************
,>!%KYD/f
% Updating coefficients for space region with nonpermeable media
Znw3P|>B
%***********************************************************************
>piVi[`
scfact=dt/muz/dx;
8Sxk[`qx\K
ca=(1.0-(dt*sig)/(2.0*epsz*eps))/(1.0+(dt*sig)/(2.0*epsz*eps));
w)N~u%
cb=scfact*(dt/epsz/eps/dx)/(1.0+(dt*sig)/(2.0*epsz*eps)); 这个式子的我认为他表达的不对分子应该是:(dt/(2.0*epsz*eps))/(1.0+(dt*sig)/(2.0*epsz*eps))
unKPqc%q=n
%***********************************************************************
rMWJ
% Field arrays
2OVN9_D%
%***********************************************************************
^'\JI
ez(1:ib)=0.0;
hsB3zqotF
hy(1:ie)=0.0;
&&% oazR=
%***********************************************************************
@eJ6UML"
% Movie initialization
mF:Pplf<
%***********************************************************************
C19}Y4r:
x=linspace(dx,ie*dx,ie);
CY~ S{w
subplot(2,1,1),plot(x,ez(1:ie)/scfact,'r'),axis([0 3 -1 1]);
) >te|@}o
ylabel('EZ');
j)ME%17
subplot(2,1,2),plot(x,hy,'b'),axis([0 3 -3.0e-3 3.0e-3]);
F[(ocxQZ3
xlabel('x (meters)');ylabel('HY');
tm&,u*6$W?
rect=get(gcf,'Position'); 这个式子是往下的3行是啥意思
Upa F>,kM
rect(1:2)=[0 0];
s<>d&W 0=
M=moviein(nmax/2,gcf,rect);
ZJe^MnE (G
%***********************************************************************
`G0k)eW
% BEGIN TIME-STEPPING LOOP
ZyM7)!+kPa
%***********************************************************************
"%}24t%
for n=1:nmax
7Q^p|;~a
%***********************************************************************
O!!N@Q2g
% Update electric fields
o_8Wnx^
%***********************************************************************
:6MV@{;PJ
ez(1)=scfact*sin(omegadt*n);
N TcojA{V$
rbc=ez(ie);
Nj;5iy
ez(2:ie)=ca*ez(2:ie)+cb*(hy(2:ie)-hy(1:ie-1));
gLm,;'h%u
ez(ib)=rbc;
NX4G;+6
%***********************************************************************
a[Nm< qV05
% Update magnetic fields
VBUrtx:
%***********************************************************************
*8r^!(Kj
hy(1:ie)=hy(1:ie)+ez(2:ib)-ez(1:ie); 这个式子?不是公式不会推而是这个式子的表达跟葛老师书上的公式表达不一致,希望能给解答
nz|6CP
%***********************************************************************
H +'6*akV
% Visualize fields
v%rmfI U
%***********************************************************************
w_h{6Kc<
if mod(n,2)==0;
cO$xT;kK
rtime=num2str(round(n*dt/1.0e-9));
ayI<-s-
subplot(2,1,1),plot( ..
nW)?cQ I
Q.?(h! )9
未注册仅能浏览
部分内容
,查看
全部内容及附件
请先
登录
或
注册
共
条评分
离线
gwzhao
方恨少
UID :17098
注册:
2008-08-24
登录:
2019-01-09
发帖:
1374
等级:
荣誉管理员
1楼
发表于: 2008-12-15 11:25:24
rect=get(gcf,'Position'); 这个式子是往下的3行是啥意思
JN:L%If
rect(1:2)=[0 0];
e,{k!BXU#'
M=moviein(nmax/2,gcf,rect);
yKuZJXGVo
M(:,n/2)=getframe(gcf,rect);这个式子的意思?
w>8HS+
5Q <vS"g
这是matlab动画显示的,多少帧显示。随便找本matlab的书上都有的。
共
条评分
逆流而上
发帖
回复