% Book: Laser Electronics by Verdeyen
% Problem: Time Averaged Electric Field Density in Cavity
% Script Author: meg noah meg_noah@student.uml.edu
function Lasers_VG

c=(3e8)*(1e6);Volume=2.0*5.0*6.0;d=6;
v1 = [1.5,2,2.1,2.2,2.3,2.4,2.41,2.42,2.43,2.44,2.45,2.47,2.48,2.49,2.5,2.55,2.56,2.6,2.7,2.8,2.9,3,3.5,4,4.5,5];
v1 = v1 * 1e13;
TAEED1=[9.35E-15,7.64E-14,1.30E-13,2.31E-13,4.19E-13,6.81E-13,7.04E-13,7.25E-13,7.44E-13,7.59E-13,7.71E-13,7.86E-13,7.88E-13,7.87E-13,7.82E-13,7.19E-13,7.01E-13,6.19E-13,4.26E-13,2.95E-13,2.13E-13,1.60E-13,5.94E-14,3.48E-14,2.63E-14,2.25E-14];
figure(1);hold off;
plot(v1,TAEED1,'-*b');hold on;
xlabel('Frequency \nu [Hz]');ylabel('Time Average Electric Field Density [J/m]');
figure(11);hold off;
plot(c./v1,TAEED1,'-*b');hold on;
xlabel('Wavelength \lambda [\mum]');ylabel('Time Average Electric Field Density [J/m]');

figure(2);hold off;
plot(v1,TAEED1,'-*b');hold on;
xlabel('Frequency \nu [Hz]');ylabel('Time Average Electric Field Density [J/m]');
n=1.06;
TAEED2=[1.201e-13,2.242e-13,4.387e-13,7.738e-13,8.757e-13,6.849e-13,6.329e-13,4.095e-13,2.760e-13,1.973e-13,1.484e-13,1.160e-13]
v2=[2.0,2.1,2.2,2.3,2.4,2.481,2.5,2.6,2.7,2.8,2.9,3.0];
v2 = v2 * 1e13;
plot(v2,TAEED2,'-+r');hold on;
legend(['Air in Cavity';
        'Cavity n=1.06']);

figure(3);hold off;
plot(v1,TAEED1,'-*b');hold on;
xlabel('Frequency \nu [Hz]');ylabel('Time Average Electric Field Density [J/m]');
TAEED3=[8.496e-14,1.497e-13,2.794e-13,5.262e-13,8.117e-13,8.153e-13,7.809e-13,5.416e-13,3.572e-13,2.462e-13,1.789e-13,1.359e-13];
v3 = v2;
plot(v3,TAEED3,'-+','color',[0 .7 0]);hold on;
legend(['Z0=0.0 m     ';
        'Z0=0.5e^-^7 m']);

f=2.481e13;
n=[1.00,1.02,1.04,1.06,1.08,1.10,1.20];
TAEED4=[7.878e-13,7.972e-13,7.579e-13,6.849e-13,5.980e-13,5.123e-13,2.351e-13];
figure(4);hold off;
plot(n,TAEED4,'-*b');hold on;
xlabel('Index of Refraction [\nu=2.481*10^-^1^3]');ylabel('Time Average Electric Field Density [J/m]');
