USPEX

USPEX

Overview

 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.

Basic USPEX Workflow

USPEX uses an evolutionary algorithm to search for stable crystal structures over multiple generations.
The initial population is generated using  PyXtal  and a  topology-based random structure generator . By default, each method contributes 50% of the initial population.
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.

Using MLIPs for Geometry Optimization

USPEX supports different approaches to geometry optimization with MLIPs.

Built-in MLIPs (abinitioCode = 0)

Setting abinitioCode to 0 allows the use of built-in MatterSim and SevenNet models.

Custom MLIPs (abinitioCode = 99)

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.
See page 36 of the  USPEX manual  for additional details.

Required Input and Output Files

When using abinitioCode = 99, USPEX expects the external script to follow a specific file convention:
File
Description
Format
geom.in
Input crystal structure
POSCAR
geom.out
Optimized crystal structure
POSCAR
energy.txt
Energy of the optimized structure
Plain text
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.

3. Example: Geometry Optimization with UMA

The following Python script demonstrates how to perform geometry optimization using UMA through the FAIRChem interface.
import os
from ase.io import read
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')

cwd = os.getcwd()
atoms = read(f'{cwd}/geom.in', format='vasp')
atoms.calc = calc

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()}')

4. Running on Princeton Research Computing Clusters

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:
% commandExecutable
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
% EndExecutable
Replace {YOUR_NET_ID} with your Princeton NetID and adjust the environment path as needed.

Running on CPU Nodes

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.