登 录
註 冊
论坛
微波仿真网
注册
登录论坛可查看更多信息
微波仿真论坛
>
程序
>
Susan C. Hagness的1D/2D/3D FDTD(matlab)源码
发帖
回复
1
2
3
4
5
6
...28
下一页
到第
页
确认
88843
阅读
277
回复
[
资料共享
]
Susan C. Hagness的1D/2D/3D FDTD(matlab)源码
离线
gwzhao
方恨少
UID :17098
注册:
2008-08-24
登录:
2019-01-09
发帖:
1374
等级:
荣誉管理员
0楼
发表于: 2008-10-23 14:40:30
— 本帖被 tensor 从 资料库 移动到本区(2009-10-28) —
[post]%***********************************************************************
5XBH$&Td
% 1-D FDTD code with simple radiation boundary conditions
J/*`7Pd
%***********************************************************************
IO-Ow!
%
}`~+]9<
% Program author: Susan C. Hagness
XOS[No~
% Department of Electrical and Computer Engineering
C3YT1tK
% University of Wisconsin-Madison
D d</`iUq
% 1415 Engineering Drive
[hj6N*4y
% Madison, WI 53706-1691
'Qe;vZ31K
% 608-265-5739
04=c-~&q
%
hagness@engr.wisc.edu
+; AZ+w]ZF
%
TWFr 4-
% Date of this version: February 2000
Jg|XH L)
%
~R92cH>L
% This MATLAB M-file implements the finite-difference time-domain
JFk lUgg
% solution of Maxwell's curl equations over a one-dimensional space
\P`hq^;
% lattice comprised of uniform grid cells.
.0]<k,JZZ
%
Z?m3~L9L2
% To illustrate the algorithm, a sinusoidal wave (1GHz) propagating
6 ~w@PRy
% in a nonpermeable lossy medium (epsr=1.0, sigma=5.0e-3 S/m) is
WI-1)1t
% modeled. The simplified finite difference system for nonpermeable
9zy!Fq
% media (discussed in Section 3.6.6 of the text) is implemented.
O@C@eW#
%
r\V ={p
% The grid resolution (dx = 1.5 cm) is chosen to provide 20
6j LCU%^
% samples per wavelength. The Courant factor S=c*dt/dx is set to
g7W"
% the stability limit: S=1. In 1-D, this is the "magic time step."
7O-x<P;
%
:G%61x&=Zc
% The computational domain is truncated using the simplest radiation
Z>5b;8
% boundary condition for wave propagation in free space:
E09:E
%
:&9s,l
% Ez(imax,n+1) = Ez(imax-1,n)
X_\otVh(D
%
7E~;xn;
% To execute this M-file, type "fdtd1D" at the MATLAB prompt.
N5b!.B x-w
% This M-file displays the FDTD-computed Ez and Hy fields at every
j+ 0I-p
% time step, and records those frames in a movie matrix, M, which is
o:Sa, !DK
% played at the end of the simulation using the "movie" command.
#'9HU2
%
:! !at:>
%***********************************************************************
?+}_1x`
YglmX"fLf
clear
:E )>\&
U|Ta4W`k\
%***********************************************************************
;@Y;g(bw:
% Fundamental constants
5taT5?n2
%***********************************************************************
_^%,x
ExL0?FemWV
cc=2.99792458e8; %speed of light in free space
Cd}<a?m,
muz=4.0*pi*1.0e-7; %permeability of free space
|H+UOEiv,p
epsz=1.0/(cc*cc*muz); %permittivity of free space
(V67`Z )
sN01rtB(UT
freq=1.0e+9; %frequency of source excitation
*mvlb (' &
lambda=cc/freq; %wavelength of source excitation
={@6{-tl
omega=2.0*pi*freq;
JO6)-U$7UG
+}os&[S
%***********************************************************************
0{}8(
% Grid parameters
,M ^<CJ
%***********************************************************************
PP33i@G
R|87%&6']
ie=200; %number of grid cells in x-direction
a'yK~;+_9
Wf>R&o6tr
ib=ie+1;
t)$:0
o9yJf#-En
dx=lambda/20.0; %space increment of 1-D lattice
nazZ*lC
dt=dx/cc; %time step
#( 146
omegadt=omega*dt;
3kp+<$
^'{Fh"5
nmax=round(12.0e-9/dt); %total number of time steps
9gK`E
gu.}M:u
%***********************************************************************
O:{~urV
% Material parameters
hH8oyIC
%***********************************************************************
=wV<hg)C
Pw`8Wj
eps=1.0;
6HWE~`ok6
sig=5.0e-3;
nB SYsp{
xHLlMn4M
%***********************************************************************
ShP^A"Do
% Updating coefficients for space region with nonpermeable media
~H<6gN<j(.
%***********************************************************************
tGE$z]1c@
aP@N)"
scfact=dt/muz/dx;
9x9 T<cx
ZdWm:(nkU
ca=(1.0-(dt*sig)/(2.0*epsz*eps))/(1.0+(dt*sig)/(2.0*epsz*eps));
T<Z &kYU:R
cb=scfact*(dt/epsz/eps/dx)/(1.0+(dt*sig)/(2.0*epsz*eps));
paE[rS\
Ee%%d
%***********************************************************************
5 ,B_u%bb
% Field arrays
By",rD- r
%***********************************************************************
$AjHbU.I{
:g=qz~2Xk
ez(1:ib)=0.0;
6@F9G4<Z
hy(1:ie)=0.0;
cO+qs[ BQ
;rGwc$?|
%***********************************************************************
`w7v*h|P
% Movie initialization
nuMD!qu!nZ
%***********************************************************************
Vl=l?A8
m6\E$;`
x=linspace(dx,ie*dx,ie);
ND#Yenye
jB Z&Ad@e
subplot(2,1,1),plot(x,ez(1:ie)/scfact,'r'),axis([0 3 -1 1]);
;LPfXpR
ylabel('EZ');
b)5uf'?-
oC: {aK6\
subplot(2,1,2),plot(x,hy,'b'),axis([0 3 -3.0e-3 3.0e-3]);
S8wLmd>
xlabel('x (meters)');ylabel('HY');
g<;q.ZylT
7<#U(,YEA
rect=get(gcf,'Position');
c&?m>2^6
rect(1:2)=[0 0];
l<LP&
kY|utoAP
M=moviein(nmax/2,gcf,rect);
bL+_j}{:N
m_?~OL S
%***********************************************************************
`O!X((
% BEGIN TIME-STEPPING LOOP
}mYx_=+VX
%***********************************************************************
F Q7T'G![
t?-n*9,#S
for n=1:nmax
+yH7v5W
TA`1U;c{n
%***********************************************************************
*ebSq)
% Update electric fields
pnowy;
%***********************************************************************
'qb E=
nn:.nU|I
ez(1)=scfact*sin(omegadt*n);
L~rBAIdD
p;59?
rbc=ez(ie);
oim9<_
ez(2:ie)=ca*ez(2:ie)+cb*(hy(2:ie)-hy(1:ie-1));
+\c5]`
ez(ib)=rbc;
F|o:W75
+ocol6G7W
%***********************************************************************
\378rQU
% Update magnetic fields
jrlVvzZ
%***********************************************************************
rb2S7k0{
9N%We|L,c
hy(1:ie)=hy(1:ie)+ez(2:ib)-ez(1:ie);
D9CaFu
Vod\a5c
%***********************************************************************
QT< }] 0
% Visualize fields
nQX:T;WL@
%*********** ..
*8yAG]z
F3v!AvA|
未注册仅能浏览
部分内容
,查看
全部内容及附件
请先
登录
或
注册
共
3
条评分
,
rf币
+11
,
技术分
+1
chenjiabao1989
rf币
+10
十分期待您分享下一贴!
2014-09-29
casey
rf币
+1
有自己的观点
2008-10-23
casey
技术分
+1
当时加错了,补上
2008-10-23
逆流而上
离线
gwzhao
方恨少
UID :17098
注册:
2008-08-24
登录:
2019-01-09
发帖:
1374
等级:
荣誉管理员
1楼
发表于: 2008-10-23 14:40:53
%***********************************************************************
/62!cp/F/D
% 2-D FDTD TE code with PML absorbing boundary conditions
5I;&mW`1,`
%***********************************************************************
s[*rzoA
%
0o4XUW
% Program author: Susan C. Hagness
Paq4
% Department of Electrical and Computer Engineering
M?49TOQA
% University of Wisconsin-Madison
.LZ?S"z$w
% 1415 Engineering Drive
7+cO_3AB
% Madison, WI 53706-1691
A2FYBM`Q&D
% 608-265-5739
n6>#/eUH
%
hagness@engr.wisc.edu
@{e}4s?7od
%
9RL`<,Q
% Date of this version: February 2000
~/U1xk%
%
P; no?
% This MATLAB M-file implements the finite-difference time-domain
;1=1:S8
% solution of Maxwell's curl equations over a two-dimensional
2.y-48Nz
% Cartesian space lattice comprised of uniform square grid cells.
{WS;dX4
%
^CH=O|8j
% To illustrate the algorithm, a 6-cm-diameter metal cylindrical
4@gG<QJW
% scatterer in free space is modeled. The source excitation is
3`?7<YJ
% a Gaussian pulse with a carrier frequency of 5 GHz.
S+6.ZZ9c
%
Q\vpqE!9
% The grid resolution (dx = 3 mm) was chosen to provide 20 samples
:,7hWs
% per wavelength at the center frequency of the pulse (which in turn
Zl!kJ:0
% provides approximately 10 samples per wavelength at the high end
(L:>\m&NO
% of the excitation spectrum, around 10 GHz).
S@tLCqV4
%
>6-`}G+|
% The computational domain is truncated using the perfectly matched
H41?/U,{
% layer (PML) absorbing boundary conditions. The formulation used
R w\gTo
% in this code is based on the original split-field Berenger PML. The
Vp\,CuQ
% PML regions are labeled as shown in the following diagram:
`(;m?<%
%
gJ+'W1$/
% ----------------------------------------------
}>|s=uGW
% | | BACK PML | |
Q{>k1$fkV
% ----------------------------------------------
RP|`HkP-2
% |L | /| R|
Dy&i&5E.-l
% |E | (ib,jb) | I|
]/6z; ~3U
% |F | | G|
G*MUO#_iuh
% |T | | H|
+`0k Fbx
% | | MAIN GRID | T|
^7*11%Q
% |P | | |
r;2^#6/Z
% |M | | P|
(WJRi:NP?
% |L | (1,1) | M|
3}1u\(Mf
% | |/ | L|
djZqc5t
% ----------------------------------------------
fOrH$?
% | | FRONT PML | |
T::85
% ----------------------------------------------
WU` rh^
%
HiFUv>,u
% To execute this M-file, type "fdtd2D" at the MATLAB prompt.
H?Wya.7
% This M-file displays the FDTD-computed Ex, Ey, and Hz fields at
3?yg\
% every 4th time step, and records those frames in a movie matrix,
Zx@a/jLO[n
% M, which is played at the end of the simulation using the "movie"
} OR+Io
% command.
T-L||yE,h
%
Zi i
%***********************************************************************
Or+U@vAnk
bJ%h53
clear
EZGIf/ 3
BO&bmfp7,
%***********************************************************************
^ @5QP$.
% Fundamental constants
_VN?#J)o
%***********************************************************************
w&#]-|$
x,-75
cc=2.99792458e8; %speed of light in free space
]m<$}
muz=4.0*pi*1.0e-7; %permeability of free space
jr."I+
epsz=1.0/(cc*cc*muz); %permittivity of free space
F>l] 9!P|m
,4$>,@WW~
freq=5.0e+9; %center frequency of source excitation
tk`v:t!6U
lambda=cc/freq; %center wavelength of source excitation
59A}}.@?m
omega=2.0*pi*freq;
cT,sh~-x,
p2](_}PK
%***********************************************************************
j^JPZ{ej?
% Grid parameters
=T@1@w
%***********************************************************************
kevrsV]/$
]ieeP4*
ie=100; %number of grid cells in x-direction
\b x$i*
je=50; %number of grid cells in y-direction
2ilQXy
tWRC$
ib=ie+1;
oc`H}Wvn
jb=je+1;
b$joY*< 6
pnOAs&QAm
is=15; %location of z-directed hard source
a=2%4Wmz
js=je/2; %location of z-directed hard source
0h_|t-9j
7NGxa6wi
dx=3.0e-3; %space increment of square lattice
K%oG,-wdg
dt=dx/(2.0*cc); %time step
6&x@.1('z
/4Gt{ygSr
nmax=300; %total number of time steps
fZF@k5*\
Xv^qVn4
iebc=8; %thickness of left and right PML region
iBaA9
jebc=8; %thickness of front and back PML region
:o3N;*o>)0
rmax=0.00001;
y)@wjH{6
orderbc=2;
,zjv7$L
ibbc=iebc+1;
0l6.<-f{
jbbc=jebc+1;
7.oM J
iefbc=ie+2*iebc;
k,*XG$2h
jefbc=je+2*jebc;
S9.o/mr
ibfbc=iefbc+1;
(9a^$C*
jbfbc=jefbc+1;
7[)E>XRE
e^voW"?%
%***********************************************************************
M= (u]%\
% Material parameters
PW0LG^xp`
%***********************************************************************
@VEb{ w[H
9.#<b|g
media=2;
h376Be{P
F^:3?JA_
eps=[1.0 1.0];
?J0y|
sig=[0.0 1.0e+7];
!nnC3y{G
mur=[1.0 1.0];
C U0YIL
sim=[0.0 0.0];
L4W5EO$
hZb_P\1X
%***********************************************************************
RA 6w}:sq7
% Wave excitation
L/K(dkx
%***********************************************************************
8s@3hXD&
:ws<-Qy
rtau=160.0e-12;
?@x/E&
tau=rtau/dt;
gSj,E8-g
delay=3*tau;
Vurqt_nb
$`8wJf9@w
source=zeros(1,nmax);
tH4B:Bgj!
for n=1:7.0*tau
Lg hfM"g
source(n)=sin(omega*(n-delay)*dt)*exp(-((n-delay)^2/tau^2));
%hP^%'G
end
2=}FBA,2
;'1d1\wiDQ
%***********************************************************************
ueNS='+m
% Field arrays
i|kRK7[6B
%***********************************************************************
DlJo^|5
sLk-x\P]|
ex=zeros(ie,jb); %fields in main grid
DY*N|OnqJ
ey=zeros(ib,je);
]?4hyN
hz=zeros(ie,je);
0jfuBj5!
dO\"?aiD
exbcf=zeros(iefbc,jebc); %fields in front PML region
]4e;RV-B
eybcf=zeros(ibfbc,jebc);
='jT~\
hzxbcf=zeros(iefbc,jebc);
;Rf'P}"]
hzybcf=zeros(iefbc,jebc);
ALHIGJW:6$
=_^X3z0
exbcb=zeros(iefbc,jbbc); %fields in back PML region
i.#:zU%o
eybcb=zeros(ibfbc,jebc);
!)$Zp\Sg
hzxbcb=zeros(iefbc,jebc);
XWw804ir
hzybcb=zeros(iefbc,jebc);
RnN!2K
@4#vm@Yf_
exbcl=zeros(iebc,jb); %fields in left PML region
lTsjxw o
eybcl=zeros(iebc,je);
%so]L+r2!
hzxbcl=zeros(iebc,je);
%iB,IEw
hzybcl=zeros(iebc,je);
mE[y SrV
O/LXdz0B
exbcr=zeros(iebc,jb); %fields in right PML region
G~m<;
eybcr=zeros(ibbc,je);
ssL\g`xe
hzxbcr=zeros(iebc,je);
:Dp0?&_
hzybcr=zeros(iebc,je);
6LhTBV
AQ Ojit6p
%***********************************************************************
mkpMfPt
% Updating coefficients
-\MG}5?!
%***********************************************************************
I1J-)R+
+ge?w#R
for i=1:media
8Fub<UhJ
eaf =dt*sig(i)/(2.0*epsz*eps(i));
JXxwr)i
ca(i)=(1.0-eaf)/(1.0+eaf);
7p[n
cb(i)=dt/epsz/eps(i)/dx/(1.0+eaf);
D_MmW
haf =dt*sim(i)/(2.0*muz*mur(i));
'%;m?t%q
da(i)=(1.0-haf)/(1.0+haf);
d-%hjy3N
db(i)=dt/muz/mur(i)/dx/(1.0+haf);
2<6UwF
end
TA\vZGJ('
&5;"#:ORcK
%***********************************************************************
{8etv:y
% Geometry specification (main grid)
^z\cyT%7t
%***********************************************************************
*WZA9G#V5
u?EN
% Initialize entire main grid to free space
@VI@fN
EX"yxZ~
caex(1:ie,1:jb)=ca(1);
`0svy}
cbex(1:ie,1:jb)=cb(1);
-g<oS9
>mkFV@`
caey(1:ib,1:je)=ca(1);
,: ^u-b|
cbey(1:ib,1:je)=cb(1);
~M$Wd2Th
YYS0`
dahz(1:ie,1:je)=da(1);
fV~~J2IK
dbhz(1:ie,1:je)=db(1);
dWW.Y*339
GX%g9f!O
% Add metal cylinder
-RLOD\ZBh
HKe K<V
diam=20; % diameter of cylinder: 6 cm
ig"L\ C"T
rad=diam/2.0; % radius of cylinder: 3 cm
fsXy"#mOkD
icenter=4*ie/5; % i-coordinate of cylinder's center
g{LP7D;6
jcenter=je/2; % j-coordinate of cylinder's center
T4F/w|Q
A(X KyEx
for i=1:ie
~Gw*r\\+
for j=1:je
#z42C?V
dist2=(i+0.5-icenter)^2 + (j-jcenter)^2;
"jCu6Rj d
if dist2 <= rad^2
c " ,*h
caex(i,j)=ca(2);
}2oc#0
cbex(i,j)=cb(2);
0"#HJA44
end
0 {mex4
dist2=(i-icenter)^2 + (j+0.5-jcenter)^2;
DNi+"[~&P
if dist2 <= rad^2
/Kbl%u
caey(i,j)=ca(2);
V6Dbd" i9
cbey(i,j)=cb(2);
8k79&|
end
4K74=r),i
end
fy$1YI>!Q
end
n@w%Zl
h];I{crh
%***********************************************************************
8Y?;x}
% Fill the PML regions
^@]3R QB
%***********************************************************************
>dT*rH 3w
ce(#2o&`
delbc=iebc*dx;
N g,j#
sigmam=-log(rmax/100.0)*epsz*cc*(orderbc+1)/(2*delbc);
_cwpA#x`}
bcfactor=eps(1)*sigmam/(dx*(delbc^orderbc)*(orderbc+1));
GthYzd:'hJ
7Lt)nq-b
% FRONT region
4P0}+
M3AXe]<eC1
caexbcf(1:iefbc,1)=1.0;
Ss`LLq0LO
cbexbcf(1:iefbc,1)=0.0;
<GsuZ
for j=2:jebc
ite~E5?#
y1=(jebc-j+1.5)*dx;
28nFRr
y2=(jebc-j+0.5)*dx;
_4f;<FL
sigmay=bcfactor*(y1^(orderbc+1)-y2^(orderbc+1));
hOeRd#AQK
ca1=exp(-sigmay*dt/(epsz*eps(1)));
nDW9NQ
cb1=(1.0-ca1)/(sigmay*dx);
"5 A!jq
caexbcf(1:iefbc,j)=ca1;
f!"w5qC^
cbexbcf(1:iefbc,j)=cb1;
7o4\oRGV
end
> P)w?:k
sigmay = bcfactor*(0.5*dx)^(orderbc+1);
cZ06Kx..
ca1=exp(-sigmay*dt/(epsz*eps(1)));
cNH7C"@GVu
cb1=(1-ca1)/(sigmay*dx);
ElXFeJ%[G
caex(1:ie,1)=ca1;
HTtnXBJ)*H
cbex(1:ie,1)=cb1;
%3rP`A
caexbcl(1:iebc,1)=ca1;
])!*_
cbexbcl(1:iebc,1)=cb1;
`x|?&Ytmf9
caexbcr(1:iebc,1)=ca1;
@8 6f
cbexbcr(1:iebc,1)=cb1;
;=N#`l
;PH~<T
for j=1:jebc
n*$ g]G$
y1=(jebc-j+1)*dx;
2?x4vI np;
y2=(jebc-j)*dx;
cu6Opq9
sigmay=bcfactor*(y1^(orderbc+1)-y2^(orderbc+1));
S[N5 ikg
sigmays=sigmay*(muz/(epsz*eps(1)));
`2snz1>!j
da1=exp(-sigmays*dt/muz);
u4j5w
db1=(1-da1)/(sigmays*dx);
b]y2+A.n
dahzybcf(1:iefbc,j)=da1;
~m |BC*)
dbhzybcf(1:iefbc,j)=db1;
BzzTGWq\
caeybcf(1:ibfbc,j)=ca(1);
% `3jL7|
cbeybcf(1:ibfbc,j)=cb(1);
|^aKs#va
dahzxbcf(1:iefbc,j)=da(1);
7 3m1
dbhzxbcf(1:iefbc,j)=db(1);
,s(,S
end
#`IN`m|
]-q;4.
% BACK region
^s=8!=A(
]tD]Wx%
caexbcb(1:iefbc,jbbc)=1.0;
}*-@!wc-N
cbexbcb(1:iefbc,jbbc)=0.0;
G2Zer=rC
for j=2:jebc
wbHb;]
y1=(j-0.5)*dx;
OCUr{Nh
y2=(j-1.5)*dx;
0mnw{fE8_
sigmay=bcfactor*(y1^(orderbc+1)-y2^(orderbc+1));
pFXEu=$3
ca1=exp(-sigmay*dt/(epsz*eps(1)));
;fJ.8C
cb1=(1-ca1)/(sigmay*dx);
Ib`XT0k
caexbcb(1:iefbc,j)=ca1;
OH88n69
cbexbcb(1:iefbc,j)=cb1;
q@qsp&0/
end
6-I'>\U~
sigmay = bcfactor*(0.5*dx)^(orderbc+1);
,^:.dFH6
ca1=exp(-sigmay*dt/(epsz*eps(1)));
R8Tx[CJ5
cb1=(1-ca1)/(sigmay*dx);
>bxS3FCX
caex(1:ie,jb)=ca1;
yZRzIb_
cbex(1:ie,jb)=cb1;
?0SEMmp`H
caexbcl(1:iebc,jb)=ca1;
xmX 4qtAL
cbexbcl(1:iebc,jb)=cb1;
u"8yK5!
caexbcr(1:iebc,jb)=ca1;
'7/)Ot(
cbexbcr(1:iebc,jb)=cb1;
OPi0~s
gSgr6TH0
for j=1:jebc
;,TFr}p`
y1=j*dx;
"zc l|@
y2=(j-1)*dx;
s S Mh`4'
sigmay=bcfactor*(y1^(orderbc+1)-y2^(orderbc+1));
rUl+
sigmays=sigmay*(muz/(epsz*eps(1)));
nu^436MSOa
da1=exp(-sigmays*dt/muz);
6mE\OS-I
db1=(1-da1)/(sigmays*dx);
d1*<Ll9K
dahzybcb(1:iefbc,j)=da1;
TV:9bn?r)
dbhzybcb(1:iefbc,j)=db1;
#QPjkR|\
caeybcb(1:ibfbc,j)=ca(1);
!W\+#ez
cbeybcb(1:ibfbc,j)=cb(1);
SKtr tm
dahzxbcb(1:iefbc,j)=da(1);
#ABCDi={zA
dbhzxbcb(1:iefbc,j)=db(1);
5\v3;;A[
end
.6> w'F{>
Fs{*XKv&lH
% LEFT region
FlQGgVN
H.;Q+A,8^
caeybcl(1,1:je)=1.0;
LLI.8kn7
cbeybcl(1,1:je)=0.0;
':q p05t
for i=2:iebc
GB^B r6
x1=(iebc-i+1.5)*dx;
edD)TpmE,
x2=(iebc-i+0.5)*dx;
0%B/,/PxD
sigmax=bcfactor*(x1^(orderbc+1)-x2^(orderbc+1));
jylD6IT
ca1=exp(-sigmax*dt/(epsz*eps(1)));
<$YlH@;)`a
cb1=(1-ca1)/(sigmax*dx);
E{\2='3\
caeybcl(i,1:je)=ca1;
YQ}o?Q$z
cbeybcl(i,1:je)=cb1;
Q/?$x*\>
caeybcf(i,1:jebc)=ca1;
t7pFW^&
cbeybcf(i,1:jebc)=cb1;
Fu~j8K
caeybcb(i,1:jebc)=ca1;
df=f62
cbeybcb(i,1:jebc)=cb1;
TzZq(?V
end
ni<(K 0~
sigmax=bcfactor*(0.5*dx)^(orderbc+1);
<%^&2UMg
ca1=exp(-sigmax*dt/(epsz*eps(1)));
7^285)UQA
cb1=(1-ca1)/(sigmax*dx);
6b,V;#Anj
caey(1,1:je)=ca1;
f^e)O$N9]
cbey(1,1:je)=cb1;
y} '@R$
caeybcf(iebc+1,1:jebc)=ca1;
TvM~y\s
cbeybcf(iebc+1,1:jebc)=cb1;
"tZe>>I
caeybcb(iebc+1,1:jebc)=ca1;
m'U0'}Ld};
cbeybcb(iebc+1,1:jebc)=cb1;
+t.b` U`-
IBGrt^$M
for i=1:iebc
cK@wsA^4
x1=(iebc-i+1)*dx;
54,er$$V
x2=(iebc-i)*dx;
xk5]^yDp
sigmax=bcfactor*(x1^(orderbc+1)-x2^(orderbc+1));
+ 3gp%`c4
sigmaxs=sigmax*(muz/(epsz*eps(1)));
("@!>|H
da1=exp(-sigmaxs*dt/muz);
;a/E42eN;
db1=(1-da1)/(sigmaxs*dx);
`V1]k_h
dahzxbcl(i,1:je)=da1;
s.rm7r@#
dbhzxbcl(i,1:je)=db1;
`^vE9nW7
dahzxbcf(i,1:jebc)=da1;
hPh-+Hb
dbhzxbcf(i,1:jebc)=db1;
"Q<MS'a
dahzxbcb(i,1:jebc)=da1;
S/ *E,))m
dbhzxbcb(i,1:jebc)=db1;
)BE1Q*= n
caexbcl(i,2:je)=ca(1);
}bDm@NU
cbexbcl(i,2:je)=cb(1);
wkq 66?
dahzybcl(i,1:je)=da(1);
NbobliC=
dbhzybcl(i,1:je)=db(1);
v19-./H^ j
end
3Vwh|1?
7$b1<.WX
% RIGHT region
+vH4MwG$.&
I]575\bA
caeybcr(ibbc,1:je)=1.0;
#WuBL_nZ~
cbeybcr(ibbc,1:je)=0.0;
!if
for i=2:iebc
c$,P ~Ws'
x1=(i-0.5)*dx;
oDR%\VY6T
x2=(i-1.5)*dx;
sK{e*[I>W
sigmax=bcfactor*(x1^(orderbc+1)-x2^(orderbc+1));
[ 3Gf2_
ca1=exp(-sigmax*dt/(epsz*eps(1)));
7v kL1IA
cb1=(1-ca1)/(sigmax*dx);
4Ig;3 ^%71
caeybcr(i,1:je)=ca1;
_#niyW+?~
cbeybcr(i,1:je)=cb1;
r$1Qf}J3=
caeybcf(i+iebc+ie,1:jebc)=ca1;
KXy6Eno
cbeybcf(i+iebc+ie,1:jebc)=cb1;
*hx
caeybcb(i+iebc+ie,1:jebc)=ca1;
.8R@2c`}Cs
cbeybcb(i+iebc+ie,1:jebc)=cb1;
osRy e3
end
+TJCLZ..
sigmax=bcfactor*(0.5*dx)^(orderbc+1);
2iOV/=+
ca1=exp(-sigmax*dt/(epsz*eps(1)));
|=w@H]r
cb1=(1-ca1)/(sigmax*dx);
S!UaH>Rh
caey(ib,1:je)=ca1;
H)?z #x
cbey(ib,1:je)=cb1;
R5D1w+
caeybcf(iebc+ib,1:jebc)=ca1;
'V {W-W<
cbeybcf(iebc+ib,1:jebc)=cb1;
A<{{iBEI`
caeybcb(iebc+ib,1:jebc)=ca1;
pb}*\/s
cbeybcb(iebc+ib,1:jebc)=cb1;
DF= *_,2/
Za9qjBH
for i=1:iebc
![1rzQvGDb
x1=i*dx;
o4X{L`m
x2=(i-1)*dx;
'NmRR]Q9
sigmax=bcfactor*(x1^(orderbc+1)-x2^(orderbc+1));
$]d^-{|
sigmaxs=sigmax*(muz/(epsz*eps(1)));
qna8|3eP
da1=exp(-sigmaxs*dt/muz);
L_T5nD^D
db1=(1-da1)/(sigmaxs*dx);
$I=~S[p
dahzxbcr(i,1:je) = da1;
V&5wRz+`W
dbhzxbcr(i,1:je) = db1;
XwmL.Gg:]7
dahzxbcf(i+ie+iebc,1:jebc)=da1;
3n _htgcv
dbhzxbcf(i+ie+iebc,1:jebc)=db1;
@5FQX
dahzxbcb(i+ie+iebc,1:jebc)=da1;
>Ry01G]_/h
dbhzxbcb(i+ie+iebc,1:jebc)=db1;
b;n[mk
caexbcr(i,2:je)=ca(1);
xpt:BBo
cbexbcr(i,2:je)=cb(1);
]esC[r]PJ
dahzybcr(i,1:je)=da(1);
}tz7b#
dbhzybcr(i,1:je)=db(1);
C _Dn{
end
wT@og|M
pP_LR ks}
%***********************************************************************
p+eh%2Jm
% Movie initialization
U6K|fYN`
%***********************************************************************
w{KavU5W
Da|z"I x
subplot(3,1,1),pcolor(ex');
AH^/V}9H
shading flat;
80I#TA6C
caxis([-80.0 80.0]);
f#;> g
axis([1 ie 1 jb]);
/wp6KXm
colorbar;
)GpK@R]{
axis image;
vaLSH xi
axis off;
7dWS
title(['Ex at time step = 0']);
K0~rN.C!0
It(_v
subplot(3,1,2),pcolor(ey');
^('wy};
shading flat;
8LKiS
caxis([-80.0 80.0]);
& 21%zPm
axis([1 ib 1 je]);
LV Ge]lD
colorbar;
2G7Wi!J
axis image;
.A|udZ,
axis off;
1M 6D3d_
title(['Ey at time step = 0']);
<I?Zk80
]Ze1s02(
subplot(3,1,3),pcolor(hz');
sRs>"zAg
shading flat;
?}oFg#m-<L
caxis([-0.2 0.2]);
th_oJcS
axis([1 ie 1 je]);
_>+Ld6.T6
colorbar;
~ljXzD93Z
axis image;
fhiM U8(&
axis off;
Ui~>SN>s
title(['Hz at time step = 0']);
54T`OE =
[,Gg^*umS
rect=get(gcf,'Position');
';CNGv -
rect(1:2)=[0 0];
K+eM
L *wYx|
M=moviein(nmax/4,gcf,rect);
3og.y+.=U.
[txE .7p
%***********************************************************************
t.<i:#rj>l
% BEGIN TIME-STEPPING LOOP
X?O[r3<
%***********************************************************************
Wr 4,YQM
l?e.9o2-
for n=1:nmax
7!1S)dup
7Q 3 k7
%***********************************************************************
?,z}%p
% Update electric fields (EX and EY) in main grid
oH@78D0A
%***********************************************************************
IGl9g_18
}jXfb@`K
ex(:,2:je)=caex(:,2:je).*ex(:,2:je)+...
:#Wd~~d
cbex(:,2:je).*(hz(:,2:je)-hz(:,1:je-1));
i!Ba]n
>4TO=i
ey(2:ie,:)=caey(2:ie,:).*ey(2:ie,:)+...
/~1+i'7V.,
cbey(2:ie,:).*(hz(1:ie-1,:)-hz(2:ie,:));
Rcuz(yS8
"oyo#-5z
%***********************************************************************
)0`C@um
% Update EX in PML regions
\bXa&Lq
%***********************************************************************
&oNAv-m^GD
:OT&
% FRONT
97Vtn4N3
mh%VrAq
exbcf(:,2:jebc)=caexbcf(:,2:jebc).*exbcf(:,2:jebc)-...
6tZI["\
cbexbcf(:,2:jebc).*(hzxbcf(:,1:jebc-1)+hzybcf(:,1:jebc-1)-...
$4\j]RE!
hzxbcf(:,2:jebc)-hzybcf(:,2:jebc));
0GL M(JmK
ex(1:ie,1)=caex(1:ie,1).*ex(1:ie,1)-...
+ {]j]OP
cbex(1:ie,1).*(hzxbcf(ibbc:iebc+ie,jebc)+...
^iA9%zp
hzybcf(ibbc:iebc+ie,jebc)-hz(1:ie,1));
X$ D6Ey
[),ige
% BACK
h[ ZN+M
?6!LL5a.
exbcb(:,2:jebc-1)=caexbcb(:,2:jebc-1).*exbcb(:,2:jebc-1)-...
e-;}366}
cbexbcb(:,2:jebc-1).*(hzxbcb(:,1:jebc-2)+hzybcb(:,1:jebc-2)-...
`[A];]
hzxbcb(:,2:jebc-1)-hzybcb(:,2:jebc-1));
6]N.%Y[(
ex(1:ie,jb)=caex(1:ie,jb).*ex(1:ie,jb)-...
_c07}aQ ],
cbex(1:ie,jb).*(hz(1:ie,jb-1)-hzxbcb(ibbc:iebc+ie,1)-...
TeQV?ZQ#}
hzybcb(ibbc:iebc+ie,1));
/ {%%"j
BtZ yn7a
% LEFT
}V>T M{
)b)z m2;
exbcl(:,2:je)=caexbcl(:,2:je).*exbcl(:,2:je)-...
YSMAd-Ef-
cbexbcl(:,2:je).*(hzxbcl(:,1:je-1)+hzybcl(:,1:je-1)-...
cQ|NJ_F{1
hzxbcl(:,2:je)-hzybcl(:,2:je));
}H2R3icE
exbcl(:,1)=caexbcl(:,1).*exbcl(:,1)-...
"@kaHIf[
cbexbcl(:,1).*(hzxbcf(1:iebc,jebc)+hzybcf(1:iebc,jebc)-...
KvSG;
hzxbcl(:,1)-hzybcl(:,1));
HW|IILFB
exbcl(:,jb)=caexbcl(:,jb).*exbcl(:,jb)-...
'w/hw'F6
cbexbcl(:,jb).*(hzxbcl(:,je)+hzybcl(:,je)-...
y`Fw-!'o
hzxbcb(1:iebc,1)-hzybcb(1:iebc,1));
WIOV2+
_F{C\}
% RIGHT
2%1hdA<
a*;b^Ze`v
exbcr(:,2:je)=caexbcr(:,2:je).*exbcr(:,2:je)-...
I fir ,8
cbexbcr(:,2:je).*(hzxbcr(:,1:je-1)+hzybcr(:,1:je-1)-...
*j=% #
hzxbcr(:,2:je)-hzybcr(:,2:je));
BUFv|z+H
exbcr(:,1)=caexbcr(:,1).*exbcr(:,1)-...
X&zis1A<
cbexbcr(:,1).*(hzxbcf(1+iebc+ie:iefbc,jebc)+...
g0H[*"hj
hzybcf(1+iebc+ie:iefbc,jebc)-...
p_ =z#
hzxbcr(:,1)-hzybcr(:,1));
<3iMRe
exbcr(:,jb)=caexbcr(:,jb).*exbcr(:,jb)-...
E^PB)D(.
cbexbcr(:,jb).*(hzxbcr(:,je)+hzybcr(:,je)-...
Z)!C'c b
hzxbcb(1+iebc+ie:iefbc,1)-...
QJNFA}*>
hzybcb(1+iebc+ie:iefbc,1));
B!yr!DWv
9L9sqZUB
%***********************************************************************
l6B@qYLZ
% Update EY in PML regions
s{++w5s
%***********************************************************************
wr4:Go`
PH"%kCI:
% FRONT
zi:BF60]=
v=k$A
eybcf(2:iefbc,:)=caeybcf(2:iefbc,:).*eybcf(2:iefbc,:)-...
;4a{$Lw~^9
cbeybcf(2:iefbc,:).*(hzxbcf(2:iefbc,:)+hzybcf(2:iefbc,:)-...
IID5c" oR
hzxbcf(1:iefbc-1,:)-hzybcf(1:iefbc-1,:));
5xde;
d _ e WcI
% BACK
iE{&*.q_}>
2:R+tn(F
eybcb(2:iefbc,:)=caeybcb(2:iefbc,:).*eybcb(2:iefbc,:)-...
$(9U @N9E
cbeybcb(2:iefbc,:).*(hzxbcb(2:iefbc,:)+hzybcb(2:iefbc,:)-...
&zhAh1m
hzxbcb(1:iefbc-1,:)-hzybcb(1:iefbc-1,:));
GfG|&VNlz
^{{ qV
% LEFT
l,:F
Qd6F H2Pl
eybcl(2:iebc,:)=caeybcl(2:iebc,:).*eybcl(2:iebc,:)-...
xPgBV~
cbeybcl(2:iebc,:).*(hzxbcl(2:iebc,:)+hzybcl(2:iebc,:)-...
d3Rw!slIq
hzxbcl(1:iebc-1,:)-hzybcl(1:iebc-1,:));
z~Q)/d,Ac
ey(1,:)=caey(1,:).*ey(1,:)-...
;=@0'xPEa-
cbey(1,:).*(hz(1,:)-hzxbcl(iebc,:)-hzybcl(iebc,:));
ddo#P%sH'
9l,oP?
% RIGHT
:]c3|J
}%z
eybcr(2:iebc,:)=caeybcr(2:iebc,:).*eybcr(2:iebc,:)-...
1}37Q&2
cbeybcr(2:iebc,:).*(hzxbcr(2:iebc,:)+hzybcr(2:iebc,:)-...
"j-CZ\]U|
hzxbcr(1:iebc-1,:)-hzybcr(1:iebc-1,:));
q;U,s)Uz^
ey(ib,:)=caey(ib,:).*ey(ib,:)-...
X.V~SeS
cbey(ib,:).*(hzxbcr(1,:)+hzybcr(1,:)- hz(ie,:));
_|]x2xb)
V1?]|HTQcT
zJXplvaL;
%***********************************************************************
oE~RySX
% Update magnetic fields (HZ) in main grid
Tr|JYLwF
%***********************************************************************
P$sxr
@6d[=!9
hz(1:ie,1:je)=dahz(1:ie,1:je).*hz(1:ie,1:je)+...
[V!tVDs&'o
dbhz(1:ie,1:je).*(ex(1:ie,2:jb)-ex(1:ie,1:je)+...
S$k&vc(0
ey(1:ie,1:je)-ey(2:ib,1:je));
Wf<LR3
fatf*}eln
hz(is,js)=source(n);
`kr?j:g
uocGbi:V';
H1T.(M/"
%***********************************************************************
nd(S3rct&
% Update HZX in PML regions
e*!kZAf
%***********************************************************************
x :7IIvP
{^'HL
% FRONT
RL<c>PY
bxWa oWE0
hzxbcf(1:iefbc,:)=dahzxbcf(1:iefbc,:).*hzxbcf(1:iefbc,:)-...
qa6,z.mQ
dbhzxbcf(1:iefbc,:).*(eybcf(2:ibfbc,:)-eybcf(1:iefbc,:));
_FEFx
SzRmF1<
% BACK
WKU=.sY
iO[<1?
hzxbcb(1:iefbc,:)=dahzxbcb(1:iefbc,:).*hzxbcb(1:iefbc,:)-...
LF7SS;&~f
dbhzxbcb(1:iefbc,:).*(eybcb(2:ibfbc,:)-eybcb(1:iefbc,:));
/@Zrq#o zx
tjnIN?YT
% LEFT
2-b6gc7
v LZoa-w:
hzxbcl(1:iebc-1,:)=dahzxbcl(1:iebc-1,:).*hzxbcl(1:iebc-1,:)-...
<t,x RBk
dbhzxbcl(1:iebc-1,:).*(eybcl(2:iebc,:)-eybcl(1:iebc-1,:));
KYP!Rs/j.
hzxbcl(iebc,:)=dahzxbcl(iebc,:).*hzxbcl(iebc,:)-...
G\?YK.Y>
dbhzxbcl(iebc,:).*(ey(1,:)-eybcl(iebc,:));
c|1&lYal;
kW (Bkuc)
% RIGHT
pNIf=lA
=2 kG%9
hzxbcr(2:iebc,:)=dahzxbcr(2:iebc,:).*hzxbcr(2:iebc,:)-...
l(q ,<[O
dbhzxbcr(2:iebc,:).*(eybcr(3:ibbc,:)-eybcr(2:iebc,:));
`XB 9Mi=
hzxbcr(1,:)=dahzxbcr(1,:).*hzxbcr(1,:)-...
;$tSb ~K+
dbhzxbcr(1,:).*(eybcr(2,:)-ey(ib,:));
|CzSU1ma
!a<ng&H^U
%***********************************************************************
\L\b $4$d
% Update HZY in PML regions
;GI&lpKK
%***********************************************************************
$kKjgQS(
yZ`wfj$Jj
% FRONT
-(#iIgmP
}{"fJ3] c^
hzybcf(:,1:jebc-1)=dahzybcf(:,1:jebc-1).*hzybcf(:,1:jebc-1)-...
X76e&~
dbhzybcf(:,1:jebc-1).*(exbcf(:,1:jebc-1)-exbcf(:,2:jebc));
/=, nGk>
hzybcf(1:iebc,jebc)=dahzybcf(1:iebc,jebc).*hzybcf(1:iebc,jebc)-...
_? OG1t!
dbhzybcf(1:iebc,jebc).*(exbcf(1:iebc,jebc)-exbcl(1:iebc,1));
s0_nLbWwO
hzybcf(iebc+1:iebc+ie,jebc)=...
j+(I"h3
dahzybcf(iebc+1:iebc+ie,jebc).*hzybcf(iebc+1:iebc+ie,jebc)-...
63A.@mL
dbhzybcf(iebc+1:iebc+ie,jebc).*(exbcf(iebc+1:iebc+ie,jebc)-...
mQ=#nk$~g
ex(1:ie,1));
$\! 7 {6a
hzybcf(iebc+ie+1:iefbc,jebc)=...
m_l[MG\
dahzybcf(iebc+ie+1:iefbc,jebc).*hzybcf(iebc+ie+1:iefbc,jebc)-...
TU7'J
dbhzybcf(iebc+ie+1:iefbc,jebc).*(exbcf(iebc+ie+1:iefbc,jebc)-...
X|8c>_}
exbcr(1:iebc,1));
g4@ lM"|S
z~Q>V]a>;
% BACK
9M9?%N:ra
,1##p77.
hzybcb(1:iefbc,2:jebc)=dahzybcb(1:iefbc,2:jebc).*hzybcb(1:iefbc,2:jebc)-...
w\brVnt
dbhzybcb(1:iefbc,2:jebc).*(exbcb(1:iefbc,2:jebc)-exbcb(1:iefbc,3:jbbc));
d:{O\
hzybcb(1:iebc,1)=dahzybcb(1:iebc,1).*hzybcb(1:iebc,1)-...
eN~=*Mn(za
dbhzybcb(1:iebc,1).*(exbcl(1:iebc,jb)-exbcb(1:iebc,2));
Y#3c }qb
hzybcb(iebc+1:iebc+ie,1)=...
pBPl6%C.X-
dahzybcb(iebc+1:iebc+ie,1).*hzybcb(iebc+1:iebc+ie,1)-...
}{< '8J.R
dbhzybcb(iebc+1:iebc+ie,1).*(ex(1:ie,jb)-exbcb(iebc+1:iebc+ie,2));
.%OR3"9@
hzybcb(iebc+ie+1:iefbc,1)=...
->{KVPHe{
dahzybcb(iebc+ie+1:iefbc,1).*hzybcb(iebc+ie+1:iefbc,1)-...
,=mS,r7
dbhzybcb(iebc+ie+1:iefbc,1).*(exbcr(1:iebc,jb)-...
W,-g=6,
exbcb(iebc+ie+1:iefbc,2));
B~du-Z22IZ
XS BA$y
% LEFT
0C*7K?/
8Bg;Kh6B
hzybcl(:,1:je)=dahzybcl(:,1:je).*hzybcl(:,1:je)-...
X~i<g?]
dbhzybcl(:,1:je).*(exbcl(:,1:je)-exbcl(:,2:jb));
i2^>vYCsl
0P(!j_2m
% RIGHT
&yol_%C
tdaL/rRe
hzybcr(:,1:je)=dahzybcr(:,1:je).*hzybcr(:,1:je)-...
-B\HI*u
dbhzybcr(:,1:je).*(exbcr(:,1:je)-exbcr(:,2:jb));
c{LO6dNg\z
4YX3+oS
%***********************************************************************
.y,0[i V N
% Visualize fields
qcGK2Qx
%***********************************************************************
2,P^n4~A?w
PAOJ\U
if mod(n,4)==0;
N{~YJ$!8
0nD/;\OU
timestep=int2str(n);
vFK<J Sk!
CWP2{
subplot(3,1,1),pcolor(ex');
9 5RBO4w%w
shading flat;
z%LIX^q9
caxis([-80.0 80.0]);
C=4Qlt[`
axis([1 ie 1 jb]);
(NnH:J`
colorbar;
]P2"[y
axis image;
;{o|9x|
axis off;
BIWWMg
title(['Ex at time step = ',timestep]);
s&!a
M+9 gL3W
subplot(3,1,2),pcolor(ey');
xpx\=iAe
shading flat;
}I6vqG
caxis([-80.0 80.0]);
G<^{&E+=
axis([1 ib 1 je]);
D+7Rz_=
colorbar;
'anG:=
axis image;
4 vV:EF-
axis off;
*``JamnSO
title(['Ey at time step = ',timestep]);
Oh\<VvZuN
VgC2+APg
subplot(3,1,3),pcolor(hz');
y%bF&
shading flat;
\A6B,|@
caxis([-0.2 0.2]);
VEw"
axis([1 ie 1 je]);
^UhBH@ti
colorbar;
a,#j =
axis image;
3fJc 9|
axis off;
A:9?ZI/X
title(['Hz at time step = ',timestep]);
A^EE32kbm
=+MPFhvg!
nn=n/4;
X<; f
M(:,nn)=getframe(gcf,rect);
~B(4qK1G
~Ti'FhN
end;
x6ARzH\
cXOK)g#
%***********************************************************************
xZF}D/S?Ov
% END TIME-STEPPING LOOP
=;&yd';k
%***********************************************************************
W$2C47i
n%s]30Xs
end
9lH?-~9
l9u!aD
movie(gcf,M,0,10,rect);
共
1
条评分
cem-uestc
rf币
+5
优秀资料+RF币
2008-10-23
逆流而上
离线
gwzhao
方恨少
UID :17098
注册:
2008-08-24
登录:
2019-01-09
发帖:
1374
等级:
荣誉管理员
2楼
发表于: 2008-10-23 14:41:19
%***********************************************************************
(%o2jroQ#
% 3-D FDTD code with PEC boundaries
TdGnf
%***********************************************************************
pzgSg[|
%
n` TSu$
% Program author: Susan C. Hagness
&o97u4xi
% Department of Electrical and Computer Engineering
Kmv+1T0,
% University of Wisconsin-Madison
g{9+O7q
% 1415 Engineering Drive
v\"S Gc
% Madison, WI 53706-1691
Gkxj?)`
% 608-265-5739
\3jW~FV
%
hagness@engr.wisc.edu
~~,rp) )
%
]a3iEA2 (
% Date of this version: February 2000
}sFm9j7yR
%
^3FE\V/=
% This MATLAB M-file implements the finite-difference time-domain
~ Yngkt
% solution of Maxwell's curl equations over a three-dimensional
^F"iP7
% Cartesian space lattice comprised of uniform cubic grid cells.
(%:>T Q(
%
d@G}~&.|
% To illustrate the algorithm, an air-filled rectangular cavity
Z@%HvB7
% resonator is modeled. The length, width, and height of the
d/e|'MPX
% cavity are 10.0 cm (x-direction), 4.8 cm (y-direction), and
b(I2m
% 2.0 cm (z-direction), respectively.
? j 9|5*
%
w7n373y%
% The computational domain is truncated using PEC boundary
@b3#X@e}
% conditions:
G>+1*\c
% ex(i,j,k)=0 on the j=1, j=jb, k=1, and k=kb planes
O8W7<Wc|z
% ey(i,j,k)=0 on the i=1, i=ib, k=1, and k=kb planes
UD y(v ]
% ez(i,j,k)=0 on the i=1, i=ib, j=1, and j=jb planes
BiZ=${y
% These PEC boundaries form the outer lossless walls of the cavity.
^p/Ob'!
%
z5X~3s\dP
% The cavity is excited by an additive current source oriented
.+([
% along the z-direction. The source waveform is a differentiated
S"hTE7`
% Gaussian pulse given by
R1W}dRE}
% J(t)=-J0*(t-t0)*exp(-(t-t0)^2/tau^2),
v^7LctcVm
% where tau=50 ps. The FWHM spectral bandwidth of this zero-dc-
$eBX
% content pulse is approximately 7 GHz. The grid resolution
C}*cx$.
% (dx = 2 mm) was chosen to provide at least 10 samples per
b]JI@=s?
% wavelength up through 15 GHz.
[J0v&{)?
%
' 2-oh
% To execute this M-file, type "fdtd3D" at the MATLAB prompt.
35x 0T/8
% This M-file displays the FDTD-computed Ez fields at every other
^v@4|E$
% time step, and records those frames in a movie matrix, M, which
T4;T6 9j;,
% is played at the end of the simulation using the "movie" command.
ez9k4IO
%
KYxBVgJ
%***********************************************************************
G^1b>K
`ZaT}#Y
clear
xT)psM'CL
5')8r';,
%***********************************************************************
tB'V
% Fundamental constants
cubk]~VD
%***********************************************************************
nB ". '=
7.+#zyF
cc=2.99792458e8; %speed of light in free space
X{-9FDW
muz=4.0*pi*1.0e-7; %permeability of free space
l#wdpD a{
epsz=1.0/(cc*cc*muz); %permittivity of free space
do ^RF<G
p=QYc)3F
%***********************************************************************
,s^<X85gp\
% Grid parameters
Bfv.$u00p
%***********************************************************************
)2E%b+"
=N|kn<h4
ie=50; %number of grid cells in x-direction
&wetzC)
je=24; %number of grid cells in y-direction
@lUlY2
ke=10; %number of grid cells in z-direction
xDO7A5
O;]?gj 1@
ib=ie+1;
qUF1XJZ}z
jb=je+1;
s Fgadz6O
kb=ke+1;
=BZ?- mIU
mEuHl>
is=26; %location of z-directed current source
,`8Y8
js=13; %location of z-directed current source
,goBq3[%?
7e&\{*
kobs=5;
sxED7,A
wp.TfKxw
dx=0.002; %space increment of cubic lattice
zG c[Z3N
dt=dx/(2.0*cc); %time step
HpexH{.u)
!)Rr] ~
nmax=500; %total number of time steps
y$tX-9U
em]xtya
%***********************************************************************
$'[q4 wo<
% Differentiated Gaussian pulse excitation
rFL$QC2
%***********************************************************************
(w2= 2$
\`,xgC9K
rtau=50.0e-12;
(5uJZ!m
tau=rtau/dt;
*N/hc
ndelay=3*tau;
BZF,=v
srcconst=-dt*3.0e+11;
oaDsk<(j;R
s([Wn)I
%***********************************************************************
C/v}^#cLD
% Material parameters
2go>
%***********************************************************************
rvwy~hO"
y?N Nz0
eps=1.0;
+EAS Aq
sig=0.0;
8t.dPy<
Ws49ImCB
%***********************************************************************
DPJh5d
% Updating coefficients
a]VGUW-
%***********************************************************************
IvW@o1Q
LBX%H GH
ca=(1.0-(dt*sig)/(2.0*epsz*eps))/(1.0+(dt*sig)/(2.0*epsz*eps));
KC&`x|
cb=(dt/epsz/eps/dx)/(1.0+(dt*sig)/(2.0*epsz*eps));
F$hZRZ
da=1.0;
<4D%v"zRP
db=dt/muz/dx;
@%@zH%b
j.QHkI1.
%***********************************************************************
\].J-^=
% Field arrays
4-:7.I(hq
%***********************************************************************
Z|`fHO3j
M<