quantumlib / OpenFermion

The electronic structure package for quantum computers.
Apache License 2.0
1.51k stars 372 forks source link

Not generating .hdf5 file #762

Closed raghavven closed 2 years ago

raghavven commented 2 years ago

Hi All,

The molecular data class is not generating .hdf5 file in the location it says it has created one. For e.g. I am running the following code. from openfermion.chem import MolecularData

Set parameters to make a simple molecule.

diatomic_bond_length = .7414 geometry = [('H', (0., 0., 0.)), ('H', (0., 0., diatomic_bond_length))] basis = 'sto-3g' multiplicity = 1 charge = 0 description = str(diatomic_bond_length)

Make molecule and print out a few interesting facts about it.

molecule = MolecularData(geometry, basis, multiplicity, charge, description) print('Molecule has automatically generated name {}'.format( molecule.name)) print('Information about this molecule would be saved at:\n{}\n'.format( molecule.filename)) print('This molecule has {} atoms and {} electrons.'.format( molecule.n_atoms, molecule.n_electrons)) for atom, atomic_number in zip(molecule.atoms, molecule.protons): print('Contains {} atom, which has {} protons.'.format( atom, atomic_number))

And then it prints in the jupyter notebook saying the following """ Molecule has automatically generated name H2_sto-3g_singlet_0.7414 Information about this molecule would be saved at: /home/subbu/psi4conda/envs/penny/lib/python3.8/site-packages/openfermion/testing/data/H2_sto-3g_singlet_0.7414

This molecule has 2 atoms and 2 electrons. Contains H atom, which has 1 protons. Contains H atom, which has 1 protons.

_However, when I see the path , there is no such file listed there. Can you kindly help me troubleshoot the error.

Thank you._

ncrubin commented 2 years ago

Hi @raghavven, could you try saving it outside your site-packages and python directory? Maybe to some random directory in your home? I am wondering if there is a permissions issue here.

ncrubin commented 2 years ago

Actually, it is because the save method is not called. For your molecule to show up in that directory you can call molecule.save() which will write the hdf5 file.

raghavven commented 2 years ago

Thanks so much for your reply @ncrubin . It worked.