Пример #1
0
def main():
    N = 2**7

    if N**2 * 128 / 8 * 1e-6 > 2000:
        raise RuntimeError('Wow wow wow wow..')

    a = 7e-3

    rs, ps = hankel.rp_space(N, a)
    Y = hankel.kernel(N)

    w = a / 3
    lda = 852e-9
    zr = np.pi * w**2 / lda
    E = np.exp(-rs**2 / w**2, dtype=np.complex128)

    f = 0.2

    dx = a / N
    print('Condition lentille a 2w : {:.2e} > 1'.format(N * lda * f /
                                                        (2 * a**2)))
    print('Condition longue propagation : {:.2e} > 1'.format(
        N * dx * np.sqrt(4 * dx**2 - lda**2) / 2 / lda / f))

    phase_shift_prop = np.pi * lda * f * ps**2
    phase_shift_lens = 2 * np.pi / lda * f * (1 + 0.5 * rs**2 / f**2)

    def propagate(E, d):
        wf = np.pi * lda * d * ps**2
        return Y.dot(Y.dot(E) * np.exp(-1j * wf))

    def lens(E, f):
        wf = 2 * np.pi / lda * f * (1 + 0.5 * rs**2 / f**2)
        return E * np.exp(-1j * wf)

    t = time()
    E1 = propagate(E, f)
    E2 = lens(E1, f)
    E3 = propagate(E2, f)
    E4 = propagate(E3, f)
    E5 = lens(E4, f)
    E_final = propagate(E5, f)
    print(time() - t)

    plt.figure()
    plt.plot(rs, abs(E)**2)
    plt.plot(rs, abs(E_final)**2)

    plt.show()
def main():
    N = 2**12
    a = 7e-3

    rs, ps = hankel.rp_space(N, a)
    Y = hankel.kernel(N)

    w = a / 10
    lda = 852e-9
    zr = np.pi * w**2 / lda
    E = np.exp(-rs**2 / w**2)

    d = 1

    phase_shift = np.pi * lda * d * ps**2

    t = time()
    E_prop = Y.dot(Y.dot(E) * np.exp(-1j * phase_shift))
    print(time() - t)

    P = ss.diags(np.exp(-1j * phase_shift))
    M = Y.dot(P.dot(Y))

    t = time()
    E_prop2 = M.dot(E)
    print(time() - t)

    w_th = w * np.sqrt(1 + (d / zr)**2)
    E_th = w / w_th * np.exp(-rs**2 / w_th**2)
    bt = Y.dot(E)

    plt.figure()
    plt.plot(ps, abs(bt))

    plt.figure()
    plt.plot(rs, abs(E)**2)
    plt.plot(rs, abs(E_prop)**2)
    plt.plot(rs, abs(E_prop2)**2)
    plt.plot(rs, abs(E_th)**2, linestyle='--')

    plt.show()
    field = total_field(fields, phase)
    return np.trapz(x=rs, y=rs * abs(field) ** 2)

lda = 852e-9

fig, ax_spectrum = plt.subplots()
fig, ax_mode = plt.subplots()

for config in configs :



    w = config['waist']
    a = 4*w

    rs, ps = hankel.rp_space(N, a)
    H_Kernel = hankel.kernel(N)


    zr = np.pi * w ** 2 / lda
    E = np.exp(-rs ** 2 / w ** 2, dtype=np.complex128)
    E /= np.sqrt(np.trapz(x=rs, y=rs * abs(E) ** 2))



    r_optic = 25e-3
    orders = config['orders']
    coeffs = config['coeffs']
    phase_map = zernike.zernike_combination(
        orders,
        np.array(coeffs),