aboutsummaryrefslogtreecommitdiff
path: root/mode_match_demo.m
blob: 23865529d4dfb05b5b5df86c6e41ccc6e4f967c0 (plain)
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
%Permute all possible lens combinations out of set of lenses
lens_set = [0.025, 0.035, 0.05, .075, 0.10, .125, 0.20, 0.50, 0.75, -.05, -0.10 ]; %Given lenses of unique focal lengths
lens_permutations = pick(lens_set,3,'or'); %3 lens solutions

%Pre-defined Constants
lambda= .795e-6 ; %Wavelength of beam
Ltot= .51 ; %Length of optical system
r0= 1.0E+100 ; %Initial radius of curvature
w0= 5.65e-4 ; %Initial waist

dummy_lens.abcd = abcd_lens(inf);
dummy_lens.x = 10000;
dummy_optic = {dummy_lens};
q0 =  gbeam_propagation ( 0, wr2q(w0, r0, lambda), -1.54, dummy_optic );

x0= 0 ; %Starting position of beam
wf= 2.6983e-4 ; %Desired final waist
rf= 1.0E+100 ; %Desired final radius
qf =  gbeam_propagation ( 0, wr2q(wf, rf, lambda), -0.4813, dummy_optic );

lens_width = .03; %Lens width
show_lens_width = 1; %Set to 1 to enable display of lens width on solution propagation plot
show_lens_position = 1; %Set to 1 to enable display of position of center of lens on solution propagation plot
display_prop = [show_lens_width, show_lens_position];
n_truncate = 3; %number of digits in truncated solution
n_visualizations = 5; %number of best solutions to visualize
n_hist = 1000; %number of sample points in histogram
stability_max = 1; %max stability (y-axis) shown on energy vs. stability graph
self_flag = 0; %Set to 1 to use Self's gaussian beam propagation, otherwise set to 0
%End list

%q0=wr2q(w0,r0,lambda); %Calculate intial q
%qf=wr2q(wf,rf,lambda); %Calculate final q

%Mode match
[ possible_lens_placement, initial_lens_placement, possible_lens_set, possible_sample_energy] = mode_match( q0, qf, Ltot, lambda, lens_permutations, lens_width, self_flag );

%Remove similar solutions
[ possible_lens_placement_uniq, possible_lens_placement, possible_sample_energy, possible_lens_set, index ] = remove_similar_soln( possible_sample_energy, possible_lens_placement, possible_lens_set, n_truncate );


%Visualize solutions
pick_visualization( possible_sample_energy, possible_lens_placement_uniq, possible_lens_placement, possible_lens_set, index, n_visualizations, q0, qf, Ltot, lambda, lens_width, display_prop );

%Plot energy vs. stability for each solution
[stability] = stability_visualization( possible_lens_placement_uniq, q0, qf, Ltot, possible_lens_placement, possible_lens_set, lambda, n_visualizations, n_hist, index, self_flag );
energy_vs_stability( possible_sample_energy, stability, index, stability_max)