summaryrefslogtreecommitdiff
path: root/solution_visualization.m
blob: 280860c046ef96990717cba8590dc234b39afaa0 (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
48
49
50
51
52
53
54
55
56
57
58
59
function [waste_at_the_end, radius_at_the_end, waist_at_lens_position] = solution_visualization(q0,x0, qf, xf, optics, lambda)
%Propagates beam with given input parameters
%   Forward propagation and backward propagation are taken in order to
%   visualize reasonable solutions.

%Array of lens positions
n_lens = size(optics,2);

for i = 1:n_lens
    lens_position(i) = optics{i}.x;
end

x=linspace(x0,xf,1000); % we will calculate beam profile between x0 and xf

%Forward propagation
[q_forward, q_lens] =gbeam_propagation(x,q0,x0,optics);
[w_forward,r_forward]=q2wr(q_forward, lambda);

%Backward propagation
q_backward=gbeam_propagation(x,qf,xf,optics);
[w_backward,r_backward]=q2wr(q_backward, lambda);

%Plot beam profile
subplot(2,1,1); plot ( ...
	x,w_forward, '-r',  ...
	x,-w_forward, '-r', ...
	x, w_backward, '-.b', ...
	x, -w_backward, '-.b')
legend({'forward propagation', '', 'backward propagation', ''})      

%Find waist at lens positions
waist_at_lens_position = zeros(1,n_lens);

for i = 1:n_lens
    waist_at_lens_position(i) = q2wr(q_lens(i), lambda);
end


%Distance from x-axis
waist_at_lens_position = waist_at_lens_position;

%Plot lenses
color = ['r' 'g' 'b'];
for i = 1:n_lens
    x1 = optics{i}.x;
    y1 = waist_at_lens_position(i);
    x2 = x1;
    y2 = -waist_at_lens_position(i);
    
    line([x1;x2], [y1;y2], 'LineWidth', 5, 'Color', color(i));
end



[waste_at_the_end,radius_at_the_end]  = q2wr(q_forward(end), lambda);