Skip to content

Skip constrained ase.atoms in forward#212

Closed
PicoCentauri wants to merge 1 commit intomainfrom
ase-constrained
Closed

Skip constrained ase.atoms in forward#212
PicoCentauri wants to merge 1 commit intomainfrom
ase-constrained

Conversation

@PicoCentauri
Copy link
Copy Markdown
Contributor

@PicoCentauri PicoCentauri commented Apr 24, 2026

Fixes #206

Particles in an ase.Atoms object that are part of a FixAtoms constraint are now
excluded from selected_atoms during model inference. avoiding redundant per-atom
output computation for atoms whose forces will be zeroed by the optimizer anyway.

Contributor (creator of pull-request) checklist

  • Tests updated (for new features and bugfixes)?
  • Documentation updated (for new features)?
  • Issue referenced (for PRs that solve an issue)?

Reviewer checklist

  • CHANGELOG updated with public API or any other important changes?

📚 Download documentation for this pull-request

@PicoCentauri PicoCentauri requested a review from Luthaf April 24, 2026 12:57
@ceriottm
Copy link
Copy Markdown
Contributor

I'm a bit confused/concerned here. Even if atoms are constrained, their per-atom energy will contribute to the forces on non-constrained atoms, so we can't really drop them from the calculation

@PicoCentauri
Copy link
Copy Markdown
Contributor Author

We don't remove them from the calculations. Fixed atoms are still neighbors and contribute.

@ceriottm
Copy link
Copy Markdown
Contributor

We don't remove them from the calculations. Fixed atoms are still neighbors and contribute.

But they don't have their own V_i, that contributes to forces on their neighbors

@Luthaf
Copy link
Copy Markdown
Member

Luthaf commented Apr 24, 2026

True, thanks for the catch @ceriottm! I think we both had a mental model with pair potentials, and did not consider higher body-order 😅

@PicoCentauri The problem is that the force on atom j f_j is d V / dr_j, and V = sum_i V_i. So in general the force on atom j arises from gradients of the energy of all atoms which have j as a neighbor, not from the energy on atom j.

We could ignore the fixed atoms/skip them in selected_atoms when computing forces directly through non_conservative_force, but at this point if might become more of a footgun/added complexity in the code for very minimal gains.

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.

Consider ase.Atoms.constraints for calculations.

3 participants