Skip to content

libcint/gbasis eri tolerance is 1e-4? #208

@NathanGillispie

Description

@NathanGillispie

test_libcint.py:83 shows that the tolerance is set high for electron repulsion integrals when comparing libcint to gbasis. libcint promises relative accuracy up to 1e-10 for close Coulomb interactions. In my tests, the diff array is very sparse. Most values are precisely 0 but some are 1e-5 or so. That makes me think it isn't just floating point error. I don't want to call it a bug yet because it may not matter.

If the precision is not needed, is there a way to increase the tolerance in libcint to improve performance?

Here's my test if interested, I get relative errors on the order of 1e-5 and absolute errors on the order of 1e-6, so all of these fail.

import pytest
from gbasis.parsers import make_contractions, parse_gbs
from gbasis.integrals.electron_repulsion import (
    electron_repulsion_integral,
    ElectronRepulsionIntegral,
)
import numpy as np
from gbasis.integrals.libcint import ELEMENTS, LIBCINT, CBasis

@pytest.mark.parametrize("atom",["Li","Be","B","C","N","O"])
def test_libcint_twoa(atom):
    basis = parse_gbs("tests/basis/cc-pVDZ.gbs")
    atoms, coords = zip((atom, np.array([0,0,0])), (atom, np.array([1,0,0])))

    shells = make_contractions(basis, atoms, np.asarray(coords), "cartesian")

    lc_basis = CBasis(shells, atoms, np.asarray(coords), coord_type="cartesian")

    libcint_eri = lc_basis.electron_repulsion_integral(notation='chemist')
    gbasis_eri = ElectronRepulsionIntegral(shells).construct_array_cartesian()

    rdiff = np.abs((libcint_eri - gbasis_eri)/libcint_eri).flatten()
    rdiff = rdiff[~np.isnan(rdiff)] # remove nans
    maxr = np.amax(rdiff)
    adiff = np.abs((libcint_eri - gbasis_eri)).flatten()
    maxa = np.amax(adiff)
    print(f"max relative err: {maxr}\nmax abs err: {maxa}")

    assert np.allclose(gbasis_eri, libcint_eri, rtol=1e-9)

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions