aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fitness.m6
-rw-r--r--fitter_check.m44
-rw-r--r--optics_placer.m8
3 files changed, 38 insertions, 20 deletions
diff --git a/fitness.m b/fitness.m
index 6c0026b..80835e5 100644
--- a/fitness.m
+++ b/fitness.m
@@ -1,8 +1,8 @@
-function Energy = fitness( q_0, q_final, x_final, optics_positions )
+function Energy = fitness( q_0, q_final, x_final, optics_positions, optics_focal_length )
%FITNESS Summary of this function goes here
% Detailed explanation goes here
x0 = 0;
- q_f_trial = gbeam_propagation(x_final,q_0,x0,optics_placer(optics_positions));
+ q_f_trial = gbeam_propagation(x_final,q_0,x0,optics_placer(optics_positions, optics_focal_length));
Energy = abs(q_final-q_f_trial);
@@ -46,7 +46,7 @@ function Energy = fitness( q_0, q_final, x_final, optics_positions )
% make collimated region between 2nd and 3rd lens
%intialize intermediate points between lenses
intermediate_positions = linspace(optics_positions(2), optics_positions(3),10);
- f_q_x = @(x) gbeam_propagation(x,q_0,x0,optics_placer(optics_positions));
+ f_q_x = @(x) gbeam_propagation(x,q_0,x0,optics_placer(optics_positions, optics_focal_length));
q_intermediate = arrayfun(f_q_x,intermediate_positions);
lambda_over_waist_sq = (-imag(1./q_intermediate)); %with numerical factor
diff --git a/fitter_check.m b/fitter_check.m
index 1898120..53d3299 100644
--- a/fitter_check.m
+++ b/fitter_check.m
@@ -6,11 +6,15 @@ Ltot= 1.010675025828971 ;
r0= 1.0E+100 ;
w0= 2.563E-5 ;
x0= 0 ;
-lns1.abcd=abcd_lens( 0.075 ) ;
+focal_length1 = .075;
+focal_length2 = .075;
+focal_length3 = .203;
+
+lns1.abcd=abcd_lens( focal_length1 ) ;
lns1.x= 0.21358727296049 ;
-lns2.abcd=abcd_lens( 0.075 ) ;
+lns2.abcd=abcd_lens( focal_length2 ) ;
lns2.x= 0.40361319425309 ;
-lns3.abcd=abcd_lens( 0.203 ) ;
+lns3.abcd=abcd_lens( focal_length3 ) ;
lns3.x= 0.80361319425309 ;
wf= 3.709E-5 ;
rf= 1.0E+100 ;
@@ -32,24 +36,38 @@ sample_energy = [];
sample_x = [];
lens_size = .03;
-for iteration = 1:10
- optics_x_rand = sort(lens_size+(xf-2*lens_size)*rand(1,3));
-
- fitness_simplified=@(x) fitness(q0, qf, Ltot, x );
- [x_sol, energy]=fminsearch(fitness_simplified, optics_x_rand, optimset('TolX',1e-8,'TolFun',1e-8,'MaxFunEvals',1e8,'MaxIter',2000));
+%Lens permutations
+lens_permutations = perms( [ focal_length1, focal_length2, focal_length3 ]);
+n_perms = size(lens_permutations,1);
+n_shuffles=10;
+
+for i = 1:n_perms
+
+
+ lenses_choice=lens_permutations(i,:)
- sample_energy = [sample_energy; energy];
- sample_x = [sample_x; x_sol];
+ for iteration = 1:n_shuffles
+ optics_x_rand = sort(lens_size+(xf-2*lens_size)*rand(1,3));
+
+ fitness_simplified=@(x) fitness(q0, qf, Ltot, x, lenses_choice );
+ [x_sol, energy]=fminsearch(fitness_simplified, optics_x_rand, optimset('TolX',1e-8,'TolFun',1e-8,'MaxFunEvals',1e8,'MaxIter',2000));
+
+ sample_energy = [sample_energy; energy];
+ sample_x = [sample_x; x_sol];
+
+ figure(2)
+ solution_visualization(q0,x0, qf, xf, optics_placer(x_sol, lenses_choice), lambda);
+ drawnow;
+ end
- figure(2)
- solution_visualization(q0,x0, qf, xf, optics_placer(x_sol), lambda);
end
[energy_min, index_of_energy_min] = min(sample_energy(:))
x_sol = sample_x(index_of_energy_min,:);
+lenses_choice=lens_permutations(ceil(index_of_energy_min/n_shuffles),:);
figure(2)
-w_final_trial = solution_visualization(q0,x0, qf, xf, optics_placer(x_sol), lambda);
+w_final_trial = solution_visualization(q0,x0, qf, xf, optics_placer(x_sol, lenses_choice), lambda);
title('Optimized made');
w_final_handmade;
diff --git a/optics_placer.m b/optics_placer.m
index 2287e1b..247cc81 100644
--- a/optics_placer.m
+++ b/optics_placer.m
@@ -1,13 +1,13 @@
-function optics = optics_placer( x )
+function optics = optics_placer( x ,f )
x1=x(1);
x2=x(2);
x3=x(3);
- lns1.abcd=abcd_lens( 0.075 ) ;
+ lns1.abcd=abcd_lens( f(1) ) ;
lns1.x= x1 ;
- lns2.abcd=abcd_lens( 0.075 ) ;
+ lns2.abcd=abcd_lens( f(2) ) ;
lns2.x= x2 ;
- lns3.abcd=abcd_lens( 0.203 ) ;
+ lns3.abcd=abcd_lens( f(3) ) ;
lns3.x= x3 ;
optics={lns1,lns2,lns3};