Skip to content

Find a Reaction Path and Transition State with AFIR and MACE

1. Introduction

Find a reaction path and its transition state with the Atomic Simulation Environment (ASE): an artificial force (artificial force induced reaction, AFIR) pulls two atoms together, and a MACE machine-learned force field (MLFF) foundation model supplies the energies and forces. The search runs in the notebook itself, submits no job and needs no login. The default molecule is allyl vinyl ether, whose Claisen rearrangement gives 4-pentenal.

2. Open the notebook

In JupyterLite, the notebook is made/workflows/local/reaction_path_afir_mace.ipynb, entry 7.4.1 "AFIR reaction path discovery (MACE)" of made/workflows/Introduction.ipynb.

3. Set the parameters

Cell 1.2 holds the molecule, the atom pairs, the force ramp and the model:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Input structure: a file named after the molecule in FOLDER, otherwise fetched from PubChem by that name
FOLDER = "../../uploads"
MOLECULE_NAME = "allyl vinyl ether"

# Atom indices, as listed by cell 2.1
BOND_FORMING_PAIR = (4, 5)  # the only pair AFIR pulls together; this choice selects the reaction
BOND_BREAKING_PAIR = (0, 1)  # expected to come apart; also directs the saddle search. None if not known
REPORTED_PAIRS = {"carbonyl": (0, 3)}  # further distances to follow, {} for none

# Artificial force between the target atoms, ramped stage by stage until the molecule reacts (eV/Å)
AFIR_FORCE_RAMP = [1.0, 2.0, 3.0, 4.0]

# Name of the expected product, used to label results. None if unknown
PRODUCT_NAME = "4-pentenal"
# Measured activation energy to draw on the diagram (kcal/mol). None to leave it out
EXPERIMENTAL_ACTIVATION_ENERGY = 30.6

# MACE foundation model family: "MACE-OFF23" for molecules, "MACE-MP-0" for crystals and surfaces
MACE_MODEL_FAMILY = "MACE-OFF23"
MACE_MODEL = "medium"  # choose between "small", "medium" and "large"
MACE_DISPERSION = False  # D3 dispersion correction, not needed for this intramolecular rearrangement
MACE_DEFAULT_DTYPE = "float64"  # float64 is recommended for geometry optimization and vibrations
MACE_DEVICE = "cpu"  # hardware target: "cpu" or "cuda" (GPU)

MOLECULE_NAME is read from a file of that name in FOLDER, ../../uploads, otherwise fetched from PubChem. BOND_FORMING_PAIR holds the indices of the two atoms AFIR pulls together, which selects the reaction; BOND_BREAKING_PAIR is the pair expected to come apart, which also directs the saddle point search, and REPORTED_PAIRS are further distances to follow. AFIR_FORCE_RAMP lists the artificial forces, in eV/Å, applied stage by stage until the molecule reacts. PRODUCT_NAME labels the results and is not checked against them, and EXPERIMENTAL_ACTIVATION_ENERGY is drawn on the energy diagram.

MACE_MODEL_FAMILY is "MACE-OFF23", trained on organic molecules, or "MACE-MP-0", trained on crystals; MACE-OFF23 is distributed under the Academic Software License, which does not permit commercial use. The other model parameters are those of Relax structure with MLFF (MACE).

Cell 1.3 holds the convergence thresholds and the output paths:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Maximum force on any atom at convergence (eV/Å)
RELAXATION_FMAX = 0.03
AFIR_FMAX = 0.05
SADDLE_FMAX = 0.02

AFIR_MAX_STEPS_PER_STAGE = 150
AFIR_MAX_DISPLACEMENT = 0.1  # per-step displacement cap, keeps the biased path smooth (Å)
SADDLE_MAX_STEPS = 200
MODE_FOLLOWING_MAX_STEPS = 400

# Modes below this magnitude are the translations and rotations of a free molecule (cm⁻¹)
IMAGINARY_MODE_THRESHOLD = 50
# Displacement along the imaginary mode used to leave the saddle point (Å)
REACTION_MODE_DISPLACEMENT = 0.3
# Two relaxed structures count as different minima if a tracked distance differs by more than this (Å)
MINIMUM_SEPARATION = 0.5
# Scales covalent radii when deciding which atoms count as bonded, for the listing in 2.1
BOND_TOLERANCE = 1.1

# Distances followed along the path and reported for every structure
TRACKED_PAIRS = {"forming": BOND_FORMING_PAIR}
if BOND_BREAKING_PAIR:
    TRACKED_PAIRS["breaking"] = BOND_BREAKING_PAIR
TRACKED_PAIRS.update(REPORTED_PAIRS)

PRODUCT_LABEL = PRODUCT_NAME or "product"
SEARCH_NAME = f"{MOLECULE_NAME.replace(' ', '_')}_{BOND_FORMING_PAIR[0]}-{BOND_FORMING_PAIR[1]}"
RESULTS_FOLDER = f"results/{SEARCH_NAME}"  # one folder per search
AFIR_TRAJECTORY_PATH = f"{RESULTS_FOLDER}/afir_path.traj"

These parameters set the precision and the run time, not the reaction found. Each search writes to its own folder, RESULTS_FOLDER, named after the molecule and the pair pulled together.

4. Run and read the result

Run the notebook up to cell 2.1, which lists the atoms with their neighbors and the selected pairs, set the pairs in cell 1.2 from that listing, and run all cells with Run > Run All.

Sections 3 to 9 relax the reactant, ramp the force, remove the bias to get the physical energy profile, relax the product, refine the transition state with the dimer method, check that it has one imaginary frequency, and follow that mode to the two minima it connects. Section 10 plots the energy diagram and shows the reactant, the transition state and the product. Section 11 passes the three structures on with set_materials, which writes them to FOLDER, and writes the energy profile and the plots to RESULTS_FOLDER.

5. Interactive JupyterLite notebook

The interactive JupyterLite notebook for discovering a reaction path with AFIR and MACE can be accessed below.

Reaction Energy Profile with NEB (Quantum ESPRESSO) calculates a reaction energy profile with Density Functional Theory from the web interface.