Atoms and forces: SchNet and NequIP
A machine-learned interatomic potential predicts a structure's energy, and forces come from its gradient. SchNet filters by distance, so it ignores rotation. NequIP carries vectors that rotate with the molecule. Compute both pieces.
What runs in CodeSplash
You will be able to
- Explain why forces are taken as the negative gradient of one predicted energy
- Compute SchNet-style distance-filtered messages and check they ignore rotation
- Contrast an invariant message with NequIP's vector message that rotates
- Plan an evaluation by held-out structures, energies and forces
Energy first, forces from it
ReadSimulating molecules and materials needs the energy of every arrangement of atoms, and accurate quantum calculations are slow. A machine-learned interatomic potentialMachine-learned interatomic potentialA network that predicts a structure's energy from atom types and positions, trained on reference calculations, to run simulations faster. is trained on those calculations to predict the energy from atom types and positions, much faster.
The forces then come from the gradient of that one energy, forces from an energyForces from an energyForces taken as the negative gradient of one predicted energy, F = −∇E, so they can't create energy in a closed loop.:
A separate force head could predict forces that don't belong to any energy, so a simulation could gain energy in a loop. Taking the gradient rules that out. Units and the energy/force loss weights decide which errors training cares about.
SchNet: filters from distances
ReadSchNetSchNetA molecule network whose filters are smooth functions of the distance between atoms, so its outputs ignore rotation. updates each atom's features with its neighbors' features, weighted by a learned function of their distance:
The distances are expanded in radial basis functions and cut off smoothly beyond a radius. Because only distances enter, SchNet's features and energy ignore rotation.
In the reference's three-atom example the updated features are 2.216, 1.950 and 2.183, the same after rotating the atoms by 90°.
Reference · SPE011 · Needs a data type CodeSplash doesn't load yetSchNetSchNet learns molecular and material properties from atomic types and positions using continuous distance-dependent filters.NequIP: features that rotate
ReadDistances alone can't tell some different shapes apart. NequIPNequIPAn interatomic potential whose atom features include vectors and higher-order tensors that rotate with the molecule. keeps richer atom features: scalars, vectors and higher-order tensors, each rotating in its own fixed way. Messages combine a neighbor's features with spherical harmonics of the bond direction, through tensor products that keep every rotation rule:
Energy is still a sum of scalar atom energies, and forces still come from its gradient.
Reference · SPE012 · Needs a data type CodeSplash doesn't load yetNequIPNequIP learns interatomic potentials with E(3)-equivariant features, using geometric tensor information to improve data efficiency.A vector message by hand
ExploreThe reference builds the simplest vector message: neighbor directions weighted by and added. It comes out as (0.270, 0.357, 0.471), and rotating the inputs rotates this vector by the same rotation.
import numpy as np
rel = np.array([[1., 0., 0.], [0., 1., .5], [-.3, .2, 1.]]) # neighbor offsets
def message(V):
r = np.linalg.norm(V, axis=1)
return (np.exp(-r)[:, None] * V / r[:, None]).sum(axis=0)
R = np.array([[0., -1., 0.], [1., 0., 0.], [0., 0., 1.]])
print(message(rel), np.allclose(message(rel @ R.T), message(rel) @ R.T))rel <- rbind(c(1, 0, 0), c(0, 1, .5), c(-.3, .2, 1)) # neighbor offsets
message <- function(V) { r <- sqrt(rowSums(V^2)); colSums(exp(-r) * V / r) }
R <- rbind(c(0, -1, 0), c(1, 0, 0), c(0, 0, 1))
print(c(message(rel), isTRUE(all.equal(message(rel %*% t(R)), drop(message(rel) %*% t(R))))))A SchNet message would give the same number before and after the rotation; this one turns with it.
DExplorable · Equivariance: rotate the input, check the output
Does a model's answer turn with its input, as physics says it must?
Rotate the input. Will this model's energy stay exactly the same?
Model
Four small networks with fixed random weights. Each gives one number (an energy) and one arrow per point.
How many points (atoms, say) the model sees.
Rotate every point by this angle about the origin before asking the model again.
Move every point by (1, −0.5) after rotating.
Red bars fail the check. Differences below 10⁻¹² are rounding and show as 0.
Commit your prediction above to see the result
Make your prediction to see the result.
Evaluating a potential
PredictPredict first
Your training data are frames from simulation trajectories. How should you split for testing?
Reveal
Whole structures or trajectories. Neighboring frames are nearly identical, so random frames leak. Report energy and force errors in physical units, and run short simulations to check stability. Equivariance and a low training loss guarantee neither.
What runs here
ReadCheck: atomistic models
CheckpointCheck yourself
Why do potentials like SchNet compute forces as rather than with a separate force head?
Show the answer
Answer: b
A gradient field of a scalar energy is conservative. An unconstrained head may not be.
Check yourself
What makes SchNet's predicted energy unchanged when a molecule is rotated?
Show the answer
Answer: a
Distances don't change under rotation, so neither do the filtered messages or the energy.
Check yourself
SchNet uses a distance cutoff. What does that limit?
Show the answer
Answer: b
A cutoff keeps cost down and makes the model local. Long-range physics needs explicit handling.
Check yourself
What does NequIP carry that SchNet doesn't?
Show the answer
Answer: b
Directional features let NequIP tell apart shapes that distances alone confuse, while energy stays a scalar.
Check yourself
You rotate the neighbor offsets in the reference's vector message. What happens to the message?
Show the answer
Answer: b
The message is a weighted sum of direction vectors with distance-only weights, so it is equivariant.
Check yourself
A potential has tiny errors on random held-out frames from its training trajectories. What should you test next?
Show the answer
Answer: a
Neighboring frames leak. New environments and rollouts show whether the potential transfers and stays stable.
Recap
Recap- An interatomic potential predicts energy; forces come from its negative gradient.
- SchNet filters by distance, so its outputs ignore rotation.
- NequIP adds vectors and tensors that rotate with the structure.
- Split by structure or trajectory. Both need molecular data, which CodeSplash doesn't load yet.
Concepts in this lesson