-
Notifications
You must be signed in to change notification settings - Fork 1
/
two_gaussian_lens_array_harmonic_fresh.py
345 lines (222 loc) · 10.2 KB
/
two_gaussian_lens_array_harmonic_fresh.py
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 7 10:17:34 2020
@author: similiarities
"""
# Gaussian beam profile (focused by lens 1) which passes lens2 close to
# focal position. The resulting beamwaist and new focal position
import math
import numpy as np
import matplotlib.pyplot as plt
class Gaussian_second_lens:
def __init__(self, w0, lambdaL, defocusing_range, Denting, N):
print('xxxxxxxx run with Denting: ' +str(Denting) + 'xxxxxxx')
self.w0 = w0
self.w0_fundamental = w0
self.N = N
self.lambdaL = lambdaL
self.z = np.arange(-defocusing_range, defocusing_range, 0.01)
self.v_array = np.zeros(len(self.z))
self.w_new = np.zeros(len(self.z))
#print(self.z)
self.Denting = Denting
self.f_array = np.zeros(len(self.z))
self.wz_array = np.zeros(len(self.z))
self.wz_array_N = np.zeros(len(self.z))
self.denting_array = np.zeros(len(self.z))
self.zr = self.Rayleigh_length()
print(self.zr)
self.Radius_array = np.zeros(len(self.z))
self.beamdivergence_array = np.zeros(len(self.z))
self.wz = float
self.f = float
self.q = self.q_initial()
self.N_array = np.arange(1, 32, 1)
self.focal_lens_of_wz()
def q_initial(self):
self.q = (self.w0**2)*math.pi/(self.lambdaL/self.N)
print(self.N, self.q)
return self.q
def diffraction_limit(self):
w0 = 1500*self.lambdaL*2/(self.N*math.pi*60)
print('diff limit initial focal length', w0)
def beamwaist_of_z(self):
self.wz_array[::] = self.w0_fundamental *(1+(self.z[::]/self.zr)**2)**0.5
print('initial beamwaist:', self.w0_fundamental)
plt.figure(11)
plt.plot(self.z, self.wz_array, label = 'fundamental')
plt.legend()
return self.wz_array
def beam_waist_of_z_harmonic(self):
zr = math.pi*self.w0**2/(self.lambdaL*self.N)
self.wz_array_N[::] = self.w0*(1+(self.z[::]/zr)**2)**0.5
name = 'N: ' + f'{self.N}'
plt.figure(11)
plt.plot(self.z, self.wz_array_N, label = name)
plt.legend()
return self.wz_array_N
def Rayleigh_length(self):
Ry = math.pi*(self.w0_fundamental**2)/(self.lambdaL)
print('Rayleigh length with which Denting scales: ' , Ry )
return Ry
def Radius_of_lens(self):
return (4*(self.Denting**2)+self.w0**2)/(8*self.Denting)
def Radius_of_lens_and_beamwaist(self):
self.denting_array[::] = self.Denting * ((self.w0_fundamental)/(self.wz_array[::]))
self.Radius_array[::] = (4*(self.denting_array[::]**2) + (self.wz_array[::]**2))/(8*self.denting_array[::])
return self.Radius_array
def focal_lens(self, Radius):
return Radius/2
def focal_lens_of_wz(self):
self.beamwaist_of_z()
self.Radius_of_lens_and_beamwaist()
self.f_array[::] = self.Radius_array[::]/2
name1 = 'f(w(z)), Dmax:' +str(self.Denting)
plt.figure(3)
plt.plot(self.z, self.f_array, label = name1)
plt.xlabel('defocusing [mm]')
plt.ylabel('focal length [mm]')
plt.legend()
return self.f_array
def calculate_new_focal_position_constant_focal_length(self, z):
# this often named v
self.f = self.focal_lens(self.Radius_of_lens())
AA = (self.q**2/self.f)-z*(1-z/self.f)
BB = (self.q**2/self.f**2) + (1-z/self.f)**2
return AA/BB
def calculate_new_focal_position_beamwaist_dependent(self, index):
i = index
AA = (self.q**2/self.f_array[i])-self.z[i]*(1-self.z[i]/self.f_array[i])
BB = (self.q**2/self.f_array[i]**2) + (1-self.z[i]/self.f_array[i])**2
return AA/BB
def calulate_beam_waist_single_value(self, index):
v_single = self.calculate_new_focal_position_beamwaist_dependent(index)
new = ((1 - v_single/self.f_array[index])**2) + (1 /self.q **2) *(self.z[index]+v_single *(1-(self.z[index]/self.f_array[index])))**2
new = self.w0*(new*0.5)
return new
def calculate_div_from_w0_new(self, w_new):
return (self.lambdaL/(self.N *math.pi *w_new))
def create_v_array_constant_focal_lens(self):
self.f_array[::] = self.f
for i in range(0, len(self.z)):
self.v_array[i] = self.calculate_new_focal_position_constant_focal_length(self.z[i])
name = 'f contst.: ' + str(round(self.f, 3))
plt.figure(1)
plt.plot(self.z, self.v_array, label = name)
plt.xlabel('defocusing [mm]')
plt.ylabel('new focal position [mm]')
plt.legend()
plt.figure(2)
name2 = 'f: ' + str(round(self.f,3))
plt.hlines(self.f, self.z[0], self.z[-1], label = name2)
plt.xlabel('defocusing [mm]')
plt.ylabel('focal length [mm]')
plt.legend()
return self.v_array
def create_v_array_z_dependent_focal_lens(self):
for i in range(0, len(self.z)):
self.v_array[i] = self.calculate_new_focal_position_beamwaist_dependent(i)
name1 = 'f(w(z)) for Dmax: ' +str(self.Denting) + 'N: ' + str(self.N)
name2 = 'f(w(z)) for Dmax: ' +str(self.Denting)
plt.figure(1)
plt.plot(self.z, self.v_array, label = name1)
plt.xlabel('defocusing [mm]')
plt.ylabel('new focal position [mm]')
plt.legend()
plt.figure(2)
plt.plot(self.z, self.f_array, label = name2)
plt.ylabel('focal lens [mm]')
plt.xlabel('defocusing [mm]')
plt.legend()
return self.v_array
def calculate_new_beamwaist(self):
self.create_v_array_z_dependent_focal_lens()
#print(self.f, 'insert in wnew')
self.w_new[::] = ((1-self.v_array[::]/self.f_array[::])**2)+(1/self.q**2)*(self.z[::]+self.v_array[::]*(1-(self.z[::]/self.f_array[::])))**2
self.w_new[::] = self.w0*(self.w_new[::]*0.5)
plt.figure(4)
name = 'new beamwaist of f(w(z)), D0: ' +str(self.Denting) + 'N: ' + str(self.N)
plt.plot(self.z, self.w_new, label = name)
plt.xlabel('defocusing [mm]')
plt.ylabel('w_new(z) [mm]')
plt.legend()
return self.w_new
def switch_sign(self, var):
return -var
def resulting_beam_divergence(self):
self.beamdivergence_array[::] = (self.lambdaL/(self.N *math.pi*self.w_new[::]))
name = 'Theta Dmax:' +str(self.Denting) + 'N: ' + str(self.N)
plt.figure(6)
plt.plot(self.z, self.beamdivergence_array, label = name)
plt.yscale('log')
plt.xlabel('defocusing [mm]')
plt.ylabel('[rad]')
plt.legend()
def resulting_divergence_over_N(self, z):
index = list(zip(*np.where(self.z >= z)))
index = index[0]
print(index, self.z[index])
result_w0_N = np.zeros(len(self.N_array))
result_div_N = np.zeros(len(self.N_array))
for x in range(0,len(self.N_array)):
self.N = self.N_array[x]
self.q_initial()
result_w0_N[x] = self.calulate_beam_waist_single_value(index)
result_div_N[x] =self.calculate_div_from_w0_new(result_w0_N[x])
name1 = 'z: ' + str(z) +'[mm] lens+'
plt.figure(10)
plt.plot(self.N_array, result_w0_N, label = name1)
plt.xlabel('N')
plt.ylabel('w0(N)* in [mm]')
plt.legend()
plt.figure(9)
plt.plot(self.N_array, result_div_N, label = name1, marker = '.')
plt.xlabel('N')
plt.ylabel('div in [rad]')
plt.legend()
plt.yscale ('log')
self.f_array[::] = self.switch_sign(self.f_array[::])
for x in range(0,len(self.N_array)):
self.N = self.N_array[x]
self.q_initial()
result_w0_N[x] = self.calulate_beam_waist_single_value(index)
result_div_N[x] =self.calculate_div_from_w0_new(result_w0_N[x])
name2 = 'z: ' + str(z) +'[mm] lens-'
plt.figure(20)
plt.plot(self.N_array, result_w0_N, label = name2, marker = 'o')
plt.xlabel('N')
plt.ylabel('w0(N)* in [mm]')
plt.legend()
plt.figure(21)
plt.plot(self.N_array, result_div_N, label = name2, marker = 'o')
plt.xlabel('N')
plt.ylabel('div in [rad]')
plt.legend()
plt.yscale ('log')
# zip the 2 arrays to get the exact coordinates
# index = list(zip(index[0])
Test = Gaussian_second_lens(0.012, 0.0008, 5, 0.0001, 1)
#Test.beamwaist_of_z()
#Test.Radius_of_lens_and_beamwaist()
#Test.create_v_array_z_dependent_focal_lens()
#Test.q_harmonic()
Test.calculate_new_beamwaist()
Test.resulting_beam_divergence()
Test2 = Gaussian_second_lens(0.012, 0.0008, 5, 0.0001, 25)
#Test.q_harmonic()
Test2.calculate_new_beamwaist()
Test2.resulting_beam_divergence()
Test2.beam_waist_of_z_harmonic()
Test3 = Gaussian_second_lens(0.012, 0.0008, 5, 0.0001, 12)
Test3.diffraction_limit()
#Test.q_harmonic()
Test3.calculate_new_beamwaist()
Test3.resulting_beam_divergence()
Test3.beam_waist_of_z_harmonic()
Test3.resulting_divergence_over_N(0.0)
Test3.resulting_divergence_over_N(1.0)
Test3.resulting_divergence_over_N(2.0)
Test3.resulting_divergence_over_N(-1.0)
Test3.resulting_divergence_over_N(-2.0)
Test3.resulting_divergence_over_N(-2.5)
Test3.resulting_divergence_over_N(2.5)