from qiskit_chemistry import QiskitChemistry

# Input dictionary to configure Qiskit Chemistry for the chemistry problem.
qiskit_chemistry_dict = {
    'problem': {'random_seed': 50},
    'driver': {'name': 'PYSCF'},
    'PYSCF': {'atom': 'O 0.0 0.0 0.0; H 0.757 0.586 0.0; H -0.757 0.586 0.0', 'basis': 'sto-3g'},
    'operator': {'name': 'hamiltonian', 'freeze_core': True},
    'algorithm': {'name': 'ExactEigensolver'}
}

solver = QiskitChemistry()
result = solver.run(qiskit_chemistry_dict)

print('Ground state energy: {}'.format(result['energy']))

for line in result['printable']:
    print(line)

qiskit_chemistry_dict['algorithm']['name'] = 'VQE'
qiskit_chemistry_dict['optimizer'] = {'name': 'COBYLA', 'maxiter': 25000}
qiskit_chemistry_dict['variational_form'] = {'name': 'UCCSD'}
qiskit_chemistry_dict['initial_state'] = {'name': 'HartreeFock'}

solver = QiskitChemistry()
result = solver.run(qiskit_chemistry_dict)

print('Ground state energy: {}'.format(result['energy']))

for line in result['printable']:
    print(line)

print('Actual VQE evaluations taken: {}'.format(result['algorithm_retvals']['eval_count']))

