Skip to content

Commit

Permalink
Fix decontract_basis function when basis are missed on certain atoms. (
Browse files Browse the repository at this point in the history
…Fix pyscf#1711) (pyscf#1943)

* Fix decontract_basis when basis are missed on certain atoms. (Fix pyscf#1711)
  • Loading branch information
sunqm authored Nov 11, 2023
1 parent cd44394 commit e21654a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyscf/gto/mole.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,9 @@ def _to_full_contraction(mol, bas_idx):

aoslices = mol.aoslice_by_atom()
for ia, (ib0, ib1) in enumerate(aoslices[:,:2]):
if ib0 == ib1: # No basis on atom ia
continue

if atoms is not None:
if isinstance(atoms, str):
to_apply = ((atoms == mol.atom_pure_symbol(ia)) or
Expand Down
5 changes: 5 additions & 0 deletions pyscf/gto/test/test_mole.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,11 @@ def test_decontract_basis(self):
s = ctr_coeff.T.dot(pmol.intor('int1e_ovlp')).dot(ctr_coeff)
self.assertAlmostEqual(abs(s - mol.intor('int1e_ovlp')).max(), 0, 12)

# discard basis on atom 2. (related to issue #1711)
mol._bas = mol._bas[:5]
pmol, c = mol.decontract_basis()
self.assertEqual(pmol.nbas, 14)

mol = gto.M(atom='He',
basis=('ccpvdz', [[0, [5, 1]], [1, [3, 1]]]))
pmol, contr_coeff = mol.decontract_basis()
Expand Down

0 comments on commit e21654a

Please sign in to comment.