Skip to content

ROHF fails with "number of atomic orbitals must equal number of molecular orbitals" when basis set is linearly dependent #543

Description

@awoodwa

For open-shell systems (spin_multiplicity > 1) with scf_type="restricted", the SCF solver dispatches to ROHF. The native ROHF builder requires n_atomic_orbitals == n_molecular_orbitals. When a basis set is linearly dependent on a given geometry, the solver drops basis functions so n_MO < n_AO, and ROHF fails:
RuntimeError: ROHF build requires number of atomic orbitals to equal number of molecular orbitals!

To Reproduce
Execute the following:

from qdk_chemistry.algorithms import create
from qdk_chemistry.data import Structure

XYZ = """13
o-benzosemiquinone
O    3.7321    1.3450    0.0000
O    2.0000    0.3450    0.0000
C    3.7321    0.3450    0.0000
C    2.8660   -0.1550    0.0000
C    4.5981   -0.1550    0.0000
C    2.8660   -1.1550    0.0000
C    4.5981   -1.1550    0.0000
C    3.7321   -1.6550    0.0000
H    5.1350    0.1550    0.0000
H    2.3291   -1.4650    0.0000
H    5.1350   -1.4650    0.0000
H    3.7321   -2.2750    0.0000
H    4.2690    1.6550    0.0000
"""

structure = Structure.from_xyz(XYZ)

solver = create("scf_solver")
solver.settings().set("scf_type", "restricted")   # -> ROHF for multiplicity > 1
solver.settings().set("enable_gdm", False)
energy, wfn = solver.run(structure, 0, 2, "def2-tzvp")   # raises RuntimeError

Output is as follows:

  File "<stdin>", line 1, in <module>
    energy, wfn = solver.run(structure, 0, 2, "def2-tzvp")   # raises RuntimeError
                  ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/qdk_chemistry/algorithms/registry.py", line 91, in run
    return self._algo.run(*args, **kwargs)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
RuntimeError: ROHF build requires number of atomic orbitals to equal number of molecular orbitals!

Expected behavior
ROHF should handle n_MO < n_AO the same way RHF/UHF do (operate in the reduced MO space after linear-dependency removal), rather than asserting n_AO == n_MO.

System:

  • OS: Linux 6.17.0-1011-azure (Linux-6.17.0-1011-azure-x86_64-with-glibc2.38)
  • System: x86_64
  • Code Version (qdk_chemistry): 2.0.0+local
  • Python: 3.13.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions