def test_enr_destory_double():
    "Excitation-number-restricted state space: two excitations"
    a1, a2 = enr_destroy([4, 4], 2)
    assert_(a1.shape == [6, 6])

    a1, a2, a3 = enr_destroy([4, 4, 4], 2)
    assert_(a1.shape == [10, 10])

    a1, a2, a3, a4 = enr_destroy([4, 4, 4, 4], 2)
    assert_(a1.shape == [15, 15])
Esempio n. 2
0
def test_enr_destory_double():
    "Excitation-number-restricted state space: two excitations"
    a1, a2 = enr_destroy([4, 4], 2)
    assert_(a1.shape == (6, 6))

    a1, a2, a3 = enr_destroy([4, 4, 4], 2)
    assert_(a1.shape == (10, 10))

    a1, a2, a3, a4 = enr_destroy([4, 4, 4, 4], 2)
    assert_(a1.shape == (15, 15))
def test_enr_destory_single():
    "Excitation-number-restricted state space: single excitations"
    a1, a2 = enr_destroy([4, 4], 1)
    assert_(a1.shape == [3, 3])

    a1, a2, a3 = enr_destroy([4, 4, 4], 1)
    assert_(a1.shape == [4, 4])

    a1, a2, a3, a4 = enr_destroy([4, 4, 4, 4], 1)
    assert_(a1.shape == [5, 5])
Esempio n. 4
0
def test_enr_destory_single():
    "Excitation-number-restricted state space: single excitations"
    a1, a2 = enr_destroy([4, 4], 1)
    assert_(a1.shape == (3, 3))

    a1, a2, a3 = enr_destroy([4, 4, 4], 1)
    assert_(a1.shape == (4, 4))

    a1, a2, a3, a4 = enr_destroy([4, 4, 4, 4], 1)
    assert_(a1.shape == (5, 5))
def test_enr_destory_full():
    "Excitation-number-restricted state-space: full state space"
    a1, a2 = enr_destroy([4, 4], 4**2)
    b1, b2 = tensor(destroy(4), identity(4)), tensor(identity(4), destroy(4))

    assert_(a1 == b1)
    assert_(a2 == b2)
Esempio n. 6
0
def test_enr_destory_full():
    "Excitation-number-restricted state-space: full state space"
    a1, a2 = enr_destroy([4, 4], 4**2)
    b1, b2 = tensor(destroy(4), identity(4)), tensor(identity(4), destroy(4))

    assert_(a1 == b1)
    assert_(a2 == b2)
 def test_space_size_reduction(self, dimensions, n_excitations):
     test_operators = qutip.enr_destroy(dimensions, n_excitations)
     expected_size = _n_enr_states(dimensions, n_excitations)
     expected_shape = (expected_size, expected_size)
     for test in test_operators:
         assert test.shape == expected_shape
         assert test.dims == [dimensions, dimensions]
 def test_no_restrictions(self, dimensions):
     """
     Test that the restricted-excitation operators are equal to the standard
     operators when there aren't any restrictions.
     """
     test_operators = qutip.enr_destroy(dimensions, sum(dimensions))
     a = [qutip.destroy(n) for n in dimensions]
     iden = [qutip.qeye(n) for n in dimensions]
     for i, test in enumerate(test_operators):
         expected = qutip.tensor(iden[:i] + [a[i]] + iden[i + 1:])
         assert test == expected
         assert test.dims == [dimensions, dimensions]
def test_fock_state(dimensions, n_excitations):
    """
    Test Fock state creation agrees with the number operators implied by the
    existence of the ENR annihiliation operators.
    """
    number = [
        a.dag() * a for a in qutip.enr_destroy(dimensions, n_excitations)
    ]
    bases = list(qutip.state_number_enumerate(dimensions, n_excitations))
    n_samples = min((len(bases), 5))
    for basis in random.sample(bases, n_samples):
        state = qutip.enr_fock(dimensions, n_excitations, basis)
        for n, x in zip(number, basis):
            assert abs(n.matrix_element(state.dag(), state)) - x < 1e-10
Esempio n. 10
0
def test_enr_fock_state():
    "Excitation-number-restricted state space: fock states"
    dims, excitations = [4, 4], 2

    a1, a2 = enr_destroy(dims, excitations)

    psi = enr_fock(dims, excitations, [0, 2])
    assert_(abs((a1.dag()*a1).matrix_element(psi.dag(), psi) - 0) < 1e-10)
    assert_(abs((a2.dag()*a2).matrix_element(psi.dag(), psi) - 2) < 1e-10)

    psi = enr_fock(dims, excitations, [2, 0])
    assert_(abs((a1.dag()*a1).matrix_element(psi.dag(), psi) - 2) < 1e-10)
    assert_(abs((a2.dag()*a2).matrix_element(psi.dag(), psi) - 0) < 1e-10)

    psi = enr_fock(dims, excitations, [1, 1])
    assert_(abs((a1.dag()*a1).matrix_element(psi.dag(), psi) - 1) < 1e-10)
    assert_(abs((a2.dag()*a2).matrix_element(psi.dag(), psi) - 1) < 1e-10)
Esempio n. 11
0
def test_enr_fock_state():
    "Excitation-number-restricted state space: fock states"
    dims, excitations = [4, 4], 2

    a1, a2 = enr_destroy(dims, excitations)

    psi = enr_fock(dims, excitations, [0, 2])
    assert_(abs((a1.dag()*a1).matrix_element(psi.dag(), psi) - 0) < 1e-10)
    assert_(abs((a2.dag()*a2).matrix_element(psi.dag(), psi) - 2) < 1e-10)

    psi = enr_fock(dims, excitations, [2, 0])
    assert_(abs((a1.dag()*a1).matrix_element(psi.dag(), psi) - 2) < 1e-10)
    assert_(abs((a2.dag()*a2).matrix_element(psi.dag(), psi) - 0) < 1e-10)

    psi = enr_fock(dims, excitations, [1, 1])
    assert_(abs((a1.dag()*a1).matrix_element(psi.dag(), psi) - 1) < 1e-10)
    assert_(abs((a2.dag()*a2).matrix_element(psi.dag(), psi) - 1) < 1e-10)