Pre-trained ODAC models are versatile across various MOF-related tasks. To begin, we’ll start with a fundamental application: calculating the adsorption energy for a single CO2 molecule. This serves as an excellent and simple demonstration of what you can achieve with these datasets and models.
For predicting the adsorption energy of a single CO2 molecule within a MOF structure, the adsorption energy () is defined as:
Each term on the right-hand side represents the energy of the relaxed state of the indicated chemical system. For a comprehensive understanding of our methodology for computing these adsorption energies, please refer to our paper.
Loading Pre-trained Models¶
Need to install fairchem-core or get UMA access or getting permissions/401 errors?
Install the necessary packages using pip, uv etc
! pip install fairchem-core fairchem-data-oc fairchem-applications-cattsunamiGet access to any necessary huggingface gated models
Get and login to your Huggingface account
Request access to https://
huggingface .co /facebook /UMA Create a Huggingface token at https://
huggingface .co /settings /tokens/ with the permission “Permissions: Read access to contents of all public gated repos you can access” Add the token as an environment variable using
huggingface-cli loginor by setting the HF_TOKEN environment variable.
# Login using the huggingface-cli utility
! huggingface-cli login
# alternatively,
import os
os.environ['HF_TOKEN'] = 'MY_TOKEN'A pre-trained model can be loaded using FAIRChemCalculator. In this example, we’ll employ UMA to determine the CO2 adsorption energies.
from fairchem.core import FAIRChemCalculator, pretrained_mlip
predictor = pretrained_mlip.get_predict_unit("uma-s-1p2p1")
calc = FAIRChemCalculator(predictor, task_name="odac")WARNING:root:device was not explicitly set, using device='cuda'.
WARNING:root:UMA Nitro cannot serve this request: nitro mode supports only CUDA compute capability 8.x-12.x, not 7.5.
WARNING:root:Now running with nitro=False, execution_mode='umas_fast_gpu' (TF32).
WARNING:root:Running in a reduced-precision mode: some values, such as higher-order derivatives and phonon calculations, will be less accurate. For standard FP32 precision, use inference_settings='high-precision'.
Adsorption in rigid MOFs: CO2 Adsorption Energy in Mg-MOF-74¶
Let’s apply our knowledge to Mg-MOF-74, a widely studied MOF known for its excellent CO2 adsorption properties. Its structure comprises magnesium atomic complexes connected by a carboxylated and oxidized benzene ring, serving as an organic linker. Previous studies consistently report the CO2 adsorption energy for Mg-MOF-74 to be around -0.40 eV [1] [2] [3].
Our goal is to verify if we can achieve a similar value by performing a simple single-point calculation using UMA. In the ODAC23 dataset, all MOF structures are identified by their CSD (Cambridge Structural Database) code. For Mg-MOF-74, this code is OPAGIX. We’ve extracted a specific OPAGIX+CO2 configuration from the dataset, which exhibits the lowest adsorption energy among its counterparts.
import matplotlib.pyplot as plt
from ase.io import read
from ase.visualize.plot import plot_atoms
mof_co2 = read("structures/OPAGIX_w_CO2.cif")
mof = read("structures/OPAGIX.cif")
co2 = read("structures/co2.xyz")
fig, ax = plt.subplots(figsize=(5, 4.5), dpi=250)
plot_atoms(mof_co2, ax)
ax.set_axis_off()
The final step in calculating the adsorption energy involves connecting the FAIRChemCalculator to each relaxed structure: OPAGIX+CO2, OPAGIX, and CO2. The structures used here are already relaxed from ODAC23. For simplicity, we assume here that further relaxations can be neglected. We will show how to go beyond this assumption in the next section.
mof_co2.calc = calc
mof.calc = calc
co2.calc = calc
E_ads = (
mof_co2.get_potential_energy()
- mof.get_potential_energy()
- co2.get_potential_energy()
)
print(f"Adsorption energy of CO2 in Mg-MOF-74: {E_ads:.3f} eV")WARNING:root:Model is being compiled. This might take a while the first time.
WARNING:root:Running (unknown commit) with inference settings: multigpu
W1117 18:37:02.995000 14312 site-packages/torch/_logging/_internal.py:1345] [0/0] Profiler record function <class 'torch.autograd.profiler.record_function'> will be ignored
WARNING:root:The UMA fast path (merge_mole + compile) is only available for fixed composition, task, charge, and spin. This is optimized for MD applications. Falling back to a less optimized version for subsequent evaluations. Reason: 'Compositions differ from merged model'.
Use inference_settings='batch' for heterogeneous batched evaluations.
WARNING:root:Now running with merge_mole=False, compile=False, execution_mode='general' (TF32).
Adsorption energy of CO2 in Mg-MOF-74: -0.482 eV
Adsorption in flexible MOFs¶
The adsorption energy calculation method outlined above is typically performed with rigid MOFs for simplicity. Both experimental and modeling literature have shown, however, that MOF flexibility can be important in accurately capturing the underlying chemistry of adsorption [1] [2] [3]. In particular, uptake can be improved by treating MOFs as flexible. Two types of MOF flexibility can be considered: intrinsic flexibility and deformation induced by guest molecules. In the Open DAC Project, we consider the latter MOF deformation by allowing the atomic positions of the MOF to relax during geometry optimization [4]. The addition of additional degrees of freedoms can complicate the computation of the adsorption energy and necessitates an extra step in the calculation procedure.
The figure below shows water adsorption in the MOF with CSD code WOBHEB with added defects (WOBHEB_0.11_0) from a DFT simulation. A typical adsorption energy calculation would only seek to capture the effects shaded in purple, which include both chemisorption and non-bonded interactions between the host and guest molecule. When allowing the MOF to relax, however, the adsorption energy also includes the energetic effect of the MOF deformation highlighted in green.

To account for this deformation, it is vital to use the most energetically favorable MOF geometry for the empty MOF term in Eqn. 1. Including MOF atomic coordinates as degrees of freedom can result in three possible outcomes:
The MOF does not deform, so the energies of the relaxed empty MOF and the MOF in the adsorbed state are the same
The MOF deforms to a less energetically favorable geometry than its ground state
The MOF locates a new energetically favorable geometry relative to the empty MOF relaxation
The first outcome requires no additional computation because the MOF rigidity assumption is valid. The second outcome represents physical and reversible deformation where the MOF returns to its empty ground state upon removal of the guest molecule. The third outcome is often the result of the guest molecule breaking local symmetry. We also found cases in ODAC in which both outcomes 2 and 3 occur within the same MOF.
To ensure the most energetically favorable empty MOF geometry is found, an addition empty MOF relaxation should be performed after MOF + adsorbate relaxation. The guest molecule should be removed, and the MOF should be relaxed starting from its geometry in the adsorbed state. If all deformation is reversible, the MOF will return to its original empty geometry. Otherwise, the lowest energy (most favorable) MOF geometry should be taken as the reference energy, , in Eqn. 1.
H2O Adsorption Energy in Flexible WOBHEB with UMA¶
The first part of this tutorial demonstrates how to perform a single point adsorption energy calculation using UMA. To treat MOFs as flexible, we perform all calculations on geometries determined by geometry optimization. The following example corresponds to the figure shown above (H2O adsorption in WOBHEB_0.11_0).
In this tutorial, corresponds to the energy of determined from geometry optimization of .
First, we obtain the energy of the empty MOF from relaxation of only the MOF:
import ase.io
from ase.optimize import BFGS
mof = ase.io.read("structures/WOBHEB_0.11.cif")
mof.calc = calc
relax = BFGS(mof)
relax.run(fmax=0.05)
E_mof_empty = mof.get_potential_energy()
print(f"Energy of empty MOF: {E_mof_empty:.3f} eV") Step Time Energy fmax
BFGS: 0 18:37:52 -1077.361727 0.157084
BFGS: 1 18:37:55 -1077.363819 0.092716
BFGS: 2 18:37:57 -1077.366762 0.102511
BFGS: 3 18:37:58 -1077.369805 0.112168
BFGS: 4 18:38:00 -1077.372809 0.108711
BFGS: 5 18:38:05 -1077.375107 0.081820
BFGS: 6 18:38:08 -1077.377096 0.059929
BFGS: 7 18:38:09 -1077.379167 0.081634
BFGS: 8 18:38:11 -1077.381439 0.086817
BFGS: 9 18:38:11 -1077.383767 0.074807
BFGS: 10 18:38:12 -1077.386161 0.097208
BFGS: 11 18:38:12 -1077.388721 0.102984
BFGS: 12 18:38:12 -1077.391366 0.102469
BFGS: 13 18:38:12 -1077.393884 0.092469
BFGS: 14 18:38:13 -1077.396293 0.108259
BFGS: 15 18:38:13 -1077.398862 0.132790
BFGS: 16 18:38:13 -1077.401810 0.117676
BFGS: 17 18:38:17 -1077.404703 0.076298
BFGS: 18 18:38:18 -1077.407170 0.077358
BFGS: 19 18:38:18 -1077.409309 0.096880
BFGS: 20 18:38:18 -1077.411619 0.094337
BFGS: 21 18:38:20 -1077.414300 0.097043
BFGS: 22 18:38:24 -1077.417216 0.103993
BFGS: 23 18:38:27 -1077.420046 0.076086
BFGS: 24 18:38:27 -1077.422612 0.092521
BFGS: 25 18:38:31 -1077.424987 0.075256
BFGS: 26 18:38:31 -1077.427307 0.088240
BFGS: 27 18:38:32 -1077.429530 0.086684
BFGS: 28 18:38:32 -1077.431511 0.069623
BFGS: 29 18:38:33 -1077.433208 0.064776
BFGS: 30 18:38:35 -1077.434723 0.050619
BFGS: 31 18:38:35 -1077.436140 0.067188
BFGS: 32 18:38:35 -1077.437485 0.061957
BFGS: 33 18:38:35 -1077.438764 0.054406
BFGS: 34 18:38:36 -1077.440066 0.040944
Energy of empty MOF: -1077.440 eV
Next, we add the H2O guest molecule and relax the MOF + adsorbate to obtain .
mof_h2o = ase.io.read("structures/WOBHEB_H2O.cif")
mof_h2o.calc = calc
relax = BFGS(mof_h2o)
relax.run(fmax=0.05)
E_combo = mof_h2o.get_potential_energy()
print(f"Energy of MOF + H2O: {E_combo:.3f} eV") Step Time Energy fmax
BFGS: 0 18:38:37 -1091.648157 1.137715
BFGS: 1 18:38:39 -1091.667006 0.323337
BFGS: 2 18:38:42 -1091.671333 0.231188
BFGS: 3 18:38:46 -1091.684671 0.293446
BFGS: 4 18:38:46 -1091.690922 0.233354
BFGS: 5 18:38:47 -1091.698608 0.197342
BFGS: 6 18:38:47 -1091.705230 0.197564
BFGS: 7 18:38:48 -1091.713824 0.253803
BFGS: 8 18:38:51 -1091.721811 0.223081
BFGS: 9 18:38:52 -1091.729996 0.200583
BFGS: 10 18:38:53 -1091.738728 0.221081
BFGS: 11 18:38:54 -1091.748966 0.290241
BFGS: 12 18:38:54 -1091.760313 0.285109
BFGS: 13 18:38:55 -1091.772068 0.191338
BFGS: 14 18:38:55 -1091.783886 0.190963
BFGS: 15 18:38:57 -1091.795382 0.272187
BFGS: 16 18:38:57 -1091.806224 0.314320
BFGS: 17 18:38:59 -1091.815599 0.230977
BFGS: 18 18:39:01 -1091.823823 0.138395
BFGS: 19 18:39:04 -1091.831512 0.132288
BFGS: 20 18:39:04 -1091.839424 0.145992
BFGS: 21 18:39:05 -1091.847561 0.154089
BFGS: 22 18:39:06 -1091.855794 0.170295
BFGS: 23 18:39:09 -1091.863481 0.150909
BFGS: 24 18:39:09 -1091.870183 0.206388
BFGS: 25 18:39:10 -1091.876083 0.145834
BFGS: 26 18:39:10 -1091.877373 0.694853
BFGS: 27 18:39:10 -1091.885684 0.147758
BFGS: 28 18:39:11 -1091.890052 0.134159
BFGS: 29 18:39:14 -1091.898108 0.174533
BFGS: 30 18:39:15 -1091.901589 0.135501
BFGS: 31 18:39:15 -1091.911283 0.151624
BFGS: 32 18:39:16 -1091.917106 0.178147
BFGS: 33 18:39:17 -1091.914834 0.801178
BFGS: 34 18:39:18 -1091.924993 0.149499
BFGS: 35 18:39:18 -1091.928851 0.151629
BFGS: 36 18:39:20 -1091.941491 0.282889
BFGS: 37 18:39:23 -1091.945653 0.172521
BFGS: 38 18:39:23 -1091.956223 0.267918
BFGS: 39 18:39:24 -1091.962030 0.198056
BFGS: 40 18:39:27 -1091.967890 0.449085
BFGS: 41 18:39:28 -1091.977025 0.192049
BFGS: 42 18:39:28 -1091.988868 0.222431
BFGS: 43 18:39:31 -1091.997268 0.157857
BFGS: 44 18:39:32 -1092.007975 0.489175
BFGS: 45 18:39:34 -1092.020317 0.292905
BFGS: 46 18:39:35 -1092.034474 0.253764
BFGS: 47 18:39:36 -1092.058396 0.464615
BFGS: 48 18:39:37 -1092.073121 0.244910
BFGS: 49 18:39:39 -1092.102085 0.294908
BFGS: 50 18:39:42 -1092.124501 0.631337
BFGS: 51 18:39:43 -1092.142823 0.489587
BFGS: 52 18:39:46 -1092.162884 0.382470
BFGS: 53 18:39:48 -1092.176486 0.315811
BFGS: 54 18:39:49 -1092.193351 0.336499
BFGS: 55 18:39:50 -1092.206851 0.398687
BFGS: 56 18:39:50 -1092.223521 0.413899
BFGS: 57 18:39:50 -1092.237382 0.392397
BFGS: 58 18:39:51 -1092.249874 0.231310
BFGS: 59 18:39:51 -1092.259318 0.212180
BFGS: 60 18:39:52 -1092.267720 0.165231
BFGS: 61 18:39:53 -1092.274635 0.100057
BFGS: 62 18:39:56 -1092.279699 0.091235
BFGS: 63 18:39:57 -1092.284585 0.109100
BFGS: 64 18:39:57 -1092.289582 0.120355
BFGS: 65 18:40:01 -1092.294200 0.130192
BFGS: 66 18:40:01 -1092.298679 0.126257
BFGS: 67 18:40:01 -1092.303364 0.189020
BFGS: 68 18:40:02 -1092.308055 0.192514
BFGS: 69 18:40:02 -1092.312318 0.153055
BFGS: 70 18:40:05 -1092.316106 0.100675
BFGS: 71 18:40:06 -1092.319746 0.105769
BFGS: 72 18:40:06 -1092.323243 0.109359
BFGS: 73 18:40:09 -1092.326286 0.071126
BFGS: 74 18:40:11 -1092.328859 0.086629
BFGS: 75 18:40:12 -1092.331242 0.085067
BFGS: 76 18:40:15 -1092.333541 0.094351
BFGS: 77 18:40:17 -1092.335645 0.079785
BFGS: 78 18:40:21 -1092.337482 0.081104
BFGS: 79 18:40:23 -1092.339225 0.103117
BFGS: 80 18:40:26 -1092.341051 0.123802
BFGS: 81 18:40:27 -1092.342989 0.115016
BFGS: 82 18:40:28 -1092.344947 0.074675
BFGS: 83 18:40:31 -1092.346836 0.065342
BFGS: 84 18:40:33 -1092.348591 0.066947
BFGS: 85 18:40:33 -1092.350177 0.060948
BFGS: 86 18:40:36 -1092.351536 0.051119
BFGS: 87 18:40:37 -1092.352661 0.043798
Energy of MOF + H2O: -1092.353 eV
We can now isolate the MOF atoms from the relaxed MOF + H2O geometry and see that the MOF has adopted a geometry that is less energetically favorable than the empty MOF by ~0.2 eV. The energy of the MOF in the adsorbed state corresponds to .
mof_adsorbed_state = mof_h2o[:-3]
mof_adsorbed_state.calc = calc
E_mof_adsorbed_state = mof_adsorbed_state.get_potential_energy()
print(f"Energy of MOF in the adsorbed state: {E_mof_adsorbed_state:.3f} eV")Energy of MOF in the adsorbed state: -1077.127 eV
H2O adsorption in this MOF appears to correspond to Case #2 as outlined above. We can now perform re-relaxation of the empty MOF starting from the geometry.
relax = BFGS(mof_adsorbed_state)
relax.run(fmax=0.05)
E_mof_rerelax = mof_adsorbed_state.get_potential_energy()
print(f"Energy of re-relaxed empty MOF: {E_mof_rerelax:.3f} eV") Step Time Energy fmax
BFGS: 0 18:40:37 -1077.126947 1.235929
BFGS: 1 18:40:39 -1077.178072 1.026628
BFGS: 2 18:40:40 -1077.239492 0.690621
BFGS: 3 18:40:40 -1077.283414 0.442383
BFGS: 4 18:40:41 -1077.302708 0.367840
BFGS: 5 18:40:42 -1077.319855 0.344439
BFGS: 6 18:40:45 -1077.335318 0.328799
BFGS: 7 18:40:47 -1077.347265 0.241411
BFGS: 8 18:40:50 -1077.354679 0.142512
BFGS: 9 18:40:53 -1077.359846 0.151054
BFGS: 10 18:40:55 -1077.364688 0.188074
BFGS: 11 18:40:58 -1077.369716 0.168053
BFGS: 12 18:40:58 -1077.374828 0.154824
BFGS: 13 18:40:59 -1077.379918 0.126209
BFGS: 14 18:41:00 -1077.384830 0.140472
BFGS: 15 18:41:03 -1077.389153 0.114069
BFGS: 16 18:41:06 -1077.392721 0.092546
BFGS: 17 18:41:07 -1077.395905 0.090046
BFGS: 18 18:41:10 -1077.399095 0.109052
BFGS: 19 18:41:13 -1077.402273 0.117249
BFGS: 20 18:41:13 -1077.405400 0.104962
BFGS: 21 18:41:17 -1077.408504 0.107666
BFGS: 22 18:41:20 -1077.411561 0.096522
BFGS: 23 18:41:23 -1077.414463 0.099396
BFGS: 24 18:41:26 -1077.417151 0.080842
BFGS: 25 18:41:29 -1077.419619 0.082716
BFGS: 26 18:41:32 -1077.421826 0.078497
BFGS: 27 18:41:34 -1077.423683 0.078646
BFGS: 28 18:41:37 -1077.425242 0.051392
BFGS: 29 18:41:39 -1077.426719 0.074738
BFGS: 30 18:41:42 -1077.428274 0.083024
BFGS: 31 18:41:44 -1077.429782 0.076272
BFGS: 32 18:41:47 -1077.431100 0.051196
BFGS: 33 18:41:49 -1077.432324 0.051896
BFGS: 34 18:41:49 -1077.433648 0.060569
BFGS: 35 18:41:50 -1077.435137 0.087295
BFGS: 36 18:41:51 -1077.436659 0.085680
BFGS: 37 18:41:52 -1077.437994 0.074173
BFGS: 38 18:41:55 -1077.439316 0.062776
BFGS: 39 18:41:56 -1077.440617 0.052436
BFGS: 40 18:41:57 -1077.441966 0.054697
BFGS: 41 18:41:57 -1077.443017 0.060630
BFGS: 42 18:41:57 -1077.444267 0.053089
BFGS: 43 18:41:58 -1077.445377 0.055993
BFGS: 44 18:41:58 -1077.446388 0.040171
Energy of re-relaxed empty MOF: -1077.446 eV
The MOF returns to its original empty reference energy upon re-relaxation, confirming that this deformation is physically relevant and is induced by the adsorbate molecule. In Case #3, this re-relaxed energy will be more negative (more favorable) than the original empty MOF relaxation. Thus, we take the reference empty MOF energy ( in Eqn. 1) to be the minimum of the original empty MOF energy and the re-relaxed MOf energy:
E_mof = min(E_mof_empty, E_mof_rerelax)
# get adsorbate reference energy
h2o = mof_h2o[-3:]
h2o.calc = calc
E_h2o = h2o.get_potential_energy()
# compute adsorption energy
E_ads = E_combo - E_mof - E_h2o
print(f"Adsorption energy of H2O in WOBHEB_0.11_0: {E_ads:.3f} eV")Adsorption energy of H2O in WOBHEB_0.11_0: -0.535 eV
This adsorption energy closely matches that from DFT (–0.699 eV) [1]. The strong adsorption energy is a consequence of both H2O chemisorption and MOF deformation. We can decompose the adsorption energy into contributions from these two factors. Assuming rigid H2O molecules, we define and , respectively, as
describes host–guest interactions for the MOF in the adsorbed state only. quantifies the magnitude of deformation between the MOF in the adsorbed state and the most energetically favorable empty MOF geometry determined from the workflow presented here. It can be shown that
For H2O adsorption in WOBHEB_0.11, we have
E_int = E_combo - E_mof_adsorbed_state - E_h2o
print(f"E_int: {E_int}")E_int: -0.8547043147729791
E_mof_deform = E_mof_adsorbed_state - E_mof_empty
print(f"E_mof_deform: {E_mof_deform}")E_mof_deform: 0.3131192408086463
E_ads = E_int + E_mof_deform
print(f"E_ads: {E_ads}")E_ads: -0.5415850739643329
is equivalent to when the MOF is assumed to be rigid. In this case, failure to consider adsorbate-induced deformation would result in an overestimation of the adsorption energy magnitude.
Acknowledgements & Authors¶
Logan Brabson and Sihoon Choi (Georgia Tech) and the OpenDAC project.
- The Open DAC 2023 Dataset and Challenges for Sorbent Discovery in Direct Air Capture. (2024). 10.1021/acscentsci.3c01629
- Carbon Dioxide Adsorption in Mg-MOF-74. (2015). 10.1039/C4SC02064B
- Carbon Dioxide Adsorption in Mg-MOF-74. (2014). 10.1039/C3SC51319J
- Carbon Dioxide Adsorption in Mg-MOF-74. (2018). 10.1021/acs.jpcc.8b00938