Kamis, 16 Agustus 2012

[bs] Review on 1 D FDTD using MATLAB

Kita lagi mupeng banget sama metode ini, Finite Difference Time Domain (FDTD) method . Sebagai pengantar, kita akan mencoba yang simple, level 1 dimensi. Kelak kita pengen juga mencoba yang level 3 Dimensi. Bagai rekan-rekan yang sudah bisa, share dong gimana caranya ? Atau bagi rekan-rekan yang berminat belajar bareng, yuk, kita bahas sama-sama. 


1D-FDTD using MATLAB

By Hui Loui, Student Member, IEEE

Abstract—This report presents a simple 1D implementation of the Yee FDTD algorithm using the MATLAB programming language. The fields Ex and Hy are simulated along the line X = Y = 0, i.e. propagation along the ˆz axis. Source implementation and the effects of various boundaries such as PEC, PMC, Mur on the incident/scattered/total fields are subsequently investigated. The goal of this project is to exercise the basic parts of a FDTD code in the simplest system.

Index Terms—1D FDTD, Gaussian Pulse.

Sumber artikel :


File  1 : Fungsi medan listrik sumber

function hitung = source(t);
lambda = 0.5*10^(-6);
epsl0 = 8.854*10^(-12);
mu0 = 4*pi*10^(-7);
c = 1/sqrt(epsl0*mu0);
f0 = c/lambda;
tau0 = 1/f0;
tc = 5*tau0/2;
dt = tau0/20;
dz = c*dt;
sigma = tc/(2*sqrt(2*log(2)));
m = sin(2*pi*f0*t);
g = exp(-((t-tc)^2/(2*sigma^2)));
hitung = m*g;


File 2 : fungsi gaussian envelope

function hitung = source3(t);
lambda = 0.5*10^(-6);
epsl0 = 8.854*10^(-12);
mu0   = 4*pi*10^(-7);
c     = 1/sqrt(epsl0*mu0);
f0    = c/lambda;
tau0  = 1/f0;
tc    = 5*tau0/2;
dt    = tau0/20;
dz    = c*dt;
sigma = tc/(2*sqrt(2*log(2)));
m     = sin(2*pi*f0*t);
hitung = exp(-((t-tc)^2/(2*sigma^2)));


File 3 : compiler

clear all
lambda = 0.5*10^(-6);
epsl0 = 8.854*10^(-12);
mu0   = 4*pi*10^(-7);
c     = 1/sqrt(epsl0*mu0);
f0    = c/lambda;
tau0  = 1/f0;
awal  = 0;
batas = 20*tau0;
n     = 0;
t     = awal;
dt    = tau0/20;

while t<=batas; 
   n = n+1; 
   
   X  = t; 
   Y1  = source(t);
   Y3  = source3(t); 
   Xaxis(n)  = t ;
   Y1axis(n) = Y1;
   Y3axis(n) = Y3;
   t=t+dt;
   
end

plot(Xaxis,Y1axis,'b-',Xaxis,Y3axis,'r-')
xlabel('t(s)')
ylabel('Ex(t)')
legend('Modulated Pulse','Gaussian Envelope')

Matlab untuk 1D FDTD terdiri dari dua file, antara lain :

File 1: Fungsi Pulsa Listrik


function hitung = source4(n);
lambda = 0.5*10^(-6);
epsl0 = 8.854*10^(-12);
mu0   = 4*pi*10^(-7);
c     = 1/sqrt(epsl0*mu0);
f0    = c/lambda;
tau0  = 1/f0;
tc    = 5*tau0/2;
dt    = tau0/20;
sigma = tc/(2*sqrt(2*log(2)));
m     = sin(2*pi*f0*n*dt);
g     = exp(-((n*dt-tc)^2/(2*sigma^2)));
hitung = m*g;

File 2 : FDTD


clear all
lambda = 0.5*10^(-6);
epsl0 = 8.854*10^(-12);
mu0   = 4*pi*10^(-7);
c     = 1/sqrt(epsl0*mu0);
f0    = c/lambda;
tau0  = 1/f0;
dt    = tau0/20;
dz    = lambda/20;
M     = 500;    %space
N     = 300;    %time
z     =0:dz:M*dz; 
zz    = 0:1:M;
yy    = 0:1:M-1;
Hy(1:M)  =0;
Ex(1:M+1)=0;
for n=1:N,
Ex(1)=source4(n);
Hy = Hy-(dt./mu0).*(diff(Ex)./dz);
Ex(2:M)=Ex(2:M)-(dt./epsl0).*(diff(Hy)./dz);
end
%plot(250,0,'.b',zz,Ex,'r-')
%plot(yy,Hy,'b-')
plot(250,0,'b.',zz,Ex,'r-','MarkerSize',15)
%plot(250,0,'b.',yy,Hy,'g-','MarkerSize',15)
xlabel('k (node step)')
ylabel('Ex')
%legend('t = 0 fs')

Hasil komputasi tampak dalam gambar di bawah ini.





















Tidak ada komentar :