You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix incorrect spin-element mapping in make_unlabeled_stru() for ABACUS STRU generation (#852)
This patch resolves a bug in dpdata/abacus/stru.py where the spin values
were misaligned with their corresponding elements when generating an
unlabeled STRU file.
Root cause:
In make_unlabeled_stru(), the code correctly identifies the global atom
index (iatomtype) for each element type, but then mistakenly uses a
separate running counter (natom_tot) to index every property except
atomic coordinates. As a result, spins (and any other per-atom
attributes) are pulled from the wrong positions in the input array,
breaking the element–spin correspondence.
Fix:
Replace all usages of natom_tot with iatomtype when accessing per-atom
data (spins, velocities, etc.). Coordinates were already using the
correct index; the change makes the remaining properties consistent.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved accuracy in assigning per-atom properties when generating
atomic position data, ensuring correct values are used for each atom.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: SuperBing <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
0 commit comments