Fix: Fix UPF100 negative lmax handling#7221
Merged
mohanchen merged 7 commits intodeepmodeling:developfrom Apr 9, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the UPF100 pseudopotential reader against legacy files where nbeta == 0 and lmax < 0, preventing negative-dimension propagation and early-runtime failures, and adds a regression test case.
Changes:
- Normalize legacy UPF100 header cases (
nbeta == 0 && lmax < 0) to a safelmax = 0. - Add additional validation while reading
<PP_DIJ>indices to prevent out-of-range matrix writes. - Add a new LCAO regression test case (
02_NAO_Gamma/scf_upf100) and register it in the CPU test list.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
source/source_cell/read_pp_upf100.cpp |
Normalizes legacy lmax and adds <PP_DIJ> bounds checking to avoid invalid allocations / writes. |
tests/02_NAO_Gamma/scf_upf100/INPUT |
Adds a new LCAO SCF test input targeting UPF100 legacy pseudopotentials. |
tests/02_NAO_Gamma/scf_upf100/STRU |
Defines the benzene structure and references legacy UPF100 pseudopotentials. |
tests/02_NAO_Gamma/scf_upf100/KPT |
Gamma-only k-point setup for the new test. |
tests/02_NAO_Gamma/scf_upf100/result.ref |
Reference outputs for autotest validation. |
tests/02_NAO_Gamma/scf_upf100/README |
Brief description of the new test case. |
tests/02_NAO_Gamma/CASES_CPU.txt |
Registers scf_upf100 in the NAO Gamma CPU test suite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Reminder
Linked Issue
Fix #7208
Unit Tests and/or Case Tests for my changes
What's changed?
This PR fixes a stability issue when reading legacy UPF100 pseudopotentials where
nbeta == 0andlmax < 0(for example,lmax = -1inH.pz-vbc.UPF). The parser now normalizes this case to a safe value to prevent invalid dimension propagation and intermittent runtime failures.To prevent regressions, this PR also adds an LCAO test case (
02_NAO_Gamma/scf_upf100).Any changes of core modules? (ignore if not applicable)