登 录
註 冊
论坛
微波仿真网
注册
登录论坛可查看更多信息
微波仿真论坛
>
时域有限差分法 FDTD
>
一维程序求解读
发帖
回复
743
阅读
0
回复
[
求助
]
一维程序求解读
离线
422204942
UID :74635
注册:
2011-03-28
登录:
2011-05-20
发帖:
25
等级:
仿真新人
0楼
发表于: 2011-05-09 13:20:32
%%Try changing the value of "profile".
to`mnp9Z
close all;
u okc:D
clear all;
/8c&Axuv
L = 5; %长度
to>
N = 505; %# 空间划分
mp1ttGUtM
Niter = 400; %迭代次数
VD[pZ2;4
fs = 300e6; %频率
`N'V#)Pi
ds = L/N; %步长
2+Yb 7 uI,
dt = ds/300e6; %”单位时间“
p0VUh!
eps0 = 8.854e-12; %真空中的介电常数
(%'9CfPx
mu0 = pi*4e-7; %真空中的磁导率
sJU`u'w
x = linspace(0,L,N); %x 轴划分
)/>A6A:
showWKB=0;
I 8zG~L%"
ae = ones(N,1)*dt/(ds*eps0);
S&wzB)#'
am = ones(N,1)*dt/(ds*mu0);
hqDqt"dKz
as = ones(N,1);
p!DP`Ouc3\
epsr = ones(N,1);
` >U?v
mur= ones(N,1);
R\O.e
sigma = zeros(N,1);
cP rwW6
%Try profile = 1,2,3,4,5,6 in sequence.
#]Y*0Wzpfn
%You can define epsr(i)介电常数ε=εr*ε0, mur(i)磁导率μ %and sigma(i)导电性
cbYK5fj"T
profile =1;
-[heV| $;
for i=1:N/2
?\y%]1
epsr(i) = 1;
UQPU"F7.
mur(i) = 1;
i=#F)AD^5#
w1 = 0.5;
+~35G:&:
w2 = 1.5;
PVYyE3`UB
if (profile==1) %介电窗口
ue\t ,*KYd
if (abs(x(i)-L/2)<0.5) epsr(i)=4; end
[>Fm[5x
end
v* ~3Z1
if (profile==2)%平稳过渡
!0"nx{7.
if (abs(x(i)-L/2)<1.5) epsr(i)=1+3*(1+cos(pi*(abs(x(i)-L/2)-w1)/(w2-w1)))/2; end
o35fifM`
if (abs(x(i)-L/2)<0.5) epsr(i)=4; end
|]sx+NlNc
end
fYX<d%?7
if (profile==3) %介质不连续
;gB`YNL
if (x(i)>L/2) epsr(i) = 9; end
E!mmLVa9
end
!20XsO
if (profile==4)
2*AG7
if (x(i)>(L/2-0.1443)) epsr(i) = 3; end
efOjTA%
if (x(i)>L/2) epsr(i) = 9; end
U(,.D}PG
end
Gu;OVLR|
+@:L|uFU
end
izwUS!5e
ae = ae./epsr;
8ObeiVXf)
am = am./mur;
*C2R`gpBI
ae = ae./(1+dt*(sigma./epsr)/(2*eps0));
Mu&x_&|
as = (1-dt*(sigma./epsr)/(2*eps0))./(1+dt*(sigma./epsr)/(2*eps0));
L0"~[zB]N
Hz = zeros(N,1);
q>s`uFRg(
Ey = zeros(N,1);
G%{0i20_
figure(2);
5/@UVY9_
set(gcf,'doublebuffer','on');
`^6 ,kI-c
plot(Ey);
RN9;kB)c
grid on;
5-vo0:hk
for iter=1:Niter
4 b,N8
Ey(3) = Ey(3)+2*(1-exp(-((iter-1)/50)^2))*sin(2*pi*fs*dt*iter);
:dwt1>
Hz(1) = Hz(2);
[Qj;/
for i=2:N-1
OH'ea5xq
Hz(i) = Hz(i)-am(i)*(Ey(i+1)-Ey(i));
@Rq}nq=k
end
:]II-$/8
Ey(N) = Ey(N-1);
Hj6'pJ4
for i=2:N-1
ar^i|`D
Ey(i) = as(i)*Ey(i)-ae(i)*(Hz(i)-Hz(i-1));
/nQ`&q
end
Jp~zX lu
figure(2)
@PSLs*
hold off
5zB~4 u
plot(x,Ey,'b');
cUk*C
axis([3*ds L -2 2]);
(.23rVvnT@
grid on;
]Kh2;>= Xj
title('E (blue) and 377*H (red)');
^?GmrHC)
hold on
lFq{O;q7}
plot(x,377*Hz,'r');
VR0=SE
xlabel('x (m)');
XKU=oI0\j
pause(0);
6v732;^
iter
$B .Qc!m
end
r{K;|'d%h
if (showWKB==1)
D1T@R)j
phase = cumsum((epsr).^0.5)*ds;
|yY`s6Uq
beta0 = 2*pi*fs/(300e6);
r>t1 _b+nu
theory = sin(2*pi*fs*(Niter+4)*dt-beta0*phase)./(epsr.^0.25);
bF-"tm
  ..
`u_Qa
eV};9VJ$F
未注册仅能浏览
部分内容
,查看
全部内容及附件
请先
登录
或
注册
共
条评分
发帖
回复