Skip to content

Can't handle PySCF custom basis sets in cclib.bridge.cclib2pyscf.makecclib #1851

Open

Description

@oliver-s-lee

PySCF allows custom basis sets to be specified in the basis keyword, eg:

from pyscf import dft, gto, lib


def calculate():
    # This is DVB.
    mol = gto.M(
        atom="""
    C          1.43386       -0.00000        0.00000
    C         -1.43386        0.00000        0.00000
    C          0.69976       -1.21791        0.00000
    C         -0.69976        1.21791        0.00000
    C         -0.70271       -1.21960        0.00000
    C          0.70271        1.21960        0.00000
    H          1.24445       -2.17211        0.00000
    H         -1.24445        2.17211        0.00000
    H         -1.24514       -2.17312        0.00000
    H          1.24514        2.17312        0.00000
    C         -2.93083        0.05118        0.00000
    C          2.93083       -0.05118        0.00000
    H         -3.35520        1.06709        0.00000
    H          3.35520       -1.06709        0.00000
    C         -3.76833       -1.00028        0.00000
    C          3.76833        1.00028        0.00000
    H         -3.41193       -2.03669        0.00000
    H          3.41193        2.03669        0.00000
    H         -4.85625       -0.86201        0.00000
    H          4.85625        0.86201        0.00000
    """,
        basis={
          'H': gto.parse('''
#BASIS SET: (3s) -> [1s]
H    S
      0.3425250914E+01       0.1543289673E+00
      0.6239137298E+00       0.5353281423E+00
      0.1688554040E+00       0.4446345422E+00
          '''),
         'C': gto.parse('''
#BASIS SET: (6s,3p) -> [2s,1p]
C    S
      0.7161683735E+02       0.1543289673E+00
      0.1304509632E+02       0.5353281423E+00
      0.3530512160E+01       0.4446345422E+00
C    SP
      0.2941249355E+01      -0.9996722919E-01       0.1559162750E+00
      0.6834830964E+00       0.3995128261E+00       0.6076837186E+00
      0.2222899159E+00       0.7001154689E+00       0.3919573931E+00
          '''),
        },
        symmetry=True,
        # MB
        max_memory=400,
    )

    lib.num_threads(8)

    scf_steps = []

    def store_intermediate(_locals):
        scf_steps.append(
            {
                "e_tot": _locals["e_tot"],
                "norm_gorb": _locals["norm_gorb"],
                "conv_tol": _locals["conv_tol"],
                "conv_tol_grad": _locals["conv_tol_grad"],
            }
        )

    method = dft.RKS(mol)
    method.callback = store_intermediate
    method.xc = "b3lyp"
    method.kernel()
    return {"methods": [method], "scf_steps": [scf_steps]}

Which unfortunately results in an error in the parsing routine:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/oliver/Dev/cclib/cclib/bridge/cclib2pyscf.py", line 233, in makecclib
    return cclibfrommethods(
  File "/home/oliver/Dev/cclib/cclib/bridge/cclib2pyscf.py", line 296, in cclibfrommethods
    else ", ".join(set(mol.basis.values())),
TypeError: unhashable type: 'list'

The PySCF basis format is just a nested list, eg:

>>> from pyscf import gto
>>> gto.parse('''
... #BASIS SET: (3s) -> [1s]
... H    S
...       0.3425250914E+01       0.1543289673E+00
...       0.6239137298E+00       0.5353281423E+00
...       0.1688554040E+00       0.4446345422E+00
...           ''')
[[0, [3.425250914, 0.1543289673], [0.6239137298, 0.5353281423], [0.168855404, 0.4446345422]]]

Should be easy enough to detect the list and skip those basis sets in the parser.

This probably belongs in regression tests right? Which makes things slightly more complicated as I don't think those support PySCF yet...

Activity

  1. self-assigned this
    on Jul 9, 2026
  2. added this to the v1.9.1 milestone on Aug 22, 2026
  3. changed the title [-]Can't handle PySCF custom bases sets in cclib.bridge.cclib2pyscf.makecclib[/-] [+]Can't handle PySCF custom basis sets in cclib.bridge.cclib2pyscf.makecclib[/+] on Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions