1D FDTD plane wave propagation simulation
I’m currently trying to simulate a simple case of wave propagation in free space before adding in more complexities, and already I’m stumped. Most examples I see online set the Courant stability condition to 1, i.e. the wave travels 1 spatial step in 1 time step. However, I set mine to 2 with the intention of increasing it further should I require more resolution.
Problem: My source is a unity amplitude sine wave (in exponential form), and when I plot it the amplitude is around 2 with increasing ringing with increasing distance.
I’m using these slides as my reference (https://empossible.net/wp-content/uploads/2020/01/Lecture-Formulation-of-1D-FDTD.pdf). The relevant slides are on p.12 and 20.
c0=299792458; %speed of light
u0 = 1.256637e-6;
e0 = 8.85418782e-12;
n1 = 1.; er1=n1^2; %refractive index and relative permittivity
fmax = 1e6; %frequency
lambda_min = c0/(fmax*n2); %minimum wavelength
z_step = lambda_min/(100); %step size in space
t_step = z_step/(2*c0); %Courant stability condition
t_total = t_step*4000; %total runtime
T = t_total/t_step; %total number of timesteps
Z = 400; %total number of spatial steps
Zarray = linspace(1,Z,Z);
Hx = zeros(Z,1); Ey = zeros(Z,1);
C_Ey = ones(Z,1).*c0*t_step/z_step/er1;
C_Hx = ones(Z,1).*c0*t_step/z_step;
H1=0;H2=0;E1=0;E2=0;
for t_count = 1:T
disp(t_count)
H2=H1; H1=Hx(1);
for z_count = 1:Z-1
Hx(z_count) = Hx(z_count) + C_Hx(z_count)*(Ey(z_count+1)-Ey(z_count));
end
Hx(Z) = Hx(Z) + C_Hx(Z)*(E1-Ey(Z));
E2=E1; E1=Ey(Z);
Ey(1) = Ey(1) + C_Ey(1)*(Hx(1)-H1);
for z_count = 2:Z
Ey(z_count) = Ey(z_count) + C_Ey(z_count)*(Hx(z_count)-Hx(z_count-1));
end
Ey(50) = Ey(50)+exp(1i*2*pi*fmax*t_count*t_step); %soft source
plot(Zarray,real(Ey))
drawnow
endI’m currently trying to simulate a simple case of wave propagation in free space before adding in more complexities, and already I’m stumped. Most examples I see online set the Courant stability condition to 1, i.e. the wave travels 1 spatial step in 1 time step. However, I set mine to 2 with the intention of increasing it further should I require more resolution.
Problem: My source is a unity amplitude sine wave (in exponential form), and when I plot it the amplitude is around 2 with increasing ringing with increasing distance.
I’m using these slides as my reference (https://empossible.net/wp-content/uploads/2020/01/Lecture-Formulation-of-1D-FDTD.pdf). The relevant slides are on p.12 and 20.
c0=299792458; %speed of light
u0 = 1.256637e-6;
e0 = 8.85418782e-12;
n1 = 1.; er1=n1^2; %refractive index and relative permittivity
fmax = 1e6; %frequency
lambda_min = c0/(fmax*n2); %minimum wavelength
z_step = lambda_min/(100); %step size in space
t_step = z_step/(2*c0); %Courant stability condition
t_total = t_step*4000; %total runtime
T = t_total/t_step; %total number of timesteps
Z = 400; %total number of spatial steps
Zarray = linspace(1,Z,Z);
Hx = zeros(Z,1); Ey = zeros(Z,1);
C_Ey = ones(Z,1).*c0*t_step/z_step/er1;
C_Hx = ones(Z,1).*c0*t_step/z_step;
H1=0;H2=0;E1=0;E2=0;
for t_count = 1:T
disp(t_count)
H2=H1; H1=Hx(1);
for z_count = 1:Z-1
Hx(z_count) = Hx(z_count) + C_Hx(z_count)*(Ey(z_count+1)-Ey(z_count));
end
Hx(Z) = Hx(Z) + C_Hx(Z)*(E1-Ey(Z));
E2=E1; E1=Ey(Z);
Ey(1) = Ey(1) + C_Ey(1)*(Hx(1)-H1);
for z_count = 2:Z
Ey(z_count) = Ey(z_count) + C_Ey(z_count)*(Hx(z_count)-Hx(z_count-1));
end
Ey(50) = Ey(50)+exp(1i*2*pi*fmax*t_count*t_step); %soft source
plot(Zarray,real(Ey))
drawnow
end I’m currently trying to simulate a simple case of wave propagation in free space before adding in more complexities, and already I’m stumped. Most examples I see online set the Courant stability condition to 1, i.e. the wave travels 1 spatial step in 1 time step. However, I set mine to 2 with the intention of increasing it further should I require more resolution.
Problem: My source is a unity amplitude sine wave (in exponential form), and when I plot it the amplitude is around 2 with increasing ringing with increasing distance.
I’m using these slides as my reference (https://empossible.net/wp-content/uploads/2020/01/Lecture-Formulation-of-1D-FDTD.pdf). The relevant slides are on p.12 and 20.
c0=299792458; %speed of light
u0 = 1.256637e-6;
e0 = 8.85418782e-12;
n1 = 1.; er1=n1^2; %refractive index and relative permittivity
fmax = 1e6; %frequency
lambda_min = c0/(fmax*n2); %minimum wavelength
z_step = lambda_min/(100); %step size in space
t_step = z_step/(2*c0); %Courant stability condition
t_total = t_step*4000; %total runtime
T = t_total/t_step; %total number of timesteps
Z = 400; %total number of spatial steps
Zarray = linspace(1,Z,Z);
Hx = zeros(Z,1); Ey = zeros(Z,1);
C_Ey = ones(Z,1).*c0*t_step/z_step/er1;
C_Hx = ones(Z,1).*c0*t_step/z_step;
H1=0;H2=0;E1=0;E2=0;
for t_count = 1:T
disp(t_count)
H2=H1; H1=Hx(1);
for z_count = 1:Z-1
Hx(z_count) = Hx(z_count) + C_Hx(z_count)*(Ey(z_count+1)-Ey(z_count));
end
Hx(Z) = Hx(Z) + C_Hx(Z)*(E1-Ey(Z));
E2=E1; E1=Ey(Z);
Ey(1) = Ey(1) + C_Ey(1)*(Hx(1)-H1);
for z_count = 2:Z
Ey(z_count) = Ey(z_count) + C_Ey(z_count)*(Hx(z_count)-Hx(z_count-1));
end
Ey(50) = Ey(50)+exp(1i*2*pi*fmax*t_count*t_step); %soft source
plot(Zarray,real(Ey))
drawnow
end fdtd, simulation MATLAB Answers — New Questions