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 .optic import Optic
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 Actions:
23 * T on HR: 0
24 * R on HR: + 1
25 * T on AR: 0
26 * R on AR: + 1
27
28 *=== Additional attributes with respect to the Optic class ===*
29
30 None
31
32 *=== Name ===*
33
34 ThickLens
35
36 **Note**: the curvature of any surface is positive for a concave surface
37 (coating inside the sphere).
38 Thus kurv*HRNorm/|kurv| always points to the center
39 of the sphere of the surface, as is the convention for the lineSurfInter of
40 geometry module. Same for AR.
41
42 ******* HRK > 0 and ARK > 0 ******* HRK > 0 and ARK < 0
43 ***** ******** and |ARK| > |HRK|
44 H***A H*********A
45 ***** ********
46 ******* *******
47
48 **Note**: in the case of thicklenses, the thickness provided to and by the
49 initializer is the thickness *on the optical axis*, and not the thickness
50 on the side of the component (like mirrors).
51
52 **Note**: in the case of thicklenses, the center provided to the initializer
53 is the *apex* of the principal face, and not the chord of the HR surface.
54
55 '''
56 Name = "ThickLens"
57
58 - def __init__(self, K1 = 0.01, K2 = 0.01, X = 0., Y = 0., Z = 0.,
59 Theta = pi/2., Phi = 0.,
60 Thickness = 2.e-2, N = 1.4585, KeepI = False,
61 Diameter = 5.e-2, R = 0.1, T = .9, Ref = None):
62 '''ThickLens initializer.
63
64 Parameters are the attributes.
65
66 Returns a ThickLens.
67
68 '''
69
70 TonHR = 0
71 RonHR = 1
72 TonAR = 0
73 RonAR = 1
74
75
76 K1 = float(K1)
77 K2 = float(K2)
78 Theta = float(Theta)
79 Phi = float(Phi)
80 Thickness = float(Thickness)
81 N = float(N)
82 Diameter = float(Diameter)
83 R = float(R)
84 T = float(T)
85 Wedge = 0.
86 Alpha = 0.
87
88
89 HRNorm = np.array([np.sin(Theta)*np.cos(Phi),
90 np.sin(Theta)*np.sin(Phi),
91 np.cos(Theta)], dtype = np.float64)
92 Apex1 = np.array([X, Y, Z], dtype = np.float64)
93
94
95 ARNorm = - HRNorm
96 Apex2 = Apex1 + Thickness * ARNorm
97
98
99 theta1 = np.abs(np.arcsin(Diameter * K1/2. ))\
100 if np.abs(Diameter * K1 /2.) < 1. else pi/2.
101 theta2 = np.abs(np.arcsin(Diameter * K2/2. ))\
102 if np.abs(Diameter * K2 /2.) < 1. else pi/2.
103
104
105 HRCenter = Apex1 + (1. - np.cos(theta1))*HRNorm/K1\
106 if np.abs(K1) > 0. else Apex1
107 ARCenter = Apex2 + (1. - np.cos(theta2))*ARNorm/K2\
108 if np.abs(K2) > 0. else Apex2
109
110
111 super(ThickLens, self).__init__(ARCenter = ARCenter, ARNorm = ARNorm,
112 N = N,
113 HRK = K1, ARK = K2,
114 ARr = R, ARt = T, HRr = R, HRt = T, KeepI = KeepI,
115 HRCenter = HRCenter, HRNorm = HRNorm, Thickness = Thickness,
116 Diameter = Diameter, Wedge = Wedge, Alpha = Alpha,
117 TonHR = TonHR, RonHR = RonHR, TonAR = TonAR, RonAR = RonAR,
118 Ref = Ref)
119
120
121 if settings.warning:
122 self.geoCheck("thick lens")
123
125 '''Returns the list of lines necessary to print the object.
126 '''
127 sph = rectToSph(self.HRNorm)
128 return ["ThickLens: %s{" % str(self.Ref),
129 "Thick: %scm" % str(self.Thick/cm),
130 "Diameter: %scm" % str(self.Dia/cm) ,
131 "Center: %s" % str(self.HRCenter),
132 "Norm: (%s, %s)deg" % (str(sph[0]/deg), str(sph[1]/deg)),
133 "Index: %s" % str(self.N),
134 "HRKurv, ARKurv: %s, %s" % (str(self.HRK), str(self.ARK)),
135 "R, T: %s, %s" % (str(self.HRr),str(self.HRt)),
136 "}"]
137