Skip to content

add structure check tol#50

Merged
AsymmetryChou merged 1 commit intoDeePTB-Lab:mainfrom
Lonya0:stru_check_tol
Dec 2, 2025
Merged

add structure check tol#50
AsymmetryChou merged 1 commit intoDeePTB-Lab:mainfrom
Lonya0:stru_check_tol

Conversation

@Lonya0
Copy link
Copy Markdown
Contributor

@Lonya0 Lonya0 commented Dec 2, 2025

#49

Summary by CodeRabbit

  • Bug Fixes
    • Improved boundary condition validation with tolerance-based checking to reduce spurious boundary errors.
    • Enhanced error messages that report exact out-of-bounds measurements for better debugging.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 2, 2025

Walkthrough

The change refines error validation in NEGF Hamiltonian initialization by replacing strict per-axis range comparisons with a tolerance-based approach. It computes escape distances per dimension, compares against a tolerance threshold (1e-8), and raises a descriptive error if exceeded.

Changes

Cohort / File(s) Change Summary
Error Handling Refinement
dpnegf/negf/negf_hamiltonian_init.py
Replaced direct cell boundary checks with tolerance-based validation; introduces escape distance calculation (max-min span minus cell length per axis) and raises ValueError with descriptive diagnostics when tolerance is exceeded

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single-file modification with focused scope
  • Tolerance-based logic is straightforward but requires careful verification of threshold value (1e-8) and escape distance calculation correctness
  • Error message quality and diagnostic information should be validated

Poem

🐰 A tolerance so fine, 1e-8 divine,
No more strict boundaries that confine,
Escape distances now tell the tale,
Of atoms safely within the veil,
Softer checks, clearer errors—the validation's hale! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding a tolerance parameter to the structure check in the NEGF Hamiltonian initialization, which aligns with the file modifications.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
dpnegf/negf/negf_hamiltonian_init.py (1)

86-97: LGTM! Tolerance-based validation is a solid improvement.

The logic correctly computes escape distances per dimension and validates against a reasonable tolerance (1e-8) for floating-point precision errors. The error message helpfully includes the actual out-of-bounds distance for debugging.

Optional: Minor wording improvement

Consider changing "Out bound distance" to "Out-of-bounds distance" for better readability:

-            msg = f"The structure cell is smaller than the range of device and leads. Out bound distance:{max(escape_distances)}"
+            msg = f"The structure cell is smaller than the range of device and leads. Out-of-bounds distance: {max(escape_distances)}"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4366d0e and a038f52.

📒 Files selected for processing (1)
  • dpnegf/negf/negf_hamiltonian_init.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
dpnegf/negf/negf_hamiltonian_init.py (1)
dpnegf/negf/device_property.py (1)
  • positions (538-539)

@AsymmetryChou AsymmetryChou merged commit 20083c2 into DeePTB-Lab:main Dec 2, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants