Exemplo n.º 1
0
def test_thermal_dm(dimensions, n_excitations, nbar_type):
    # Ensure that the average number of excitations over all the states is
    # much less than the total number of allowed excitations.
    if nbar_type == "scalar":
        nbars = 0.1 * n_excitations / len(dimensions)
    else:
        nbars = np.random.rand(len(dimensions))
        nbars = (0.1 * n_excitations) / np.sum(nbars)
    test_dm = qutip.enr_thermal_dm(dimensions, n_excitations, nbars)
    expect_dm = _reference_dm(dimensions, n_excitations, nbars)
    np.testing.assert_allclose(test_dm.full(), expect_dm.full(), atol=1e-12)
Exemplo n.º 2
0
def test_enr_thermal_dm2():
    "Excitation-number-restricted state space: thermal density operator (II)"
    dims, excitations = [3, 4, 5], 2

    n_vec = 0.1

    rho = enr_thermal_dm(dims, excitations, n_vec)

    rho_ref = tensor([thermal_dm(d, n_vec) for idx, d in enumerate(dims)])
    gonners = [idx for idx, state in enumerate(state_number_enumerate(dims))
               if sum(state) > excitations]
    rho_ref = rho_ref.eliminate_states(gonners)
    rho_ref = rho_ref / rho_ref.tr()

    assert_(abs((rho.data - rho_ref.data).data).max() < 1e-12)
Exemplo n.º 3
0
def test_enr_thermal_dm2():
    "Excitation-number-restricted state space: thermal density operator (II)"
    dims, excitations = [3, 4, 5], 2

    n_vec = 0.1

    rho = enr_thermal_dm(dims, excitations, n_vec)

    rho_ref = tensor([thermal_dm(d, n_vec) for idx, d in enumerate(dims)])
    gonners = [idx for idx, state in enumerate(state_number_enumerate(dims))
               if sum(state) > excitations]
    rho_ref = rho_ref.eliminate_states(gonners)
    rho_ref = rho_ref / rho_ref.tr()

    assert_(abs((rho.data - rho_ref.data).data).max() < 1e-12)