Skip to content

Fix: Enhance the warning of ntype#7239

Merged
mohanchen merged 3 commits intodeepmodeling:developfrom
sunliang98:fix_ntype
Apr 14, 2026
Merged

Fix: Enhance the warning of ntype#7239
mohanchen merged 3 commits intodeepmodeling:developfrom
sunliang98:fix_ntype

Conversation

@sunliang98
Copy link
Copy Markdown
Collaborator

@sunliang98 sunliang98 commented Apr 14, 2026

Reminder

  • Have you linked an issue with this pull request?
  • Have you added adequate unit tests and/or case tests for your pull request?
  • Have you noticed possible changes of behavior below or in the linked issue?
  • Have you explained the changes of codes in core modules of ESolver, HSolver, ElecState, Hamilt, Operator or Psi? (ignore if not applicable)

Linked Issue

Fix #7229

Unit Tests and/or Case Tests for my changes

  • A unit test is added for each new feature or bug fix.

What's changed?

  • Example: My changes might affect the performance of the application under certain conditions, and I have tested the impact on various scenarios...

Any changes of core modules? (ignore if not applicable)

  • Example: I have added a new virtual function in the esolver base class in order to ...

Copilot AI review requested due to automatic review settings April 14, 2026 12:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves validation and user-facing warnings around ntype by making STRU parsing safer and clarifying how ntype is determined when omitted in INPUT.

Changes:

  • Prevent potential out-of-bounds access when checking STRU tokens (temp.empty() guard before indexing).
  • Fail fast with a clearer error when no valid ATOMIC_SPECIES entries can be detected in STRU.
  • Refine ntype validation: disallow negative values, enforce consistency when explicitly provided, and auto-fill from STRU when ntype == 0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/source_io/module_parameter/read_input.cpp Outdated
Comment thread source/source_io/module_parameter/read_input.cpp Outdated
@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes Input&Output Suitable for coders without knowing too many DFT details labels Apr 14, 2026
@mohanchen mohanchen merged commit 6d1d4fa into deepmodeling:develop Apr 14, 2026
15 checks passed
@sunliang98 sunliang98 deleted the fix_ntype branch April 14, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugs Bugs that only solvable with sufficient knowledge of DFT Input&Output Suitable for coders without knowing too many DFT details Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The error message for broken STRU files is ambiguous

3 participants