aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--energy_vs_stability.m4
-rw-r--r--fitter_check.m21
-rw-r--r--gbeam_propagation.m4
-rw-r--r--gbeam_propagation_froward_only.m3
-rw-r--r--mode_match.m6
-rw-r--r--pick_visualization.m4
-rw-r--r--solution_visualization.m52
7 files changed, 55 insertions, 39 deletions
diff --git a/energy_vs_stability.m b/energy_vs_stability.m
index 25e0d06..796c631 100644
--- a/energy_vs_stability.m
+++ b/energy_vs_stability.m
@@ -20,8 +20,8 @@ function [] = energy_vs_stability( possible_energy, stability, index, stability_
ylabel('Stability')
ylim([0,stability_max])
- dx =0.000000005;
- dy =0.000000005;
+ dx =0.0000000005;
+ dy =0.0000000005;
for i = 1:n
n_solution = num2str(i);
diff --git a/fitter_check.m b/fitter_check.m
index 1796cce..f70ded6 100644
--- a/fitter_check.m
+++ b/fitter_check.m
@@ -1,6 +1,5 @@
%Permute all possible lens combinations out of set of lenses
-lens_set = [.075, .203, .05, .03];
-lens_set = [.075,.203];
+lens_set = [.075, .203];
lens_permutations = pick(lens_set,3,'or');
%Pre-defined Constants
@@ -14,20 +13,26 @@ rf= 1.0E+100 ;
xf= Ltot;
q0=wr2q(w0,r0,lambda);
qf=wr2q(wf,rf,lambda);
+lens_width = .03;
+show_lens_width = 1;
+show_lens_position = 1;
+display_prop = [show_lens_width, show_lens_position];
%End list
%Mode match
-[ possible_lens_placement, initial_lens_placement, possible_lens_set, possible_sample_energy] = mode_match( q0, qf, Ltot, lambda, lens_permutations );
+[ possible_lens_placement, initial_lens_placement, possible_lens_set, possible_sample_energy] = mode_match( q0, qf, Ltot, lambda, lens_permutations, lens_width );
%Remove similar solutions
n_truncate = 3; %number of digits in truncated solution
[ 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 );
-n_visualizations = 20; %number of best solutions to visualize
-n_hist = 10000;
-pick_visualization( possible_sample_energy, possible_lens_placement_uniq, possible_lens_placement, possible_lens_set, index, n_visualizations, q0, qf, Ltot, lambda );
-[stability]= stability_visualization( possible_lens_placement_uniq, q0, qf, xf, possible_lens_placement, possible_lens_set, lambda, n_visualizations, n_hist, index )
-energy_vs_stability( possible_sample_energy, stability, index)
+n_visualizations = 5; %number of best solutions to visualize
+n_hist = 10000; %number of sample points in histogram
+stability_max = 1; %max stability (y-axis) shown on energy vs. stability graph
+
+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 );
+[stability] = stability_visualization( possible_lens_placement_uniq, q0, qf, xf, possible_lens_placement, possible_lens_set, lambda, n_visualizations, n_hist, index );
+energy_vs_stability( possible_sample_energy, stability, index, stability_max)
% %Visualize fitness function for fixed f2 and f3
% lens_set = [.075, .075, .203];
diff --git a/gbeam_propagation.m b/gbeam_propagation.m
index eeb6a3d..585048d 100644
--- a/gbeam_propagation.m
+++ b/gbeam_propagation.m
@@ -1,4 +1,4 @@
-function [q, q_lens] = gbeam_propagation(x_pos, q_in, x_in, optics_elements)
+function [q] = 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, q_lens] = 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), q_lens] = gbeam_propagation_froward_only(x_pos(x_pos>=x_in), q_in, x_in, optics_elements);
+ [q(x_pos >= x_in)] = gbeam_propagation_froward_only(x_pos(x_pos>=x_in), q_in, x_in, optics_elements);
end
if any(x_pos < x_in)
diff --git a/gbeam_propagation_froward_only.m b/gbeam_propagation_froward_only.m
index 8a14cf5..2cdc1d8 100644
--- a/gbeam_propagation_froward_only.m
+++ b/gbeam_propagation_froward_only.m
@@ -1,4 +1,4 @@
-function [q, q_lens] = gbeam_propagation_froward_only(x_pos, q_in, x_in, optics_elements)
+function [q] = 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
@@ -39,7 +39,6 @@ function [q, q_lens] = gbeam_propagation_froward_only(x_pos, q_in, x_in, optics
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;
diff --git a/mode_match.m b/mode_match.m
index 3eed53f..dafe209 100644
--- a/mode_match.m
+++ b/mode_match.m
@@ -1,4 +1,4 @@
-function [ final_possible_lens_placement, initial_possible_lens_placement, possible_lens_set, possible_sample_energy] = mode_match( q0, qf, Ltot, lambda, lens_permutations )
+function [ final_possible_lens_placement, initial_possible_lens_placement, possible_lens_set, possible_sample_energy] = mode_match( q0, qf, Ltot, lambda, lens_permutations, lens_width )
%Shuffles lenses into random positions and stores possible solutions
% Shuffles over entire lens permutation array for n_shuffles times.
% Afterwards, solutions are sorted by Energy and truncated to n_truncate
@@ -18,15 +18,13 @@ possible_lens_set = zeros(N,3);
possible_sample_energy = zeros(N,1);
initial_rand_lens_placement=zeros(N,3);
-lens_size = .03; % physical size of the lens
-
for ip = 1:n_perms
f3=lens_permutations(ip,3);
x3=Ltot-f3; % last lense transfer collimated region to focused spot
for is = 1:n_shuffles
possible_lens_set((ip-1)*n_shuffles + is,:) = lens_permutations(ip,:);
- initial_rand_lens_placement_tmp = sort(lens_size+(x3-2*lens_size)*rand(1,2));
+ initial_rand_lens_placement_tmp = sort(lens_width+(x3-2*lens_width)*rand(1,2));
initial_rand_lens_placement((ip-1)*n_shuffles + is,:) = [initial_rand_lens_placement_tmp, x3];
end
end
diff --git a/pick_visualization.m b/pick_visualization.m
index 58140c1..26bd2a6 100644
--- a/pick_visualization.m
+++ b/pick_visualization.m
@@ -1,4 +1,4 @@
-function [ ] = pick_visualization( fitness_energy, possible_lens_placement_uniq, possible_lens_placement, possible_lens_set, index, n_visualizations, q0, qf, Ltot, lambda )
+function [ ] = pick_visualization( fitness_energy, possible_lens_placement_uniq, possible_lens_placement, possible_lens_set, index, n_visualizations, q0, qf, Ltot, lambda, lens_width, display_prop )
%Picks n_visualizations of sets of data and graphs each
x0 = 0;
@@ -6,7 +6,7 @@ n_possible_lens_placement = min(n_visualizations,size(possible_lens_placement_un
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);
+ [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, lens_width, display_prop);
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));
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);