Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

FDTD code that can compare different absorbing boundary conditions

Status
Not open for further replies.

gladiator

Member level 3
Joined
May 29, 2002
Messages
57
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
309
Hello,
I am looking for an FDTD code 2D or 3D that can compare different
absorbing boundary condiditons


help please


thanks
 

peter-gr

Member level 1
Joined
Sep 24, 2003
Messages
34
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,288
Location
Hellas(Greece)
Activity points
334
FDTD code

A simple 1-D FDTD code in matlab with ABC is given below.

% 1-D FDTD code
KE=200 ;%KE is he number of cells to be used
ex=zeros(1,KE);
hy=zeros(1,KE);
ex_low_m1=0;
ex_low_m2=0;
ex_high_m1=0;
ex_high_m2=0;

kc=KE/2;
%Gaussian pulse
t0=40;
spread=12;
n=input('T=?');
for T=1:n
%Main FDTD Loop
%Ex field

for k=2:KE
ex(k)=ex(k) + 0.5*(hy(k-1)-hy(k));
end

%Gaussian pulse in the middle

pulse=exp(-0.5*((t0-T)^2/spread^2));
ex(kc)=pulse;

%Absorbing Boundary Conditions

ex(1)=ex_low_m2;
ex_low_m2=ex_low_m1;
ex_low_m1=ex(2);

ex(KE)=ex_high_m2;
ex_high_m2=ex_high_m1;
ex_high_m1=ex(KE-1);

%Hy field

for k=1:KE-1
hy(k)=hy(k)+ 0.5*(ex(k)-ex(k+1));
end

end

%End of FDTD Loop

plot(ex)
 

g86

Full Member level 4
Joined
Jan 21, 2003
Messages
212
Helped
11
Reputation
22
Reaction score
7
Trophy points
1,298
Location
On top of antenna :))
Activity points
2,232
Re: FDTD code

Nice piece ....

Can you please teach me a bit? I have some small questions and I am not verey familier with FDTD.

1. Can we replace the gaussian pulse? How?
2. Can we MIX FDTD with some other method?

thanks

:!: :idea: :?:

peter-gr said:
A simple 1-D FDTD code in matlab with ABC is given below.

% 1-D FDTD code
KE=200 ;%KE is he number of cells to be used
ex=zeros(1,KE);
hy=zeros(1,KE);
ex_low_m1=0;
ex_low_m2=0;
ex_high_m1=0;
ex_high_m2=0;

kc=KE/2;
%Gaussian pulse
t0=40;
spread=12;
n=input('T=?');
for T=1:n
%Main FDTD Loop
%Ex field

for k=2:KE
ex(k)=ex(k) + 0.5*(hy(k-1)-hy(k));
end

%Gaussian pulse in the middle

pulse=exp(-0.5*((t0-T)^2/spread^2));
ex(kc)=pulse;

%Absorbing Boundary Conditions

ex(1)=ex_low_m2;
ex_low_m2=ex_low_m1;
ex_low_m1=ex(2);

ex(KE)=ex_high_m2;
ex_high_m2=ex_high_m1;
ex_high_m1=ex(KE-1);

%Hy field

for k=1:KE-1
hy(k)=hy(k)+ 0.5*(ex(k)-ex(k+1));
end

end

%End of FDTD Loop

plot(ex)
 

loucy

Advanced Member level 1
Joined
Aug 26, 2001
Messages
414
Helped
24
Reputation
48
Reaction score
11
Trophy points
1,298
Activity points
4,657
Re: FDTD code

1. I think you can use any wave-form. How to do it would depend on the software you are using. An example would be providing a data file specifying the amplitude of pusle at a series of time steps. Now the accuracy of the result and the time to convergence would be affected by the wave-form. If your source runs for 10000 time steps before reaching "practical" zero, you would check carefully whether the output has stablized much earlier (say 5000). If the simulation is terminated too early, you have error. You would also think about numerical dispersion...

2. Obviously you can mix FDTD with other method. Some commercial codes (e.g. WASP-net) does that. From a theoretical point of view, those methods are used to solve some differential equations, and you could appy equivalent principle to decompose a problem domain into subdomains and apply different methods in each of them.
 

peter-gr

Member level 1
Joined
Sep 24, 2003
Messages
34
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,288
Location
Hellas(Greece)
Activity points
334
Re: FDTD code

Of course you can use a pulse other than gaussian.For example you can use a sinusoidal pulse.
Download the following file which will probaly help you.

good luck.

peter-gr.
 

peter-gr

Member level 1
Joined
Sep 24, 2003
Messages
34
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,288
Location
Hellas(Greece)
Activity points
334
Re: FDTD code

It is very easy to switch to switch to a sinusoidal source.Just replace the parameter pulse with the following:

pulse=sin(2*pi*freq_in*dt*T);

The parameter freq_in determines the frequency of the wave.
 

danielwood

Newbie level 5
Joined
Dec 21, 2001
Messages
10
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,283
Activity points
107
Re: FDTD code

Maybe you can find the 2d and 3d code in the book by Taflove.
Computational Electrodynamics: The Finite-Difference Time-Domain Method by Allen Taflove, Susan C. Hagness (Hardcover - June 2000)

Or You can find another book
Electromagnetic Simulation Using the FDTD Method by Dennis M. Sullivan (Author) (Hardcover)
 

fgc

Newbie level 5
Joined
May 17, 2004
Messages
10
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
37
FDTD code

I need a 3D FDTD code implementing a point source in a free-space mesh with Mur absorbing boundaries. Would help me?
 

peter-gr

Member level 1
Joined
Sep 24, 2003
Messages
34
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,288
Location
Hellas(Greece)
Activity points
334
Re: FDTD code

The book of Dennis Sullivan gives the programs you want for 3D FDTD simulation.
 

tangvu

Newbie level 4
Joined
Nov 12, 2004
Messages
6
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
51
Re: FDTD code

in the matlab source code above, when it is asking for an input of "T" what does that do? help is appreciated.
 

peter-gr

Member level 1
Joined
Sep 24, 2003
Messages
34
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,288
Location
Hellas(Greece)
Activity points
334
Re: FDTD code

The T indicates the time-steps.(the time the pulse will last: T=δt*n)
 

tangvu

Newbie level 4
Joined
Nov 12, 2004
Messages
6
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
51
Re: FDTD code

can someone explain the absorbing boundary condition? i'm still a bit lost on the algorithm. thanks.
 

peter-gr

Member level 1
Joined
Sep 24, 2003
Messages
34
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,288
Location
Hellas(Greece)
Activity points
334
Re: FDTD code

Absorbing Boundary Conditions are necessary to keep outgoing H and E fields from being reflected back into the problem space. Normally, in calculating the E field, we know the surrounding H values;this is a fundamental assumption in the FDTD method.At the edge of the problem space we will not have the value to one side.
Suppose we are looking for a boundary condition in the end.If the wave is going toward the boundary condition in free space, it is travelling at c, the speed of light.So in one time step of the FDTD algorithm,it travels:
distance=c*dt=c*(dx/2c)=dx/2

The above equation explains that it takes two time steps for a wave to cross one cell.So a common sense approach tells as that a common boundary condition would be Ex(n)(0)=Ex(n-2)(1)
It is relativeley easy to implement this.Store a value of Ex(1) for two time steps and then put it in Ex(0).
 

nguyenduyvy

Newbie level 1
Joined
Dec 2, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
5
Re: FDTD code

Yes we can see this from the book of Sullivan. But, in the code you have pasted above, how were the time indexes "n" and "n-2" are presented, i.e. in
" ex(1) = ex_low_m2
ex_low_m2 = ex_low_m1
ex_low_m1 = ex(2) "
I saw just that ex(1) = ex(2).
Sorry for my zombie question. Thanks!
Absorbing Boundary ... So in one time step of the FDTD algorithm,it travels:
distance=c*dt=c*(dx/2c)=dx/2

The above equation explains that it takes two time steps for a wave to cross one cell.So a common sense approach tells as that a common boundary condition would be Ex(n)(0)=Ex(n-2)(1)
It is relativeley easy to implement this.Store a value of Ex(1) for two time steps and then put it in Ex(0).
 
Last edited:

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top