# Openfermion : get_sparse_operator issue

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.

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

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.