1 '''Defines the SetupComponent class for theia.'''
2
3
4
5
6
7
8
9
10
11
12 import numpy as np
13 from abc import ABCMeta, abstractmethod
14 from ..helpers.tools import formatter
17 '''
18
19 SetupComponent class.
20
21 This is an Abstract Base Class for all the components (optical or not) of
22 the setup. Its methods may be implemented in daughter classes.
23
24 *=== Attributes ===*
25 SetupCount: class attribute, counts setup components. [integer]
26 HRCenter: center of the principal face of the component in space.
27 [3D vector]
28 HRNorm: normal unitary vector the this principal face, supposed to point
29 outside the media. [3D vector]
30 Thick: thickness of the component, counted in opposite direction to
31 HRNorm. [float]
32 Dia: diameter of the component. [float]
33 Name: name of the component. [string]
34 Ref: reference string (for keeping track with the lab). [string]
35
36
37 '''
38
39 __metaclass__ = ABCMeta
40 SetupCount = 0
41 Name = "SetupComponent"
42
43 - def __init__(self, HRCenter, HRNorm, Ref, Thickness, Diameter):
44 '''SetupComponent initializer.
45
46 Parameters are the attributes of the object to construct.
47
48 Returns a setupComponent.
49
50 '''
51
52 if Ref is None:
53 Ref = "Set" + str(SetupComponent.SetupCount)
54
55 self.HRCenter = HRCenter
56 self.HRNorm = HRNorm
57 self.Thick = Thickness
58 self.Dia = Diameter
59 self.Ref = Ref
60
61 SetupComponent.SetupCount = SetupComponent.SetupCount + 1
62
64 '''String representation of the component, when calling print(object).
65
66 '''
67 return formatter(self.lines())
68
69 @abstractmethod
71 '''Method to return the list of strings to __str__.
72
73 Abstract (pure virtual) method.
74
75 '''
76 pass
77
78 @abstractmethod
80 '''Method to determine if component is hit by a beam.
81
82 Abstract (pure virtual) method.
83
84 '''
85 pass
86
87 @abstractmethod
88 - def hit(self, beam, order, threshold):
89 '''Compute the refracted and reflected beams after interaction.
90
91 Abstract (pure virtual) method.
92
93 '''
94
96 '''Move the component to (current position + (X, Y, Z)).
97
98 This version only takes care of the HRCenter, version of sub classes
99 take care of ARCenter if relevant.
100
101 X, Y, Z: components of the translation vector.
102
103 No return value.
104 '''
105 self.HRCenter = self.HRCenter + np.array([X, Y, Z], dtype = np.float64)
106