Skip to content

[Code scan] Call PyABACUS RadialCollection methods correctly in overlap_generator #7558

Description

@njzjz

This issue is a result of a Codex global repository scan.

overlap_generator.py treats RadialCollection.rcut_max and lmax as properties and also calls lmax_, but the PyABACUS wrapper exposes them as methods named rcut_max(...) and lmax(...). This makes overlap generation fail before producing matrices.

Script usage:

self.orb = nao.RadialCollection()
self.orb.build(orb_file_num, orb_file_list, 'o')
# Standardize the orbital grid
rmax = self.orb.rcut_max * 2.0
dr = 0.01
nr = int(rmax/dr) + 1
self.orb.set_uniform_grid(True, nr, rmax, 'i', True)
# Print basic orbital information
ntype = self.orb.ntype
lmax = self.orb.lmax

for it, element in enumerate(unique_elements):
for ia in range(element_counts[element]):
for iL in range(self.orb.lmax_(it)+1):
for iN in range(self.orb.nzeta(it, iL)):

def cal_R_direct_coor(self):
rcut=self.orb.rcut_max*np.ones(len(self.atom_positions_c),dtype=float)
print(rcut)
Ncell = NeighbourCell(self.lattice_vector, self.atom_positions_c, self.atom_positions_ct, rcut)

Wrapper API:

@overload
def lmax(self) -> int: ...
@overload
def lmax(self, itype: int) -> int: ...
def lmax(self, *args, **kwargs):
return super().lmax(*args, **kwargs)
@overload
def rcut_max(self) -> float: ...
@overload
def rcut_max(self, itype: int) -> float: ...
def rcut_max(self, *args, **kwargs):
return super().rcut_max(*args, **kwargs)

Relevant code:

rmax = self.orb.rcut_max * 2.0
...
lmax = self.orb.lmax
...
for iL in range(self.orb.lmax_(it)+1):
...
rcut=self.orb.rcut_max*np.ones(...)

Suggested fix:

Use the actual method calls, for example self.orb.rcut_max(), self.orb.rcut_max(it), and self.orb.lmax(it). Add a smoke test that constructs overlap_R with a minimal orbital collection or mocked wrapper.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions