Commit 7c8253de authored by Wright, Jerimiah's avatar Wright, Jerimiah
Browse files

Updated Benchmarksuite



Signed-off-by: Wright, Jerimiah's avatarJerimiah <Jerimiah.wright@utexas.edu>
parent c48fa59b
......@@ -36,13 +36,18 @@ class Chemistry(Benchmark):
elif inputParams['Observable']['name'] == 'fermion':
obs_str = inputParams['Observable']['obs_str']
H = xacc.getObservable('fermion', obs_str)
elif inputParams['Observable']['name'] == 'psi4':
opts = {'basis':inputParams['Observable']['basis'], 'geometry':inputParams['Observable']['geometry']}
if 'fo' in inputParams['Observable'] and 'ao' in inputParams['Observable']:
opts['frozen-spin-orbitals'] = ast.literal_eval(inputParams['Observable']['fo'])
opts['active-spin-orbitals'] = ast.literal_eval(inputParams['Observable']['ao'])
H = xacc.getObservable('psi4', opts)
elif inputParams['Observable']['name'] == 'pyscf':
opts = {'basis':inputParams['Observable']['basis'], 'geometry':inputParams['Observable']['geometry']}
if 'fo' in inputParams['Observable'] and 'ao' in inputParams['Observable']:
opts['frozen-spin-orbitals'] = ast.literal_eval(inputParams['Observable']['fo'])
opts['active-spin-orbitals'] = ast.literal_eval(inputParams['Observable']['ao'])
H = xacc.getObservable('pyscf', opts)
#print('Ham: ', H.toString())
qpu = xacc.getAccelerator(acc_name, xacc_opts)
......@@ -74,6 +79,20 @@ class Chemistry(Benchmark):
provider = xacc.getIRProvider('quantum')
if inputParams['Benchmark']['algorithm'] == 'adapt-vqe':
alg = xacc.getAlgorithm(inputParams['Benchmark']['algorithm'], {
'pool' : inputParams['Ansatz']['pool'],
'nElectrons' : int(inputParams['Ansatz']['electrons']),
'accelerator': qpu,
'observable': H,
'optimizer': optimizer,
})
alg.execute(buffer)
return buffer
else:
if 'source' in inputParams['Ansatz']:
# here assume this is xasm always
src = inputParams['Ansatz']['source']
......@@ -98,7 +117,6 @@ class Chemistry(Benchmark):
alg.execute(buffer)
return buffer
def analyze(self, buffer, inputParams):
if 'Decorators' in inputParams and 'readout_error' in inputParams['Decorators']:
......@@ -123,4 +141,3 @@ class Chemistry(Benchmark):
print('Energy = ', buffer['opt-val'])
print('Opt Params = ', buffer['opt-params'])
\ No newline at end of file
......@@ -35,6 +35,7 @@ class PySCFObservable(xacc.Observable):
mol = gto.mole.Mole()
mol.atom = inputParams['geometry']
mol.basis = inputParams['basis']
mol.build()
scf_wfn = scf.RHF(mol) # needs to be changed for open-shells
scf_wfn.conv_tol = 1e-8
scf_wfn.kernel() # runs RHF calculations
......
......@@ -406,10 +406,20 @@ def benchmark(xacc_settings):
results_name = "%s_%s_out" % (os.path.splitext(
tail)[0], timestr)
if 'output_logs' not in xacc_settings['Benchmark']:
xacc_settings['Benchmark']['output_logs'] = False
if xacc_settings['Benchmark']['output_logs'] == True:
f = open(results_name+".ab", 'w')
f.write(str(buffer))
f.close()
else:
pass
return buffer
def benchmark_from_cmd_line(opts):
if opts.benchmark is not None:
inputfile = opts.benchmark
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment