deepmodeling / deepmodeling/tbplas

[Code scan] Clear degenerate AC products in the Cython Lindhard backend

Open Beginner friendly
#22 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
19
Forks
6
PR merge metrics
No merged PRs in 30d

Description

This issue comes from a Codex global scan of deepmodeling/tbplas at commit 4d3652b3dba8eb930e4869a6d41074f62d703692.

Severity: Medium

The Cython `prod_ac()` path assigns `prod_df[ik, mm, nn]` only when the band-energy difference exceeds the threshold. Degenerate entries are left at whatever value the caller supplied. The Fortran implementation explicitly initializes `prod_df = 0.0` before filling, so the two backends have different safety contracts.

Code references:
https://github.com/deepmodeling/tbplas/blob/4d3652b3dba8eb930e4869a6d41074f62d703692/tbplas/cython/lindhard.pyx#L359-L375
https://github.com/deepmodeling/tbplas/blob/4d3652b3dba8eb930e4869a6d41074f62d703692/tbplas/fortran/lindhard.f90#L188-L193

Suggested fix: explicitly set the degenerate `prod_df` entries to zero, or initialize the whole output array inside the Cython function before filling it.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Cython prod_ac() path in tbplas/cython/lindhard.pyx around lines 359-375, then compare its initialization behavior with tbplas/fortran/lindhard.f90 around lines 188-193. Ensure degenerate prod_df entries are zero rather than caller-provided values, and verify that the Cython and Fortran backends have the same safety contract.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.