Conversation
There was a problem hiding this comment.
Pull request overview
This pull request addresses floating-point underflow issues in Gaussian weight calculations for the D4 dispersion model. When coordination numbers are significantly larger than reference coordination numbers, the normalization values can become extremely small, triggering floating-point underflows that produce inconsistent results depending on compiler optimization levels (e.g., ifort -O3 vs -O0).
Key Changes:
- Added guard against tiny norm values before inversion using
eps_norm = tiny(1._wp)**0.5_wp - Set problematic norm values to zero to ensure consistent behavior across optimization levels
- Added additional checks with
norm < 1e-7_wpthreshold in conditional logic - Included explanatory comment documenting the optimization-dependent behavior
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/dftd4/model/d4.f90 | Added norm underflow guards and additional checks in weight_references subroutine to prevent FP underflow in C6 coefficient calculations |
| src/dftd4/model/d4s.f90 | Applied same norm underflow guards and checks in system-specific D4 model variant |
| .gitignore | Added .venv* pattern to ignore Python virtual environment directories |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
@marvinfriede I've opened a new pull request, #326, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Replace norm < 1e-7_wp with norm == 0.0_wp for consistency Co-authored-by: marvinfriede <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: marvinfriede <[email protected]>
For systems with coordination numbers much larger than the largest reference coordination number, the norm in the calculation of the Gaussian weights can become tiny. This can trigger floating-point underflows that lead to essentially random values. This also made the correctness depend on the compilation settings (ifort with -O3 was correct, -O0 was incorrect).
We now guard against tiny norms and set problematic cases to zero.
Related: grimme-lab/xtb#1190.