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

Source Code for Module theia.optics.thinlens

  1  '''Defines the ThinLens class for theia.''' 
  2   
  3  # Provides: 
  4  #   class ThinLens 
  5  #       __init__ 
  6  #       lines 
  7   
  8  import numpy as np 
  9  from ..helpers import settings 
 10  from ..helpers.units import mm, cm, deg, pi 
 11  from ..helpers.geometry import rectToSph 
 12  from .lens import Lens 
 13   
14 -class ThinLens(Lens):
15 ''' 16 17 ThinLens class. 18 19 This class represents thin lenses, which are specified only by their focal 20 lengths, diameter, position and orientation. Only the initializer and the 21 printing distinguishes thin lenses (in implementation) from other lenses. 22 23 *=== Attributes ===* 24 SetupCount (inherited): class attribute, counts all setup components. 25 [integer] 26 OptCount (inherited): 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 (inherited): center of the 'chord' of the AR surface. [3D vector] 36 ARNorm (inherited): unitary normal to the 'chord' of the AR (always pointing 37 towards the outside of the component). [3D vector] 38 N (inherited): refraction index of the material. [float] 39 HRK, ARK (inherited): curvature of the HR, AR surfaces. [float] 40 HRr, HRt, ARr, ARt (inherited): power reflectance and transmission 41 coefficients of the HR and AR surfaces. [float] 42 KeepI (inherited): whether of not to keep data of rays for interference 43 calculations on the HR. [boolean] 44 Focal: Focal length of the lens. [float] 45 46 **Note**: the curvature of any surface is positive for a concave surface 47 (coating inside the sphere). 48 Thus kurv*HRNorm/|kurv| always points to the center 49 of the sphere of the surface, as is the convention for the lineSurfInter of 50 geometry module. Same for AR. 51 52 ******* HRK > 0 and ARK > 0 ******* HRK > 0 and ARK < 0 53 ***** ******** and |ARK| > |HRK| 54 H***A H*********A 55 ***** ******** 56 ******* ******* 57 58 ''' 59
60 - def __init__(self, Focal = 10.e-2, KeepI = False, Theta = pi/2., Phi = 0., 61 Diameter = 5.e-2, R = .1, T = .9, 62 X = 0., Y = 0., Z = 0., Name = "ThinLens", Ref = None):
63 '''ThinLens initializer. 64 65 Parameters are the attributes. 66 67 Returns a ThinLens. 68 69 ''' 70 # initialize focal and check data 71 self.Focal = float(Focal) 72 Theta = float(Theta) 73 Phi = float(Phi) 74 Diameter = float(Diameter) 75 R = float(R) 76 T = float(T) 77 78 #prepare for mother initializer 79 HRNorm = np.array([np.sin(Theta)*np.cos(Phi), 80 np.sin(Theta) * np.sin(Phi), 81 np.cos(Theta)], dtype = np.float64) 82 Center = np.array([X, Y, Z], dtype = np.float64) 83 N = 1.4548 84 85 # thin lens approximation of lensmaker's equation 86 HRK = - 0.5/(self.Focal*(N - 1.)) 87 ARK = HRK 88 ARNorm = - HRNorm 89 90 # calculate ARCenter, ARNorm and HRCenter with focal 91 if self.Focal >= 0.: 92 Thickness = settings.zero 93 else: 94 try: #arcsin might fail, if it does then the semi angle is pi/2 95 theta = np.arcsin(Diameter * HRK/2.) # half angle 96 except FloatingPointError: 97 theta = pi/2. 98 Thickness = settings.zero + 2.*(1.-np.cos(theta))/HRK 99 HRCenter = Center + Thickness*HRNorm/2. 100 ARCenter = Center - Thickness*HRNorm/2. 101 102 # initialize with lens mother initializer 103 super(Lens, self).__init__(ARCenter = ARCenter, ARNorm = ARNorm, N = N, 104 HRK = HRK, ARK = ARK, 105 ARr = R, ARt = T, HRr = R, HRt = T, KeepI = KeepI, 106 HRCenter = HRCenter, HRNorm = HRNorm, Thickness = Thickness, 107 Diameter = Diameter, Name = Name, Ref = Ref) 108 109 #warns on geometry 110 if settings.warning: 111 self.geoCheck("thinlens")
112
113 - def lines(self):
114 '''Returns the list of lines necessary to print the object. 115 ''' 116 ans = [] 117 ans.append("ThinLens: " + self.Name + " (" + str(self.Ref) + ") {") 118 ans.append("Diameter: " + str(self.Dia/cm) + "cm") 119 ans.append("Focal: " + str(self.Focal/mm) + "mm") 120 ans.append("Center: " + str(self.HRCenter)) 121 sph = rectToSph(self.HRNorm) 122 ans.append("Norm: (" + str(sph[0]/deg) + ', ' \ 123 + str(sph[1]/deg) + ')deg') 124 ans.append("R, T: " + str(self.HRr) + ", " + str(self.HRt) ) 125 ans.append("}") 126 127 return ans
128