aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gbeam_propagation.m8
-rw-r--r--gbeam_propagation_froward_only.m10
-rw-r--r--pick_visualization.m6
-rw-r--r--solution_visualization.m38
4 files changed, 51 insertions, 11 deletions
diff --git a/gbeam_propagation.m b/gbeam_propagation.m
index d81f70e..eeb6a3d 100644
--- a/gbeam_propagation.m
+++ b/gbeam_propagation.m
@@ -1,4 +1,4 @@
-function q = gbeam_propagation(x_pos, q_in, x_in, optics_elements)
+function [q, q_lens] = gbeam_propagation(x_pos, q_in, x_in, optics_elements)
% calculate the 'q' parameter of the Gaussian beam propagating through optical
% 'optics_elements' array along 'x' axis at points 'x_pos'
% takes the gaussian beam with initial q_in parameter at x_in
@@ -8,7 +8,7 @@ function q = gbeam_propagation(x_pos, q_in, x_in, optics_elements)
if any(x_pos >= x_in)
% Forward propagation to the right of x_in
- q(x_pos >= x_in) = gbeam_propagation_froward_only(x_pos(x_pos>=x_in), q_in, x_in, optics_elements);
+ [q(x_pos >= x_in), q_lens] = gbeam_propagation_froward_only(x_pos(x_pos>=x_in), q_in, x_in, optics_elements);
end
if any(x_pos < x_in)
@@ -45,8 +45,10 @@ function q = gbeam_propagation(x_pos, q_in, x_in, optics_elements)
% final assignment of the backwards propagating beam
% which we need to flip back
q(x_pos<x_in) = fliplr(q_backw);
- end
+ end
+
+
end
%!test
diff --git a/gbeam_propagation_froward_only.m b/gbeam_propagation_froward_only.m
index afc1316..8a14cf5 100644
--- a/gbeam_propagation_froward_only.m
+++ b/gbeam_propagation_froward_only.m
@@ -1,4 +1,4 @@
-function q = gbeam_propagation_froward_only(x_pos, q_in, x_in, optics_elements)
+function [q, q_lens] = gbeam_propagation_froward_only(x_pos, q_in, x_in, optics_elements)
% calculate the 'q' parameter of the Gaussian beam propagating through optical
% 'optics_elements' only in the positive direction along 'x' axis at points 'x_pos'
% takes the gaussian beam with initial q_in parameter at x_in
@@ -8,6 +8,10 @@ function q = gbeam_propagation_froward_only(x_pos, q_in, x_in, optics_elements)
%
% all x_pos must be to the right of x_in
% x_pos must be monotonic!
+
+ %Initialize q_lens (q at position of lens)
+ q_lens = zeros(1,size(optics_elements,2));
+
if (any(x_pos < x_in))
error('all beam positions must be to the right of the x_in');
end
@@ -35,6 +39,7 @@ function q = gbeam_propagation_froward_only(x_pos, q_in, x_in, optics_elements)
end
%propagate beam up to the lens
q_at_lens = q_after_free_space(q_last_calc,elx - x_last_calc);
+ q_lens(k) = q_at_lens;
%Applying lens transformation
q_last_calc=q_after_abcd(q_at_lens,el.abcd);
x_last_calc = elx;
@@ -45,8 +50,7 @@ function q = gbeam_propagation_froward_only(x_pos, q_in, x_in, optics_elements)
index = (x_last_calc <= x_pos);
x=x_pos(index);
q(index)= q_after_free_space(q_last_calc,x-x_last_calc);
-
-
+
end
diff --git a/pick_visualization.m b/pick_visualization.m
index 602e509..58140c1 100644
--- a/pick_visualization.m
+++ b/pick_visualization.m
@@ -8,9 +8,9 @@ for n_graph = 1:n_possible_lens_placement
figure(n_graph)
[w_final_trial, r_final_trial] = solution_visualization(q0, x0, qf, Ltot, optics_placer(possible_lens_placement(index(n_graph),:), possible_lens_set(index(n_graph),:)), lambda);
- str1=sprintf('\n f_1 = %0.4f, x_1 = %0.4f\n',possible_lens_set(index(n_graph),1),possible_lens_placement(index(n_graph),1));
- str2=sprintf('f_2 = %0.4f, x_2 = %0.4f\n',possible_lens_set(index(n_graph),2),possible_lens_placement(index(n_graph),2));
- str3=sprintf('f_3 = %0.4f, x_3 = %0.4f\n',possible_lens_set(index(n_graph),3),possible_lens_placement(index(n_graph),3));
+ str1=sprintf('\n (red) f_1 = %0.4f, x_1 = %0.4f\n',possible_lens_set(index(n_graph),1),possible_lens_placement(index(n_graph),1));
+ str2=sprintf(' (green) f_2 = %0.4f, x_2 = %0.4f\n',possible_lens_set(index(n_graph),2),possible_lens_placement(index(n_graph),2));
+ str3=sprintf(' (blue) f_3 = %0.4f, x_3 = %0.4f\n',possible_lens_set(index(n_graph),3),possible_lens_placement(index(n_graph),3));
tstr='Solution #';
str_w = ['w_{final}= ',num2str(w_final_trial)];
str_r = [', r_{final}= ',num2str(r_final_trial)];
diff --git a/solution_visualization.m b/solution_visualization.m
index 6f8fddb..280860c 100644
--- a/solution_visualization.m
+++ b/solution_visualization.m
@@ -1,11 +1,19 @@
-function [waste_at_the_end, radius_at_the_end] = solution_visualization(q0,x0, qf, xf, optics, lambda)
+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=gbeam_propagation(x,q0,x0,optics);
+[q_forward, q_lens] =gbeam_propagation(x,q0,x0,optics);
[w_forward,r_forward]=q2wr(q_forward, lambda);
%Backward propagation
@@ -20,6 +28,32 @@ subplot(2,1,1); plot ( ...
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);
+
+