Sunday, January 18, 2009

One-Dimensional FDTD Simulation

In 1966, Kane Yee originated a set of finite-difference equations for the time-dependent Maxwell’s curl equations system for the lossless materials case. We now apply the Yee's ideas to achieve a numerical approximations of the Maxwell’s curl equation in one dimension.
Now based on the formulations, we can write the program code for one dimension using the Fortran language.
!* FD1D_001 1D FDTD simulation in free space *!
real,allocatable:: Ez(:),Hy(:)
real c0,Eps0,Mu0
Imax=500
Imin=-500
allocate (Ez(Imin:Imax))
allocate (Hy(Imin:Imax-1))
c0=3.e8
Eps0=8.854e-12
Mu0=1.256637e-6
derta=1.e-2
dt=derta/2./c0
t=50
t0=120
Ez=0.
Hy=0.
open(1,file='ex')
open(2,file='z_cell')
do n=1,800
do i=Imin+1,Imax-1
Ez(i)=Ez(i)+(Hy(i-1)-Hy(i))*dt/derta/Eps0
enddo
Ez(0)=Ez(0)+exp(-((n-1)*1.-t0)**2/t**2)
do i=Imin,Imax-1
Hy(i)=Hy(i)-(Ez(i+1)-Ez(i))*dt/derta/Mu0
enddo
enddo
write(1,*) (Ez(i),i=Imin,Imax)
write(2,*) (i,i=Imin,Imax)
end
It generates a Gaussian pulse in the center of the problem space, and the pulse propagates away in both directions as seen in Fig.1. The wave will be total reflected when arrive the boundary. So next section we will introduce the absorbing boundary conditions.

Fig.1 The snaps plots of the Ez field for FDTD simulation in free space.
The pulse originated in the center.

No comments:

Post a Comment

Followers

Blog Archive