Package theia :: Package optics :: Module optic
[hide private]
[frames] | no frames]

Source Code for Module theia.optics.optic

  1  '''Defines the Optic class for theia.''' 
  2   
  3  # Provides: 
  4  #   class Optic 
  5  #       __init__ 
  6  #       hitSide 
  7  #       collision 
  8  #       geoCheck 
  9   
 10  import numpy as np 
 11  from ..helpers import settings 
 12  from .component import SetupComponent 
 13   
14 -class Optic(SetupComponent):
15 ''' 16 17 Optic class. 18 19 This class is a base class for optics which may interact with Gaussian 20 beams and return transmitted and reflected beams (mirrors, lenses, etc.) 21 22 23 *=== Attributes ===* 24 SetupCount (inherited): class attribute, counts all setup components. 25 [integer] 26 OptCount: class attribute, counts optical components. [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 Name (inherited): name of the component. [string] 34 Ref (inherited): reference string (for keeping track with the lab). [string] 35 ARCenter: center of the 'chord' of the AR surface. [3D vector] 36 ARNorm: unitary normal to the 'chord' of the AR (always pointing 37 towards the outside of the component). [3D vector] 38 N: refraction index of the material. [float] 39 HRK, ARK: curvature of the HR, AR surfaces. [float] 40 HRr, HRt, ARr, ARt: power reflectance and transmission coefficients of 41 the HR and AR surfaces. [float] 42 KeepI: whether of not to keep data of rays for interference calculations 43 on the HR. [boolean] 44 45 **Note**: the curvature of any surface is positive for a concave surface 46 (coating inside the sphere). 47 Thus kurv*HRNorm/|kurv| always points to the center 48 of the sphere of the surface, as is the convention for the lineSurfInter of 49 geometry module. Same for AR. 50 51 ******* HRK > 0 and ARK > 0 ******* HRK > 0 and ARK < 0 52 ***** ******** and |ARK| > |HRK| 53 H***A H*********A 54 ***** ******** 55 ******* ******* 56 57 ''' 58 59 OptCount = 0 #counts the setup components 60
61 - def __init__(self, ARCenter, ARNorm, N, HRK, ARK, ARr, ARt, HRr, 62 HRt, KeepI, HRCenter, HRNorm, Thickness, Diameter, Name, Ref):
63 '''Optic base initializer. 64 65 Parameters are the attributes of the object to construct. 66 67 Returns an Optic. 68 69 ''' 70 # allow empty initializer 71 if Ref is None: 72 Ref = "Opt" + str(Optic.OptCount) 73 74 # initialize with input data 75 self.ARCenter = np.array(ARCenter, dtype = np.float64) 76 self.ARNorm = np.array(ARNorm, dtype = np.float64) 77 self.ARNorm = self.ARNorm/np.linalg.norm(self.ARNorm) 78 self.N = N 79 self.HRK = HRK 80 self.ARK = ARK 81 self.HRr = HRr 82 self.HRt = HRt 83 self.ARr = ARr 84 self.ARt = ARt 85 self.KeepI = KeepI 86 87 #call mother initializer 88 super(Optic, self).__init__(HRCenter = HRCenter, HRNorm = HRNorm, 89 Name = Name, Ref = Ref, Thickness = Thickness, 90 Diameter = Diameter) 91 Optic.OptCount = Optic.OptCount + 1
92
93 - def hitSide(self, beam):
94 '''Compute the daughter beams after interaction on Side at point. 95 96 Generic function: all sides stop beams. 97 98 beam: incident beam. [GaussianBeam] 99 100 Returns {'t': None, 'r': None} 101 102 ''' 103 if settings.info: 104 print "theia: Info: Reached leaf of tree by interaction ("\ 105 + beam.Ref + " on " + self.Ref + ', ' + 'Side).' 106 return {'t': None, 'r': None}
107
108 - def collision(self):
109 '''Determine whether the HR and AR surfaces intersect. 110 111 Returns True if there is an intersection, False if not. 112 113 ''' 114 115 if self.ARK <= 0. and self.HRK <= 0.: 116 # no collision if negative curvatures 117 return False 118 119 try: # the arcsin may fail because dia/2. > ROC 120 theta1 = np.arcsin(self.Dia * self.HRK/2.) #semi angles 121 122 if self.HRK == 0.: 123 apex1 = self.HRcenter 124 else: 125 apex1 = self.HRCenter - (1-np.cos(theta1))*self.HRNorm/self.HRK 126 127 except FloatingPointError: 128 #if it fails then the whole semisphere is in the mirror and apex 129 # is a radius away from Center. 130 apex1 = self.HRCenter - self.HRNorm/self.HRK 131 132 try: #same 133 theta2 = np.arcsin(self.Dia * self.ARK/2.) 134 135 if self.ARK == 0.: 136 apex2 = self.ARCenter 137 else: 138 apex2 = self.ARCenter - (1-np.cos(theta2))*self.ARNorm/self.ARK 139 140 except FloatingPointError: 141 apex2 = self.ARCenter - self.ARNorm/self.ARK 142 #vector from apex1 to apex2 143 vec = apex2 - apex1 144 145 return np.dot(vec, self.HRNorm) > 0.
146
147 - def geoCheck(self, word):
148 '''Makes geometrical checks on surfaces and warns when necessary. 149 150 ''' 151 if self.HRt + self.HRr > 1.: 152 print "theia: Warning: In " + word + " %s (%s) on HR, R + T > 1."\ 153 %(self.Name, self.Ref) 154 155 if self.ARt + self.ARr > 1.: 156 print "theia: Warning: In " + word + " %s (%s) on AR, R + T > 1."\ 157 %(self.Name, self.Ref) 158 159 if self.N < 1.: 160 print "theia: Warning: In " + word + " %s (%s), optical index < 1."\ 161 %(self.Name, self.Ref) 162 163 if self.HRK != 0. and np.abs(1./self.HRK) < self.Dia/2.: 164 print "theia: Warning: In " + word + " %s (%s), the diameter of " \ 165 %(self.Name, self.Ref)\ 166 +"the "+word+" exceeds the diameter of the HR surface."\ 167 168 if self.ARK != 0. and np.abs(1./self.ARK) < self.Dia/2.: 169 print "theia: Warning: In " + word + " %s (%s), the diameter of " \ 170 %(self.Name, self.Ref)\ 171 +"the "+word+" exceeds the diameter of the AR surface."\ 172 173 if self.collision(): 174 print "theia: Warning: In " + word + " %s (%s), HR and AR surfaces"\ 175 %(self.Name, self.Ref)\ 176 +" intersect."
177