Tutorial 5

Machine Learning Interatomic Potentials

Train and test a MACE potential on molecular liquids, then push it further: model liquid water's density, compare training levers, and try to freeze, boil, and melt it.

Madeline Murphy
Anjali Gurajapu
105 min
Python · Google Colab
Back to schedule

Open in Google Colab

Requires a GPU runtime (Runtime → Change runtime type → T4 GPU). Most of the code is pre-filled — complete the cells marked ### TODO ###.

Open Notebook

Getting started

Open the Colab notebook using the button above and connect a T4 GPU runtime. The notebook runs in two parts — cells marked ### TODO ### require you to fill in code.

Part A — MACE in Practice

  1. Set up the environment. Install condacolab, xtb-python, and MACE, then clone the tutorial's data repo. This takes a few minutes and may prompt a session restart — that's expected.

  2. Understand the data. Explore a set of carbonate-solvent conformations (VC, EC, PC, DMC, EMC, DEC) — single molecules up through six-molecule clusters — and check whether all compositions and cluster sizes are well represented.

  3. Label the data with XTB. Compute reference energies and forces at the GFN2-xTB level, including isolated-atom energies so the model can learn atomization energies (E_atm = E_tot − Σᵢ E₀).

  4. Configure & train your first MACE model. Write a small YAML config (num_channels, max_L, r_max) and train. Evaluate error against XTB with parity plots, and look at the harder intra-/inter-molecular force decomposition.

  5. Run molecular dynamics. Check stability and speed against XTB, then accuracy via radial distribution functions — first for a single molecule, then for a full molecular liquid.

Part B — Building Models of Water

  1. Explore & label the water dataset. 64-molecule periodic water boxes, labeled with the cheap GFN-FF force field. Check which densities the training data actually samples before trusting a model's prediction on density.

  2. Train a baseline & get a density. Run NPT molecular dynamics with your model, then compute density from the trajectory and compare to the experimental value (0.997 g/cm³ at 25°C) — after sanity-checking that the dynamics actually converged.

  3. Pull four independent levers. Training-set size, reference level of theory (GFN-FF vs. three DFT functionals), model architecture, and fine-tuning the MACE-MP-0 foundation model. Change one at a time, then compare all your models on a cost-vs-accuracy Pareto plot.

  4. (Optional) Push your best model further. Sweep density across the liquid temperature range, push past freezing/boiling, melt a block of ice, and try seeding ice–liquid coexistence at an interface.


Answer these questions as you work through the notebook. Discuss with your neighbour — some have no single right answer.

    Warm-up

    Check the distribution of molecular compositions at each cluster size (1 through 6). Are all six pure single-molecule compositions well sampled? With six molecules there should be 6×7/2 = 21 possible dimers — are they all present? Where is there class imbalance?

    Easy
    Core

    Look at your MACE-vs-XTB parity plots for energy and forces. Do the RMSEs match the numbers printed at the end of training? The intra-molecular (bonded) and inter-molecular force components are shown separately — which one is harder to capture, and why does that matter more for molecular dynamics than for a single-point energy?

    Medium
    Core

    Run your trained water model with NPT molecular dynamics. Did the temperature hold near 298 K? Is the density trace flat by the end of the run, or still drifting? If it's still sloping, is the reported density number trustworthy?

    Medium
    Core

    Across your four levers — training-set size, level of theory, model architecture, and foundation-model fine-tuning — which moved the predicted density closest to experiment? Is that the ranking you'd have guessed from the Part A error metrics? Did a model that fit its own (imperfect) reference faithfully ever beat one that fit a better reference badly?

    Medium
    Challenge

    Take your best water model past its training range: try to freeze it (below 0°C) and boil it (above 100°C). Does the density trend correctly, including the fact that ice is less dense than liquid water — one of the few substances where the solid floats? If you seed an ice–liquid interface, where does the extrapolated melting point land relative to 273 K?

    Challenge

Notebook (Colab) Solutions notebook (Colab) Tutorial Slides (PDF) UMA Universal Atomic Simulator MACE GitHub repo Paired lecture notes