facebookresearch / fairchem
- пятница, 16 мая 2025 г. в 00:00:04
FAIR Chemistry's library of machine learning methods for chemistry
fairchem
is the FAIR Chemistry's centralized repository of all its data, models,
demos, and application efforts for materials science and quantum chemistry.
⚠️ FAIRChem version 2 is a breaking change from version 1 and is not compatible with our previous pretrained models and code. If you want to use an older model or code from version 1 you will need to install version 1, as detailed here.
Read about the UMA model and dataset release.
If you want to explore model capabilities check out our educational demo
Install fairchem-core using pip,
pip install git+https://github.com/facebookresearch/fairchem.git@fairchem_core-2.0.0#subdirectory=packages/fairchem-core
The PyPI install (pip install fairchem-core) is not available right now as we are waiting for a few dependencies to release their PyPI packages, will update this soon when it's available!
The easiest way to use pretrained models is via the ASE FAIRChemCalculator
.
A single uma model can be used for a wide range of applications in chemistry and materials science by picking the
appropriate task name for domain specific prediction.
Make sure you have a Hugging Face account, have already applied for model access to the UMA model repository, and have logged in to Hugging Face using an access token.
Relax adsorbate on a catalytic surface,
from ase.build import fcc100, add_adsorbate, molecule
from ase.optimize import LBFGS
from fairchem.core import FAIRChemCalculator
calc = FAIRChemCalculator(hf_hub_filename="uma_sm.pt", device="cuda", task_name="oc20")
# Set up your system as an ASE atoms object
slab = fcc100("Cu", (3, 3, 3), vacuum=8, periodic=True)
adsorbate = molecule("CO")
add_adsorbate(slab, adsorbate, 2.0, "bridge")
slab.calc = calc
# Set up LBFGS dynamics object
opt = LBFGS(slab)
opt.run(0.05, 100)
Or relax an inorganic crystal,
from ase.build import bulk
from ase.optimize import FIRE
from ase.filters import FrechetCellFilter
from fairchem.core import FAIRChemCalculator
calc = FAIRChemCalculator(hf_hub_filename="uma_sm.pt", device="cuda", task_name="omat")
atoms = bulk("Fe")
atoms.calc = calc
opt = LBFGS(FrechetCellFilter(atoms))
opt.run(0.05, 100)
Run molecular MD,
from ase import units
from ase.io import Trajectory
from ase.md.langevin import Langevin
from ase.build import molecule
from fairchem.core import FAIRChemCalculator
calc = FAIRChemCalculator(hf_hub_filename="uma_sm.pt", device="cuda", task_name="omol")
atoms = molecule("H2O")
atoms.calc = calc
dyn = Langevin(
atoms,
timestep=0.1 * units.fs,
temperature_K=400,
friction=0.001 / units.fs,
)
trajectory = Trajectory("my_md.traj", "w", atoms)
dyn.attach(trajectory.write, interval=1)
dyn.run(steps=1000)
A single repository simplifies testing and ensures consistency across our interconnected core, data and application packages. The repo is organized into several directories to help you find what you are looking for:
fairchem.core
: State-of-the-art machine learning models for materials science and chemistryfairchem.data
: Dataset downloads and input generation codesfairchem.demo
: Python API for the Open Catalyst Demofairchem.applications
: Follow up applications and works (AdsorbML, CatTSunami, etc.)You can still use models from fairchem version 1, by installing version 1,
pip install fairchem-core==1.10
And using the OCPCalculator
from fairchem.core import OCPCalculator
calc = OCPCalculator(
model_name="EquiformerV2-31M-S2EF-OC20-All+MD",
local_cache="pretrained_models",
cpu=False,
)
fairchem
is available under a MIT License.