Esempio n. 1
0
def gaussian_beam(fwhm=10):
    """Display a Gaussian beam at the given fwhm.

    Parameters
    ----------
    fwhm : float
        Full width at half maximum (for intensity not amplitude) (µm).
    """
    w = fwhm / np.sqrt(2 * np.log(2))
    bpm = Bpm(1, 1, 1, 1, 1, 1, 1)
    bpm.x = np.linspace(-1.5*fwhm, 1.5*fwhm, 500)
    x = bpm.x
    plt.figure("Beam")
    plt.title("Width definition of a gaussian beam with FWHM=%s µm" % fwhm)
    plt.xlabel("x (µm)")
    plt.plot(x, bpm.gauss_light(fwhm, 0), label='field')
    plt.plot(x, (bpm.gauss_light(fwhm, 0))**2, label='intensity')
    plt.plot(x, [1/2]*x.size, '-.', label='1/2')
    plt.plot([fwhm/2]*x.size, np.linspace(0, 1, x.size),
             '--', label='fwhm/2')
    plt.plot(x, [np.exp(-1)]*x.size, '-.', label='1/e')
    plt.plot(x, [np.exp(-2)]*x.size, '-.', label='1/$e^2$')
    plt.plot([w]*x.size, np.linspace(0, 1, x.size),
             '--', label='$w_0$=%.2f' % w)
    plt.legend()
    plt.show()
Esempio n. 2
0
def guides_x():
    """Display a Gaussian guide, two super-Gaussian guides and a flat-top guide
    to illustrate the width definition."""
    width = 10
    bpm = Bpm(1, 1, 1, 1, 1, 1, 1)
    bpm.x = np.linspace(-15, 9.1, 500)
    x = bpm.x
    plt.figure("guide_x")
    plt.title("Different waveguides shape available")
    plt.plot(x, bpm.gauss_guide(width, 1)(x), label='Gaussian')
    plt.plot(x, bpm.gauss_guide(width, 4)(x), label='super-Gaussian P=4')
    plt.plot(x, bpm.gauss_guide(width, 10)(x), label='super-Gaussian P=10')
    plt.plot(x, bpm.squared_guide(width)(x), label='Flat-top')
    plt.plot([width/2]*x.size, np.linspace(0, 1, x.size), '--',
             label='width/2')
    plt.plot(x, [np.exp(-1)]*x.size, '-.', label='1/e')
    plt.legend()
    plt.show()