Skip to content

Raise ValueError for off-grid nucleus in clamped_molecular_potential_Poisson#34

Merged
haakoek merged 1 commit into
mainfrom
warn-nearest-grid-point-poisson
Apr 29, 2026
Merged

Raise ValueError for off-grid nucleus in clamped_molecular_potential_Poisson#34
haakoek merged 1 commit into
mainfrom
warn-nearest-grid-point-poisson

Conversation

@haakoek
Copy link
Copy Markdown
Collaborator

@haakoek haakoek commented Apr 29, 2026

Raise error for off-grid nucleus in clamped_molecular_potential_Poisson; add force parameter

Previously, if a nuclear radius did not coincide with a radial grid point, the function silently issued a warning and proceeded with the nearest grid point. This is potentially dangerous: the user may not notice the warning, and the result will be inaccurate without any indication of how large the error is.

Changes

  • By default (force=False), a ValueError is now raised when a nuclear radius is not a grid point, halting execution and prompting the user to either adjust their grid or explicitly opt in to the approximation.
  • Passing force=True restores the previous behaviour: a UserWarning is issued and the nearest grid point is used.
  • The existing test for the off-grid warning case was updated to pass force=True and match the new warning message.

Migration

Code that previously relied on the silent fallback should add force=True to the call, or ideally adjust the radial grid so that nuclear positions coincide with grid points.

…Poisson; add force=True to allow nearest-grid-point fallback
@haakoek haakoek merged commit c055b24 into main Apr 29, 2026
1 check passed
@haakoek haakoek deleted the warn-nearest-grid-point-poisson branch April 29, 2026 15:12
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.

1 participant