fuse_auxcell assumes l ≤ 7 and crashes with high-angular-momentum auxiliary basis#3
Draft
WSLinkK wants to merge 3 commits intoGreen-Phys:mainfrom
Draft
fuse_auxcell assumes l ≤ 7 and crashes with high-angular-momentum auxiliary basis#3WSLinkK wants to merge 3 commits intoGreen-Phys:mainfrom
fuse_auxcell assumes l ≤ 7 and crashes with high-angular-momentum auxiliary basis#3WSLinkK wants to merge 3 commits intoGreen-Phys:mainfrom
Conversation
Update modchg_offset array size to 9.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When using
green_igenwith an auxiliary cell that contains high-angular-momentum functions (e.g. g functions), the code crashes insidefuse_auxcellwith anIndexError. The function currently assumes that the maximum angular momentum in the compensating charge basis (chgcell) is at most 7, and allocates an array with a hard-coded second dimension of size 8. Same issue has been noted by Pavel in upstream in PySCF in issues [pyscf/pyscf#22169]Relevant snippet from
green_igen/df.py:Error message
Steps to reproduce
gggdf._make_j3cwith an auxiliary / main basis that includes g functions (high angular momentum)._make_j3ccallsfuse_auxcell(mydf, auxcell).modchg_offset[ia, l]assignment whenbas_angular(i)returns a value beyond the hard-coded limit.Expected behavior
fuse_auxcellshould work for arbitrary angular momentum inchgcelland not assumel ≤ 7. Themodchg_offsetarray should be sized according to the actual maximum angular momentum present in the (auxiliary / compensating) cell.How PySCF fixes it
The same problem was fixed upstream in PySCF in PR [pyscf/pyscf#2361](pyscf/pyscf#2361), in
pyscf/pbc/df/gdf_builder.py. The fix replaces the hard-coded dimension8by computing the maximum angular momentum and sizing the offset array accordingly, e.g.That is:
lmaxfrom the basis.modchg_offsetwith shape(natm, lmax + 1)so all angular momenta up to the maximum are covered.Environment
green_igenversion: 0.2.7