Hi I am having trouble accurately finding the refractive index of a structure I simulate in HFSS.
I have been using chapter 3 of optical metamaterials (Wenshan Cai Vladimir Shalaev) to aid me in creation of a script to define mu and epsilon from scatter parameters S11 and S21. Where Z and then the real and imaginary components of N are calculated and combined where
Epsilon = n/Z
and
Mu = n*Z
My script.
clear all;
close all;
disp('test extraction routing');
%Known parameters d = thickness l = frequency k = wave number
%frequency adjusted to wavelength. d remains constant. For now using speed
%of light and freq to calculate wavelength
d=200e-9;
freqraw=load('freqs.csv');
freq=freqraw;
lambda=(2.99792458*10^8)./(freq*10^12);
k=(2.*pi)./lambda;
%Outputs S11 (r) and S21 (t) and phase variables
S11=load('magS11m2.csv');
S21=load('magS21m2.csv');
PhaseS11=load('phaseS11m2.csv');
PhaseS21=load('phaseS21m2.csv');
r = S11.*exp(j*PhaseS11);
t = S21.*exp(j*PhaseS21);
figure
hold on
plot(freq,abs(r),'r.')
plot(freq,abs(t),'b.')
title('reflection and transmission over frequency')
xlabel('freq')
ylabel('tranmission (red) and reflection (blue) over frequency')
for gh=1:length(freq);
% Impedance - Z - The route much be chosen which leads to the real
% component of Z being positive
q(gh)=1;
z(gh)=q(gh)*(sqrt(((1+r(gh)).^2-t(gh).^2)/((1-r(gh)).^2-t(gh).^2)));
if real(z(gh))