Repository navigation
Conversation
Near hard walls / capped external potentials, FFT round-off can give |n2v| > n2 (xi < 0) and n0 < 0. Clamp xi to [0, 1] and n0 to >= 0 before evaluating the association Helmholtz energy, which requires rho0 >= 0.
There was a problem hiding this comment.
🟢 Approval recommended
The localized guards address invalid association inputs without changing valid-density calculations, and no blocking issues remain.
No open issues 🎉
What changed in this PR
Guards the PC-SAFT association energy calculation against negative weighted densities caused by FFT ringing near hard walls.
Changes:
- Clamps negative
xivalues to zero. - Uses nonnegative
n0when computing association density, preserving valid inputs.
| File | Description |
|---|---|
crates/feos/src/pcsaft/dft/pure_saft_functional.rs |
Adds guards against negative association densities. |
Review effort: Balanced
prehner
approved these changes
Oct 20, 2026
This branch has not been deployed
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.
Near hard walls / capped external potentials, FFT round-off can give |n2v| > n2 (xi < 0) and n0 < 0. Clamp xi to [0, 1] and n0 to >= 0 before evaluating the association Helmholtz energy, which requires rho0 >= 0.
I tested a calf-20 isotherm for h2o, co2 and n2 with the wheel compiled from this branch and they all converge now.