<jupyter_start><jupyter_text>_*LiH plot using ExactEigensolver*_This notebook demonstrates using QISKit ACQUA Chemistry to plot graphs of the ground state energy and dipole moments of a Lithium Hydride (LiH) molecule over a range of inter-atomic distances.This notebook populates a dictionary, which is a progammatic representation of an input file, in order to drive the QISKit ACQUA Chemistry stack. Such a dictionary can be manipulated programmatically and this is indeed the case here where we alter the molecule supplied to the driver in each loop.    This notebook has been written to use the PYSCF chemistry driver. See the PYSCF chemistry driver readme if you need to install the external PySCF library that this driver requires.<jupyter_code>import numpy as np
import pylab
from qiskit_acqua_chemistry import ACQUAChemistry

# Input dictionary to configure QISKit ACQUA Chemistry for the chemistry problem.
# Note: In order to allow this to run reasonably quickly it takes advantage
#       of the ability to freeze core orbitals and remove unoccupied virtual
#       orbitals to reduce the size of the problem. The result without this
#       will be more accurate but it takes rather longer to run.
acqua_chemistry_dict = {
    'driver': {'name': 'PYSCF'},
    'PYSCF': {'atom': '', 'basis': 'sto3g'},
    'algorithm': {'name': 'ExactEigensolver'},
    'operator': {'name': 'hamiltonian', 'freeze_core': True, 'orbital_reduction': [-3, -2]},
}
molecule = 'Li .0 .0 -{0}; H .0 .0 {0}'

start = 1.25 # Start distance
by    = 0.5  # How much to increase distance by
steps = 20   # Number of steps to increase by
energies  = np.empty(steps+1)
distances = np.empty(steps+1)
dipoles   = np.empty(steps+1)

print('Processing step __', end='')
for i in range(steps+1):
    print('\b\b{:2d}'.format(i), end='', flush=True)
    d = start + i*by/steps
    acqua_chemistry_dict['PYSCF']['atom'] = molecule.format(d/2) 
    solver = ACQUAChemistry()
    result = solver.run(acqua_chemistry_dict)
    distances[i] = d
    energies[i] = result['energy']
    dipoles[i]  = result['total_dipole_moment']
print(' --- complete')

print('Distances: ', distances)
print('Energies:', energies)
print('Dipole moments:', dipoles)
pylab.plot(distances, energies)
pylab.xlabel('Interatomic distance')
pylab.ylabel('Energy')
pylab.title('LiH Ground State Energy')
pylab.plot(distances, dipoles)
pylab.xlabel('Interatomic distance')
pylab.ylabel('Moment a.u')
pylab.title('LiH Dipole Moment')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10698602794411177, 'fraction_numerical': 0.008782435129740519, 'mean_word_length': 4.7214611872146115, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '60976', 'license': 'Apache-2.0', 'n_tokens_mistral': 801, 'n_tokens_neox': 776, 'n_words': 284, 'path': 'chemistry/energyplot.ipynb', 'repo_name': 'alfrisch/aqua-tutorials', 'size': '2505'}