0% found this document useful (0 votes)
93 views

SOLUTIONS To Homework Assignment #2

This document contains solutions to homework problems involving 1D FDTD electromagnetic simulations. Problem 1 numerically simulates a current source between two materials (free space and copper), plotting the electric field, Poynting flux, and wave impedance. It also calculates reflection/transmission coefficients and attenuation/phase constants using the chirp z-transform. Problems 2 and 3 repeat this with sea water and sand, respectively. Problem 4 uses a total-field/scattered-field formulation with a plane wave source.

Uploaded by

rawoo5
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views

SOLUTIONS To Homework Assignment #2

This document contains solutions to homework problems involving 1D FDTD electromagnetic simulations. Problem 1 numerically simulates a current source between two materials (free space and copper), plotting the electric field, Poynting flux, and wave impedance. It also calculates reflection/transmission coefficients and attenuation/phase constants using the chirp z-transform. Problems 2 and 3 repeat this with sea water and sand, respectively. Problem 4 uses a total-field/scattered-field formulation with a plane wave source.

Uploaded by

rawoo5
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

EEL 6487 - Electromagnetic Field Theory and Applications II

Moore
Spring 2014

Handout #11
25 February 2014

SOLUTIONS to Homework Assignment #2

1. 1-D FDTD. Numerically simulate a J~ current source between two perfect electric conductors
spaced 4 meters apart. The perfect electric conductors are located at x = 0 and at x = 4 meters.
Use the 1-D equivalent of the FDTD equations given by Taflove and Hagness Equations 3.29
3.30, choose x = 0.001 meters and S = 1.0, and assume the following J~ current source:

2.5 sin(4 109t) 0 t 2 109 sec
Jz (x = 2.5 m,t) =
(1)
0 otherwise
Region 1 (0 x < 3 m) is free-space (1 = 0 , 1 = 0 , 1 = 0), and Region 2 (3 x 4 m) is
filled with copper (2 = 0 , 2 = 0 , 2 = 5.8 107 S/m).
a) Plot the z-component of the electric field, the x-component of the (instantaneous) Poynting
flux, and the wave impedance when the first wave front is approximately at x = 0.5 meters.
b) Use the chirp z-transform (czt) to numerically calculate the reflection coefficient and the
transmission coefficient T .
c) Use the chirp z-transform (czt) to numerically calculate the attenuation rate and the phase
constant in each medium.
2. 1-D FDTD. Repeat Problem 1 with Region 2 filled with sea water (2 = 810 , 2 = 0 ,
2 = 4.0 S/m).
3. 1-D FDTD. Repeat Problem 1 with Region 2 filled with sand (2 = 100 , 2 = 0 , 2 =
0.01 S/m).
4. 1-D TF/SF. Repeat Problem 1 using the total-field/scattered-field formulation to introduce the
source. Let the total-field section of the grid be defined as 2.95 x 4 and the scattered field
section of the grid be defined as 0 x 2.95. Define the source at the TF/SF boundary to be
a linearly-polarized (in the z-direction), 2-GHz plane wave.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EEL 6486
% Spring 2014
% Homework #2, Problem 1
% Moore
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we implement a 1-D version of the FDTD equations, as
% discretized by Tavlove and Hagness [2000]. The program automatically
% displays plots of the numerical solution when the wave front is about
% 0.5 meters from the left-most boundary.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We start by supplying our constants
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps0 = 8.854e-12;
mu0 = 4*pi*1e-7;
c = 1/sqrt(mu0*eps0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We then provide our S parameter, calculate our range for x, and use them
% to calculate delta_t.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S = 1.0;
f0 = 2e9;%Hz
lambda0 = c/f0;
min_x = 0;%meters
max_x = 4;%meters
delta_x = 1e-3;%meters
x = (min_x:delta_x:max_x)';
N_lambda = lambda0/delta_x;
delta_t = delta_x*S/c;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We provide the permittivity, permeability, and conductivity as a function
% of space.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps = zeros(size(x));
mu = zeros(size(x));
sigma = zeros(size(x));
s = find((x >= 0) & (x < 3));
eps(s) = eps0;
mu(s) = mu0;
sigma(s) = 0;
s = find((x >= 3) & (x <= 4));
eps(s) = eps0;
mu(s) = mu0;
sigma(s) = 5.8e7;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We calculate the "C" and "D" parameters, as given by Taflove and Hagness
% [2000]. We provide a half-spatial-step version as well for simlicity.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ca = (1-sigma.*delta_t./2./eps)./(1+sigma.*delta_t./2./eps);
Cb = (delta_t./eps./delta_x)./(1+sigma.*delta_t./2./eps);
Da = ones(size(Ca));
Db = delta_t./mu./delta_x;
eps_half = eps(1:end-1);
mu_half = mu(1:end-1);

sigma_half = sigma(1:end-1);
Ca_half
Cb_half
Da_half
Db_half

=
=
=
=

(1-sigma_half.*delta_t./2./eps_half)./(1+sigma_half.*delta_t./2./eps_half);
(delta_t./eps_half./delta_x)./(1+sigma_half.*delta_t./2./eps_half);
ones(size(Ca_half));
delta_t./mu_half./delta_x;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We then set our initial conditions (E=H=J=0 everywhere). Based on the
% Yee grid, some vectors are longer than others. We keep 1 past value of
% all vectors, except for J.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hx = zeros(length(x),2);
Ey = zeros(length(x),2);
Ez = zeros(length(x),2);
Jy = zeros(length(x),1);
Jz = zeros(length(x),1);
Hy
Hz
Ex
Jx

=
=
=
=

zeros(length(x)-1,2);
zeros(length(x)-1,2);
zeros(length(x)-1,2);
zeros(length(x)-1,1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we calculate the index of the source location.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[val, source_location] = min(abs(x - 2.5));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% In order to calculate the reflection coefficient, transmission
% coefficient, attenuation rate, and phase constant in each medium, we save
% the values at certain locations for all time. Here we calculate the
% indices of those locations. These values change based on the parameters
% of medium 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[val, save_location1] = min(abs(x - 2.60));
[val, save_location2] = min(abs(x - 2.65));
[val, save_location3] = min(abs(x - 3.01));
[val, save_location4] = min(abs(x - 3.02));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We identify the time steps at which we would like to make plots.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
min_t = 0;
max_t = 2.0*sqrt(mu(1)*eps(1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% And finally we run the FDTD loop.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t = min_t;
iteration = 0;
range = [-0.5 0.5];
output_save_Ez = zeros(round(max_t/delta_t)+1,4);
while (t <= max_t)
iteration = iteration + 1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The crux of the FDTD routine are these next lines, followed by
% perfect electric conductor boundary conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hx(:,2) = 0;
Hy(:,2) = Da_half.*Hy(:,1) + Db_half.*(Ez(2:end,1)-Ez(1:end-1,1));
Hz(:,2) = Da_half.*Hz(:,1) + Db_half.*(Ey(1:end-1,1)-Ey(2:end,1));
if (t <= 2e-9)
Jz(source_location,1) = 2.5.*sin(2*pi*f0.*t);
else
Jz(source_location,1) = 0;

end
Ex(:,2) = Ca_half.*Ex(:,1) - Cb_half.*Jx(:,1).*delta_x;
Ey(2:end-1,2) = Ca(2:end-1).*Ey(2:end-1,1) + Cb(2:end-1).*(Hz(1:end-1,2)-Hz(2:end,2) Jy(2:end-1,1).*delta_x);
Ey(1,2) = 0;
Ey(end,2) = 0;
Ez(2:end-1,2) = Ca(2:end-1).*Ez(2:end-1,1) + Cb(2:end-1).*(Hy(2:end,2)-Hy(1:end-1,2) Jz(2:end-1,1).*delta_x);
Ez(1,2) = 0;
Ez(end,2) = 0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate S at half points in space and whole points in time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TAvg_Ex = (Ex(:,1)+Ex(:,2))/2;
TAvg_Ey = (Ey(:,1)+Ey(:,2))/2;
TAvg_Ez = (Ez(:,1)+Ez(:,2))/2;
STAvg_Ey = (TAvg_Ey(1:end-1)+TAvg_Ey(2:end))/2;
STAvg_Ez = (TAvg_Ez(1:end-1)+TAvg_Ez(2:end))/2;
SAvg_Hx = 0;
Sx = STAvg_Ey.*Hz(:,2) - STAvg_Ez.*Hy(:,2);
Sy = STAvg_Ez.*SAvg_Hx - TAvg_Ex.*Hz(:,2);
Sz = TAvg_Ex.*Hy(:,2) - STAvg_Ey.*SAvg_Hx;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate wave impedance at half points in space and whole points in
% time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eta = -STAvg_Ez./Hy(:,2);
s = find(Sx < 0);
eta(s) = -eta(s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure-making code below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(1);
plot(x, Ez(:,2));
ylim(range);
xlim([min_x max_x]);
grid on;
title(['EEL6487 HW 2, Problem 1: Time: ' num2str(round(t*1e12)) ' picoseconds']);
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
if (iteration == round(max_t/delta_t)),
figure(2);
subplot(3,1,1);
plot(x, Ez(:,2));
ylim(range);
xlim([min_x max_x]);
grid on;
title(['EEL6487 HW 2, Problem 1: Time: ' num2str(round(t*1e12)) ' picoseconds']);
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('E_z (V/m)');
range = [-6 6]*1e-4;
subplot(3,1,2);
plot(x(1:end-1)+delta_x/2, Sx);
ylim(range);
xlim([min_x max_x]);
grid on;
h1 = line([3 3],range);

set(h1,'color','r','LineWidth',2);
ylabel('S_x (W/m^2)');
range = [0 600];
subplot(3,1,3);
plot(x(1:end-1)+delta_x/2, eta);
ylim(range);
xlim([min_x max_x]);
grid on;
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('\eta_w (\Omega)');
xlabel('x (meters)');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Update the arrays/variables for the next iteration.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ex(:,1) = Ex(:,2);
Ex(:,2) = 0;
Ey(:,1) = Ey(:,2);
Ey(:,2) = 0;
Ez(:,1) = Ez(:,2);
Ez(:,2) = 0;
Hx(:,1) = Hx(:,2);
Hx(:,2) = 0;
Hy(:,1) = Hy(:,2);
Hy(:,2) = 0;
Hz(:,1) = Hz(:,2);
Hz(:,2) = 0;
t = t + delta_t;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Save the electric field values at the locations calculated above.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
output_save_Ez(iteration,1) = Ez(save_location1,1);
output_save_Ez(iteration,2) = Ez(save_location2,1);
output_save_Ez(iteration,3) = Ez(save_location3,1);
output_save_Ez(iteration,4) = Ez(save_location4,1);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate ideal reflection and transmission coefficients as well as ideal
% attenuation rates and phase constants in both media.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps1 = eps(1);
mu1 = mu(1);
sigma1 = sigma(1);
eps2 = eps(end);
mu2 = mu(end);
sigma2 = sigma(end);
eta1 = sqrt(sqrt(-1)*2*pi*f0*mu1/(sigma1 +sqrt(-1)*2*pi*f0*eps1));
eta2 = sqrt(sqrt(-1)*2*pi*f0*mu2/(sigma2 +sqrt(-1)*2*pi*f0*eps2));
ideal_alpha1 = 2*pi*f0*sqrt(mu1*eps1)*sqrt(1/2*(sqrt(1+(sigma1/2/pi/f0/eps1)^2)-1))
ideal_alpha2 = 2*pi*f0*sqrt(mu2*eps2)*sqrt(1/2*(sqrt(1+(sigma2/2/pi/f0/eps2)^2)-1))
ideal_beta1 = 2*pi*f0*sqrt(mu1*eps1)*sqrt(1/2*(sqrt(1+(sigma1/2/pi/f0/eps1)^2)+1))
ideal_beta2 = 2*pi*f0*sqrt(mu2*eps2)*sqrt(1/2*(sqrt(1+(sigma2/2/pi/f0/eps2)^2)+1))
ideal_gamma = (eta2-eta1)/(eta2+eta1);
mag_ideal_gamma = abs(ideal_gamma)
angle_ideal_gamma = angle(ideal_gamma)*180/pi
ideal_T = 2*eta2/(eta2+eta1);
mag_ideal_T = abs(ideal_T)
angle_ideal_T = angle(ideal_T)*180/pi

vp1 = 2*pi*f0/ideal_beta1;
vp2 = 2*pi*f0/ideal_beta2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the reflection and transmission
% coefficients.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.1/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(0.9/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
incident_field = output_save_Ez(t1_index:t2_index,1);
reflected_field = output_save_Ez(t3_index:t4_index,1);
IFZ = czt(incident_field,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
RFZ = czt(reflected_field,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
gamma = RFZ./IFZ;
T = gamma + 1;
mag_gamma = abs(gamma)
angle_gamma = angle(gamma)*180/pi
mag_T = abs(T)
angle_T = angle(T)*180/pi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the attenuation rate and phase
% constant in medium 1.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.1/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(0.15/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
incident_field1 = output_save_Ez(t1_index:t2_index,1);
incident_field2 = output_save_Ez(t3_index:t4_index,2);
IFZ1 = czt(incident_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
IFZ2 = czt(incident_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
alpha1 = -log(abs(IFZ2./IFZ1))/0.05
incident_field1 = output_save_Ez(t3_index:t2_index,1);
incident_field2 = output_save_Ez(t3_index:t2_index,2);
IFZ1 = czt(incident_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
IFZ2 = czt(incident_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
beta1 = angle(IFZ2./IFZ1)/0.05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the attenuation rate and phase
% constant in medium 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.51/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(0.52/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
transmitted_field1 = output_save_Ez(t1_index:t2_index,3);
transmitted_field2 = output_save_Ez(t3_index:t4_index,4);
TFZ1 = czt(transmitted_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
TFZ2 = czt(transmitted_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));

alpha2 = -log(abs(TFZ2./TFZ1))/0.01
transmitted_field1 = output_save_Ez(t3_index:t2_index,3);
transmitted_field2 = output_save_Ez(t3_index:t2_index,4);
TFZ1 = czt(transmitted_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
TFZ2 = czt(transmitted_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
beta2 = angle(TFZ2./TFZ1)/0.01
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Reflection Coefficient Results:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mag_ideal_gamma = 9.999380612777624e-01
% angle_ideal_gamma = 1.799964510627202e+02
% mag_gamma = 1.000001593964612e+00
% angle_gamma = 1.799967281651190e+02
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Transmission Coefficient Results:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mag_ideal_T = 8.759458098238177e-05
% angle_ideal_T = 4.499822553136009e+01
% mag_T = 5.712657875068623e-05
% angle_T = 9.159725730173959e+01
%
% The numerically calculated values are moderately close to the ideal
% values. They are off a bit, but the magnitudes of the fields used to
% make the calculations are very low.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alpha/beta Results, Medium 1:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ideal_alpha1 = 0
% ideal_beta1 = 4.191645585990301e+01
% alpha1 = 4.440892098500627e-15
% beta1 = 4.055126750393537e+01
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alpha/beta Results, Medium 2:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ideal_alpha2 = 6.767197672094791e+05
% ideal_beta2 = 6.767197685076451e+05
% alpha2 = 1.315773322402996e+04
% beta2 = 3.244964364896134e+01
%
% The numerically calculated values are very far from the ideal values.
% They are likely off because the skin depth (1/alpha) is significantly
% less than delta_x. Additionally, the velocity of the wave in medium 2
% is very low, skewing our results that depend on timing. It turns out
% that these are important considerations.

EEL 6487 Homework 2, Problem 1: Time: 6668 picoseconds

Ez (V/m)

0.5

0.0

0.5

= 0
= 0
= 0 S/m

= 0
= 0
= 5.8x107 S/m

w ()

Sx (W/m2)

400
200
0
200
400
600
500
400
300
200
100
0
0

0.5

1.0

1.5

2.0

x (meters)

2.5

3.0

3.5

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EEL 6486
% Spring 2014
% Homework #2, Problem 2
% Moore
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we implement a 1-D version of the FDTD equations, as
% discretized by Tavlove and Hagness [2000]. The program automatically
% displays plots of the numerical solution when the wave front is about
% 0.5 meters from the left-most boundary.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We start by supplying our constants
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps0 = 8.854e-12;
mu0 = 4*pi*1e-7;
c = 1/sqrt(mu0*eps0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We then provide our S parameter, calculate our range for x, and use them
% to calculate delta_t.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S = 1.0;
f0 = 2e9;%Hz
lambda0 = c/f0;
min_x = 0;%meters
max_x = 4;%meters
delta_x = 1e-3;%meters
x = (min_x:delta_x:max_x)';
N_lambda = lambda0/delta_x;
delta_t = delta_x*S/c;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We provide the permittivity, permeability, and conductivity as a function
% of space.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps = zeros(size(x));
mu = zeros(size(x));
sigma = zeros(size(x));
s = find((x >= 0) & (x < 3));
eps(s) = eps0;
mu(s) = mu0;
sigma(s) = 0;
s = find((x >= 3) & (x <= 4));
eps(s) = 81*eps0;
mu(s) = mu0;
sigma(s) = 4.0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We calculate the "C" and "D" parameters, as given by Taflove and Hagness
% [2000]. We provide a half-spatial-step version as well for simlicity.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ca = (1-sigma.*delta_t./2./eps)./(1+sigma.*delta_t./2./eps);
Cb = (delta_t./eps./delta_x)./(1+sigma.*delta_t./2./eps);
Da = ones(size(Ca));
Db = delta_t./mu./delta_x;
eps_half = eps(1:end-1);
mu_half = mu(1:end-1);

sigma_half = sigma(1:end-1);
Ca_half
Cb_half
Da_half
Db_half

=
=
=
=

(1-sigma_half.*delta_t./2./eps_half)./(1+sigma_half.*delta_t./2./eps_half);
(delta_t./eps_half./delta_x)./(1+sigma_half.*delta_t./2./eps_half);
ones(size(Ca_half));
delta_t./mu_half./delta_x;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We then set our initial conditions (E=H=J=0 everywhere). Based on the
% Yee grid, some vectors are longer than others. We keep 1 past value of
% all vectors, except for J.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hx = zeros(length(x),2);
Ey = zeros(length(x),2);
Ez = zeros(length(x),2);
Jy = zeros(length(x),1);
Jz = zeros(length(x),1);
Hy
Hz
Ex
Jx

=
=
=
=

zeros(length(x)-1,2);
zeros(length(x)-1,2);
zeros(length(x)-1,2);
zeros(length(x)-1,1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we calculate the index of the source location.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[val, source_location] = min(abs(x - 2.5));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% In order to calculate the reflection coefficient, transmission
% coefficient, attenuation rate, and phase constant in each medium, we save
% the values at certain locations for all time. Here we calculate the
% indices of those locations. These values change based on the parameters
% of medium 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[val, save_location1] = min(abs(x - 2.60));
[val, save_location2] = min(abs(x - 2.65));
[val, save_location3] = min(abs(x - 3.01));
[val, save_location4] = min(abs(x - 3.02));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We identify the time steps at which we would like to make plots.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
min_t = 0;
max_t = 2.0*sqrt(mu(1)*eps(1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% And finally we run the FDTD loop.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t = min_t;
iteration = 0;
range = [-0.5 0.5];
output_save_Ez = zeros(round(max_t/delta_t)+1,4);
while (t <= max_t)
iteration = iteration + 1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The crux of the FDTD routine are these next lines, followed by
% perfect electric conductor boundary conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hx(:,2) = 0;
Hy(:,2) = Da_half.*Hy(:,1) + Db_half.*(Ez(2:end,1)-Ez(1:end-1,1));
Hz(:,2) = Da_half.*Hz(:,1) + Db_half.*(Ey(1:end-1,1)-Ey(2:end,1));
if (t <= 2e-9)
Jz(source_location,1) = 2.5.*sin(2*pi*f0.*t);
else
Jz(source_location,1) = 0;

end
Ex(:,2) = Ca_half.*Ex(:,1) - Cb_half.*Jx(:,1).*delta_x;
Ey(2:end-1,2) = Ca(2:end-1).*Ey(2:end-1,1) + Cb(2:end-1).*(Hz(1:end-1,2)-Hz(2:end,2) Jy(2:end-1,1).*delta_x);
Ey(1,2) = 0;
Ey(end,2) = 0;
Ez(2:end-1,2) = Ca(2:end-1).*Ez(2:end-1,1) + Cb(2:end-1).*(Hy(2:end,2)-Hy(1:end-1,2) Jz(2:end-1,1).*delta_x);
Ez(1,2) = 0;
Ez(end,2) = 0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate S at half points in space and whole points in time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TAvg_Ex = (Ex(:,1)+Ex(:,2))/2;
TAvg_Ey = (Ey(:,1)+Ey(:,2))/2;
TAvg_Ez = (Ez(:,1)+Ez(:,2))/2;
STAvg_Ey = (TAvg_Ey(1:end-1)+TAvg_Ey(2:end))/2;
STAvg_Ez = (TAvg_Ez(1:end-1)+TAvg_Ez(2:end))/2;
SAvg_Hx = 0;
Sx = STAvg_Ey.*Hz(:,2) - STAvg_Ez.*Hy(:,2);
Sy = STAvg_Ez.*SAvg_Hx - TAvg_Ex.*Hz(:,2);
Sz = TAvg_Ex.*Hy(:,2) - STAvg_Ey.*SAvg_Hx;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate wave impedance at half points in space and whole points in
% time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eta = -STAvg_Ez./Hy(:,2);
s = find(Sx < 0);
eta(s) = -eta(s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure-making code below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(1);
plot(x, Ez(:,2));
ylim(range);
xlim([min_x max_x]);
grid on;
title(['EEL6487 HW 2, Problem 1: Time: ' num2str(round(t*1e12)) ' picoseconds']);
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
if (iteration == round(max_t/delta_t)),
figure(2);
subplot(3,1,1);
plot(x, Ez(:,2));
ylim(range);
xlim([min_x max_x]);
grid on;
title(['EEL6487 HW 2, Problem 1: Time: ' num2str(round(t*1e12)) ' picoseconds']);
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('E_z (V/m)');
range = [-6 6]*1e-4;
subplot(3,1,2);
plot(x(1:end-1)+delta_x/2, Sx);
ylim(range);
xlim([min_x max_x]);
grid on;
h1 = line([3 3],range);

set(h1,'color','r','LineWidth',2);
ylabel('S_x (W/m^2)');
range = [0 600];
subplot(3,1,3);
plot(x(1:end-1)+delta_x/2, eta);
ylim(range);
xlim([min_x max_x]);
grid on;
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('\eta_w (\Omega)');
xlabel('x (meters)');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Update the arrays/variables for the next iteration.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ex(:,1) = Ex(:,2);
Ex(:,2) = 0;
Ey(:,1) = Ey(:,2);
Ey(:,2) = 0;
Ez(:,1) = Ez(:,2);
Ez(:,2) = 0;
Hx(:,1) = Hx(:,2);
Hx(:,2) = 0;
Hy(:,1) = Hy(:,2);
Hy(:,2) = 0;
Hz(:,1) = Hz(:,2);
Hz(:,2) = 0;
t = t + delta_t;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Save the electric field values at the locations calculated above.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
output_save_Ez(iteration,1) = Ez(save_location1,1);
output_save_Ez(iteration,2) = Ez(save_location2,1);
output_save_Ez(iteration,3) = Ez(save_location3,1);
output_save_Ez(iteration,4) = Ez(save_location4,1);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate ideal reflection and transmission coefficients as well as ideal
% attenuation rates and phase constants in both media.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps1 = eps(1);
mu1 = mu(1);
sigma1 = sigma(1);
eps2 = eps(end);
mu2 = mu(end);
sigma2 = sigma(end);
eta1 = sqrt(sqrt(-1)*2*pi*f0*mu1/(sigma1 +sqrt(-1)*2*pi*f0*eps1));
eta2 = sqrt(sqrt(-1)*2*pi*f0*mu2/(sigma2 +sqrt(-1)*2*pi*f0*eps2));
ideal_alpha1 = 2*pi*f0*sqrt(mu1*eps1)*sqrt(1/2*(sqrt(1+(sigma1/2/pi/f0/eps1)^2)-1))
ideal_alpha2 = 2*pi*f0*sqrt(mu2*eps2)*sqrt(1/2*(sqrt(1+(sigma2/2/pi/f0/eps2)^2)-1))
ideal_beta1 = 2*pi*f0*sqrt(mu1*eps1)*sqrt(1/2*(sqrt(1+(sigma1/2/pi/f0/eps1)^2)+1))
ideal_beta2 = 2*pi*f0*sqrt(mu2*eps2)*sqrt(1/2*(sqrt(1+(sigma2/2/pi/f0/eps2)^2)+1))
ideal_gamma = (eta2-eta1)/(eta2+eta1);
mag_ideal_gamma = abs(ideal_gamma)
angle_ideal_gamma = angle(ideal_gamma)*180/pi
ideal_T = 2*eta2/(eta2+eta1);
mag_ideal_T = abs(ideal_T)
angle_ideal_T = angle(ideal_T)*180/pi

vp1 = 2*pi*f0/ideal_beta1;
vp2 = 2*pi*f0/ideal_beta2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the reflection and transmission
% coefficients.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.1/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(0.9/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
incident_field = output_save_Ez(t1_index:t2_index,1);
reflected_field = output_save_Ez(t3_index:t4_index,1);
IFZ = czt(incident_field,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
RFZ = czt(reflected_field,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
gamma = RFZ./IFZ;
T = gamma + 1;
mag_gamma = abs(gamma)
angle_gamma = angle(gamma)*180/pi
mag_T = abs(T)
angle_T = angle(T)*180/pi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the attenuation rate and phase
% constant in medium 1.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.1/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(0.15/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
incident_field1 = output_save_Ez(t1_index:t2_index,1);
incident_field2 = output_save_Ez(t3_index:t4_index,2);
IFZ1 = czt(incident_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
IFZ2 = czt(incident_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
alpha1 = -log(abs(IFZ2./IFZ1))/0.05
incident_field1 = output_save_Ez(t3_index:t2_index,1);
incident_field2 = output_save_Ez(t3_index:t2_index,2);
IFZ1 = czt(incident_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
IFZ2 = czt(incident_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
beta1 = angle(IFZ2./IFZ1)/0.05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the attenuation rate and phase
% constant in medium 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round((0.5/vp1 + 0.01/vp2)/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round((0.5/vp1 + 0.02/vp2)/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
transmitted_field1 = output_save_Ez(t1_index:t2_index,3);
transmitted_field2 = output_save_Ez(t3_index:t4_index,4);
TFZ1 = czt(transmitted_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
TFZ2 = czt(transmitted_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));

alpha2 = -log(abs(TFZ2./TFZ1))/0.01
transmitted_field1 = output_save_Ez(t3_index:t2_index,3);
transmitted_field2 = output_save_Ez(t3_index:t2_index,4);
TFZ1 = czt(transmitted_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
TFZ2 = czt(transmitted_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
beta2 = angle(TFZ2./TFZ1)/0.01
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Reflection Coefficient Results:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mag_ideal_gamma = 8.118117194577373e-01
% angle_ideal_gamma = 1.774489411567733e+02
% mag_gamma = 8.176446708021385e-01
% angle_gamma = -1.798417037074187e+02
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Transmission Coefficient Results:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mag_ideal_T = 1.924159944908357e-01
% angle_ideal_T = 1.082373892090762e+01
% mag_T = 1.823724408414141e-01
% angle_T = -7.097194330325466e-01
%
% The numerically calculated values are reasonably close to the ideal
% values. They are off a little bit, but they are better than for copper.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alpha/beta Results, Medium 1:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ideal_alpha1 = 0
% ideal_beta1 = 4.191645585990301e+01
% alpha1 = 4.440892098500627e-15
% beta1 = 4.055126750393537e+01
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alpha/beta Results, Medium 2:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ideal_alpha2 = 8.181668323067048e+01
% ideal_beta2 = 3.860182646911139e+02
% alpha2 = 8.265871327917400e+01
% beta2 = 3.840622771769553e+02
%
% The numerically calculated values are very close to the ideal values.

EEL 6487 Homework 2, Problem 2: Time: 6668 picoseconds

Ez (V/m)

0.5

0.0

0.5

= 0
= 0
= 0 S/m

= 810
= 0
= 4.0 S/m

w ()

Sx (W/m2)

400
200
0
200
400
600
500
400
300
200
100
0
0

0.5

1.0

1.5

2.0

x (meters)

2.5

3.0

3.5

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EEL 6486
% Spring 2014
% Homework #2, Problem 3
% Moore
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we implement a 1-D version of the FDTD equations, as
% discretized by Tavlove and Hagness [2000]. The program automatically
% displays plots of the numerical solution when the wave front is about
% 0.5 meters from the left-most boundary.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We start by supplying our constants
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps0 = 8.854e-12;
mu0 = 4*pi*1e-7;
c = 1/sqrt(mu0*eps0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We then provide our S parameter, calculate our range for x, and use them
% to calculate delta_t.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S = 1.0;
f0 = 2e9;%Hz
lambda0 = c/f0;
min_x = 0;%meters
max_x = 4;%meters
delta_x = 1e-3;%meters
x = (min_x:delta_x:max_x)';
N_lambda = lambda0/delta_x;
delta_t = delta_x*S/c;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We provide the permittivity, permeability, and conductivity as a function
% of space.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps = zeros(size(x));
mu = zeros(size(x));
sigma = zeros(size(x));
s = find((x >= 0) & (x < 3));
eps(s) = eps0;
mu(s) = mu0;
sigma(s) = 0;
s = find((x >= 3) & (x <= 4));
eps(s) = 10*eps0;
mu(s) = mu0;
sigma(s) = 0.01;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We calculate the "C" and "D" parameters, as given by Taflove and Hagness
% [2000]. We provide a half-spatial-step version as well for simlicity.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ca = (1-sigma.*delta_t./2./eps)./(1+sigma.*delta_t./2./eps);
Cb = (delta_t./eps./delta_x)./(1+sigma.*delta_t./2./eps);
Da = ones(size(Ca));
Db = delta_t./mu./delta_x;
eps_half = eps(1:end-1);
mu_half = mu(1:end-1);

sigma_half = sigma(1:end-1);
Ca_half
Cb_half
Da_half
Db_half

=
=
=
=

(1-sigma_half.*delta_t./2./eps_half)./(1+sigma_half.*delta_t./2./eps_half);
(delta_t./eps_half./delta_x)./(1+sigma_half.*delta_t./2./eps_half);
ones(size(Ca_half));
delta_t./mu_half./delta_x;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We then set our initial conditions (E=H=J=0 everywhere). Based on the
% Yee grid, some vectors are longer than others. We keep 1 past value of
% all vectors, except for J.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hx = zeros(length(x),2);
Ey = zeros(length(x),2);
Ez = zeros(length(x),2);
Jy = zeros(length(x),1);
Jz = zeros(length(x),1);
Hy
Hz
Ex
Jx

=
=
=
=

zeros(length(x)-1,2);
zeros(length(x)-1,2);
zeros(length(x)-1,2);
zeros(length(x)-1,1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we calculate the index of the source location.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[val, source_location] = min(abs(x - 2.5));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% In order to calculate the reflection coefficient, transmission
% coefficient, attenuation rate, and phase constant in each medium, we save
% the values at certain locations for all time. Here we calculate the
% indices of those locations. These values change based on the parameters
% of medium 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[val, save_location1] = min(abs(x - 2.60));
[val, save_location2] = min(abs(x - 2.65));
[val, save_location3] = min(abs(x - 3.01));
[val, save_location4] = min(abs(x - 3.02));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We identify the time steps at which we would like to make plots.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
min_t = 0;
max_t = 2.0*sqrt(mu(1)*eps(1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% And finally we run the FDTD loop.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t = min_t;
iteration = 0;
range = [-0.5 0.5];
output_save_Ez = zeros(round(max_t/delta_t)+1,4);
while (t <= max_t)
iteration = iteration + 1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The crux of the FDTD routine are these next lines, followed by
% perfect electric conductor boundary conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hx(:,2) = 0;
Hy(:,2) = Da_half.*Hy(:,1) + Db_half.*(Ez(2:end,1)-Ez(1:end-1,1));
Hz(:,2) = Da_half.*Hz(:,1) + Db_half.*(Ey(1:end-1,1)-Ey(2:end,1));
if (t <= 2e-9)
Jz(source_location,1) = 2.5.*sin(2*pi*f0.*t);
else
Jz(source_location,1) = 0;

end
Ex(:,2) = Ca_half.*Ex(:,1) - Cb_half.*Jx(:,1).*delta_x;
Ey(2:end-1,2) = Ca(2:end-1).*Ey(2:end-1,1) + Cb(2:end-1).*(Hz(1:end-1,2)-Hz(2:end,2) Jy(2:end-1,1).*delta_x);
Ey(1,2) = 0;
Ey(end,2) = 0;
Ez(2:end-1,2) = Ca(2:end-1).*Ez(2:end-1,1) + Cb(2:end-1).*(Hy(2:end,2)-Hy(1:end-1,2) Jz(2:end-1,1).*delta_x);
Ez(1,2) = 0;
Ez(end,2) = 0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate S at half points in space and whole points in time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TAvg_Ex = (Ex(:,1)+Ex(:,2))/2;
TAvg_Ey = (Ey(:,1)+Ey(:,2))/2;
TAvg_Ez = (Ez(:,1)+Ez(:,2))/2;
STAvg_Ey = (TAvg_Ey(1:end-1)+TAvg_Ey(2:end))/2;
STAvg_Ez = (TAvg_Ez(1:end-1)+TAvg_Ez(2:end))/2;
SAvg_Hx = 0;
Sx = STAvg_Ey.*Hz(:,2) - STAvg_Ez.*Hy(:,2);
Sy = STAvg_Ez.*SAvg_Hx - TAvg_Ex.*Hz(:,2);
Sz = TAvg_Ex.*Hy(:,2) - STAvg_Ey.*SAvg_Hx;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate wave impedance at half points in space and whole points in
% time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eta = -STAvg_Ez./Hy(:,2);
s = find(Sx < 0);
eta(s) = -eta(s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure-making code below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(2);
plot(x, Ez(:,2));
ylim(range);
xlim([min_x max_x]);
grid on;
title(['EEL6487 HW 2, Problem 1: Time: ' num2str(round(t*1e12)) ' picoseconds']);
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
if (iteration == round(max_t/delta_t)),
figure(3);
subplot(3,1,1);
plot(x, Ez(:,2));
ylim(range);
xlim([min_x max_x]);
grid on;
title(['EEL6487 HW 2, Problem 1: Time: ' num2str(round(t*1e12)) ' picoseconds']);
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('E_z (V/m)');
range = [-6 6]*1e-4;
subplot(3,1,2);
plot(x(1:end-1)+delta_x/2, Sx);
ylim(range);
xlim([min_x max_x]);
grid on;
h1 = line([3 3],range);

set(h1,'color','r','LineWidth',2);
ylabel('S_x (W/m^2)');
range = [0 600];
subplot(3,1,3);
plot(x(1:end-1)+delta_x/2, eta);
ylim(range);
xlim([min_x max_x]);
grid on;
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('\eta_w (\Omega)');
xlabel('x (meters)');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Update the arrays/variables for the next iteration.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ex(:,1) = Ex(:,2);
Ex(:,2) = 0;
Ey(:,1) = Ey(:,2);
Ey(:,2) = 0;
Ez(:,1) = Ez(:,2);
Ez(:,2) = 0;
Hx(:,1) = Hx(:,2);
Hx(:,2) = 0;
Hy(:,1) = Hy(:,2);
Hy(:,2) = 0;
Hz(:,1) = Hz(:,2);
Hz(:,2) = 0;
t = t + delta_t;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Save the electric field values at the locations calculated above.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
output_save_Ez(iteration,1) = Ez(save_location1,1);
output_save_Ez(iteration,2) = Ez(save_location2,1);
output_save_Ez(iteration,3) = Ez(save_location3,1);
output_save_Ez(iteration,4) = Ez(save_location4,1);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate ideal reflection and transmission coefficients as well as ideal
% attenuation rates and phase constants in both media.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps1 = eps(1);
mu1 = mu(1);
sigma1 = sigma(1);
eps2 = eps(end);
mu2 = mu(end);
sigma2 = sigma(end);
eta1 = sqrt(sqrt(-1)*2*pi*f0*mu1/(sigma1 +sqrt(-1)*2*pi*f0*eps1));
eta2 = sqrt(sqrt(-1)*2*pi*f0*mu2/(sigma2 +sqrt(-1)*2*pi*f0*eps2));
ideal_alpha1 = 2*pi*f0*sqrt(mu1*eps1)*sqrt(1/2*(sqrt(1+(sigma1/2/pi/f0/eps1)^2)-1))
ideal_alpha2 = 2*pi*f0*sqrt(mu2*eps2)*sqrt(1/2*(sqrt(1+(sigma2/2/pi/f0/eps2)^2)-1))
ideal_beta1 = 2*pi*f0*sqrt(mu1*eps1)*sqrt(1/2*(sqrt(1+(sigma1/2/pi/f0/eps1)^2)+1))
ideal_beta2 = 2*pi*f0*sqrt(mu2*eps2)*sqrt(1/2*(sqrt(1+(sigma2/2/pi/f0/eps2)^2)+1))
ideal_gamma = (eta2-eta1)/(eta2+eta1);
mag_ideal_gamma = abs(ideal_gamma)
angle_ideal_gamma = angle(ideal_gamma)*180/pi
ideal_T = 2*eta2/(eta2+eta1);
mag_ideal_T = abs(ideal_T)
angle_ideal_T = angle(ideal_T)*180/pi

vp1 = 2*pi*f0/ideal_beta1;
vp2 = 2*pi*f0/ideal_beta2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the reflection and transmission
% coefficients.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.1/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(0.9/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
incident_field = output_save_Ez(t1_index:t2_index,1);
reflected_field = output_save_Ez(t3_index:t4_index,1);
IFZ = czt(incident_field,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
RFZ = czt(reflected_field,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
gamma = RFZ./IFZ;
T = gamma + 1;
mag_gamma = abs(gamma)
angle_gamma = angle(gamma)*180/pi
mag_T = abs(T)
angle_T = angle(T)*180/pi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the attenuation rate and phase
% constant in medium 1.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.1/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(0.15/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
incident_field1 = output_save_Ez(t1_index:t2_index,1);
incident_field2 = output_save_Ez(t3_index:t4_index,2);
IFZ1 = czt(incident_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
IFZ2 = czt(incident_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
alpha1 = -log(abs(IFZ2./IFZ1))/0.05
incident_field1 = output_save_Ez(t3_index:t2_index,1);
incident_field2 = output_save_Ez(t3_index:t2_index,2);
IFZ1 = czt(incident_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
IFZ2 = czt(incident_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
beta1 = angle(IFZ2./IFZ1)/0.05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the attenuation rate and phase
% constant in medium 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round((0.5/vp1 + 0.01/vp2)/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round((0.5/vp1 + 0.02/vp2)/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
transmitted_field1 = output_save_Ez(t1_index:t2_index,3);
transmitted_field2 = output_save_Ez(t3_index:t4_index,4);
TFZ1 = czt(transmitted_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
TFZ2 = czt(transmitted_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));

alpha2 = -log(abs(TFZ2./TFZ1))/0.01
transmitted_field1 = output_save_Ez(t3_index:t2_index,3);
transmitted_field2 = output_save_Ez(t3_index:t2_index,4);
TFZ1 = czt(transmitted_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
TFZ2 = czt(transmitted_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
beta2 = angle(TFZ2./TFZ1)/0.01
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Reflection Coefficient Results:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mag_ideal_gamma = 5.195057303848667e-01
% angle_ideal_gamma = 1.798190721495866e+02
% mag_gamma = 5.202522378426062e-01
% angle_gamma = 1.777712192340359e+02
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Transmission Coefficient Results:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mag_ideal_T = 4.804996601879765e-01
% angle_ideal_T = 1.956152922781980e-01
% mag_T = 4.805674242177409e-01
% angle_T = 2.412936146231353e+00
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alpha/beta Results, Medium 1:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ideal_alpha1 = 0
% ideal_beta1 = 4.191645585990301e+01
% alpha1 = 4.440892098500627e-15
% beta1 = 4.055126750393537e+01
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alpha/beta Results, Medium 2:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ideal_alpha2 = 5.956632303507368e-01
% ideal_beta2 = 1.325528103558576e+02
% alpha2 = 5.996571768437397e-01
% beta2 = 1.250187437968903e+02
%
% The numerically calculated values are very close to the ideal values.

EEL 6487 Homework 2, Problem 3: Time: 6668 picoseconds

Ez (V/m)

0.5

0.0

0.5

= 0
= 0
= 0 S/m

= 100
= 0
= 0.01 S/m

w ()

Sx (W/m2)

400
200
0
200
400
600
500
400
300
200
100
0
0

0.5

1.0

1.5

2.0

x (meters)

2.5

3.0

3.5

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EEL 6486
% Spring 2014
% Homework #2, Problem 4
% Moore
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we implement a 1-D version of the FDTD equations, as
% discretized by Tavlove and Hagness [2000]. The program automatically
% displays plots of the numerical solution when the wave front is about
% 0.5 meters from the left-most boundary. We introduce the wave at x = 2.5
% meters using the TF/SF formulation.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We start by supplying our constants
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps0 = 8.854e-12;
mu0 = 4*pi*1e-7;
c = 1/sqrt(mu0*eps0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We then provide our S parameter, calculate our range for x, and use them
% to calculate delta_t.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S = 1.0;
f0 = 2e9;%Hz
lambda0 = c/f0;
min_x = 0;%meters
max_x = 4;%meters
delta_x = 1e-3;%meters
x = (min_x:delta_x:max_x)';
N_lambda = lambda0/delta_x;
delta_t = delta_x*S/c;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We provide the permittivity, permeability, and conductivity as a function
% of space.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps = zeros(size(x));
mu = zeros(size(x));
sigma = zeros(size(x));
s = find((x >= 0) & (x < 3));
eps(s) = eps0;
mu(s) = mu0;
sigma(s) = 0;
s = find((x >= 3) & (x <= 4));
eps(s) = eps0;
mu(s) = mu0;
sigma(s) = 5.8e7;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We calculate the "C" and "D" parameters, as given by Taflove and Hagness
% [2000]. We provide a half-spatial-step version as well for simlicity.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ca = (1-sigma.*delta_t./2./eps)./(1+sigma.*delta_t./2./eps);
Cb = (delta_t./eps./delta_x)./(1+sigma.*delta_t./2./eps);
Da = ones(size(Ca));
Db = delta_t./mu./delta_x;
eps_half = eps(1:end-1);

mu_half = mu(1:end-1);
sigma_half = sigma(1:end-1);
Ca_half
Cb_half
Da_half
Db_half

=
=
=
=

(1-sigma_half.*delta_t./2./eps_half)./(1+sigma_half.*delta_t./2./eps_half);
(delta_t./eps_half./delta_x)./(1+sigma_half.*delta_t./2./eps_half);
ones(size(Ca_half));
delta_t./mu_half./delta_x;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We then set our initial conditions (E=H=J=0 everywhere). Based on the
% Yee grid, some vectors are longer than others. We keep 1 past value of
% all vectors, except for J.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hx = zeros(length(x),2);
Ey = zeros(length(x),2);
Ez = zeros(length(x),2);
Jy = zeros(length(x),1);
Jz = zeros(length(x),1);
Hy
Hz
Ex
Jx

=
=
=
=

zeros(length(x)-1,2);
zeros(length(x)-1,2);
zeros(length(x)-1,2);
zeros(length(x)-1,1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we calculate the index of the source location.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[val, tfsf_boundary] = min(abs(x - 2.500));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% In order to calculate the reflection coefficient, transmission
% coefficient, attenuation rate, and phase constant in each medium, we save
% the values at certain locations for all time. Here we calculate the
% indices of those locations. These values change based on the parameters
% of medium 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[val, save_location1] = min(abs(x - 2.60));
[val, save_location2] = min(abs(x - 2.40));
[val, save_location3] = min(abs(x - 2.65));
[val, save_location4] = min(abs(x - 3.01));
[val, save_location5] = min(abs(x - 3.02));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We identify the time steps at which we would like to make plots.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
min_t = 0;
max_t = 3.0*sqrt(mu(1)*eps(1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% And finally we run the FDTD loop.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t = min_t;
iteration = 0;
output_save_Ez = zeros(round(max_t/delta_t)+1,4);
eta1 = sqrt(sqrt(-1)*2*pi*f0*mu(1)/(sigma(1) +sqrt(-1)*2*pi*f0*eps(1)));
beta1 = 2*pi*f0*sqrt(mu(1)*eps(1))*sqrt(1/2*(sqrt(1+(sigma(1)/2/pi/f0/eps(1))^2)+1));
while (t <= max_t)
iteration = iteration + 1;
Ey_inc = 0;
Ez_inc = 0.5*sin(2*pi*f0*(t-delta_t/2));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The crux of the FDTD routine are these next lines, followed by
% perfect electric conductor boundary conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hx(:,2) = 0;
Hy(:,2) = Da_half.*Hy(:,1) + Db_half.*(Ez(2:end,1)-Ez(1:end-1,1));

Hy(tfsf_boundary-1,2) = Hy(tfsf_boundary-1,2) - Db_half(tfsf_boundary-1).*Ez_inc;


Hz(:,2) = Da_half.*Hz(:,1) + Db_half.*(Ey(1:end-1,1)-Ey(2:end,1));
Hz(tfsf_boundary-1,2) = Hz(tfsf_boundary-1,2) + Db_half(tfsf_boundary-1).*Ey_inc;
Hy_inc = -0.5/eta1*sin(2*pi*f0*t + beta1*delta_x/2);
Hz_inc = 0;
Ex(:,2) = Ca_half.*Ex(:,1) - Cb_half.*Jx(:,1).*delta_x;
Ey(2:end-1,2) = Ca(2:end-1).*Ey(2:end-1,1) + Cb(2:end-1).*(Hz(1:end-1,2)-Hz(2:end,2) Jy(2:end-1,1).*delta_x);
Ey(tfsf_boundary,2) = Ey(tfsf_boundary,2) + Cb(tfsf_boundary).*Hz_inc;
Ey(1,2) = 0;
Ey(end,2) = 0;
Ez(2:end-1,2) = Ca(2:end-1).*Ez(2:end-1,1) + Cb(2:end-1).*(Hy(2:end,2)-Hy(1:end-1,2) Jz(2:end-1,1).*delta_x);
Ez(tfsf_boundary,2) = Ez(tfsf_boundary,2) - Cb(tfsf_boundary).*Hy_inc;
Ez(1,2) = 0;
Ez(end,2) = 0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate S at half points in space and whole points in time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TAvg_Ex = (Ex(:,1)+Ex(:,2))/2;
TAvg_Ey = (Ey(:,1)+Ey(:,2))/2;
TAvg_Ez = (Ez(:,1)+Ez(:,2))/2;
STAvg_Ey = (TAvg_Ey(1:end-1)+TAvg_Ey(2:end))/2;
STAvg_Ez = (TAvg_Ez(1:end-1)+TAvg_Ez(2:end))/2;
SAvg_Hx = 0;
Sx = STAvg_Ey.*Hz(:,2) - STAvg_Ez.*Hy(:,2);
Sy = STAvg_Ez.*SAvg_Hx - TAvg_Ex.*Hz(:,2);
Sz = TAvg_Ex.*Hy(:,2) - STAvg_Ey.*SAvg_Hx;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate wave impedance at half points in space and whole points in
% time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eta = -STAvg_Ez./Hy(:,2);
s = find(Sx < 0);
eta(s) = -eta(s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure-making code below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
range = [-0.5 0.5];
figure(1);
plot(x, Ez(:,2));
ylim(range);
xlim([min_x max_x]);
grid on;
title(['EEL6487 HW 2, Problem 1: Time: ' num2str(round(t*1e12)) ' picoseconds']);
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
if (iteration == round(max_t/delta_t)),
figure(2);
subplot(3,1,1);
plot(x, Ez(:,2));
ylim(range);
xlim([min_x max_x]);
grid on;
title(['EEL6487 HW 2, Problem 1: Time: ' num2str(round(t*1e12)) ' picoseconds']);
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('E_z (V/m)');

range = [-6 6]*1e-4;


subplot(3,1,2);
plot(x(1:end-1)+delta_x/2, Sx);
ylim(range);
xlim([min_x max_x]);
grid on;
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('S_x (W/m^2)');
range = [0 600];
subplot(3,1,3);
plot(x(1:end-1)+delta_x/2, eta);
ylim(range);
xlim([min_x max_x]);
grid on;
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('\eta_w (\Omega)');
xlabel('x (meters)');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Update the arrays/variables for the next iteration.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ex(:,1) = Ex(:,2);
Ex(:,2) = 0;
Ey(:,1) = Ey(:,2);
Ey(:,2) = 0;
Ez(:,1) = Ez(:,2);
Ez(:,2) = 0;
Hx(:,1) = Hx(:,2);
Hx(:,2) = 0;
Hy(:,1) = Hy(:,2);
Hy(:,2) = 0;
Hz(:,1) = Hz(:,2);
Hz(:,2) = 0;
t = t + delta_t;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Save the electric field values at the locations calculated above.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
output_save_Ez(iteration,1) = Ez(save_location1,1);
output_save_Ez(iteration,2) = Ez(save_location2,1);
output_save_Ez(iteration,3) = Ez(save_location3,1);
output_save_Ez(iteration,4) = Ez(save_location4,1);
output_save_Ez(iteration,5) = Ez(save_location5,1);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate ideal reflection and transmission coefficients as well as ideal
% attenuation rates and phase constants in both media.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps1 = eps(1);
mu1 = mu(1);
sigma1 = sigma(1);
eps2 = eps(end);
mu2 = mu(end);
sigma2 = sigma(end);
eta1 = sqrt(sqrt(-1)*2*pi*f0*mu1/(sigma1 +sqrt(-1)*2*pi*f0*eps1));
eta2 = sqrt(sqrt(-1)*2*pi*f0*mu2/(sigma2 +sqrt(-1)*2*pi*f0*eps2));
ideal_alpha1 = 2*pi*f0*sqrt(mu1*eps1)*sqrt(1/2*(sqrt(1+(sigma1/2/pi/f0/eps1)^2)-1))
ideal_alpha2 = 2*pi*f0*sqrt(mu2*eps2)*sqrt(1/2*(sqrt(1+(sigma2/2/pi/f0/eps2)^2)-1))
ideal_beta1 = 2*pi*f0*sqrt(mu1*eps1)*sqrt(1/2*(sqrt(1+(sigma1/2/pi/f0/eps1)^2)+1))
ideal_beta2 = 2*pi*f0*sqrt(mu2*eps2)*sqrt(1/2*(sqrt(1+(sigma2/2/pi/f0/eps2)^2)+1))

ideal_gamma = (eta2-eta1)/(eta2+eta1);
mag_ideal_gamma = abs(ideal_gamma)
angle_ideal_gamma = angle(ideal_gamma)*180/pi
ideal_T = 2*eta2/(eta2+eta1);
mag_ideal_T = abs(ideal_T)
angle_ideal_T = angle(ideal_T)*180/pi
vp1 = 2*pi*f0/ideal_beta1;
vp2 = 2*pi*f0/ideal_beta2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the reflection and transmission
% coefficients.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.1/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(1.1/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
incident_field = output_save_Ez(t1_index:t2_index,1);
reflected_field = output_save_Ez(t3_index:t4_index,2);
IFZ = czt(incident_field,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
RFZ = czt(reflected_field,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
gamma = RFZ./IFZ;
T = gamma + 1;
mag_gamma = abs(gamma)
angle_gamma = angle(gamma)*180/pi
mag_T = abs(T)
angle_T = angle(T)*180/pi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the attenuation rate and phase
% constant in medium 1.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.1/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(0.15/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
incident_field1 = output_save_Ez(t1_index:t2_index,1);
incident_field2 = output_save_Ez(t3_index:t4_index,3);
IFZ1 = czt(incident_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
IFZ2 = czt(incident_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
alpha1 = -log(abs(IFZ2./IFZ1))/0.05
incident_field1 = output_save_Ez(t3_index:t2_index,1);
incident_field2 = output_save_Ez(t3_index:t2_index,3);
IFZ1 = czt(incident_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
IFZ2 = czt(incident_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
beta1 = angle(IFZ2./IFZ1)/0.05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the attenuation rate and phase
% constant in medium 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round((0.51/vp1)/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);

t3_index = round((0.52/vp1)/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
transmitted_field1 = output_save_Ez(t1_index:t2_index,4);
transmitted_field2 = output_save_Ez(t3_index:t4_index,5);
TFZ1 = czt(transmitted_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
TFZ2 = czt(transmitted_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
alpha2 = -log(abs(TFZ2./TFZ1))/0.01
transmitted_field1 = output_save_Ez(t3_index:t2_index,4);
transmitted_field2 = output_save_Ez(t3_index:t2_index,5);
TFZ1 = czt(transmitted_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
TFZ2 = czt(transmitted_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
beta2 = angle(TFZ2./TFZ1)/0.01
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Reflection Coefficient Results:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mag_ideal_gamma = 9.999380612777624e-01
% angle_ideal_gamma = 1.799964510627202e+02
% mag_gamma = 1.000001978810664e+00
% angle_gamma = 1.799959974761156e+02
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Transmission Coefficient Results:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mag_ideal_T = 8.759458098238177e-05
% angle_ideal_T = 4.499822553136009e+01
% mag_T = 6.988531001897814e-05
% angle_T = 9.162055224534703e+01
%
% The numerically calculated values are moderately close to the ideal
% values. They are off a bit, but the magnitudes of the fields used to
% make the calculations are very low.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alpha/beta Results, Medium 1:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ideal_alpha1 = 0
% ideal_beta1 = 4.191645585990301e+01
% alpha1 = 0
% beta1 = 4.055380717482323e+01
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alpha/beta Results, Medium 2:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ideal_alpha2 = 6.767197672094791e+05
% ideal_beta2 = 6.767197685076451e+05
% alpha2 = 1.315773322402996e+04
% beta2 = 3.244964364896143e+01
%
% The numerically calculated values are very far from the ideal values.
% They are likely off because the skin depth (1/alpha) is significantly
% less than delta_x. Additionally, the velocity of the wave in medium 2
% is very low, skewing our results that depend on timing. It turns out
% that these are important considerations.

EEL 6487 Homework 2, Problem 4a: Time: 10003 picoseconds

Ez (V/m)

0.5

0.0

0.5

= 0
= 0
= 0 S/m

= 0
= 0
= 5.8x107 S/m

w ()

Sx (W/m2)

400
200
0
200
400
600
500
400
300
200
100
0
0

0.5

1.0

1.5

2.0

x (meters)

2.5

3.0

3.5

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EEL 6486
% Spring 2014
% Homework #2, Problem 4
% Moore
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we implement a 1-D version of the FDTD equations, as
% discretized by Tavlove and Hagness [2000]. The program automatically
% displays plots of the numerical solution when the wave front is about
% 0.5 meters from the left-most boundary. We introduce the wave at x = 2.5
% meters using the TF/SF formulation.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We start by supplying our constants
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps0 = 8.854e-12;
mu0 = 4*pi*1e-7;
c = 1/sqrt(mu0*eps0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We then provide our S parameter, calculate our range for x, and use them
% to calculate delta_t.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S = 1.0;
f0 = 2e9;%Hz
lambda0 = c/f0;
min_x = 0;%meters
max_x = 4;%meters
delta_x = 1e-3;%meters
x = (min_x:delta_x:max_x)';
N_lambda = lambda0/delta_x;
delta_t = delta_x*S/c;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We provide the permittivity, permeability, and conductivity as a function
% of space.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps = zeros(size(x));
mu = zeros(size(x));
sigma = zeros(size(x));
s = find((x >= 0) & (x < 3));
eps(s) = eps0;
mu(s) = mu0;
sigma(s) = 0;
s = find((x >= 3) & (x <= 4));
eps(s) = 81*eps0;
mu(s) = mu0;
sigma(s) = 4.0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We calculate the "C" and "D" parameters, as given by Taflove and Hagness
% [2000]. We provide a half-spatial-step version as well for simlicity.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ca = (1-sigma.*delta_t./2./eps)./(1+sigma.*delta_t./2./eps);
Cb = (delta_t./eps./delta_x)./(1+sigma.*delta_t./2./eps);
Da = ones(size(Ca));
Db = delta_t./mu./delta_x;
eps_half = eps(1:end-1);

mu_half = mu(1:end-1);
sigma_half = sigma(1:end-1);
Ca_half
Cb_half
Da_half
Db_half

=
=
=
=

(1-sigma_half.*delta_t./2./eps_half)./(1+sigma_half.*delta_t./2./eps_half);
(delta_t./eps_half./delta_x)./(1+sigma_half.*delta_t./2./eps_half);
ones(size(Ca_half));
delta_t./mu_half./delta_x;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We then set our initial conditions (E=H=J=0 everywhere). Based on the
% Yee grid, some vectors are longer than others. We keep 1 past value of
% all vectors, except for J.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hx = zeros(length(x),2);
Ey = zeros(length(x),2);
Ez = zeros(length(x),2);
Jy = zeros(length(x),1);
Jz = zeros(length(x),1);
Hy
Hz
Ex
Jx

=
=
=
=

zeros(length(x)-1,2);
zeros(length(x)-1,2);
zeros(length(x)-1,2);
zeros(length(x)-1,1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we calculate the index of the source location.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[val, tfsf_boundary] = min(abs(x - 2.500));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% In order to calculate the reflection coefficient, transmission
% coefficient, attenuation rate, and phase constant in each medium, we save
% the values at certain locations for all time. Here we calculate the
% indices of those locations. These values change based on the parameters
% of medium 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[val, save_location1] = min(abs(x - 2.60));
[val, save_location2] = min(abs(x - 2.40));
[val, save_location3] = min(abs(x - 2.65));
[val, save_location4] = min(abs(x - 3.01));
[val, save_location5] = min(abs(x - 3.02));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We identify the time steps at which we would like to make plots.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
min_t = 0;
max_t = 3.0*sqrt(mu(1)*eps(1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% And finally we run the FDTD loop.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t = min_t;
iteration = 0;
output_save_Ez = zeros(round(max_t/delta_t)+1,4);
eta1 = sqrt(sqrt(-1)*2*pi*f0*mu(1)/(sigma(1) +sqrt(-1)*2*pi*f0*eps(1)));
beta1 = 2*pi*f0*sqrt(mu(1)*eps(1))*sqrt(1/2*(sqrt(1+(sigma(1)/2/pi/f0/eps(1))^2)+1));
while (t <= max_t)
iteration = iteration + 1;
Ey_inc = 0;
Ez_inc = 0.5*sin(2*pi*f0*(t-delta_t/2));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The crux of the FDTD routine are these next lines, followed by
% perfect electric conductor boundary conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hx(:,2) = 0;
Hy(:,2) = Da_half.*Hy(:,1) + Db_half.*(Ez(2:end,1)-Ez(1:end-1,1));

Hy(tfsf_boundary-1,2) = Hy(tfsf_boundary-1,2) - Db_half(tfsf_boundary-1).*Ez_inc;


Hz(:,2) = Da_half.*Hz(:,1) + Db_half.*(Ey(1:end-1,1)-Ey(2:end,1));
Hz(tfsf_boundary-1,2) = Hz(tfsf_boundary-1,2) + Db_half(tfsf_boundary-1).*Ey_inc;
Hy_inc = -0.5/eta1*sin(2*pi*f0*t + beta1*delta_x/2);
Hz_inc = 0;
Ex(:,2) = Ca_half.*Ex(:,1) - Cb_half.*Jx(:,1).*delta_x;
Ey(2:end-1,2) = Ca(2:end-1).*Ey(2:end-1,1) + Cb(2:end-1).*(Hz(1:end-1,2)-Hz(2:end,2) Jy(2:end-1,1).*delta_x);
Ey(tfsf_boundary,2) = Ey(tfsf_boundary,2) + Cb(tfsf_boundary).*Hz_inc;
Ey(1,2) = 0;
Ey(end,2) = 0;
Ez(2:end-1,2) = Ca(2:end-1).*Ez(2:end-1,1) + Cb(2:end-1).*(Hy(2:end,2)-Hy(1:end-1,2) Jz(2:end-1,1).*delta_x);
Ez(tfsf_boundary,2) = Ez(tfsf_boundary,2) - Cb(tfsf_boundary).*Hy_inc;
Ez(1,2) = 0;
Ez(end,2) = 0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate S at half points in space and whole points in time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TAvg_Ex = (Ex(:,1)+Ex(:,2))/2;
TAvg_Ey = (Ey(:,1)+Ey(:,2))/2;
TAvg_Ez = (Ez(:,1)+Ez(:,2))/2;
STAvg_Ey = (TAvg_Ey(1:end-1)+TAvg_Ey(2:end))/2;
STAvg_Ez = (TAvg_Ez(1:end-1)+TAvg_Ez(2:end))/2;
SAvg_Hx = 0;
Sx = STAvg_Ey.*Hz(:,2) - STAvg_Ez.*Hy(:,2);
Sy = STAvg_Ez.*SAvg_Hx - TAvg_Ex.*Hz(:,2);
Sz = TAvg_Ex.*Hy(:,2) - STAvg_Ey.*SAvg_Hx;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate wave impedance at half points in space and whole points in
% time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eta = -STAvg_Ez./Hy(:,2);
s = find(Sx < 0);
eta(s) = -eta(s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure-making code below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
range = [-0.5 0.5];
figure(1);
plot(x, Ez(:,2));
ylim(range);
xlim([min_x max_x]);
grid on;
title(['EEL6487 HW 2, Problem 1: Time: ' num2str(round(t*1e12)) ' picoseconds']);
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
if (iteration == round(max_t/delta_t)),
figure(2);
subplot(3,1,1);
plot(x, Ez(:,2));
ylim(range);
xlim([min_x max_x]);
grid on;
title(['EEL6487 HW 2, Problem 1: Time: ' num2str(round(t*1e12)) ' picoseconds']);
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('E_z (V/m)');

range = [-6 6]*1e-4;


subplot(3,1,2);
plot(x(1:end-1)+delta_x/2, Sx);
ylim(range);
xlim([min_x max_x]);
grid on;
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('S_x (W/m^2)');
range = [0 600];
subplot(3,1,3);
plot(x(1:end-1)+delta_x/2, eta);
ylim(range);
xlim([min_x max_x]);
grid on;
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('\eta_w (\Omega)');
xlabel('x (meters)');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Update the arrays/variables for the next iteration.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ex(:,1) = Ex(:,2);
Ex(:,2) = 0;
Ey(:,1) = Ey(:,2);
Ey(:,2) = 0;
Ez(:,1) = Ez(:,2);
Ez(:,2) = 0;
Hx(:,1) = Hx(:,2);
Hx(:,2) = 0;
Hy(:,1) = Hy(:,2);
Hy(:,2) = 0;
Hz(:,1) = Hz(:,2);
Hz(:,2) = 0;
t = t + delta_t;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Save the electric field values at the locations calculated above.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
output_save_Ez(iteration,1) = Ez(save_location1,1);
output_save_Ez(iteration,2) = Ez(save_location2,1);
output_save_Ez(iteration,3) = Ez(save_location3,1);
output_save_Ez(iteration,4) = Ez(save_location4,1);
output_save_Ez(iteration,5) = Ez(save_location5,1);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate ideal reflection and transmission coefficients as well as ideal
% attenuation rates and phase constants in both media.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps1 = eps(1);
mu1 = mu(1);
sigma1 = sigma(1);
eps2 = eps(end);
mu2 = mu(end);
sigma2 = sigma(end);
eta1 = sqrt(sqrt(-1)*2*pi*f0*mu1/(sigma1 +sqrt(-1)*2*pi*f0*eps1));
eta2 = sqrt(sqrt(-1)*2*pi*f0*mu2/(sigma2 +sqrt(-1)*2*pi*f0*eps2));
ideal_alpha1 = 2*pi*f0*sqrt(mu1*eps1)*sqrt(1/2*(sqrt(1+(sigma1/2/pi/f0/eps1)^2)-1))
ideal_alpha2 = 2*pi*f0*sqrt(mu2*eps2)*sqrt(1/2*(sqrt(1+(sigma2/2/pi/f0/eps2)^2)-1))
ideal_beta1 = 2*pi*f0*sqrt(mu1*eps1)*sqrt(1/2*(sqrt(1+(sigma1/2/pi/f0/eps1)^2)+1))
ideal_beta2 = 2*pi*f0*sqrt(mu2*eps2)*sqrt(1/2*(sqrt(1+(sigma2/2/pi/f0/eps2)^2)+1))

ideal_gamma = (eta2-eta1)/(eta2+eta1);
mag_ideal_gamma = abs(ideal_gamma)
angle_ideal_gamma = angle(ideal_gamma)*180/pi
ideal_T = 2*eta2/(eta2+eta1);
mag_ideal_T = abs(ideal_T)
angle_ideal_T = angle(ideal_T)*180/pi
vp1 = 2*pi*f0/ideal_beta1;
vp2 = 2*pi*f0/ideal_beta2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the reflection and transmission
% coefficients.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.1/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(1.1/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
incident_field = output_save_Ez(t1_index:t2_index,1);
reflected_field = output_save_Ez(t3_index:t4_index,2);
IFZ = czt(incident_field,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
RFZ = czt(reflected_field,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
gamma = RFZ./IFZ;
T = gamma + 1;
mag_gamma = abs(gamma)
angle_gamma = angle(gamma)*180/pi
mag_T = abs(T)
angle_T = angle(T)*180/pi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the attenuation rate and phase
% constant in medium 1.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.1/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(0.15/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
incident_field1 = output_save_Ez(t1_index:t2_index,1);
incident_field2 = output_save_Ez(t3_index:t4_index,3);
IFZ1 = czt(incident_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
IFZ2 = czt(incident_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
alpha1 = -log(abs(IFZ2./IFZ1))/0.05
incident_field1 = output_save_Ez(t3_index:t2_index,1);
incident_field2 = output_save_Ez(t3_index:t2_index,3);
IFZ1 = czt(incident_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
IFZ2 = czt(incident_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
beta1 = angle(IFZ2./IFZ1)/0.05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the attenuation rate and phase
% constant in medium 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round((0.51/vp1)/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);

t3_index = round((0.52/vp1)/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
transmitted_field1 = output_save_Ez(t1_index:t2_index,4);
transmitted_field2 = output_save_Ez(t3_index:t4_index,5);
TFZ1 = czt(transmitted_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
TFZ2 = czt(transmitted_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
alpha2 = -log(abs(TFZ2./TFZ1))/0.01
transmitted_field1 = output_save_Ez(t3_index:t2_index,4);
transmitted_field2 = output_save_Ez(t3_index:t2_index,5);
TFZ1 = czt(transmitted_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
TFZ2 = czt(transmitted_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
beta2 = (angle(TFZ2./TFZ1)+2*pi)/0.01
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Reflection Coefficient Results:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mag_ideal_gamma = 8.118117194577373e-01
% angle_ideal_gamma = 1.799964510627202e+02
% mag_gamma = 8.176454436981953e-01
% angle_gamma =-1.798439594203051e+02
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Transmission Coefficient Results:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mag_ideal_T = 1.924159944908357e-01
% angle_ideal_T = 1.082373892090762e+01
% mag_T = 1.823711838487847e-01
% angle_T = -6.996109752561255e-01
%
% The numerically calculated values are reasonably close to the ideal
% values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alpha/beta Results, Medium 1:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ideal_alpha1 = 0
% ideal_beta1 = 4.191645585990301e+01
% alpha1 = 0
% beta1 = 4.055380717482323e+01
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alpha/beta Results, Medium 2:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ideal_alpha2 = 8.181668323067048e+01
% ideal_beta2 = 3.860182646911139e+02
% alpha2 = 9.867771050153775e+01
% beta2 = 3.840818148265086e+02
%
% The numerically calculated values are reasonably close to the ideal
% values.

EEL 6487 Homework 2, Problem 4b: Time: 10003 picoseconds

Ez (V/m)

0.5

0.0

0.5

= 0
= 0
= 0 S/m

= 810
= 0
= 4.0 S/m

w ()

Sx (W/m2)

400
200
0
200
400
600
500
400
300
200
100
0
0

0.5

1.0

1.5

2.0

x (meters)

2.5

3.0

3.5

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EEL 6486
% Spring 2014
% Homework #2, Problem 4
% Moore
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we implement a 1-D version of the FDTD equations, as
% discretized by Tavlove and Hagness [2000]. The program automatically
% displays plots of the numerical solution when the wave front is about
% 0.5 meters from the left-most boundary. We introduce the wave at x = 2.5
% meters using the TF/SF formulation.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We start by supplying our constants
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps0 = 8.854e-12;
mu0 = 4*pi*1e-7;
c = 1/sqrt(mu0*eps0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We then provide our S parameter, calculate our range for x, and use them
% to calculate delta_t.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S = 1.0;
f0 = 2e9;%Hz
lambda0 = c/f0;
min_x = 0;%meters
max_x = 4;%meters
delta_x = 1e-3;%meters
x = (min_x:delta_x:max_x)';
N_lambda = lambda0/delta_x;
delta_t = delta_x*S/c;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We provide the permittivity, permeability, and conductivity as a function
% of space.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps = zeros(size(x));
mu = zeros(size(x));
sigma = zeros(size(x));
s = find((x >= 0) & (x < 3));
eps(s) = eps0;
mu(s) = mu0;
sigma(s) = 0;
s = find((x >= 3) & (x <= 4));
eps(s) = 10*eps0;
mu(s) = mu0;
sigma(s) = 0.01;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We calculate the "C" and "D" parameters, as given by Taflove and Hagness
% [2000]. We provide a half-spatial-step version as well for simlicity.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ca = (1-sigma.*delta_t./2./eps)./(1+sigma.*delta_t./2./eps);
Cb = (delta_t./eps./delta_x)./(1+sigma.*delta_t./2./eps);
Da = ones(size(Ca));
Db = delta_t./mu./delta_x;
eps_half = eps(1:end-1);

mu_half = mu(1:end-1);
sigma_half = sigma(1:end-1);
Ca_half
Cb_half
Da_half
Db_half

=
=
=
=

(1-sigma_half.*delta_t./2./eps_half)./(1+sigma_half.*delta_t./2./eps_half);
(delta_t./eps_half./delta_x)./(1+sigma_half.*delta_t./2./eps_half);
ones(size(Ca_half));
delta_t./mu_half./delta_x;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We then set our initial conditions (E=H=J=0 everywhere). Based on the
% Yee grid, some vectors are longer than others. We keep 1 past value of
% all vectors, except for J.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hx = zeros(length(x),2);
Ey = zeros(length(x),2);
Ez = zeros(length(x),2);
Jy = zeros(length(x),1);
Jz = zeros(length(x),1);
Hy
Hz
Ex
Jx

=
=
=
=

zeros(length(x)-1,2);
zeros(length(x)-1,2);
zeros(length(x)-1,2);
zeros(length(x)-1,1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we calculate the index of the source location.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[val, tfsf_boundary] = min(abs(x - 2.500));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% In order to calculate the reflection coefficient, transmission
% coefficient, attenuation rate, and phase constant in each medium, we save
% the values at certain locations for all time. Here we calculate the
% indices of those locations. These values change based on the parameters
% of medium 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[val, save_location1] = min(abs(x - 2.60));
[val, save_location2] = min(abs(x - 2.40));
[val, save_location3] = min(abs(x - 2.65));
[val, save_location4] = min(abs(x - 3.01));
[val, save_location5] = min(abs(x - 3.02));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We identify the time steps at which we would like to make plots.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
min_t = 0;
max_t = 3.0*sqrt(mu(1)*eps(1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% And finally we run the FDTD loop.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t = min_t;
iteration = 0;
output_save_Ez = zeros(round(max_t/delta_t)+1,4);
eta1 = sqrt(sqrt(-1)*2*pi*f0*mu(1)/(sigma(1) +sqrt(-1)*2*pi*f0*eps(1)));
beta1 = 2*pi*f0*sqrt(mu(1)*eps(1))*sqrt(1/2*(sqrt(1+(sigma(1)/2/pi/f0/eps(1))^2)+1));
while (t <= max_t)
iteration = iteration + 1;
Ey_inc = 0;
Ez_inc = 0.5*sin(2*pi*f0*(t-delta_t/2));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The crux of the FDTD routine are these next lines, followed by
% perfect electric conductor boundary conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hx(:,2) = 0;
Hy(:,2) = Da_half.*Hy(:,1) + Db_half.*(Ez(2:end,1)-Ez(1:end-1,1));

Hy(tfsf_boundary-1,2) = Hy(tfsf_boundary-1,2) - Db_half(tfsf_boundary-1).*Ez_inc;


Hz(:,2) = Da_half.*Hz(:,1) + Db_half.*(Ey(1:end-1,1)-Ey(2:end,1));
Hz(tfsf_boundary-1,2) = Hz(tfsf_boundary-1,2) + Db_half(tfsf_boundary-1).*Ey_inc;
Hy_inc = -0.5/eta1*sin(2*pi*f0*t + beta1*delta_x/2);
Hz_inc = 0;
Ex(:,2) = Ca_half.*Ex(:,1) - Cb_half.*Jx(:,1).*delta_x;
Ey(2:end-1,2) = Ca(2:end-1).*Ey(2:end-1,1) + Cb(2:end-1).*(Hz(1:end-1,2)-Hz(2:end,2) Jy(2:end-1,1).*delta_x);
Ey(tfsf_boundary,2) = Ey(tfsf_boundary,2) + Cb(tfsf_boundary).*Hz_inc;
Ey(1,2) = 0;
Ey(end,2) = 0;
Ez(2:end-1,2) = Ca(2:end-1).*Ez(2:end-1,1) + Cb(2:end-1).*(Hy(2:end,2)-Hy(1:end-1,2) Jz(2:end-1,1).*delta_x);
Ez(tfsf_boundary,2) = Ez(tfsf_boundary,2) - Cb(tfsf_boundary).*Hy_inc;
Ez(1,2) = 0;
Ez(end,2) = 0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate S at half points in space and whole points in time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TAvg_Ex = (Ex(:,1)+Ex(:,2))/2;
TAvg_Ey = (Ey(:,1)+Ey(:,2))/2;
TAvg_Ez = (Ez(:,1)+Ez(:,2))/2;
STAvg_Ey = (TAvg_Ey(1:end-1)+TAvg_Ey(2:end))/2;
STAvg_Ez = (TAvg_Ez(1:end-1)+TAvg_Ez(2:end))/2;
SAvg_Hx = 0;
Sx = STAvg_Ey.*Hz(:,2) - STAvg_Ez.*Hy(:,2);
Sy = STAvg_Ez.*SAvg_Hx - TAvg_Ex.*Hz(:,2);
Sz = TAvg_Ex.*Hy(:,2) - STAvg_Ey.*SAvg_Hx;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate wave impedance at half points in space and whole points in
% time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eta = -STAvg_Ez./Hy(:,2);
s = find(Sx < 0);
eta(s) = -eta(s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure-making code below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
range = [-0.5 0.5];
figure(1);
plot(x, Ez(:,2));
ylim(range);
xlim([min_x max_x]);
grid on;
title(['EEL6487 HW 2, Problem 1: Time: ' num2str(round(t*1e12)) ' picoseconds']);
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
if (iteration == round(max_t/delta_t)),
figure(2);
subplot(3,1,1);
plot(x, Ez(:,2));
ylim(range);
xlim([min_x max_x]);
grid on;
title(['EEL6487 HW 2, Problem 1: Time: ' num2str(round(t*1e12)) ' picoseconds']);
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('E_z (V/m)');

range = [-6 6]*1e-4;


subplot(3,1,2);
plot(x(1:end-1)+delta_x/2, Sx);
ylim(range);
xlim([min_x max_x]);
grid on;
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('S_x (W/m^2)');
range = [0 600];
subplot(3,1,3);
plot(x(1:end-1)+delta_x/2, eta);
ylim(range);
xlim([min_x max_x]);
grid on;
h1 = line([3 3],range);
set(h1,'color','r','LineWidth',2);
ylabel('\eta_w (\Omega)');
xlabel('x (meters)');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Update the arrays/variables for the next iteration.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ex(:,1) = Ex(:,2);
Ex(:,2) = 0;
Ey(:,1) = Ey(:,2);
Ey(:,2) = 0;
Ez(:,1) = Ez(:,2);
Ez(:,2) = 0;
Hx(:,1) = Hx(:,2);
Hx(:,2) = 0;
Hy(:,1) = Hy(:,2);
Hy(:,2) = 0;
Hz(:,1) = Hz(:,2);
Hz(:,2) = 0;
t = t + delta_t;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Save the electric field values at the locations calculated above.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
output_save_Ez(iteration,1) = Ez(save_location1,1);
output_save_Ez(iteration,2) = Ez(save_location2,1);
output_save_Ez(iteration,3) = Ez(save_location3,1);
output_save_Ez(iteration,4) = Ez(save_location4,1);
output_save_Ez(iteration,5) = Ez(save_location5,1);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate ideal reflection and transmission coefficients as well as ideal
% attenuation rates and phase constants in both media.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps1 = eps(1);
mu1 = mu(1);
sigma1 = sigma(1);
eps2 = eps(end);
mu2 = mu(end);
sigma2 = sigma(end);
eta1 = sqrt(sqrt(-1)*2*pi*f0*mu1/(sigma1 +sqrt(-1)*2*pi*f0*eps1));
eta2 = sqrt(sqrt(-1)*2*pi*f0*mu2/(sigma2 +sqrt(-1)*2*pi*f0*eps2));
ideal_alpha1 = 2*pi*f0*sqrt(mu1*eps1)*sqrt(1/2*(sqrt(1+(sigma1/2/pi/f0/eps1)^2)-1))
ideal_alpha2 = 2*pi*f0*sqrt(mu2*eps2)*sqrt(1/2*(sqrt(1+(sigma2/2/pi/f0/eps2)^2)-1))
ideal_beta1 = 2*pi*f0*sqrt(mu1*eps1)*sqrt(1/2*(sqrt(1+(sigma1/2/pi/f0/eps1)^2)+1))
ideal_beta2 = 2*pi*f0*sqrt(mu2*eps2)*sqrt(1/2*(sqrt(1+(sigma2/2/pi/f0/eps2)^2)+1))

ideal_gamma = (eta2-eta1)/(eta2+eta1);
mag_ideal_gamma = abs(ideal_gamma)
angle_ideal_gamma = angle(ideal_gamma)*180/pi
ideal_T = 2*eta2/(eta2+eta1);
mag_ideal_T = abs(ideal_T)
angle_ideal_T = angle(ideal_T)*180/pi
vp1 = 2*pi*f0/ideal_beta1;
vp2 = 2*pi*f0/ideal_beta2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the reflection and transmission
% coefficients.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.1/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(1.1/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
incident_field = output_save_Ez(t1_index:t2_index,1);
reflected_field = output_save_Ez(t3_index:t4_index,2);
IFZ = czt(incident_field,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
RFZ = czt(reflected_field,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
gamma = RFZ./IFZ;
T = gamma + 1;
mag_gamma = abs(gamma)
angle_gamma = angle(gamma)*180/pi
mag_T = abs(T)
angle_T = angle(T)*180/pi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the attenuation rate and phase
% constant in medium 1.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round(0.1/vp1/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);
t3_index = round(0.15/vp1/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
incident_field1 = output_save_Ez(t1_index:t2_index,1);
incident_field2 = output_save_Ez(t3_index:t4_index,3);
IFZ1 = czt(incident_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
IFZ2 = czt(incident_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
alpha1 = -log(abs(IFZ2./IFZ1))/0.05
incident_field1 = output_save_Ez(t3_index:t2_index,1);
incident_field2 = output_save_Ez(t3_index:t2_index,3);
IFZ1 = czt(incident_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
IFZ2 = czt(incident_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
beta1 = angle(IFZ2./IFZ1)/0.05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the chirp z-transform to calculate the attenuation rate and phase
% constant in medium 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1_index = round((0.51/vp1)/delta_t)+1;
t2_index = t1_index + round(2e-9/delta_t);

t3_index = round((0.52/vp1)/delta_t)+1;
t4_index = t3_index + round(2e-9/delta_t);
transmitted_field1 = output_save_Ez(t1_index:t2_index,4);
transmitted_field2 = output_save_Ez(t3_index:t4_index,5);
TFZ1 = czt(transmitted_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
TFZ2 = czt(transmitted_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
alpha2 = -log(abs(TFZ2./TFZ1))/0.01
transmitted_field1 = output_save_Ez(t3_index:t2_index,4);
transmitted_field2 = output_save_Ez(t3_index:t2_index,5);
TFZ1 = czt(transmitted_field1,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
TFZ2 = czt(transmitted_field2,1,1,exp(-sqrt(-1)*2*pi*2e9*delta_t));
beta2 = (angle(TFZ2./TFZ1))/0.01
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Reflection Coefficient Results:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mag_ideal_gamma = 5.195057303848667e-01
% angle_ideal_gamma = 1.798190721495866e+02
% mag_gamma = 5.202587629644551e-01
% angle_gamma = 1.777650673937463e+02
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Transmission Coefficient Results:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mag_ideal_T = 4.804996601879765e-01
% angle_ideal_T = 1.956152922781980e-01
% mag_T = 4.805654472330949e-01
% angle_T = 2.419637194948447e+00
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alpha/beta Results, Medium 1:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ideal_alpha1 = 0
% ideal_beta1 = 4.191645585990301e+01
% alpha1 = 0
% beta1 = 4.055380717482323e+01
%
% The numerically calculated values are very close to the ideal values.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alpha/beta Results, Medium 2:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ideal_alpha2 = 5.956632303507368e-01
% ideal_beta2 = 1.325528103558576e+02
% alpha2 = 7.327681160086927e+00
% beta2 = 1.322365597261991e+02
%
% The numerically calculated values are reasonably close to the ideal
% values.

EEL 6487 Homework 2, Problem 4c: Time: 10003 picoseconds

Ez (V/m)

0.5

0.0

0.5

= 0
= 0
= 0 S/m

= 100
= 0
= 0.01 S/m

w ()

Sx (W/m2)

400
200
0
200
400
600
500
400
300
200
100
0
0

0.5

1.0

1.5

2.0

x (meters)

2.5

3.0

3.5

You might also like