aboutsummaryrefslogtreecommitdiff
path: root/solution_visualization.m
diff options
context:
space:
mode:
authorMatt Argao <mcargao@email.wm.edu>2013-03-02 10:14:05 -0500
committerMatt Argao <mcargao@email.wm.edu>2013-03-02 10:14:05 -0500
commitc181a0d3181a7f5a24e9fdc712f2cdab38a928cb (patch)
treea1e8123f47b0e954c317a0012b73935b32f340f8 /solution_visualization.m
parent563330e918440fd6ef34ffac88706c0e19a0ba08 (diff)
downloadmode_match-c181a0d3181a7f5a24e9fdc712f2cdab38a928cb.tar.gz
mode_match-c181a0d3181a7f5a24e9fdc712f2cdab38a928cb.zip
Fixed lens bug and added more accurate representation of lenses.
Diffstat (limited to 'solution_visualization.m')
-rw-r--r--solution_visualization.m52
1 files changed, 33 insertions, 19 deletions
diff --git a/solution_visualization.m b/solution_visualization.m
index 280860c..2b4158c 100644
--- a/solution_visualization.m
+++ b/solution_visualization.m
@@ -1,4 +1,4 @@
-function [waste_at_the_end, radius_at_the_end, waist_at_lens_position] = 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, lens_width, display_prop)
%Propagates beam with given input parameters
% Forward propagation and backward propagation are taken in order to
% visualize reasonable solutions.
@@ -13,7 +13,7 @@ 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);
+q_forward =gbeam_propagation(x,q0,x0,optics);
[w_forward,r_forward]=q2wr(q_forward, lambda);
%Backward propagation
@@ -22,34 +22,48 @@ q_backward=gbeam_propagation(x,qf,xf,optics);
%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', ''})
+ 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
+%Find q and waist at lens positions
waist_at_lens_position = zeros(1,n_lens);
+q_lens = zeros(1,n_lens);
for i = 1:n_lens
- waist_at_lens_position(i) = q2wr(q_lens(i), lambda);
+ q_lens(i) = gbeam_propagation(lens_position(i),q0,x0,optics);
end
-%Distance from x-axis
-waist_at_lens_position = waist_at_lens_position;
+for i = 1:n_lens
+ waist_at_lens_position(i) = q2wr(q_lens(i), lambda);
+end
+
%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));
+color = ['m' 'g' 'c'];
+
+if display_prop(1) == 1
+ for i = 1:n_lens
+ half_width = lens_width/2;
+ corrected_lens_position = lens_position(i)-half_width;
+ corrected_waist = waist_at_lens_position(i)*2;
+ rectangle('Position', [corrected_lens_position,-waist_at_lens_position(i),lens_width,corrected_waist], 'EdgeColor', color(i), 'LineWidth',1);
+ end
end
+if display_prop(2) == 1
+ 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', 3, 'Color', color(i));
+ end
+end
[waste_at_the_end,radius_at_the_end] = q2wr(q_forward(end), lambda);