-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaser.m
126 lines (114 loc) · 4.66 KB
/
laser.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
classdef laser < handle
%LASER Defines a class that represents a laser beam
properties
intensity %Intensity in W/m^2
field %Electric field in V/m
pol %Polarization as 3-element vector in either spherical [sigma_-,pi,sigma_+] or linear [x,y,z] polarization
ground %|F,mF> ground state to use as a reference for the detuning
excited %|F',mF'> excited state to use as a reference for the detuning
detuning %The detuning of the laser from the reference transition
end
properties(Constant)
sphPolBasis = [[1 1i 0]/sqrt(2);
[0 0 1];
[-1 1i 0]/sqrt(2)]; %Converts (x,y,z) components to q=(-1,0,1) (spherical) components
end
methods
function self = laser(P,w0)
%LASER Creates a LASER object
%
% L = LASER(I) Creates a LASER object with intensity I
%
% L = LASER(P,W) Creates a LASER object corresponding to a
% Gaussian beam with total power P and beam waist W
self.detuning = 0;
if nargin == 1
self.setIntensity(I);
elseif nargin == 2
self.setGaussBeam(P,w0);
end
end
function new_laser = copy(self)
%COPY Copies the laser object into a new object
new_laser = laser;
p = properties(self);
for nn = 1:numel(p)
try
new_laser.(p{nn}) = self.(p{nn});
catch
end
end
end
function self = setIntensity(self,I)
%SETINTENSITY Sets the intensity of the laser field
%
% L = L.SETINTENSITY(I) Sets the intensity of the laser field
% to I. Automatically calculates the new electric field
self.intensity = I;
self.field = self.calcField(self.intensity);
end
function self = setGaussBeam(self,P,w0)
%SETGAUSSBEAM Sets intensity based on the assumption of a
%Gaussian beam
%
% L = L.SETGAUSSBEAM(P,W) sets the intensity and electric
% field assuming a Gaussian beam of total power P and beam
% waist W
self.intensity = 2*P/(pi*w0^2);
self.field = self.calcField(self.intensity);
end
function self = setPolarization(self,pol,polBasis)
%SETPOLARIZATION Sets the polarization of the field. Function
%automatically normalises the input polarization to have unit
%length
%
% L = L.SETPOLARIZATION(POL) Sets the polarization to the
% polarization POL assuming that POL is in the spherical
% basis q = [-1,0,1].
%
% L = L.SETPOLARIZATION(__,BASIS) uses BASIS (either 'linear'
% or 'spherical') to set the polarization. If 'linear',
% assumes polarization is in [x,y,z] order
if nargin == 2 || strcmpi(polBasis,'spherical')
self.pol = self.sphPolBasis'*pol(:);
elseif strcmpi(polBasis,'linear')
self.pol = pol(:);
else
error('Polarization basis not supported!');
end
self.pol = self.pol./sqrt(self.pol'*self.pol);
end
function self = setStates(self,ground,excited,detuning)
%SETSTATES Sets the reference transition/states and the
%detuning from that transition
%
% L = L.SETSTATES(GROUND) Sets the reference ground state as
% a 2-element vector [F,mF].
%
% L = L.SETSTATES(__,EXCITED) Sets the reference excited
% state as a 2-element vector [F,mF]
%
% L = L.SETSTATUS(__,DETUNING) Sets the detuning from the
% reference states/transition to be DETUNING
if nargin == 2
self.ground = ground;
elseif nargin == 3
self.ground = ground;
self.excited = excited;
elseif nargin == 4
self.ground = ground;
self.excited = excited;
self.detuning = detuning;
end
end
end
methods(Static)
function E = calcField(I)
%CALCFIELD Calculates the electric field for a given intensity
%
% E = CALCFIELD(I) Calculates the electric field given
% intensity I
E = sqrt(0.5*I./(const.eps0*const.c));
end
end
end