1 '''Defines the ThickLens class for theia.'''
2
3
4
5
6
7
8 import numpy as np
9 from ..helpers import settings
10 from ..helpers.geometry import rectToSph
11 from ..helpers.units import cm, deg, pi
12 from .lens import Lens
13
15 '''
16
17 ThickLens class.
18
19 This class represents thick lenses, specified by curvatures and thickness
20 instead of focal length.
21
22 *=== Attributes ===*
23 SetupCount (inherited): class attribute, counts all setup components.
24 [integer]
25 OptCount (inherited): class attribute, counts optical components. [integer]
26 Name: class attribute. [string]
27 HRCenter (inherited): center of the 'chord' of the HR surface. [3D vector]
28 HRNorm (inherited): unitary normal to the 'chord' of the HR (always pointing
29 towards the outside of the component). [3D vector]
30 Thick (inherited): thickness of the optic, counted in opposite direction to
31 HRNorm. [float]
32 Dia (inherited): diameter of the component. [float]
33 Ref (inherited): reference string (for keeping track with the lab). [string]
34 ARCenter (inherited): center of the 'chord' of the AR surface. [3D vector]
35 ARNorm (inherited): unitary normal to the 'chord' of the AR (always pointing
36 towards the outside of the component). [3D vector]
37 N (inherited): refraction index of the material. [float]
38 HRK, ARK (inherited): curvature of the HR, AR surfaces. [float]
39 HRr, HRt, ARr, ARt (inherited): power reflectance and transmission
40 coefficients of the HR and AR surfaces. [float]
41 KeepI (inherited): whether of not to keep data of rays for interference
42 calculations on the HR. [boolean]
43
44 **Note**: the curvature of any surface is positive for a concave surface
45 (coating inside the sphere).
46 Thus kurv*HRNorm/|kurv| always points to the center
47 of the sphere of the surface, as is the convention for the lineSurfInter of
48 geometry module. Same for AR.
49
50 ******* HRK > 0 and ARK > 0 ******* HRK > 0 and ARK < 0
51 ***** ******** and |ARK| > |HRK|
52 H***A H*********A
53 ***** ********
54 ******* *******
55
56 **Note**: in the case of thicklenses, the thickness provided to and by the
57 initializer is the thickness *on the optical axis*, and not the thickness
58 on the side of the component (like mirrors).
59
60 **Note**: in the case of thicklenses, the center provided to the initializer
61 is the *apex* of the principal face, and not the chord of the HR surface.
62
63 '''
64 Name = "ThickLens"
65
66 - def __init__(self, K1 = 0.01, K2 = 0.01, X = 0., Y = 0., Z = 0.,
67 Theta = pi/2., Phi = 0.,
68 Thickness = 2.e-2, N = 1.4585, KeepI = False,
69 Diameter = 5.e-2, R = 0.1, T = .9, Ref = None):
70 '''ThickLens initializer.
71
72 Parameters are the attributes.
73
74 Returns a ThickLens.
75
76 '''
77
78 K1 = float(K1)
79 K2 = float(K2)
80 Theta = float(Theta)
81 Phi = float(Phi)
82 Thickness = float(Thickness)
83 N = float(N)
84 Diameter = float(Diameter)
85 R = float(R)
86 T = float(T)
87
88
89 HRNorm = np.array([np.sin(Theta)*np.cos(Phi), np.sin(Theta) * np.sin(Phi),
90 np.cos(Theta)], dtype = np.float64)
91 Apex1 = np.array([X, Y, Z], dtype = np.float64)
92
93
94 ARNorm = - HRNorm
95 Apex2 = Apex1 + Thickness * ARNorm
96
97
98 try:
99 theta1 = np.abs(np.arcsin(Diameter * K1/2. ))
100 except FloatingPointError:
101 theta1 = pi/2.
102 try:
103 theta2 = np.abs(np.arcsin(Diameter * K2/2. ))
104 except FloatingPointError:
105 theta2 = pi/2.
106
107
108 if np.abs(K1) > 0.:
109 HRCenter = Apex1\
110 + (1. - np.cos(theta1))*HRNorm/K1
111 else:
112 HRCenter = Apex1
113
114 if np.abs(K2) > 0.:
115 ARCenter = Apex2\
116 + (1. - np.cos(theta2))*ARNorm/K2
117 else:
118 ARCenter = Apex2
119
120
121 super(Lens, self).__init__(ARCenter = ARCenter, ARNorm = ARNorm, N = N,
122 HRK = K1, ARK = K2,
123 ARr = R, ARt = T, HRr = R, HRt = T, KeepI = KeepI,
124 HRCenter = HRCenter, HRNorm = HRNorm, Thickness = Thickness,
125 Diameter = Diameter, Ref = Ref)
126
127
128 if settings.warning:
129 self.geoCheck("thicklens")
130
132 '''Returns the list of lines necessary to print the object.
133 '''
134 ans = []
135 ans.append("ThickLens: " + self.Name + " (" + str(self.Ref) + ") {")
136 ans.append("Thick: " + str(self.Thick/cm) + "cm")
137 ans.append("Diameter: " + str(self.Dia/cm) + "cm")
138 ans.append("Center: " + str(self.HRCenter))
139 sph = rectToSph(self.HRNorm)
140 ans.append("Norm: (" + str(sph[0]/deg) + ', ' \
141 + str(sph[1]/deg) + ')deg')
142 ans.append("Index: " + str(self.N))
143 ans.append("HRKurv, ARKurv: " + str(self.HRK) + ", " + str(self.ARK))
144 ans.append("R, T: " + str(self.HRr) + ", " + str(self.HRt) )
145 ans.append("}")
146
147 return ans
148