示例#1
0
handler = fc.cavityhandler.CavityHandler(cavity, radial=True)

logging.info('Cavity finesse : {:.0f}'.format(int(cavity.finess)))
logging.info('Expected gain : {:.1f}'.format((1 - R) / (1 - Tl * R)**2))
"""Defining the input field
"""
lda = 852e-9
win = 6e-3
x0, N = 7 * win, 2**12
x = np.linspace(-x0, x0, N)
x_transverse = 0
E_ref = (hg_efield(
    n=0,
    lda=lda,
    x=x,
    w=win,
    amplitude=1.0,
    x0=x_transverse,
    normalize_power=True,
    radial=handler.radial,
) + 0 * hg_efield(
    n=1,
    lda=lda,
    x=x,
    w=win,
    amplitude=1.0,
    x0=0,
    normalize_power=True,
    radial=handler.radial,
))
# E_ref = FD_efield(
#     x=x, R0=5e-3, b=16, amplitude=1.0, x0=0,
# cavity.append(fc.interfaces.FreeSpace(183.81671435e-3 + 2e-3))
cavity.append(fc.interfaces.FreeSpace(183.84e-3 + 2e-3))
cavity.append(fc.interfaces.FlatMirror(R))

handler = CavityHandler(cavity, radial=False)
logging.info('Expected gain : {:.1f}'.format((1 - R) / (1 - TL * R)**2))
""" Defining the input field """
lda = 852e-9
win = 2e-3
x0, N = 10 * win, 2**15
x = np.linspace(-x0, x0, N)
x_trans = 0
E_ref = (1 * hg_efield(n=0,
                       x=x,
                       w=win,
                       amplitude=1.0,
                       x0=x_trans,
                       normalize_power=True,
                       lda=lda,
                       radial=handler.radial) +
         0 * hg_efield(n=1,
                       x=x,
                       w=win,
                       amplitude=1.0,
                       x0=0,
                       normalize_power=True,
                       lda=lda,
                       radial=handler.radial))
# E_ref = fd_efield(x=x, R0=5e-3, b=16, amplitude=1.0, x0=0,
#         normalize_power=True, lda=lda, radial=handler.radial)
E_ref.radial = handler.radial
E_ref.E /= np.sqrt(E_ref.P)
# cavity.S1.distance -= 1e-3
phase_shifter = fc.interfaces.PhaseMask(0)
cavity.insert(-1, phase_shifter)

handler = fc.CavityHandler(cavity, radial=True)
""" Defining the input field """
lda = 852e-9
win = 6.8e-3
x0, N = 4 * win, 2**12
x = np.linspace(-x0, x0, N)
E_ref = efields.hg_efield(
    n=0,
    x=x,
    w=win,
    amplitude=1.0,
    x0=0,
    normalize_power=True,
    lda=lda,
    radial=handler.radial,
    prop_type='evanescent',
)

# E_ref = E_ref.propagated(-200)
# E_ref.plot()

fig_modes, ax_modes = plt.subplots()
fig_modes.canvas.set_window_title('Modes')

fig_spectra, ax_spectra = plt.subplots()
fig_spectra.canvas.set_window_title('Spectra {:.1f} mm'.format(win * 1e3))
# cavity = cavities.PlanePlaneCavity(R1=0.98, R2=0.98, L=f)
handler = CavityHandler(cavity, radial=True)
logging.info('Expected gain : {:.1f}'.format((1 - R) / (1 - TL * R)**2))
""" Defining the input field """
lda = 852e-9
win = 5.0e-3  #0.23e-3
x0, N = 5 * win, 2**12
x = np.linspace(-x0, x0, N)
x_trans = 0
E_ref = (
    1 * hg_efield(
        n=0,
        x=x,
        w=win,
        amplitude=1.0,
        x0=x_trans,
        normalize_power=True,
        lda=lda,
        radial=handler.radial,
        prop_type='fresnel',
    )
    # 0 * hg_efield(
    #         n=1, x=x, w=win, amplitude=1.0, x0=0,
    #         normalize_power=True, lda=lda, radial=handler.radial
    # )
)
# E_ref = fd_efield(x=x, R0=5e-3, b=16, amplitude=1.0, x0=0,
#         normalize_power=True, lda=lda, radial=handler.radial)
E_ref.E /= np.sqrt(E_ref.P)
# E_ref = E_ref.tilt(0).propagate(20)
import numpy as np
import matplotlib.pyplot as plt

from efield.efields import hg_efield
from fftcavity1d.interfaces import ParabolicLens, SphericalLens

lens = ParabolicLens(f=20e-2)

w = 5e-3
num = 2**14
x = np.linspace(-7 * w, 7 * w, num)

E = hg_efield(0, x, w, prop_type='fresnel')

E_1 = lens(E.propagated(lens.f)).propagated(lens.f)
E_out = lens(E_1.propagated(lens.f)).propagated(lens.f)

fig, (axI, axP) = E.plot(
    normalize=True,
    label='in',
)
E_1.plot(fig=fig, normalize=True, label='1')
E_out.plot(fig=fig, normalize=True, label='out')

rel_phase = np.unwrap(E.phase - E_out.phase)

_, ax = plt.subplots()
# ax.plot(x, 1 - abs(E_out.E/E.E))
ax.plot(x, rel_phase - rel_phase[num // 2])

ax2 = ax.twinx()
示例#6
0
from fftcavity1d.spectrum import Spectrum
import image_helpers as ih
import zernike

N = 2**11

w = 0.25e-3
a = 5 * w
rs, ps = hankel.rp_space(N, a)
Y = hankel.kernel(N)
lda = 852e-9
zr = np.pi * w**2 / lda

ef = efields.hg_efield(
    1,
    rs,
    w,
    lda=lda,
)
ef = efields.lg_efield(
    2,
    rs,
    w,
    lda=lda,
)
E = ef.E

# E = np.exp(-rs ** 2 / w ** 2, dtype=np.complex128)

E /= np.sqrt(np.trapz(x=rs, y=rs * abs(E)**2))

f = 0.2
示例#7
0
def do_the_thing(waist, d2_ref):
    """ Defining the input field """
    lda = 852e-9
    win = waist
    x0, N = 4 * win, 2**13
    x = np.linspace(-x0, x0, N)
    E_ref = efields.hg_efield(
        n=0,
        x=x,
        w=win,
        amplitude=1.0,
        x0=0,
        normalize_power=True,
        lda=lda,
        radial=handler.radial,
        # prop_type='evanescent',
        prop_type='evanescent',
    )

    fig_modes, (ax_modes_1, ax_modes_2) = plt.subplots(2,
                                                       1,
                                                       sharex=True,
                                                       figsize=(6, 6))
    fig_modes.canvas.set_window_title('Modes {:.1f} mm waist'.format(waist *
                                                                     1e3))
    ax_modes_1.set_title('Modes with {:.1f} mm input waist'.format(waist *
                                                                   1e3))
    ax_modes_1.set_ylabel('Intensity (au)')
    ax_modes_2.set_ylabel('Intensity (au)')
    ax_modes_2.set_xlabel('x (mm)')

    fig_spectra, (ax_spectra_1, ax_spectra_2) = plt.subplots(2,
                                                             1,
                                                             sharex=True,
                                                             figsize=(6, 6))
    fig_spectra.canvas.set_window_title('Spectra {:.1f} mm waist'.format(
        waist * 1e3))
    ax_spectra_1.set_title('Resonances with {:.1f} mm input waist'.format(
        waist * 1e3))
    ax_spectra_1.set_ylabel('Optical Gain')
    ax_spectra_2.set_ylabel('Optical Gain')
    ax_spectra_2.set_xlabel('Frequency (MHz)')

    center_phase = None
    for displacement in np.linspace(0, 6 * 25e-6, 7):
        label = '{:.1f} um'.format(displacement * 1e6)
        cavity.S2.distance = f + displacement + d2_ref
        phase_shifter.phase_map = -2 * np.pi / lda * displacement

        handler.calculate_fields(E_ref, int(2 * finess))
        resonance_phases = handler.compute_resonances(n_res=1)
        if center_phase is None:
            center_phase = resonance_phases[0]

        phases, spectrum = handler.spectrum.spectrum(focus_width=1 / 5,
                                                     num_focused=200)

        ax_spectra_1.plot((phases - center_phase) / (2 * np.pi) * 375,
                          spectrum,
                          label=label)

        mode = handler.efield_at(resonance_phases[0])
        ax_modes_1.plot(mode.x * 1e3, mode.I, label=label)

        # Other direction
        label = '-{:.1f} um'.format(displacement * 1e6)
        cavity.S2.distance = f - displacement + d2_ref
        phase_shifter.phase_map = +2 * np.pi / lda * displacement

        handler.calculate_fields(E_ref, int(2 * finess))
        resonance_phases = handler.compute_resonances(n_res=1)

        phases, spectrum = handler.spectrum.spectrum(focus_width=1 / 4,
                                                     num_focused=200)

        ax_spectra_2.plot((phases - center_phase) / (2 * np.pi) * 375,
                          spectrum,
                          label=label)

        mode = handler.efield_at(resonance_phases[0])
        ax_modes_2.plot(mode.x * 1e3, mode.I, label=label)

    ax_spectra_1.legend()
    ax_spectra_2.legend()
    ax_modes_1.legend()
    ax_modes_2.legend()

    fig_modes.tight_layout()
    fig_spectra.tight_layout()
interfaces.append(fc.interfaces.FreeSpace(179.82e-3))

# interfaces.append(fc.interfaces.FreeSpace(200e-3))
# interfaces.append(fc.interfaces.ParabolicLens(f=200e-3, T=TL))
# interfaces.append(fc.interfaces.FreeSpace(200e-3))
""" Defining the input field """
lda = 852e-9
win = 1e-3
x0, N = 6 * win, 2**14
x = np.linspace(-x0, x0, N)
E_ref = hg_efield(
    n=0,
    x=x,
    w=win,
    amplitude=1.0,
    x0=0,
    normalize_power=True,
    lda=lda,
    radial=False,
    prop_type='evanescent',
)

# E_once = propagate_through(interfaces, E_ref)
fig, ax = plt.subplots()
E_rt = round_trip(interfaces, E_ref)
E_rt2 = round_trip(interfaces, E_rt)
E_rt100 = nth_round_trip(interfaces, E_ref, 100)

fig, (axI, axP) = efield.EField.create_figure()
E_ref.plot(fig, normalize=True, label='ref field')
# E_once.plot(fig, normalize=True, label='once propagated')