# How to Design FP resonator from Bragg mirror in Matlab?

1. May 4, 2014

### RAND1234

1. The problem statement, all variables and given/known data
Below is a {MATLAB}code for Bragg mirror. How can I implement the code to create an FP resonator?

2. Relevant equations

3. The attempt at a solution
Code (Text):
%User input parameters
num_layers = input('The Number of Layers in the structure = ');
r_index1 = input('refractive index of layer 1 = ');
r_index2 = input('refractive index of layer 2 = ');
i_index = input('refractive index of the incident medium = ');
s_index = input('refractive index of the substrate = ');
angle_incidence = input('angle of incidence (degrees) = ');
bragg_wave = input('bragg wavelength (nm) = ');
min_wave = input('lowest wavelength in range (nm) = ');
max_wave = input('highest wavelength in range (nm)= ');
step_wave = input('step wavelength in range (nm) = ');

%converting to nm
bragg_wave1 = bragg_wave * 1E-9;
min_wave1 = min_wave * 1E-9;
max_wave1 = max_wave * 1E-9;
step_wave1 = step_wave * 1E-9;

theta_incidence = angle_incidence*pi/180;

%calculating incidence angle at each layer (snells laws)
theta1 = asin(i_index/r_index1*sin(theta_incidence));
theta2 = asin(r_index1/r_index2*sin(theta1));
theta_s = asin(r_index2/s_index*sin(theta2));

%calculating layer quater-wavelength optical thickness
d1 = bragg_wave1/(4*r_index1);
d2 = bragg_wave1/(4*r_index2);

%calculating optical admitance, for s-polarisation (TE is in normal to the plane of incidence)(assuming in free space Y = 2.6544*E-3)
Y = 2.6544*1E-3;
QA_I = i_index*cos(theta_incidence)*Y;
QA1 = r_index1*cos(theta1)*Y;
QA2 = r_index2*cos(theta2)*Y;
QA_s = s_index*cos(theta_s)*Y; x=1;
y=1;
Wavelength = [];
Reflectivity = [];
for lambda = min_wave1 :step_wave1 : max_wave1 %calculating delta for n1 and n2
del1 = (2*pi*d1*r_index1*cos(theta1))/lambda;
del2 = (2*pi*d2*r_index2*cos(theta2))/lambda;
%calculating characteristic matrix for n1 and n2 %M1
r1 = [cos(del1), i*(sin(del1)/QA1)];
r2 = [(i*(sin(del1)*QA1)), cos(del1)];
M1 = [r1 ; r2];
%M2
t1 = [cos(del2), i*(sin(del2)/QA2)];
t2 = [(i*(sin(del2)*QA2)), cos(del2)];
M2 = [t1 ; t2];
cm = M1*M2;
if (num_layers/2) == round(num_layers/2) M = cm^(num_layers/2);
else
M = cm^((num_layers-1)/2)*M1;
end

%calculate the elements of the characteristic matrix
b = M(1,1) + M(1,2)*QA_s;
c = M(2,1) + M(2,2)*QA_s;
%reflectivity
demin = (QA_I*b) + c; numin = (QA_I*b) - c;
r = numin/demin; r1 = conj(r);
Reflect = r*r1;
fprintf('%f, %f\n', Reflect, lambda); lambda1 = lambda *1E9;
Reflectivity(x)= Reflect; x= x+1;
Wavelength(y)= lambda1;
y=y+1;
end
plot(Wavelength, Reflectivity);
title('Reflectivity vs Wavelength');
xlabel('Wavelength (nm)');
ylabel('Reflectivity (%)')
grid on;
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution

2. May 4, 2014

### RAND1234

Not sure if this thread belongs here or at Electrical engineering. Please let me know if you have violated any rules.

3. May 5, 2014

### RAND1234

Now solved ! Used different TMM,