1 '''Defines the Special class for theia.'''
2
3
4
5
6
7
8 import numpy as np
9 from ..helpers import geometry, settings
10 from ..helpers.units import deg, cm, pi
11 from .optic import Optic
12
14 '''
15
16 Special class.
17
18 This class represents general optics, as their actions on R and T are left
19 to the user to input. They are useful for special optics which are neither
20 reflective nor transmissive.
21
22 Actions:
23 * T on HR: user input
24 * R on HR: user input
25 * T on AR: user input
26 * R on AR: user input
27
28 **Note**: by default the actions of these objects are those of
29 beamsplitters (0, 0, 0, 0)
30
31 *=== Additional attributes with respect to the Optic class ===*
32
33 None
34
35 *=== Name ===*
36
37 Special
38
39 **Note**: the curvature of any surface is positive for a concave surface
40 (coating inside the sphere).
41 Thus kurv*HRNorm/|kurv| always points to the center
42 of the sphere of the surface, as is the convention for the lineSurfInter of
43 geometry module. Same for AR.
44
45 ******* HRK > 0 and ARK > 0 ******* HRK > 0 and ARK < 0
46 ***** ******** and |ARK| > |HRK|
47 H***A H*********A
48 ***** ********
49 ******* *******
50
51 '''
52
53 Name = "Special"
54 - def __init__(self, Wedge = 0., Alpha = 0., X = 0., Y = 0., Z = 0.,
55 Theta = pi/2., Phi = 0., Diameter = 10.e-2,
56 HRr = .99, HRt = .01, ARr = .1, ARt = .9,
57 HRK = 0.01, ARK = 0, Thickness = 2.e-2,
58 N = 1.4585, KeepI = False,
59 RonHR = 0, TonHR = 0, RonAR = 0, TonAR = 0,
60 Ref = None):
61 '''Special optic initializer.
62
63 Parameters are the attributes.
64
65 Returns a special optic.
66
67 '''
68
69 TonHR = int(TonHR)
70 RonHR = int(RonHR)
71 TonAR = int(TonAR)
72 RonAR = int(RonAR)
73
74
75 N = float(N)
76 Wedge = float(Wedge)
77 Alpha = float(Alpha)
78 Theta = float(Theta)
79 Phi = float(Phi)
80 Diameter = float(Diameter)
81 Thickness = float(Thickness)
82 HRK = float(HRK)
83 ARK = float(ARK)
84 HRt = float(HRt)
85 HRr = float(HRr)
86 ARt = float(ARt)
87 ARr = float(ARr)
88
89
90 HRNorm = np.array([np.sin(Theta)*np.cos(Phi),
91 np.sin(Theta) * np.sin(Phi),
92 np.cos(Theta)], dtype = np.float64)
93
94 HRCenter = np.array([X, Y, Z], dtype = np.float64)
95
96
97 ARCenter = HRCenter\
98 - (Thickness + .5 * np.tan(Wedge) * Diameter) * HRNorm
99
100 a,b = geometry.basis(HRNorm)
101 ARNorm = -np.cos(Wedge) * HRNorm\
102 + np.sin(Wedge) * (np.cos(Alpha) * a\
103 + np.sin(Alpha) * b)
104
105 super(Special, self).__init__(ARCenter = ARCenter, ARNorm = ARNorm,
106 N = N, HRK = HRK, ARK = ARK, ARr = ARr, ARt = ARt, HRr = HRr, HRt = HRt,
107 KeepI = KeepI, HRCenter = HRCenter, HRNorm = HRNorm,
108 Thickness = Thickness, Diameter = Diameter,
109 Wedge = Wedge, Alpha = Alpha,
110 TonHR = TonHR, RonHR = RonHR, TonAR = TonAR, RonAR = RonAR,
111 Ref = Ref)
112
113
114 if settings.warning:
115 self.geoCheck("mirror")
116
118 '''Returns the list of lines necessary to print the object.'''
119 sph = geometry.rectToSph(self.HRNorm)
120 return ["Special: %s {" % str(self.Ref),
121 "TonHR, RonHR: %s, %s" % (str(self.TonHR), str(self.RonHR)),
122 "TonAR, RonAR: %s, %s" % (str(self.TonAR), str(self.RonAR)),
123 "Thick: %scm" % str(self.Thick/cm),
124 "Diameter: %scm" % str(self.Dia/cm),
125 "Wedge: %sdeg" % str(self.Wedge/deg),
126 "Alpha: %sdeg" % str(self.Alpha/deg),
127 "HRCenter: %s" % str(self.HRCenter),
128 "HRNorm: (%s, %s)deg" % (str(sph[0]/deg), str(sph[1]/deg)),
129 "Index: %s" %str(self.N),
130 "HRKurv, ARKurv: %s, %s" % (str(self.HRK), str(self.ARK)),
131 "HRr, HRt, ARr, ARt: %s, %s, %s, %s" \
132 % (str(self.HRr), str(self.HRt), str(self.ARr), str(self.ARt)),
133 "}"]
134