登 录
註 冊
论坛
微波仿真网
注册
登录论坛可查看更多信息
微波仿真论坛
>
时域有限差分法 FDTD
>
Taflove的FDTD书附带程序的问题请教
发帖
回复
1999
阅读
4
回复
[
求助
]
Taflove的FDTD书附带程序的问题请教
离线
awell
UID :8837
注册:
2008-03-03
登录:
2010-05-28
发帖:
66
等级:
仿真一级
0楼
发表于: 2009-02-26 20:18:55
刚开始学习FDTD,看了Taflove的FDTD书附带程序里的一维FDTD算法,有些不明白的地方,想请教各位,请大家不吝赐教!
+<&E3O r
1。scfact=dt/muz/dx;中的scfact有什么作用?为什么要设这个参数呢,有何实际意义?
;:P7}v fz!
2.cb=scfact*(dt/epsz/eps/dx)/(1.0+(dt*sig)/(2.0*epsz*eps));中的计算方法为什么是这样的而不是cb=(dt/(epsz*eps))/(1.0+(dt*sig)/(2.0*epsz*eps));后一个是我在课本上找到的公式。为什么会用前一个!
d>UnJ)V}
$nj\\,(g
本人很菜,希望高手能耐心赐教,不胜感激!谢谢
cI5N"U@yN
Q\H_t)-
附上源程序:
{Jrf/p9w
%***********************************************************************
]* 0(-@
% 1-D FDTD code with simple radiation boundary conditions
5`"iq "5Cf
%***********************************************************************
4bnt=5]
%
$Jc q7E~
% Program author: Susan C. Hagness
D>P;Izb
% Department of Electrical and Computer Engineering
(}G!np
% University of Wisconsin-Madison
L/ ~D<V
% 1415 Engineering Drive
bV_j`:MD
% Madison, WI 53706-1691
gt'*B5F(
% 608-265-5739
C?/r;
%
hagness@engr.wisc.edu
YUCC*t
%
L${m/@9
% Date of this version: February 2000
Q |%-9^
%
SgiDh dE
% This MATLAB M-file implements the finite-difference time-domain
rR\;G2p)
% solution of Maxwell's curl equations over a one-dimensional space
m;c3Z-
% lattice comprised of uniform grid cells.
VrVDm*AGQ
%
q]K'p,'
% To illustrate the algorithm, a sinusoidal wave (1GHz) propagating
975 _d_U
% in a nonpermeable lossy medium (epsr=1.0, sigma=5.0e-3 S/m) is
6.[)`iF+#
% modeled. The simplified finite difference system for nonpermeable
avg4K*v v
% media (discussed in Section 3.6.6 of the text) is implemented.
~Po<(A}`f
%
I`NUurQTX
% The grid resolution (dx = 1.5 cm) is chosen to provide 20
cM3jnim
% samples per wavelength. The Courant factor S=c*dt/dx is set to
.@@an;C
% the stability limit: S=1. In 1-D, this is the "magic time step."
M_Bu,<q^
%
GLCAiSMz[
% The computational domain is truncated using the simplest radiation
e^zHw^js
% boundary condition for wave propagation in free space:
"TfI+QgLF
%
tj[ c#@[B
% Ez(imax,n+1) = Ez(imax-1,n)
ZNi +Aw$u
%
syRN4
% To execute this M-file, type "fdtd1D" at the MATLAB prompt.
%yfE7UPS]
% This M-file displays the FDTD-computed Ez and Hy fields at every
mg` j[<wp
% time step, and records those frames in a movie matrix, M, which is
RpYcD
% played at the end of the simulation using the "movie" command.
Hte[TRbM
%
e9 *lixh
%***********************************************************************
k=`$6(>Fz
clear
6AAswz'$P
%***********************************************************************
G{+2xN a(
% Fundamental constants
j1A|D
%***********************************************************************
P].eAAXnP
cc=2.99792458e8; %speed of light in free space
Fwb5u!_,
muz=4.0*pi*1.0e-7; %permeability of free space
UU[H@ym#
epsz=1.0/(cc*cc*muz); %permittivity of free space
2L:$aZ
freq=1.0e+9; %frequency of source excitation
\9w~pO
lambda=cc/freq; %wavelength of source excitation
0'`S,
omega=2.0*pi*freq;
w//omF'`
%***********************************************************************
-G-3q6A
% Grid parameters
1DqX:WM6
%***********************************************************************
*jE;9^
ie=200; %number of grid cells in x-direction
t!jYu<P
ib=ie+1;
Kk=LXmL2
dx=lambda/20.0; %space increment of 1-D lattice
o5SQ1;`
dt=dx/cc; %time step
<[ZI.+_Wt
omegadt=omega*dt;
z6I% wh
nmax=round(12.0e-9/dt); %total number of time steps
xz8G}Ku
%***********************************************************************
_lX8K:C(
% Material parameters
P_&p=${
%***********************************************************************
DHv2&zH
eps=1.0;
6Cv.5Vhx
sig=5.0e-3;
pw\P<9e=
%***********************************************************************
&))\2pl
% Updating coefficients for space region with nonpermeable media
RJhK$\
%***********************************************************************
-%,"iaO
scfact=dt/muz/dx;
P\AqpQv
ca=(1.0-(dt*sig)/(2.0*epsz*eps))/(1.0+(dt*sig)/(2.0*epsz*eps));
N'QqJe7Z
cb=scfact*(dt/epsz/eps/dx)/(1.0+(dt*sig)/(2.0*epsz*eps));
6Hk="$6K
%***********************************************************************
QD$Gw-U-l=
% Field arrays
'C^;OjAg
%***********************************************************************
i $C-)d]
ez(1:ib)=0.0;
{~_Y _-
hy(1:ie)=0.0;
dw9T f ^V
%***********************************************************************
m'bi\1Q
% Movie initialization
L=]p_2+
%***********************************************************************
cI:-Z{M7z
x=linspace(dx,ie*dx,ie);
&iBNO,v
subplot(2,1,1),plot(x,ez(1:ie)/scfact,'r'),axis([0 3 -1 1]);
{n&Uf{
ylabel('EZ');
n1,S_Hs
subplot(2,1,2),plot(x,hy,'b'),axis([0 3 -3.0e-3 3.0e-3]);
JRY_nX
xlabel('x (meters)');ylabel('HY');
[9AM\n>g
rect=get(gcf,'Position');
'mE^5K
rect(1:2)=[0 0];
h&`y$Jj
M=moviein(nmax/2,gcf,rect);
0e16Ow6\!1
%***********************************************************************
'1-maM\r
% BEGIN TIME-STEPPING LOOP
D:9 2\l
%***********************************************************************
@^&7$#jq%
for n=1:nmax
m(_9<bc>
%***********************************************************************
,F9nDF@)
% Update electric fields
~x#vZ=]8
%***********************************************************************
kAo.C Nj7
ez(1)=scfact*sin(omegadt*n);
KP{3iUqvO
rbc=ez(ie);
"(f`U.
ez(2:ie)=ca*ez(2:ie)+cb*(hy(2:ie)-hy(1:ie-1));
r[pF^y0
ez(ib)=rbc;
64umul
%***********************************************************************
{$33B'wk
% Update magnetic fields
u okc:D
%***********************************************************************
%j5ywr:
hy(1:ie)=hy(1:ie)+ez(2:ib)-ez(1:ie);
<<,>S&/
%************************************ ..
?:uNN
RV;!05^<
未注册仅能浏览
部分内容
,查看
全部内容及附件
请先
登录
或
注册
共
条评分
离线
herosword
UID :3621
注册:
2007-07-01
登录:
2019-11-03
发帖:
30
等级:
仿真二级
1楼
发表于: 2009-03-02 10:12:48
你看谁的程序应结合谁的书看,因为各个人编程时离散方程后设置的迭代系数形式上可能不一样。
:kG)sw7
这个程序你最好看Allen的第三版的书(第二版)也可以
1m)M;^_
1.是用来归一化电场的一个表示式。第三版P71页(3.37)式。
Bm /YgQi
2.P72(3.38)和P67(3.31)
共
1
条评分
gwzhao
技术分
+1
积极参与讨论+技术分 论坛感谢您的参与
2009-03-02
离线
wq_463
UID :20925
注册:
2008-11-06
登录:
2021-04-22
发帖:
227
等级:
仿真三级
2楼
发表于: 2009-03-05 15:43:37
呵呵,我以前也被这个问题困惑原来如此,谢谢
共
条评分
离线
wq_463
UID :20925
注册:
2008-11-06
登录:
2021-04-22
发帖:
227
等级:
仿真三级
3楼
发表于: 2009-03-05 15:43:57
楼主留个qq咱们可以多交流
共
条评分
离线
awell
UID :8837
注册:
2008-03-03
登录:
2010-05-28
发帖:
66
等级:
仿真一级
4楼
发表于: 2009-03-23 10:54:10
非常感谢herosword!~
3$/ 4wH^
wq_463 ,我的QQ是15469459!一起学习交流!
共
条评分
发帖
回复