Esempio n. 1
0
def test_kraus_through_qvm_t2():
    noise = NoiseModel(T1=INFINITY, ro_fidelity=1.0)
    qvm = QVMConnection(type_trans='density', noise_model=noise)
    rho = random_1q_density()
    identity_program = Program().inst(Igate(0))
    qvm._density = sps.csc_matrix(rho)
    qvm.num_qubits = 1
    qvm.load_program(identity_program)
    qvm.kernel()
    p = 1 - np.exp(-noise.gate_time_1q / noise.T2)
    final_density = np.array([[rho[0, 0], (1 - p) * rho[0, 1]],
                              [(1 - p) * rho[1, 0], rho[1, 1]]])
    assert np.allclose(final_density, qvm._density.todense())
def test_occupation_basis(qvm):
    prog = Program().inst([Xgate(0), Xgate(1), Igate(2), Igate(3)])
    state = np.zeros(2**4)
    state[3] = 1.0
    meanfield_state, _ = qvm.wavefunction(prog)
    assert np.allclose(meanfield_state.amplitudes, state)