% Fig_3_3a
% Essential Semiconductor Device Physics
% Fabry-Perot optical resonator
clear all;
clf;
err=0.00001;
c=3e8;						%speed of light in vacuum
nr=3.3;						%effective refractive index in cavity
lambda0=1310e-9;			%center emission wavelength
Lc=300e-6;					%Cavity length
r1=0.4						%Reflectivity of mirror1
r2=0.8						%Reflectivity of mirror2
r=r1*r2;					%Optical loss per photon round-trip

F=pi*r^0.5/(1-r)			%Optical Finesse
Fconst=(2*F/pi)^2;
Imax=1/((1-r)^2);			%Peak intensity inside cavity normalized to I0
f0=c*1e-12/lambda0			%center frequency in THz
deltaf=c*1e-12/(2*Lc*nr)	%THz
deltawavelength=lambda0^2/(2*Lc*nr)  %m;
gamma_opt=deltaf/F
Q=f0/gamma_opt

for i=[1:1:1000]
   
   Frequency(i)=(f0+i*0.001);
   Fwavelength(i)=c/Frequency(i);
   x=sin(pi*Frequency(i)/deltaf);
   x2=x*x;
   Intensity(i)=Imax/(1+(Fconst*(x2)));
   
end
%********************  plot figures ************************
figure(1);
 plot(Frequency,Intensity);
 axis([f0,f0+1,0,2.5]); 
 hold on;
 xlabel('Frequency, \nu(THz)'),ylabel('Intensity');
 title(['\itr\rm_1 = ',num2str(r1,'%4.2f\n'),', \itr\rm_2 = ',...
   num2str(r2,'%4.2f\n'),', \itn\rm_r = ',...
   num2str(nr,'%4.1f\n'),', \itf\rm_0 = ',...
   num2str(f0,'%4.0f\n'),' THz, \itL\rm_C = ',num2str(Lc*1e6,'%4.1f\n'),...
   ' \mum, \lambda_0 = ',num2str(lambda0*1e6,'%4.3f\n'),' \mum']);

 figure(2);
 plot(Fwavelength*10^-6,Intensity);
xlabel('Wavelength, \lambda (\mum)'),ylabel('Intensity');
title(['\itr\rm_1 = ',num2str(r1,'%4.2f\n'),', \itr\rm_2 = ',...
   num2str(r2,'%4.2f\n'),', \itn\rm_r = ',...
   num2str(nr,'%4.1f\n'),', \itf\rm_0 = ',...
   num2str(f0,'%4.0f\n'),' THz, \itL\rm_C = ',num2str(Lc*1e6,'%4.1f\n'),...
   ' \mum, \lambda_0 = ',num2str(lambda0*1e6,'%4.3f\n'),' \mum']);
