Skip to content

Guard association term against FFT ringing artefacts - #398

Open
bebuhk wants to merge 1 commit into
feos-org:developmentfrom
bebuhk:fix-assoc-fft-ringing
Open

bebuhk wants to merge 1 commit into
feos-org:developmentfrom
bebuhk:fix-assoc-fft-ringing

Conversation

@bebuhk

@bebuhk bebuhk commented Oct 19, 2026

Copy link
Copy Markdown

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.

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.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 18:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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 xi values to zero.
  • Uses nonnegative n0 when 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

This branch has not been deployed

No deployments
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.

3 participants