def test_gauss_opt(): mat = RayTransferMatrix(1, 2, 3, 4) assert mat == Matrix([[1, 2], [3, 4]]) assert mat == RayTransferMatrix(Matrix([[1, 2], [3, 4]])) assert [mat.A, mat.B, mat.C, mat.D] == [1, 2, 3, 4] d, f, h, n1, n2, R = symbols('d f h n1 n2 R') lens = ThinLens(f) assert lens == Matrix([[1, 0], [-1 / f, 1]]) assert lens.C == -1 / f assert FreeSpace(d) == Matrix([[1, d], [0, 1]]) assert FlatRefraction(n1, n2) == Matrix([[1, 0], [0, n1 / n2]]) assert CurvedRefraction(R, n1, n2) == Matrix([[1, 0], [(n1 - n2) / (R * n2), n1 / n2]]) assert FlatMirror() == Matrix([[1, 0], [0, 1]]) assert CurvedMirror(R) == Matrix([[1, 0], [-2 / R, 1]]) assert ThinLens(f) == Matrix([[1, 0], [-1 / f, 1]]) mul = CurvedMirror(R) * FreeSpace(d) mul_mat = Matrix([[1, 0], [-2 / R, 1]]) * Matrix([[1, d], [0, 1]]) assert mul.A == mul_mat[0, 0] assert mul.B == mul_mat[0, 1] assert mul.C == mul_mat[1, 0] assert mul.D == mul_mat[1, 1] angle = symbols('angle') assert GeometricRay(h, angle) == Matrix([[h], [angle]]) assert FreeSpace(d) * GeometricRay(h, angle) == Matrix([[angle * d + h], [angle]]) assert GeometricRay(Matrix(((h, ), (angle, )))) == Matrix([[h], [angle]]) assert (FreeSpace(d) * GeometricRay(h, angle)).height == angle * d + h assert (FreeSpace(d) * GeometricRay(h, angle)).angle == angle p = BeamParameter(530e-9, 1, w=1e-3) assert streq(p.q, 1 + 1.88679245283019 * I * pi) assert streq(N(p.q), 1.0 + 5.92753330865999 * I) assert streq(N(p.w_0), Float(0.00100000000000000)) assert streq(N(p.z_r), Float(5.92753330865999)) fs = FreeSpace(10) p1 = fs * p assert streq(N(p.w), Float(0.00101413072159615)) assert streq(N(p1.w), Float(0.00210803120913829)) w, wavelen = symbols('w wavelen') assert waist2rayleigh(w, wavelen) == pi * w**2 / wavelen z_r, wavelen = symbols('z_r wavelen') assert rayleigh2waist(z_r, wavelen) == sqrt(wavelen * z_r) / sqrt(pi) a, b, f = symbols('a b f') assert geometric_conj_ab(a, b) == a * b / (a + b) assert geometric_conj_af(a, f) == a * f / (a - f) assert geometric_conj_bf(b, f) == b * f / (b - f) assert geometric_conj_ab(oo, b) == b assert geometric_conj_ab(a, oo) == a s_in, z_r_in, f = symbols('s_in z_r_in f') assert gaussian_conj(s_in, z_r_in, f)[0] == 1 / (-1 / (s_in + z_r_in**2 / (-f + s_in)) + 1 / f) assert gaussian_conj( s_in, z_r_in, f)[1] == z_r_in / (1 - s_in**2 / f**2 + z_r_in**2 / f**2) assert gaussian_conj( s_in, z_r_in, f)[2] == 1 / sqrt(1 - s_in**2 / f**2 + z_r_in**2 / f**2) l, w_i, w_o, f = symbols('l w_i w_o f') assert conjugate_gauss_beams( l, w_i, w_o, f=f)[0] == f * (-sqrt(w_i**2 / w_o**2 - pi**2 * w_i**4 / (f**2 * l**2)) + 1) assert factor(conjugate_gauss_beams( l, w_i, w_o, f=f)[1]) == f * w_o**2 * (w_i**2 / w_o**2 - sqrt(w_i**2 / w_o**2 - pi**2 * w_i**4 / (f**2 * l**2))) / w_i**2 assert conjugate_gauss_beams(l, w_i, w_o, f=f)[2] == f z, l, w_0 = symbols('z l w_0', positive=True) p = BeamParameter(l, z, w=w_0) assert p.radius == z * (pi**2 * w_0**4 / (l**2 * z**2) + 1) assert p.w == w_0 * sqrt(l**2 * z**2 / (pi**2 * w_0**4) + 1) assert p.w_0 == w_0 assert p.divergence == l / (pi * w_0) assert p.gouy == atan2(z, pi * w_0**2 / l) assert p.waist_approximation_limit == 2 * l / pi p = BeamParameter(530e-9, 1, w=1e-3, n=2) assert streq(p.q, 1 + 3.77358490566038 * I * pi) assert streq(N(p.z_r), Float(11.8550666173200)) assert streq(N(p.w_0), Float(0.00100000000000000))
def propagate_to_tube(init_h, init_theta, init_z): return FreeSpace(fT + fOb) * ThinLens(fOb) * origin( init_h, init_theta, init_z)
def propagate_to_sensor(init_h, init_theta, init_z): return FreeSpace(fT) * ThinLens(fT) * propagate_to_tube( init_h, init_theta, init_z)
# ####################Fiber and Laser parameters ########################### # mode field diameter =2*waist MFD = 3.4 * um p_coupl = BeamParameter(lambda_480, 0, w=MFD / 2) # ########################## Lens and geometry parameters ############################### f_outcoupling = sp.symbols('f0', real=True) # f_outcoupling = 7.5 * mm l_outcoupling = f_outcoupling + 0.1 * mm l_coll = 30 * 10**-3 l_EIT_cell = 120 * mm f2 = 150 * 10**-3 # ######### List of optical components ############### coupling_opt_list = [] coupling_opt_list.append(FreeSpace(l_outcoupling)) coupling_opt_list.append(ThinLens(f_outcoupling)) coupling_opt_list.append(FreeSpace(l_coll)) coupling_opt_list.append(ThinLens(f2)) coupling_opt_list.append(FreeSpace(l_EIT_cell)) # coupling_opt_list.append(ThinLens(t2)) # coupling_opt_list.append(FreeSpace(d1)) # ###### Calculate Beam Parameter p ################## p_final = calculateBeam(p_coupl, coupling_opt_list) # print(p_final.w) # ################# Further beam property calculations ####################### f_outcoupling_list = np.array([4.5 * mm, 6.24 * mm, 7.5 * mm, 8.2 * mm]) # l_coll_list = np.linspace(0.01, 0.2, 20) # func_w_0 = lambdify(f_outcoupling, p_final.w_0, 'numpy') # returns a numpy-ready function for w_0