Beispiel #1
0
def displacedSqueezed(alpha, r, phi, trunc):
    r"""
    The displaced squeezed state :math:`\ket{\alpha,\zeta} = D(\alpha)S(r\exp{(i\phi)})\ket{0}`.
    """
    if r == 0:
        return coherentState(alpha, trunc)

    if alpha == 0:
        return squeezedState(r, phi, trunc)

    ph = np.exp(1j * phi)
    ch = cosh(r)
    sh = sinh(r)
    th = tanh(r)

    gamma = alpha * ch + np.conj(alpha) * ph * sh
    hermite_arg = gamma / np.sqrt(ph * np.sinh(2 * r) + 1e-10)

    # normalization constant
    N = np.exp(-0.5 * np.abs(alpha)**2 - 0.5 * np.conj(alpha)**2 * ph * th)

    coeff = np.array([(0.5 * ph * th)**(n / 2) / np.sqrt(fac(n) * ch)
                      for n in range(trunc)])
    vec = np.array([H(hermite_arg, row) for row in np.diag(coeff)])
    state = N * vec

    return state
def displacedSqueezed(r_d, phi_d, r_s, phi_s, trunc):
    r"""
    The displaced squeezed state :math:`\ket{\alpha,\zeta} = D(\alpha)S(r\exp{(i\phi)})\ket{0}`  where `alpha = r_d * np.exp(1j * phi_d)` and `zeta = r_s * np.exp(1j * phi_s)`.
    """
    if np.allclose(r_s, 0.0):
        return coherentState(r_d, phi_d, trunc)

    if np.allclose(r_d, 0.0):
        return squeezedState(r_s, phi_s, trunc)

    ph = np.exp(1j * phi_s)
    ch = cosh(r_s)
    sh = sinh(r_s)
    th = tanh(r_s)
    alpha = r_d * np.exp(1j * phi_d)

    gamma = alpha * ch + np.conj(alpha) * ph * sh
    hermite_arg = gamma / np.sqrt(ph * np.sinh(2 * r_s) + 1e-10)

    # normalization constant
    N = np.exp(-0.5 * np.abs(alpha) ** 2 - 0.5 * np.conj(alpha) ** 2 * ph * th)

    coeff = np.array([(0.5 * ph * th) ** (n / 2) / np.sqrt(fac(n) * ch) for n in range(trunc)])
    vec = np.array([H(hermite_arg, row) for row in np.diag(coeff)])
    state = N * vec

    return state
    def test_displaced_squeezed_state_fock(self, r_d, phi_d, r_s, phi_s, hbar,
                                           cutoff, tol):
        """test displaced squeezed state returns correct Fock basis state vector"""
        state = utils.displaced_squeezed_state(r_d,
                                               phi_d,
                                               r_s,
                                               phi_s,
                                               basis="fock",
                                               fock_dim=cutoff,
                                               hbar=hbar)
        a = r_d * np.exp(1j * phi_d)

        if r_s == 0:
            pytest.skip("test only non-zero squeezing")

        n = np.arange(cutoff)
        gamma = a * np.cosh(r_s) + np.conj(a) * np.exp(
            1j * phi_s) * np.sinh(r_s)
        coeff = np.diag((0.5 * np.exp(1j * phi_s) * np.tanh(r_s))**(n / 2) /
                        np.sqrt(fac(n) * np.cosh(r_s)))

        expected = H(gamma / np.sqrt(np.exp(1j * phi_s) * np.sinh(2 * r_s)),
                     coeff)
        expected *= np.exp(-0.5 * np.abs(a)**2 - 0.5 * np.conj(a)**2 *
                           np.exp(1j * phi_s) * np.tanh(r_s))

        assert np.allclose(state, expected, atol=tol, rtol=0)
Beispiel #4
0
def gauss_hermite(x, p):
    #The constants are only to make p[3] and p[4] correspond to a
    #rigorous definition of h3 and h4
    A = p[0] * (p[2] / sp.sqrt(2 * sp.pi))
    w = (x - p[1]) / p[2]
    h = H([1., 0., 0., p[3], p[4]])

    return A * sp.exp(-0.5 * w**2) * h(w)
Beispiel #5
0
def displaced_squeezed_state(a, r, phi, basis='fock', fock_dim=5, hbar=2.):
    r""" Returns the squeezed coherent state

    This can be returned either in the Fock basis,

    .. math::

        |\alpha,z\rangle = e^{-\frac{1}{2}|\alpha|^2-\frac{1}{2}\alpha^*2e^{i\phi}}\tanh{(r)}
        \sum_{n=0}^\infty\frac{\left[\frac{1}{2}e^{i\phi}\tanh(r)\right]^{n/2}}{\sqrt{n!\cosh(r)}}
        H_n\left[ \frac{\alpha\cosh(r)+\alpha^*e^{i\phi}\sinh(r)}{\sqrt{e^{i\phi}\sinh(2r)}} \right]|n\rangle

    where :math:`H_n(x)` is the Hermite polynomial, or as a Gaussian:

    .. math:: \mu = (\text{Re}(\alpha),\text{Im}(\alpha))

    .. math::
        :nowrap:

        \begin{align*}
            \sigma = R(\phi/2)\begin{bmatrix}e^{-2r} & 0 \\0 & e^{2r} \\\end{bmatrix}R(\phi/2)^T
        \end{align*}

    where :math:`z = re^{i\phi}` is the squeezing factor
    and :math:`\alpha` is the displacement.

    Args:
        a (complex): the displacement
        r (complex): the squeezing magnitude
        phi (float): the squeezing phase :math:`\phi`
        basis (str): if 'fock', calculates the initial state
            in the Fock basis. If 'gaussian', returns the
            vector of means and the covariance matrix.
        fock_dim (int): the size of the truncated Fock basis if
            using the Fock basis representation.
        hbar (float): (default 2) the value of :math:`\hbar` in the commutation
            relation :math:`[\x,\p]=i\hbar`.
    Returns:
        array: the squeezed coherent state
    """
    # pylint: disable=too-many-arguments
    if basis == 'fock':

        if r != 0:
            phase_factor = np.exp(1j * phi)
            ch = np.cosh(r)
            sh = np.sinh(r)
            th = np.tanh(r)

            gamma = a * ch + np.conj(a) * phase_factor * sh
            N = np.exp(-0.5 * np.abs(a)**2 -
                       0.5 * np.conj(a)**2 * phase_factor * th)

            coeff = np.diag([
                (0.5 * phase_factor * th)**(n / 2) / np.sqrt(fac(n) * ch)
                for n in range(fock_dim)
            ])

            vec = [
                H(gamma / np.sqrt(phase_factor * np.sinh(2 * r)), row)
                for row in coeff
            ]

            state = N * np.array(vec)

        else:
            state = coherent_state(a, basis='fock',
                                   fock_dim=fock_dim)  # pragma: no cover

    elif basis == 'gaussian':
        means = np.array([a.real, a.imag]) * np.sqrt(2 * hbar)
        state = [means, squeezed_cov(r, phi, hbar)]

    return state