Repository navigation
Conversation
Added checks for finite scale and kinetic energy in NPT barostat calculations.
|
Thanks for tracking down the underflow in |
ABACUS-PR-BOT
left a comment
There was a problem hiding this comment.
The new guards need the stray source + prefixes removed before this revision can compile. A focused regression-test suggestion is also included inline.
Static review only; no builds or runtime tests were run.
| scale *= exp(-v_peta[0] * delta / 2.0); | ||
| kecurrent = ke_omega * scale * scale; | ||
| scale *= exp(-v_peta[0] * delta / 2.0); | ||
| + if (!std::isfinite(scale) || scale <= 0.0) |
There was a problem hiding this comment.
The committed source contains ten literal leading + characters in the two new guard blocks, including + if here. These are invalid C++ tokens, and nhchain.cpp is compiled by the unconditional md target even when NPT is unused. Please remove the stray patch markers from both blocks.
There was a problem hiding this comment.
Removed the stray patch markers from both blocks. The build checks are now passing.
| + "Invalid NPT barostat velocity scale. Check md_pfreq and md_dt."); | ||
| + } | ||
| kecurrent = ke_omega * scale * scale; | ||
| + if (!std::isfinite(kecurrent)) |
There was a problem hiding this comment.
Non-blocking: please add focused cases in test_nhchain.cpp for zero/non-finite scale and non-finite kecurrent with a finite scale. The existing tests cover ordinary integration and restart behavior; assert the expected nonzero exit for each rejection path. Retain the existing finite-trajectory reference checks.
There was a problem hiding this comment.
Added four tests in test_nhchain.cpp covering zero, infinite and NaN scale, and non-finite kinetic energy with a finite scale. Each checks for exit code 1. The existing trajectory and restart tests are retained.
All 10 NHC tests passed locally. I also checked that removing the guards makes the four new tests fail. The latest CI checks are all passing.
|
Thanks for sharing the test case. After reproducing it on beta13, I agree with your diagnosis of Out of curiosity, I also tried adaptive substeps for the barostat thermostat while keeping the original |
Thanks for looking into this. I tested the same case with only md_pfreq changed from 1.0 to 0.005. It completed all 10 MD steps, though SCF did not converge at steps 7–9. I have also added regression tests for the new checks, and all CI checks are now passing. |
Thanks for reproducing the case and trying the adaptive substeps. Your results agree with the comparison using md_pfreq = 0.005. I have also added four regression tests for the rejection paths. All checks on the latest commit are now passing. |
Linked Issue
Refs #6681
What's changed?
The NPT barostat scale can underflow to zero and later produce
NaNwhen multiplied by an overflowing exponential. The invalid value then propagates to the cell, causing an assertion failure during the next MD step.This adds checks for a non-positive or non-finite scale and non-finite barostat kinetic energy. The calculation exits with a message asking the user to check
md_pfreqandmd_dt.Unit Tests and/or Case Tests for my changes
Tested the attached
test.zipwith a patchedv3.11.0-beta13CUDA build on an RTX 4090, using one MPI process and 12 OpenMP threads.md_pfreq = 1.0, the new check caught the invalid scale and exited with code 1.md_pfreqto0.005allowed all 10 MD steps to finish with exit code 0. SCF did not converge at steps 7–9.test_nhchain.cpp. All 10 NHC tests passed locally.646e50epassed.Governance Notes
The change adds runtime checks in nhchain.cpp and regression tests in test_nhchain.cpp. A friend declaration in nhchain.h gives the existing test fixture access to the required internal state. No new INPUT parameters are added.