USPEX is a crystal structure prediction software package that uses evolutionary algorithms to identify stable structures based on chemical composition or molecular building blocks. The official USPEX manual provides comprehensive documentation of its features and available parameters. This guide focuses on integrating machine-learning interatomic potentials (MLIPs) into USPEX for geometry optimization, replacing computationally expensive DFT calculations performed with software such as VASP.
To understand how MLIPs can be incorporated, we first briefly review the basic USPEX workflow.
USPEX uses an evolutionary algorithm to search for stable crystal structures over multiple generations.
Once the population is generated, each candidate structure undergoes geometry optimization to evaluate its stability. The optimized structures and their energies are then used to guide the evolutionary search in subsequent generations.
The geometry optimization method is controlled by the abinitioCode parameter.
USPEX supports different approaches to geometry optimization with MLIPs.
Setting abinitioCode to 0 allows the use of built-in MatterSim and SevenNet models.
To use other MLIPs, such as UMA, MACE, or PET, or fine-tuned versions of MatterSim and SevenNet, set abinitioCode to 99.
This option enables external geometry optimization through a custom script specified in the commandExecutable block.
When using abinitioCode = 99, USPEX expects the external script to follow a specific file convention:
Optimized crystal structure
Energy of the optimized structure
The external script must read geom.in, perform geometry optimization, and write the optimized structure and its energy to geom.out and energy.txt, respectively.
The following Python script demonstrates how to perform geometry optimization using UMA through the FAIRChem interface.
from ase.optimize import BFGS
from ase.filters import FrechetCellFilter
from fairchem.core import pretrained_mlip, FAIRChemCalculator
predictor = pretrained_mlip.get_predict_unit(
'uma-s-1p2p1', device='cuda'
calc = FAIRChemCalculator(predictor, task_name='omat')
atoms = read(f'{cwd}/geom.in', format='vasp')
fcf = FrechetCellFilter(atoms)
opt = BFGS(fcf, trajectory=f'{cwd}/relax.traj', logfile=f'{cwd}/relax.log')
opt.run(fmax=0.02, steps=2000)
fcf.atoms.write(f'{cwd}/geom.out', format='vasp')
with open(f'{cwd}/energy.txt', 'w') as f:
f.write(f'{fcf.atoms.get_potential_energy()}')
To execute the Python script on Princeton Research Computing clusters, specify the appropriate commands in the commandExecutable block.
Assuming the script is named relax.py and the Conda environment is named uma, an example configuration is:
module purge; module load anaconda3/2025.6; conda activate uma; /home/{YOUR_NET_ID}/.conda/envs/uma/bin/python /your/path/to/relax.py > output 2>&1
Replace {YOUR_NET_ID} with your Princeton NetID and adjust the environment path as needed.
If you are running calculations on CPU nodes, add the following environment variable before executing the Python script:
export TORCH_COMPILE_DISABLE=1
Also ensure that the UMA predictor is configured to use the CPU rather than CUDA.
predictor = pretrained_mlip.get_predict_unit(
"uma-s-1p2p1", device="cpu"
This allows the same general workflow to be used on CPU nodes, although computational performance may differ substantially from GPU execution.