summaryrefslogtreecommitdiff
path: root/mode_match.m
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2013-03-20 16:53:39 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2013-03-20 16:53:39 -0400
commit99f39dc1423adc360a04344689a83d2f788aae33 (patch)
tree2731d3687b663d27fad56d97c3e20fe05a5949f9 /mode_match.m
parent4943c1cb5d453dd08aab0ec7000f094779178c94 (diff)
downloadmode_match-99f39dc1423adc360a04344689a83d2f788aae33.tar.gz
mode_match-99f39dc1423adc360a04344689a83d2f788aae33.zip
Matt's changes to use faster beam propagator
Diffstat (limited to 'mode_match.m')
-rw-r--r--mode_match.m26
1 files changed, 7 insertions, 19 deletions
diff --git a/mode_match.m b/mode_match.m
index dafe209..0a36332 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, lens_width )
+function [ possible_lens_placement, possible_lens_set, possible_sample_energy] = mode_match( q0, qf, Ltot, lambda, lens_permutations )
%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
@@ -6,10 +6,6 @@ function [ final_possible_lens_placement, initial_possible_lens_placement, possi
n_perms = size(lens_permutations,1);
n_shuffles=20; %number of random placements of lenses
-initial_MaxFunEvals = 1e8;
-initial_MaxIter = 10;
-final_MaxFunEvals = 1e8;
-final_MaxIter = 100;
%Initialize sample arrays
N = n_perms * n_shuffles;
@@ -18,33 +14,25 @@ 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_width+(x3-2*lens_width)*rand(1,2));
+ initial_rand_lens_placement_tmp = sort(lens_size+(x3-2*lens_size)*rand(1,2));
initial_rand_lens_placement((ip-1)*n_shuffles + is,:) = [initial_rand_lens_placement_tmp, x3];
end
end
-
-
-
parfor i = 1:N
+
fitness_simplified=@(x) fitness(q0, qf, Ltot, x, possible_lens_set(i,:), lambda );
- [ x_sol, energy ] = find_min(i, initial_rand_lens_placement, fitness_simplified, initial_MaxFunEvals, initial_MaxIter )
-
- initial_possible_lens_placement(i,:) =x_sol;
+ [x_sol, energy]=fminsearch(fitness_simplified, initial_rand_lens_placement(i,:), optimset('TolFun',1e-5,'MaxFunEvals',1e8,'MaxIter',200));
-end
-
-parfor i = 1:N
- fitness_simplified=@(x) fitness(q0, qf, Ltot, x, possible_lens_set(i,:), lambda );
- [ x_sol, energy ] = find_min(i, initial_possible_lens_placement, fitness_simplified, final_MaxFunEvals, final_MaxIter )
-
- final_possible_lens_placement(i,:) =x_sol;
+ possible_lens_placement(i,:) =x_sol;
possible_sample_energy(i) = energy;
end