Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

Anyone know how to code FDTD in matlab?

Status
Not open for further replies.

fungyong

Newbie level 3
Joined
May 27, 2006
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,352
matlab permittivity of free space

Hi ppl,
I am new to this FDTD subject. Got a task to write a matlab code for 1 dimension. I don't really know how to start this coding.
Can someone help me?

The question is:

The equation is in a pdf file.

These two equations are readily programmed for solution by iteration.
For stability purposes Δx and Δt must be selected appropriately. Field values must
affect nearest neighbours only and a conservative choice is cΔt = 0.5Δx .

Use a geometry with 512 layers (or at least 400). The medium is free space
( ε0,µ0,σ = 0 ) except for layers 250-309 which are some type of dielectric
( εr,µ0,σ) . Each layer ( Δx) is 1.5 mm thick, so the dielectric is 90 mm thick.

Write a program that will show a sequence of plots of electric field versus cell
position for an incident 400 ps (to 0.001amplitude) Gaussian pulse at different
time steps. The dielectric slab should have a dielectric constant of 4 with = 0.
Show a plot of the field as a function of position after time steps of (a) 50 time
steps (b) 175 time steps (c) 300 time steps (d) 425 time steps (e) 450 time steps
and (f) 550 time steps.

If we take the Gaussian pulse width of 400 ps (w =40) and set xp = 0.2625, then
after 50 time steps the incident field should be at layer 200 (just in front of the
dielectric). This will ensure that all plots are the same for the same number of
time steps.
 

fdtd howto

Tried some coding but don't understand part of it.
Anyone knows what is dx?
and dt?

nsteps=550; % Number of time steps

m0=12.566E-7; %permability of free space
e0=8.854E-12; %permittivity of free space
er=4; %relative permittivity
c=1/sqrt(e0*m0); %velocity of light
z=120*pi;
w=40; %Gaussian pulse width
dx= ;
dt= ;
xp=0.2625; %original location of peak
sigma=0; %conductivity of the dielectric
 

matlab fdtd

Dear fungyong,

Go to matlabcentral.com and search for a particular ToyFDTD matlab file.

Hope this helps,
Watson
 

FDTD MAtlab Codes in 1D, 2D and 3D

My friend here is the matlab code sof 1D,2D and 3D programs you can easily understand from the commands whats going on and modify the programs as you wish this iis really a good beginning and you are mora lucky than me by having these simple codes and by the way my friend if you can finda good resources about matalb inform us also and in the form if you search there is a book as electromagnetics with matlab it will be helpful to you as well see youu soon

the programs are in the following link
 

Thanks for your help.
I have been trying hard to code as well.
Got some progress but still need to made the wave move.

m0=12.566E-7; %permability of free space
e0=8.854E-12; %permittivity of free space
er=4; %relative permittivity
c=1/sqrt(e0*m0); %velocity of light
Z0=120*pi;
w=40; %Gaussian pulse width
dx=1.5e-3; %Each layer is 1.5mm thick, dielectric is 90mm thick
dt=(0.5*dx)/c ; %time step size (s)
xp=0.2625; %original location of peak
sigma=0; %conductivity of the dielectric
E0=1; %Amplitude
i=1; %Starting at layer zero
lay=0; %counting layer

Ey(i)=E0*exp(log(0.001)*(((lay-(xp/dx))/w)^2));
 

Dear
I think you need to read the fdtd Sullivan book.It is very good book in fdtd. It contains answers for all your questions. and It contains a lot of codes.
if you don't have the book ican send it for you or you can search for it in edaboard.
regards
 

been working like crazy but there is little progress.
How can I program for solution by iteration???
anyone know about the n+1/2?

this part of the code doesn't seems to work.

c1 = e0 ./ (e0 + (dt*sigma));
c2 = dt ./ (dx .* (e0 + (dt .* sigma)));
c3 = dt ./ (dx .* m0);
% Define the source and its location
Nz=512;
pf = 20;
Ex = zeros(1,Nz);
srcIndex = (Nz - 1)/2;

for j = 2:nsteps
Ex(2:end-1) = c1(2:end-1) .* Ex(2:end) - c2(2:end-1) .* (Hy(2:end)-Hy(1:end-1));
%Ex(srcIndex) = Ex(srcIndex) - c3(srcIndex)*srcJx(i);
Hy = Hy - (c3 .* (Ex(2:end) - Ex(1:end-1)));
if (mod(i, pf) == 0)
plot(Ex);
a = sprintf('step number = %d', i);
title(a);
set(gcf,'color','white');
xlabel('Grid Points -->');
ylabel('Magnitude -->');
% axis([1 1001 -1 1]);
pause(0.2);
end
end

Thanks engmfarhat, but i don't have the book u mention.
 

it is uploaded somewhere in edaboard but i didnt remember where?
Ok send me your email
 

you may used more compact code such as "diff".
 

Hi all,
here are some matlab FDTD codes from Sullivan's book.

Hope helps.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top