-
Notifications
You must be signed in to change notification settings - Fork 1
/
aspheric_surface_optimisation.py
127 lines (79 loc) · 3.26 KB
/
aspheric_surface_optimisation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This file is used to model adaptive optics by using aspheric surfaces:
1. Optimised single aspheric surface (compare with single spherical surface)
2. Optimised plano-aspheric lens (compare with plano-convex lens)
3. Optimised bi-convex lens by using aspheric surface (compare with bi-convex)
Tips:
- Use optimum.x to call the optimised parameters
- Use optimum.fun to call the optimised RMS spot size value
Created on Sun Nov 20 13:13:25 2022
@author: williamnguyen
"""
import scipy.optimize as op
import optimisation
#%% 1. Optimised RMS for a single aspheric surface at a given focal plane.
#Compare with single spherical surface
#Initial guess for A4 and A6. Should be <<1
A4 = 1e-6
A6 =0
#Set screen to be at 200 mm to compare with the single spherical case
focus_point = 200
#Setting bound to look for solution.
#Magnitude of A4 and A6 are definitely less than 1
bound = ((-0.1,0.1), (-0.1,0.1))
#minimising
optimum = op.minimize(optimisation.aspheric_rms, [A4, A6],
args=(100, 0.03, 1, 1.5,1/0.03, focus_point, 5),
bounds=bound )
#Print out the optimised values
optimum_param = optimum.x
min_rms = optimum.fun
print('The optimum A4, A6 is:', optimum_param)
print('The minimised RMS is:', min_rms, 'mm')
#%% 2. Optimised RMS for a single aspheric surface and planar surface.
#Compare with plano-convex lens
#Initial guess for A4 and A6. Should be <<1
A4 = 1e-6
A6 =0
#Set screen to be at 198.452 mm to compare with planoconvex
focus_point = 198.452700178
#Setting bound to look for solution. Magnitude of A4 and A6 are definitely less than 1
bound = ((-0.1,0.1), (-0.1,0.1))
#minimising
optimum = op.minimize(optimisation.plano_aspheric_rms, [A4, A6],
args=(100, 5, 0.02, 1, 1.5168,1/0.02, focus_point ,10),
bounds=bound )
optimum_param = optimum.x
min_rms = optimum.fun
print('The optimum (A4, A6) is:', optimum_param)
print('The minimised RMS is:', min_rms, 'mm')
#%% 3. Optimised RMS for a double aspheric surface lens.
#Compare with bi-convex lens
#Initial guess for curvatures from biconvex optimisation
C1 = 0.01596323 #1st curvature
C2 = -0.00425303 #2nd curvature
#Initial guess for aspheric constants for 1st surface and 2nd surface.
A4 = 1e-9
A4_2 = -1e-9
A6 = A6_2 = 0
#Set screen to be at 198.452 mm to compare with bi-convex and plano-convex
focus_point = 198.452700178
#Setting bound to look for solution.
#Magnitude of A4 and A6 are definitely less than 1
rmin = 5
bound = ( (0,1./rmin), (-1./rmin,0), (-0.1, 0.1),
(-0.1, 0.1), (-0.1, 0.1), (-0.1, 0.1) )
#minimising. Set maxfev high due to high number of parameters
#Use Nelder-Mead method, which is not gradient based
optimum = op.minimize(optimisation.double_aspheric_rms, [C1, C2, A4,
A6, A4_2, A6_2], args=(100, 5, 1, 1.5168, focus_point, 10),
bounds=bound, options = {'maxfev': 1e+3},
method = 'Nelder-Mead' )
#Print out the optimised values
optimum_param = optimum.x
min_rms = optimum.fun
print('The optimum parameters are:', optimum_param)
print('The minimised RMS is:', min_rms, 'mm')
#10 times better than the initial bi-convex set up! Spot size 2e-4 mm !