adapt_vqe_h2.py 928 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import xacc

qpu = xacc.getAccelerator('tnqvm')
optimizer = xacc.getOptimizer('nlopt',{'nlopt-optimizer':'l-bfgs'})
buffer = xacc.qalloc(4)

geom = '''
H  0.000000   0.0      0.0
H   0.0        0.0  .7474
'''
H = xacc.getObservable('pyscf', {'basis': 'sto-3g', 'geometry': geom})
print(H.toString())

adapt = xacc.getAlgorithm('adapt-vqe', {'accelerator': qpu,
                                  'optimizer': optimizer,
                                  'observable': H,
                                  'nElectrons': 2,
                                  'gradient-strategy': 'parameter-shift-gradient',
                                  'print-operators': True,
                                  'threshold': 1.0e-2,
                                  'print-threshold': 1.0e-10,
                                  'maxiter': 2,
23
                                  'pool': "singlet-adapted-uccsd"})
24
25
# execute
adapt.execute(buffer)