1
$\begingroup$

I am trying to use operfermion to calculated the eigen values for different molecules. Tried for Hydrogen, LithiumHydride, Water. It works fine. When Itried to calculated the same thing for Ozone, Oxygen, HCN etc., the program finally got killed after consuming all the memory.

Any help is deeply appreciated.


Here is the sample code to reproduce the issue

from numpy import pi

from openfermion.chem import MolecularData
geometry=[['O',[0,0,0]],['O',[0,1.0885,0.6697]],['O',[0,-1.0885,0.6697]]]
basis='sto-3g'
multiplicity=1 #singlet 
charge=0 #neutral
ozone_molecule=MolecularData(geometry,basis,multiplicity,charge)
from openfermionpsi4 import run_psi4
ozone_molecule = run_psi4(ozone_molecule,
                       run_mp2=True,
                       run_cisd=True,
                       run_ccsd=True,
                       run_fci=True)
two_electron_integrals = ozone_molecule.two_body_integrals
orbitals = ozone_molecule.canonical_orbitals
ozone_filename = ozone_molecule.filename
ozone_molecule.save()

one_body_integrals = ozone_molecule.one_body_integrals

from openfermion.transforms import get_fermion_operator, jordan_wigner

ozone_qubit_hamiltonian = jordan_wigner(get_fermion_operator(ozone_molecule.get_molecular_hamiltonian()))

from openfermion.linalg import get_sparse_operator
from scipy.linalg import eigh

ozone_matrix= get_sparse_operator(ozone_qubit_hamiltonian).todense()
eigenvalues, eigenvectors = eigh(ozone_matrix)
print(eigenvalues)

This consumes roughly 128 GB of RAM and finally gets killed.

$\endgroup$
2
  • $\begingroup$ Welcome to QC StackExchange! Could you provide some more details on your attempts so far, maybe snippets of your code? $\endgroup$
    – rjh324
    Apr 15 at 13:50
  • $\begingroup$ Code Snipped attached above $\endgroup$ Apr 18 at 5:01
1
$\begingroup$

This is normal! If you look at the molecular Hamiltonian ozone_molecule.get_molecular_hamiltonian(), you will notice that it is a Hamiltonian that acts on 30 spin orbitals, and so ozone_qubit_hamiltonian is a 30 qubit Hamiltonian. This means it has $2^{30} \times 2^{30} = 2^{60} \approx 1.15 \times 10^{18}$ matrix elements, which will surely consume all your computers memory.

If you want to study these larger molecules, perhaps you should consider an active space approximation (see the Openfermion tutorials some details on how to implement this). This will reduce the number of spin orbitals in your molecular Hamiltonian, giving you an exponential reduction in the dimension of the sparse/dense matrix.

$\endgroup$
1
  • $\begingroup$ Thank you very much. I will go through it and see how we can use the active space approximation. If possible can you provide some example code, coz that will expedite the work. Regards, $\endgroup$ Apr 19 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.