Stability

Stability#

We’re going to start simple here - let’s run a local relaxation (optimize the unit cell and positions) using a pre-trained EquiformerV2-31M-OMAT24-MP-sAlex checkpoint. This checkpoint has a few fun properties

  1. It’s a relatively small (31M) parameter model

  2. It was pre-trained on the OMat24 dataset, and then fine-tuned on the MPtrj and Alexandria datasets, so it should emit energies and forces that are consistent with the MP GGA (PBE/PBE+U) level of theory

This code will download the appropriate checkpoint from huggingface_hub automatically; if you don’t have the right access token specified, you’ll hit an permission or 401 error.

from __future__ import annotations

import pprint

from ase.build import bulk
from ase.optimize import LBFGS
from quacc.recipes.mlp.core import relax_job

# Make an Atoms object of a bulk Cu structure
atoms = bulk("Cu")

# Run a structure relaxation
result = relax_job(
    atoms,
    method="fairchem",
    name_or_path="uma-s-1",
    task_name="omat",
    opt_params={"fmax": 1e-3, "optimizer": LBFGS},
)
/home/runner/work/_tool/Python/3.12.11/x64/lib/python3.12/site-packages/torchtnt/utils/version.py:12: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
WARNING:root:device was not explicitly set, using device='cuda'.
INFO:root:Setting random seed to 41
INFO:root:Setting random seed to 41
INFO:quacc.runners.prep:Calculation will run at /home/runner/work/fairchem/fairchem/docs/inorganic_materials/examples_tutorials/tmp-quacc-2025-06-05-20-43-49-848642-59941
INFO:quacc.runners.prep:Calculation results stored at /home/runner/work/fairchem/fairchem/docs/inorganic_materials/examples_tutorials/quacc-2025-06-05-20-43-49-848642-59941
pprint.pprint(result)
{'atoms': Atoms(symbols='Cu', pbc=True, cell=[[0.0, 1.805, 1.805], [1.805, 0.0, 1.805], [1.805, 1.805, 0.0]]),
 'converged': np.True_,
 'dir_name': '/home/runner/work/fairchem/fairchem/docs/inorganic_materials/examples_tutorials/quacc-2025-06-05-20-43-49-848642-59941',
 'input_atoms': {'atoms': Atoms(symbols='Cu', pbc=True, cell=[[0.0, 1.805, 1.805], [1.805, 0.0, 1.805], [1.805, 1.805, 0.0]]),
                 'structure_metadata': {'builder_meta': {'build_date': datetime.datetime(2025, 6, 5, 20, 43, 50, 559708, tzinfo=datetime.timezone.utc),
                                                         'emmet_version': '0.84.6',
                                                         'pymatgen_version': '2025.1.9'},
                                        'chemsys': 'Cu',
                                        'composition': Composition('Cu1'),
                                        'composition_reduced': Composition('Cu1'),
                                        'density': 8.971719813140734,
                                        'density_atomic': 11.761470249999999,
                                        'elements': [Element Cu],
                                        'formula_anonymous': 'A',
                                        'formula_pretty': 'Cu',
                                        'nelements': 1,
                                        'nsites': 1,
                                        'symmetry': {'angle_tolerance': 5.0,
                                                     'crystal_system': <CrystalSystem.cubic: 'Cubic'>,
                                                     'number': 225,
                                                     'point_group': 'm-3m',
                                                     'symbol': 'Fm-3m',
                                                     'symprec': 0.1,
                                                     'version': '2.6.0'},
                                        'volume': 11.761470249999999}},
 'name': 'fairchem Relax',
 'nid': 'runnervm1w6u6.04p4rmzsbequpadhmj22ussfqa.ex.internal.cloudapp.net',
 'parameters': {'version': '0.1.dev1+g52c975e'},
 'parameters_opt': {'fmax': 0.001,
                    'max_steps': 1000,
                    'maxstep': 0.2,
                    'optimizer': 'LBFGS',
                    'type': 'optimization'},
 'quacc_version': '0.15.5',
 'results': {'energy': -3.757900797531085,
             'forces': array([[0., 0., 0.]], dtype=float32),
             'free_energy': -3.757900797531085,
             'stress': array([-6.3946825e-03, -6.3946820e-03, -6.3946806e-03,  5.8823268e-10,
       -3.2705114e-10, -1.2671243e-09], dtype=float32)},
 'structure_metadata': {'builder_meta': {'build_date': datetime.datetime(2025, 6, 5, 20, 43, 50, 570712, tzinfo=datetime.timezone.utc),
                                         'emmet_version': '0.84.6',
                                         'pymatgen_version': '2025.1.9'},
                        'chemsys': 'Cu',
                        'composition': Composition('Cu1'),
                        'composition_reduced': Composition('Cu1'),
                        'density': 8.971719813140734,
                        'density_atomic': 11.761470249999999,
                        'elements': [Element Cu],
                        'formula_anonymous': 'A',
                        'formula_pretty': 'Cu',
                        'nelements': 1,
                        'nsites': 1,
                        'symmetry': {'angle_tolerance': 5.0,
                                     'crystal_system': <CrystalSystem.cubic: 'Cubic'>,
                                     'number': 225,
                                     'point_group': 'm-3m',
                                     'symbol': 'Fm-3m',
                                     'symprec': 0.1,
                                     'version': '2.6.0'},
                        'volume': 11.761470249999999},
 'trajectory': [Atoms(symbols='Cu', pbc=True, cell=[[0.0, 1.805, 1.805], [1.805, 0.0, 1.805], [1.805, 1.805, 0.0]], calculator=SinglePointCalculator(...))],
 'trajectory_results': [{'energy': -3.757900797531085,
                         'forces': array([[0., 0., 0.]]),
                         'free_energy': -3.757900797531085,
                         'stress': array([-6.39468245e-03, -6.39468199e-03, -6.39468059e-03,  5.88232685e-10,
       -3.27051136e-10, -1.26712429e-09])}]}

Congratulations; you ran your first relaxation using an OMat24-trained checkpoint and quacc!