-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcylmidfreq.py
More file actions
188 lines (159 loc) · 7.33 KB
/
cylmidfreq.py
File metadata and controls
188 lines (159 loc) · 7.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
from numpy import *
from matplotlib.pyplot import *
import PyTrace as PT
import pdb
import reconstruct
from conicsolve import primrad
import time
#Test out Wolter-I using L-L surfaces
def testwolter():
tstart = time.time()
#Set up beam
PT.subannulus(primrad(8425.,220.,8400.),primrad(8525.,220.,8400.),pi/6,1e6)
PT.transform(0,0,8800.,pi,0,0)
#Trace down to primary
PT.primaryLL(220.,8400.,8525.,8425.,pi/6,[-0.01,.0001],[0,0],[4,0])
PT.reflect()
PT.secondaryLL(220.,8400.,8375.,8275.,pi/6,0.001,0,0)
PT.reflect()
PT.flat()
print time.time()-tstart
#Trace source to test optic
def tracesource(num,cylNullX=0.,cylNullY=0.,cylNullZ=0.,\
cylNullRX=0.,cylNullRY=0.,cylNullRZ=0.):
#Set up source
PT.circularbeam(12.5,num)
#Go to cylindrical field lens
PT.transform(-cylNullX,-cylNullY,-cylNullZ,-cylNullRX,-cylNullRY,-cylNullRZ)
PT.LJ1653L2()
PT.transform(cylNullX,cylNullY,cylNullZ,cylNullRX,cylNullRY,cylNullRZ)
#Go to test optic
PT.transform(0,0,420.,0,0,0)
PT.flat()
return 0
#Trace ideal cylindrical test optic
def idealcylinder(testX=0.,testY=0.,testZ=0.,testRX=0.,testRY=0.,testRZ=0.):
PT.transform(-testX,-testY,-testZ,-testRX,-testRY,-testRZ)
PT.transform(0,0,-220.,0,0,0)
PT.cyl(220.)
PT.reflect()
PT.transform(testX,testY,testZ,testRX,testRY,testRZ)
PT.transform(0,0,0,pi,0,0) #Get rays going in +z direction
return 0
#Trace ideal Wolter primary
def idealprimary(testX=0.,testY=0.,testZ=0.,testRX=0.,testRY=0.,testRZ=0.):
PT.transform(-testX,-testY,-testZ,-testRX,-testRY,-testRZ)
PT.wolterprimtan(220.,8400.)
PT.reflect()
PT.transform(testX,testY,testZ,testRX,testRY,testRZ)
PT.transform(0,0,0,pi,0,0) #Get rays going in +z direction
PT.transform(0,0,220,0,0,0) #Reference frame at line focus
#Trace rippled Wolter primary
def rippleprimary(amp,freq,testX=0.,testY=0.,testZ=0.,testRX=0.,testRY=0.,testRZ=0.):
PT.transform(-testX,-testY,-testZ,-testRX,-testRY,-testRZ)
PT.woltersinetan(220.,8400.,amp,freq)
PT.reflect()
PT.transform(testX,testY,testZ,testRX,testRY,testRZ)
PT.transform(0,0,0,pi,0,0) #Get rays going in +z direction
PT.transform(0,0,220,0,0,0) #Reference frame at line focus
#Trace using a L-L deformed Wolter primary
def primaryLL(coeff,axial,az,testX=0.,testY=0.,testZ=0.,testRX=0.,testRY=0.,testRZ=0.):
PT.transform(-testX,-testY,-testZ,-testRX,-testRY,-testRZ)
PT.primaryLLtan(220.,8400.,8525.,8425.,pi/6.,coeff,axial,az)
PT.reflect()
PT.transform(testX,testY,testZ,testRX,testRY,testRZ)
PT.transform(0,0,0,pi,0,0) #Get rays going in +z direction
PT.transform(0,0,220,0,0,0) #Reference frame at line focus
#Trace from test optic - plane is assumed to be at point
#tangent to cylindrical optic, optical axis going in +z direction
def tracefromtest(cylFieldX=0.,cylFieldY=0.,cylFieldZ=0.,\
cylFieldRX=0.,cylFieldRY=0.,cylFieldRZ=0.,\
cylNullX=0.,cylNullY=0.,cylNullZ=0.,\
cylNullRX=0.,cylNullRY=0.,cylNullRZ=0.):
PT.transform(0,0,200.,0,0,0)#Go back to cylindrical null lens
PT.transform(cylNullX,cylNullY,cylNullZ,cylNullRX,cylNullRY,cylNullRZ)
PT.flat()
PT.LJ1653L2(reverse=True)
PT.transform(-cylNullX,-cylNullY,-cylNullZ,-cylNullRX,-cylNullRY,-cylNullRZ)
PT.transform(0,0,100.,0,0,0) #Go to spherical collimator lens
PT.flat()
PT.AC254_400_A(reverse=True)
PT.transform(0,0,331.29,0,0,0) #Go to cylindrical field lens
PT.flat()
PT.transform(cylFieldX,cylFieldY,cylFieldZ,cylFieldRX,cylFieldRY,cylFieldRZ)
PT.LJ1629L2()
PT.transform(-cylFieldX,-cylFieldY,-cylFieldZ,\
-cylFieldRX,-cylFieldRY,-cylFieldRZ)
PT.transform(0,0,314.250,0,0,0) #Go to field lens
PT.flat()
PT.AC508_200_A()
PT.transform(0,0,161.293,0,0,0) #Go to WFS plane
PT.flat()
#Compute wavefront of perfect primary with respect
#to perfect cylindrical reference - should see the cone
def computeidealinf(num):
#Trace reference wavefront
tracesource(num)
idealcylinder()
tracefromtest()
#Subtract all rays outside of WFS
ind = where(logical_and(abs(PT.y) < 7.3,abs(PT.x) < 7.3))
PT.vignette(ind=ind)
#Create reference WFS data
xang, yang, phase = reconstruct.southwellbin(PT.x,PT.y,PT.l,PT.m,\
.114,130,130)
#Trace conical mirror
tracesource(num)
primaryLL(.01,2.,0.)
tracefromtest()
#Subtract all rays outside of WFS
ind = where(logical_and(abs(PT.y) < 7.3,abs(PT.x) < 7.3))
PT.vignette(ind=ind)
#Create conical mirror WFS data
xang2, yang2, phase2 = reconstruct.southwellbin(PT.x,PT.y,PT.l,PT.m,\
.114,130,130)
#Construct phase and angle arrays for wavefront reconstruction
influence = PT.referencedWavefront(xang,yang,phase,xang2,yang2,phase2)
return influence
#Compute wavefront of rippled primary with respect
#to perfect cylindrical reference - should see the cone
#Handles cylindrical lens and test optic misalignments
def computerippleinf(num,amp,freq,testX=0.,testY=0.,testZ=0.,\
testRX=0.,testRY=0.,testRZ=0.,\
cylFieldX=0.,cylFieldY=0.,cylFieldZ=0.,\
cylFieldRX=0.,cylFieldRY=0.,cylFieldRZ=0.,\
cylNullX=0.,cylNullY=0.,cylNullZ=0.,\
cylNullRX=0.,cylNullRY=0.,cylNullRZ=0.):
#Trace reference wavefront
tracesource(num,cylNullX=cylNullX,cylNullY=cylNullY,cylNullZ=cylNullZ,\
cylNullRX=cylNullRX,cylNullRY=cylNullRY,cylNullRZ=cylNullRZ)
idealcylinder(testX=testX,testY=testY,testZ=testZ,\
testRX=testRX,testRY=testRY,testRZ=testRZ)
tracefromtest(cylNullX=cylNullX,cylNullY=cylNullY,cylNullZ=cylNullZ,\
cylNullRX=cylNullRX,cylNullRY=cylNullRY,cylNullRZ=cylNullRZ,\
cylFieldX=cylFieldX,cylFieldY=cylFieldY,cylFieldZ=cylFieldZ,\
cylFieldRX=cylFieldRX,cylFieldRY=cylFieldRY,cylFieldRZ=cylFieldRZ)
#Subtract all rays outside of WFS
ind = where(logical_and(abs(PT.y) < 7.3,abs(PT.x) < 7.3))
PT.vignette(ind=ind)
#Create reference WFS data
xang, yang, phase = reconstruct.southwellbin(PT.x,PT.y,PT.l,PT.m,\
.114,130,130)
#Trace conical mirror
tracesource(num,cylNullX=cylNullX,cylNullY=cylNullY,cylNullZ=cylNullZ,\
cylNullRX=cylNullRX,cylNullRY=cylNullRY,cylNullRZ=cylNullRZ)
rippleprimary(amp,freq,testX=testX,testY=testY,testZ=testZ,\
testRX=testRX,testRY=testRY,testRZ=testRZ)
tracefromtest(cylNullX=cylNullX,cylNullY=cylNullY,cylNullZ=cylNullZ,\
cylNullRX=cylNullRX,cylNullRY=cylNullRY,cylNullRZ=cylNullRZ,\
cylFieldX=cylFieldX,cylFieldY=cylFieldY,cylFieldZ=cylFieldZ,\
cylFieldRX=cylFieldRX,cylFieldRY=cylFieldRY,cylFieldRZ=cylFieldRZ)
#Subtract all rays outside of WFS
ind = where(logical_and(abs(PT.y) < 7.3,abs(PT.x) < 7.3))
PT.vignette(ind=ind)
#Create conical mirror WFS data
xang2, yang2, phase2 = reconstruct.southwellbin(PT.x,PT.y,PT.l,PT.m,\
.114,130,130)
#Construct phase and angle arrays for wavefront reconstruction
influence = PT.referencedWavefront(xang,yang,phase,xang2,yang2,phase2)
return influence