微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微波和射频技术 > 电磁仿真讨论 > matlab coding for adi fdtd

matlab coding for adi fdtd

时间:03-22 整理:3721RD 点击:
can anyone plz upload matlab coding for adi fdtd-(2d&3d)

these may be helpful, this is 2d

----------------------
function FDTD2_2= fdtd2_2(er1,er2, Mr1,Mr2, o1,o2, Et1,Et2,Et3,Et4,Et5,Ht1,Ht2)
%FDTD2_2 Implements FDTD algorithm for a domain of for Hy(k)=0 at the
%right boundary-Part2-Question2
%Draws the graphs of Ex at times of Et1,Et2,Et3,Et4,Et5 and Hy at times of
%Ht1,Ht2 where time is an integer
%If you do not want a graph at a specific time,just assign zero for that
%time(Et5 has to be assigned and it should be the largest time)
%er1:Dielectric constant of first medium
%er2:Dielectric constant of second medium
%Mr1:Relative permittivity of first medium
%Mr2:Relative permittivity of second medium
%o1:Conductivity of first medium
%o2:Conductivity of second medium

%Initializations
e1=er1*10^-9/36/pi;
e2=er2*10^-9/36/pi;
M1=Mr1*4*pi*10^-7;
M2=Mr2*4*pi*10^-7;
v1=1/(sqrt(M1*e1));
v2=1/(sqrt(M2*e2));
K=500;
K_D=250;
z=(0:K);
Ex=zeros(1,K+1);
Hy=zeros(1,K+1);
dz=0.015;
dt=2.5*10^-11;
T=1*10^-9;
N=2500;
h1=figure;
h2=figure;

%Computations
for i=1:Et5,

Ex1=Ex(1);
Ex2=Ex(2);
ExK=Ex(K);
ExK_plus1=Ex(K+1);
for j=1:K,
if j<=K_D
Hy(j)=Hy(j)-(dt/M1/dz)*(Ex(j+1)-Ex(j));
elseif j==K
Hy(j)=0;
else
Hy(j)=Hy(j)-(dt/M2/dz)*(Ex(j+1)-Ex(j));
end

end
for j=1:K+1,

if ((i-1)*dt)<=(6*T)
Ex(1)=exp(-(((i-1)*dt-3*T)^2)/(T^2));
else
Ex(1)=0;

end
if j~=1&j<=K_D
Ex(j)=(1-dt*o1/2/e1)/(1+dt*o1/2/e1)*Ex(j)-(dt/dz/e1)/(1+dt*o1/2/e1)*(Hy(j)-Hy(j-1));
elseif j==K_D+1
Ex(j)=(1-dt*o1/2/((e1+e2)/2))/(1+dt*o1/2/((e1+e2)/2))*Ex(j)-(dt/dz/((e1+e2)/2))/(1+dt*o1/2/((e1+e2)/2))*(Hy(j)-Hy(j-1));
elseif j>K_D+1&j<=K
Ex(j)=(1-dt*o2/2/e2)/(1+dt*o2/2/e2)*Ex(j)-(dt/dz/e2)/(1+dt*o2/2/e2)*(Hy(j)-Hy(j-1));
end
end

%Draws the graphs
if i==Et1|i==Et2|i==Et3|i==Et4
figure(h1);
end
if i==Et1
plot(z,Ex,'k');
hold on;
end
if i==Et2
plot(z,Ex,'b');
hold on;
end
if i==Et3
plot(z,Ex,'g');
hold on;
end
if i==Et4
plot(z,Ex,'r');
hold on;
end
if i==Ht1|i==Ht2
figure(h2);
end
if i==Ht1
plot(z,Hy,'c');
hold on;
end
if i==Ht2
plot(z,Hy,'m');
xlabel('z(0.015m)');
ylabel('Hy(A/m)');
title('FDTD2_2 Implements FDTD algorithm for a domain of for Hy(k)=0 at the right boundary-Part2-Question2');
legend('Hy at t1','Hy at t2');
grid;
hold on;
end
end
figure(h1);
plot(z,Ex,'y');
xlabel('z(0.015m)');
ylabel('Ex(V/m)');
title('FDTD2_2 Implements FDTD algorithm for a domain of for Hy(k)=0 at the right boundary-Part2-Question2');
legend('Ex at t1','Ex at t2','Ex at t3','Ex at t4','Ex at t5');
grid;
return

this is matlab coding for fdtd in 1d. it is not adi fdtd .
can any one please upload matlab coding for adi fdtd. i am finding difficult in implementation. it takes longer time for the simulation. i also find so much difficult in implementing pml condition.
atleast can anyone please guide me.

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top