|
楼主 |
发表于 2007-10-24 09:34
|
显示全部楼层
现在我把源改在中心了,网格也改成300nm了,并且把电场和磁场放在纵坐标内部循环了,结果还是变大,就是不收敛!!
program fdtd2D
real*8,dimension(:,:),allocatable::hx,hy,ez
real eps0,mu0,dt,dx,dy,c0,pi,f
integer pmin,pmax
pi=3.14159265
c0=3.0e8 !光速
f=3.e12 !源频率
dx=3.e-7
dy=dx
dt=dx/(2*c0)
eps0=8.854e-12
mu0=4.0e-7
nn=100 !网格数
pmin=0
pmax=nn
open(1,file='D:\MSDEV\ex.txt')
allocate (hx(pmin:pmax,pmin:pmax))
allocate (hy(pmin:pmax,pmin:pmax))
allocate (ez(pmin:pmax,pmin:pmax))
do i=pmin,pmax
do j=pmin,pmax
hx(i,j)=0.
end do
end do
do i=pmin,pmax
do j=pmin,pmax
hy(i,j)=0.
end do
end do
do i=pmin,pmax
do j=pmin,pmax
ez(i,j)=0.
end do
end do
nt=20 !时间步数
do n=1,nt
do j=pmin+1,pmax
if(j>=pmin+1) then
do i=pmin+1,pmax
if (i.eq.50.and.j.eq.50) then
ez(i,j)=sin(2*pi*f*n*dt) !激励源 !
else
ez(i,j)=ez(i,j)+(dt/eps0)*((hy(i,j)-hy(i-1,j))/dx-(hx(i,j)-hx(i,j-1))/dy)
end if
end do
end if
if(j<=pmax-1) then
do i=pmin,pmax-1
hx(i,j)=hx(i,j)-(dt/mu0)*(ez(i,j+1)-ez(i,j))/dy
hy(i,j)=hy(i,j)+(dt/mu0)*(ez(i+1,j)-ez(i,j))/dx
end do
end if
end do
end do
write(1,'(f20.10)') (hx(i,52),i=pmin,pmax)
end
[ 本帖最后由 lanzhiyu520 于 2007-10-24 09:37 编辑 ] |
|