Esempio n. 1
0
i = 0
for R in tqdm(Rs):
    h, v, Enuc, E = get_H2(R)
    #fci_coeffs[i] = FCI(h,v)
    FCIs[i] = E['fci']
    HFs[i] = E['hf']

    h2 = SecondQuantizedHamiltonian(n,
                                    l,
                                    h,
                                    v,
                                    nuclear_repulsion=Enuc,
                                    add_spin=True)

    h2.group_paulis(qwc=True, gc=True)

    model = VQE(h2,
                Minimizer('Cobyla', tol=1 / (10 * shots), disp=False),
                'RYRZ',
                options=options)
    theta = model.optimize()
    Es[i], VARs[i] = model.get_mean(theta, N=10000, M=10)
    #vqe_coeffs[i] = model.get_state_coeffs(theta)
    i += 1

np.save('RYRZ/bonds.npy', Rs)
np.save('RYRZ/fci.npy', FCIs)
np.save('RYRZ/hf.npy', HFs)
np.save('RYRZ/E.npy', Es)
np.save('RYRZ/var.npy', VARs)
Esempio n. 2
0
from optimizer import Minimizer

from vqe import VQE

l = 4  # number of spin orbitals / number of qubits
n = 2  # Number of occupied spin orbitals

omega = 1

h, v, E = get_qdot_matrix(n, l, omega)

print(E, FCI(n, l, h, v))

qdot = SecondQuantizedHamiltonian(n, l, h, v, anti_symmetric=True)
qdot.group_paulis()
options = {
    'shots': 10000,
    'print': True,
    'device': 'ibmq_london',
    'noise_model': True,
    'meas_fit': True,
    'coupling_map': True,
    'layout': [1, 0, 2, 3],
    'basis_gates': True
}

model = VQE(qdot,
            Minimizer('Cobyla'),
            'RYPAIRING',
            ansatz_depth=1,