Part 1 ended with one question: given where the atoms are, what is the energy? Every model is an attempt to answer it. This page is about letting a computer work out the answer instead of a human guessing it.
Start with Part 1 if it is still unread. This page assumes force is the slope of the energy, and that a pair potential adds up every pair of atoms.
Every model in Part 1 was a guess at the shape of the energy. There is one way to stop guessing: work out what the electrons are actually doing. That is quantum mechanics, and it gives real answers, bonds that break, metals that behave like metals, chemistry that happens.
The catch is the cost. Here are the real numbers from a simulation of one small molecule of five atoms, measured on a laptop:
| Method | Time for one energy | Good enough to… |
|---|---|---|
| Pair potential | ~0.000001 s | simulate argon |
| Classical force field | ~0.000001 s | simulate proteins, but bonds never break |
| Quantum mechanics (DFT) | 2.6 s | get the chemistry right |
2.6 seconds does not sound slow. But remember the loop: we need this every single step, and a step is one femtosecond. To simulate one nanosecond, still a very short time in biology, we need a million steps.
And that is for five atoms. A protein has tens of thousands. This is the wall the whole field ran into.
Here is the trick, and it is simpler than it sounds.
We cannot afford to run quantum mechanics a million times. But we can afford to run it a few thousand times. So do that: pick a few thousand arrangements of the atoms, and compute the exact energy for each one. That is our set of examples.
Then fit a flexible mathematical function to those examples, one with enough knobs to bend into almost any shape. Afterwards, throw away the quantum calculation and just use the fit. The fit runs in microseconds.
This is the whole idea. Pay the expensive cost a few thousand times, up front. Then get answers essentially for free, forever.
The widget below shows this happening. The grey curve is the truth, which in real life we never get to see. The dots are the expensive calculations we chose to run. The blue curve is what a machine learning model builds from only those dots.
So we need a function that takes atom positions and returns energy. The obvious thing is to feed the raw numbers, x, y, z for every atom, straight into a neural network. This does not work, and the reason is important.
A molecule sitting in empty space has the same energy no matter where it is, no matter which way it is turned, and no matter what order we happen to list identical atoms in. Physics does not care about any of those. But the raw numbers change completely.
If we trained a network on raw coordinates, it would waste all its effort learning that turning a molecule does nothing, and it would still get it wrong for angles it had never seen. Worse, it would give two different answers for the same molecule described two different ways.
Instead of feeding in positions, we give the network a description of each atom's surroundings, built only out of distances and angles to its neighbours.
Think of it as a fingerprint of the neighbourhood. "There are two atoms about 1.1 Å away, one at 1.8 Å, nothing else nearby, and the angle between the first two is 109°." That description is unchanged if we move the molecule, turn it, or relabel identical atoms, because it never mentions where anything is in absolute terms.
This is the part people get most confused about, so here it is spelled out.
What comes out of the model is one number for the whole system: the total energy of all the atoms together. Plus the forces, which are just the slope of that one number, three numbers per atom. That is all. There is no separate prediction for each atom.
But inside, the model works atom by atom. Each atom's fingerprint goes through a small network which returns a number, and those numbers get added up:
So does that mean the model learns "the energy of one atom"? No, and this is the important bit.
Nobody ever tells the network what a single atom's energy should be. There is no such measurement. Quantum mechanics does not produce one either. The only thing ever compared against the truth is the sum.
The per-atom numbers are the network's own invention. It is free to divide the total between the atoms however it likes, as long as the total comes out right. Two differently trained networks will split it differently and both be equally correct. So we should not read a single atom's number as "how much energy this atom has": that quantity does not exist, because an atom's energy only means anything in relation to its neighbours.
Why bother splitting it up at all, then? Two reasons, both practical:
The widget below uses a real trained model. Drag the slider to stretch a bond in a methane molecule and watch what happens.
Adding up per-atom terms looks like the pair sum from Part 1, but there is a crucial difference. A pair term only ever sees two atoms. An atom's fingerprint sees all of its neighbours at once, so the network can learn exactly the kind of crowding effect that EAM had to hard-code, and anything else besides. It is many-body without anybody deciding in advance what the many-body rule should be.
It also means the model does not care how big the system is. Every hydrogen atom shares the same small network. Train on small molecules, run on large ones.
Every quantum calculation gives us the energy, one number. But it also gives us the force on every atom, almost for free. For a molecule of N atoms, that is 3N more numbers, all from the same expensive calculation.
Here is the whole recipe, in order:
That is a machine-learned interatomic potential. It is not magic and it is not a black box replacing physics; it is a very good curve fit to a physics calculation we could not afford to keep repeating.
What it buys us. This exact recipe reproduces a quantum dissociation curve to within 0.3 kcal/mol, and runs about 17,000× faster than the quantum calculation it learned from, fast enough to run live in a browser tab.
Worth being straight about, because these are real limits.
None of that stops it working. Modern general-purpose versions of this idea are trained on millions of structures across most of the periodic table, and they have genuinely changed what simulations people can run.
That is the end of the two-part explainer. Back to Part 1: How molecular dynamics works, or reach me on GitHub or by email.