| Property | Value |
|---|---|
| Difficulty | Beginner |
| Time | 15-30 minutes |
| Prerequisites | Basic Python, familiarity with ASE |
| Goal | Calculate adsorption energies using UMA models |
To introduce OCP we start with using it to calculate adsorption energies for a simple, atomic adsorbate where we specify the site we want to the adsorption energy for. Conceptually, you do this like you would do it with density functional theory. You create a slab model for the surface, place an adsorbate on it as an initial guess, run a relaxation to get the lowest energy geometry, and then compute the adsorption energy using reference states for the adsorbate.
Intro to Adsorption energies¶
Adsorption energies are always a reaction energy (an adsorbed species relative to some implied combination of reactants). There are many common schemes in the catalysis literature.
For example, you may want the adsorption energy of oxygen, and you might compute that from this reaction:
1/2 O2 + slab -> slab-ODFT has known errors with the energy of a gas-phase O2 molecule, so it’s more common to compute this energy relative to a linear combination of H2O and H2. The suggested reference scheme for consistency with OC20 is a reaction
x CO + (x + y/2 - z) H2 + (z-x) H2O + w/2 N2 + * -> CxHyOzNw*Here, x=y=w=0, z=1, so the reaction ends up as
-H2 + H2O + * -> O*or alternatively,
H2O + * -> O* + H2It is possible through thermodynamic cycles to compute other reactions. If we can look up rH1 below and compute rH2
H2 + 1/2 O2 -> H2O re1 = -3.03 eV, from exp
H2O + * -> O* + H2 re2 # Get from UMAThen, the adsorption energy for
1/2O2 + * -> O*is just re1 + re2.
Based on https://atct.anl.gov/Thermochemical Data/version 1.118/species/?species_number=986, the formation energy of water is about -3.03 eV at standard state experimentally. You could also compute this using DFT, but you would probably get the wrong answer for this.
The first step is getting a checkpoint for the model we want to use. UMA is currently the state-of-the-art model and will provide total energy estimates at the RPBE level of theory if you use the “OC20” task.
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'If you find your kernel is crashing, it probably means you have exceeded the allowed amount of memory. This checkpoint works fine in this example, but it may crash your kernel if you use it in the NRR example.
This next cell will automatically download the checkpoint from huggingface and load it.
from __future__ import annotations
from fairchem.core import FAIRChemCalculator, pretrained_mlip
predictor = pretrained_mlip.get_predict_unit("uma-s-1p2p1")
calc = FAIRChemCalculator(predictor, task_name="oc20")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'.
Next we can build a slab with an adsorbate on it. Here we use the ASE module to build a Pt slab. We use the experimental lattice constant that is the default. This can introduce some small errors with DFT since the lattice constant can differ by a few percent, and it is common to use DFT lattice constants. In this example, we do not constrain any layers.
from ase.build import add_adsorbate, fcc111
from ase.optimize import BFGS# reference energies from a linear combination of H2O/N2/CO/H2!
atomic_reference_energies = {
"H": -3.477,
"N": -8.083,
"O": -7.204,
"C": -7.282,
}
re1 = -3.03
slab = fcc111("Pt", size=(2, 2, 5), vacuum=20.0)
slab.pbc = True
adslab = slab.copy()
add_adsorbate(adslab, "O", height=1.2, position="fcc")
slab.set_calculator(calc)
opt = BFGS(slab)
opt.run(fmax=0.05, steps=100)
slab_e = slab.get_potential_energy()
adslab.set_calculator(calc)
opt = BFGS(adslab)
opt.run(fmax=0.05, steps=100)
adslab_e = adslab.get_potential_energy()
# Energy for ((H2O-H2) + * -> *O) + (H2 + 1/2O2 -> H2) leads to 1/2O2 + * -> *O!
adslab_e - slab_e - atomic_reference_energies["O"] + re1/tmp/ipykernel_13731/3752951811.py:17: FutureWarning: Please use atoms.calc = calc
slab.set_calculator(calc)
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:33:01.411000 13731 site-packages/torch/_logging/_internal.py:1345] [0/0] Profiler record function <class 'torch.autograd.profiler.record_function'> will be ignored
Step Time Energy fmax
BFGS: 0 18:33:41 -104.713230 0.695699
BFGS: 1 18:33:41 -104.770833 0.592989
BFGS: 2 18:33:41 -104.910088 0.340089
BFGS: 3 18:33:41 -104.937705 0.411474
BFGS: 4 18:33:41 -105.009225 0.454697
/tmp/ipykernel_13731/3752951811.py:22: FutureWarning: Please use atoms.calc = calc
adslab.set_calculator(calc)
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.
BFGS: 5 18:33:41 -105.068383 0.352796
BFGS: 6 18:33:41 -105.105352 0.173380
BFGS: 7 18:33:41 -105.116031 0.042064
WARNING:root:Now running with merge_mole=False, compile=False, execution_mode='general' (TF32).
Step Time Energy fmax
BFGS: 0 18:33:48 -110.098582 1.709168
BFGS: 1 18:33:48 -110.275965 0.961389
BFGS: 2 18:33:48 -110.420419 0.724063
BFGS: 3 18:33:48 -110.468240 0.788381
BFGS: 4 18:33:48 -110.569491 0.640716
BFGS: 5 18:33:49 -110.633821 0.473709
BFGS: 6 18:33:49 -110.685971 0.559150
BFGS: 7 18:33:49 -110.731266 0.612394
BFGS: 8 18:33:49 -110.762440 0.457357
BFGS: 9 18:33:49 -110.776663 0.240121
BFGS: 10 18:33:50 -110.780698 0.109503
BFGS: 11 18:33:50 -110.781686 0.093772
BFGS: 12 18:33:50 -110.782524 0.057396
BFGS: 13 18:33:50 -110.783130 0.043500
-1.4930990852071981It is good practice to look at your geometries to make sure they are what you expect.
import matplotlib.pyplot as plt
from ase.visualize.plot import plot_atoms
fig, axs = plt.subplots(1, 2)
plot_atoms(slab, axs[0])
plot_atoms(slab, axs[1], rotation=("-90x"))
axs[0].set_axis_off()
axs[1].set_axis_off()
import matplotlib.pyplot as plt
from ase.visualize.plot import plot_atoms
fig, axs = plt.subplots(1, 2)
plot_atoms(adslab, axs[0])
plot_atoms(adslab, axs[1], rotation=("-90x"))
axs[0].set_axis_off()
axs[1].set_axis_off()
How did we do? We need a reference point. In the paper below, there is an atomic adsorption energy for O on Pt(111) of about -4.264 eV. This is for the reaction O + * -> O*. To convert this to the dissociative adsorption energy, we have to add the reaction:
1/2 O2 -> O D = 2.58 eV (expt)to get a comparable energy of about -1.68 eV. There is about ~0.2 eV difference (we predicted -1.47 eV above, and the reference comparison is -1.68 eV) to account for. The biggest difference is likely due to the differences in exchange-correlation functional. The reference data used the PBE functional, and eSCN was trained on RPBE data. To additional places where there are differences include:
Difference in lattice constant
The reference energy used for the experiment references. These can differ by up to 0.5 eV from comparable DFT calculations.
How many layers are relaxed in the calculation
Some of these differences tend to be systematic, and you can calibrate and correct these, especially if you can augment these with your own DFT calculations.
See convergence study for some additional studies of factors that influence this number.
Exercises¶
Explore the effect of the lattice constant on the adsorption energy.
Try different sites, including the bridge and top sites. Compare the energies, and inspect the resulting geometries.
Trends in adsorption energies across metals.¶
Xu, Z., & Kitchin, J. R. (2014). Probing the coverage dependence of site and adsorbate configurational correlations on (111) surfaces of late transition metals. J. Phys. Chem. C, 118(44), 25597–25602. Xu & Kitchin (2014)
These are atomic adsorption energies:
O + * -> O*We have to do some work to get comparable numbers from OCP
H2 + 1/2 O2 -> H2O re1 = -3.03 eV
H2O + * -> O* + H2 re2 # Get from UMA
O -> 1/2 O2 re3 = -2.58 eVThen, the adsorption energy for
O + * -> O*is just re1 + re2 + re3.
Here we just look at the fcc site on Pt. First, we get the data stored in the paper.
Next we get the structures and compute their energies. Some subtle points are that we have to account for stoichiometry, and normalize the adsorption energy by the number of oxygens.
First we get a reference energy from the paper (PBE, 0.25 ML O on Pt(111)).
import json
with open("energies.json") as f:
edata = json.load(f)
with open("structures.json") as f:
sdata = json.load(f)
edata["Pt"]["O"]["fcc"]["0.25"]-4.263842000000002Next, we load data from the SI to get the geometry to start from.
with open("structures.json") as f:
s = json.load(f)
sfcc = s["Pt"]["O"]["fcc"]["0.25"]Next, we construct the atomic geometry, run the geometry optimization, and compute the energy.
re3 = -2.58 # O -> 1/2 O2 re3 = -2.58 eV
from ase import Atoms
adslab = Atoms(sfcc["symbols"], positions=sfcc["pos"], cell=sfcc["cell"], pbc=True)
# Grab just the metal surface atoms
slab = adslab[adslab.arrays["numbers"] == adslab.arrays["numbers"][0]]
adsorbates = adslab[~(adslab.arrays["numbers"] == adslab.arrays["numbers"][0])]
slab.set_calculator(calc)
opt = BFGS(slab)
opt.run(fmax=0.05, steps=100)
adslab.set_calculator(calc)
opt = BFGS(adslab)
opt.run(fmax=0.05, steps=100)
re2 = (
adslab.get_potential_energy()
- slab.get_potential_energy()
- sum([atomic_reference_energies[x] for x in adsorbates.get_chemical_symbols()])
)
nO = 0
for atom in adslab:
if atom.symbol == "O":
nO += 1
re2 += re1 + re3
print(re2 / nO)/tmp/ipykernel_13731/647904475.py:10: FutureWarning: Please use atoms.calc = calc
slab.set_calculator(calc)
Step Time Energy fmax
BFGS: 0 18:33:54 -82.875792 1.001622
BFGS: 1 18:33:55 -82.933706 0.753713
BFGS: 2 18:33:55 -83.029080 0.343665
BFGS: 3 18:33:55 -83.033631 0.315219
BFGS: 4 18:33:55 -83.043724 0.217696
BFGS: 5 18:33:55 -83.048512 0.144951
BFGS: 6 18:33:56 -83.051139 0.085606
BFGS: 7 18:33:56 -83.052236 0.080543
BFGS: 8 18:33:56 -83.053002 0.071026
BFGS: 9 18:33:56 -83.053266 0.042011
Step Time Energy fmax
BFGS: 0 18:33:56 -88.766846 0.297396
/tmp/ipykernel_13731/647904475.py:14: FutureWarning: Please use atoms.calc = calc
adslab.set_calculator(calc)
BFGS: 1 18:33:57 -88.770225 0.257427
BFGS: 2 18:33:57 -88.780027 0.098766
BFGS: 3 18:33:57 -88.781393 0.101431
BFGS: 4 18:33:57 -88.785247 0.121378
BFGS: 5 18:33:57 -88.787296 0.095686
BFGS: 6 18:33:58 -88.788633 0.063879
BFGS: 7 18:33:58 -88.789398 0.055452
BFGS: 8 18:33:58 -88.789992 0.047872
-4.14272642773775
Site correlations¶
This cell reproduces a portion of a figure in the paper. We compare oxygen adsorption energies in the fcc and hcp sites across metals and coverages. These adsorption energies are highly correlated with each other because the adsorption sites are so similar.
At higher coverages, the agreement is not as good. This is likely because the model is extrapolating and needs to be fine-tuned.
import time
from tqdm import tqdm
t0 = time.time()
data = {"fcc": [], "hcp": []}
refdata = {"fcc": [], "hcp": []}
for metal in ["Cu", "Ag", "Pd", "Pt", "Rh", "Ir"]:
print(metal)
for site in ["fcc", "hcp"]:
for adsorbate in ["O"]:
for coverage in tqdm(["0.25"]):
entry = s[metal][adsorbate][site][coverage]
adslab = Atoms(
entry["symbols"],
positions=entry["pos"],
cell=entry["cell"],
pbc=True,
)
# Grab just the metal surface atoms
adsorbates = adslab[
~(adslab.arrays["numbers"] == adslab.arrays["numbers"][0])
]
slab = adslab[adslab.arrays["numbers"] == adslab.arrays["numbers"][0]]
slab.set_calculator(calc)
opt = BFGS(slab)
opt.run(fmax=0.05, steps=100)
adslab.set_calculator(calc)
opt = BFGS(adslab)
opt.run(fmax=0.05, steps=100)
re2 = (
adslab.get_potential_energy()
- slab.get_potential_energy()
- sum(
[
atomic_reference_energies[x]
for x in adsorbates.get_chemical_symbols()
]
)
)
nO = 0
for atom in adslab:
if atom.symbol == "O":
nO += 1
re2 += re1 + re3
data[site] += [re2 / nO]
refdata[site] += [edata[metal][adsorbate][site][coverage]]
f"Elapsed time = {time.time() - t0} seconds"Cu
0%| | 0/1 [00:00<?, ?it/s] Step Time Energy fmax
BFGS: 0 18:33:58 -48.900179 0.640047
/tmp/ipykernel_13731/1356342052.py:33: FutureWarning: Please use atoms.calc = calc
slab.set_calculator(calc)
BFGS: 1 18:33:58 -48.922876 0.535702
BFGS: 2 18:33:58 -48.987830 0.278368
BFGS: 3 18:33:59 -48.990214 0.248664
BFGS: 4 18:33:59 -48.996771 0.151935
BFGS: 5 18:33:59 -49.001689 0.134448
BFGS: 6 18:33:59 -49.004634 0.067513
BFGS: 7 18:33:59 -49.005324 0.049306
Step Time Energy fmax
BFGS: 0 18:33:59 -55.218070 0.302093
BFGS: 1 18:33:59 -55.220112 0.247387
/tmp/ipykernel_13731/1356342052.py:37: FutureWarning: Please use atoms.calc = calc
adslab.set_calculator(calc)
BFGS: 2 18:33:59 -55.227359 0.151301
BFGS: 3 18:34:00 -55.229154 0.148929
BFGS: 4 18:34:00 -55.232173 0.091646
BFGS: 5 18:34:00 -55.233779 0.078589
BFGS: 6 18:34:00 -55.235011 0.078972
BFGS: 7 18:34:00 -55.236091 0.099328
BFGS: 8 18:34:01 -55.237339 0.093231
BFGS: 9 18:34:01 -55.238149 0.053169
100%|██████████| 1/1 [00:03<00:00, 3.08s/it]100%|██████████| 1/1 [00:03<00:00, 3.09s/it]
BFGS: 10 18:34:01 -55.238500 0.041211
0%| | 0/1 [00:00<?, ?it/s] Step Time Energy fmax
BFGS: 0 18:34:01 -48.924787 0.554787
BFGS: 1 18:34:01 -48.942464 0.470220
BFGS: 2 18:34:02 -48.996418 0.215336
BFGS: 3 18:34:02 -48.997677 0.194299
BFGS: 4 18:34:02 -49.003507 0.083918
BFGS: 5 18:34:02 -49.005257 0.064537
BFGS: 6 18:34:02 -49.005839 0.042564
Step Time Energy fmax
BFGS: 0 18:34:03 -55.116423 0.283250
BFGS: 1 18:34:03 -55.118140 0.228270
BFGS: 2 18:34:03 -55.123704 0.148243
BFGS: 3 18:34:03 -55.125335 0.153679
BFGS: 4 18:34:03 -55.128600 0.101045
BFGS: 5 18:34:04 -55.129937 0.061993
BFGS: 6 18:34:04 -55.130646 0.052161
BFGS: 7 18:34:04 -55.131257 0.073539
BFGS: 8 18:34:04 -55.132125 0.080354
BFGS: 9 18:34:04 -55.132810 0.052460
BFGS: 10 18:34:04 -55.133080 0.029270
100%|██████████| 1/1 [00:03<00:00, 3.48s/it]100%|██████████| 1/1 [00:03<00:00, 3.48s/it]
Ag
0%| | 0/1 [00:00<?, ?it/s] Step Time Energy fmax
BFGS: 0 18:34:05 -33.031602 0.626106
BFGS: 1 18:34:05 -33.050395 0.544534
BFGS: 2 18:34:05 -33.117862 0.175300
BFGS: 3 18:34:05 -33.119735 0.160487
BFGS: 4 18:34:05 -33.121179 0.145178
BFGS: 5 18:34:06 -33.123868 0.114213
BFGS: 6 18:34:06 -33.127504 0.105987
BFGS: 7 18:34:06 -33.130241 0.068347
BFGS: 8 18:34:06 -33.131083 0.031900
Step Time Energy fmax
BFGS: 0 18:34:06 -38.192075 0.102268
BFGS: 1 18:34:06 -38.193078 0.099455
BFGS: 2 18:34:07 -38.203695 0.090580
BFGS: 3 18:34:07 -38.204613 0.091028
BFGS: 4 18:34:07 -38.207027 0.090028
BFGS: 5 18:34:07 -38.209187 0.077644
BFGS: 6 18:34:07 -38.210986 0.071189
BFGS: 7 18:34:08 -38.211907 0.063855
BFGS: 8 18:34:08 -38.212366 0.043663
100%|██████████| 1/1 [00:03<00:00, 3.20s/it]100%|██████████| 1/1 [00:03<00:00, 3.21s/it]
0%| | 0/1 [00:00<?, ?it/s] Step Time Energy fmax
BFGS: 0 18:34:08 -33.054096 0.549953
BFGS: 1 18:34:08 -33.068315 0.483648
BFGS: 2 18:34:08 -33.123290 0.132357
BFGS: 3 18:34:08 -33.124235 0.121002
BFGS: 4 18:34:08 -33.125328 0.105056
BFGS: 5 18:34:09 -33.127115 0.077527
BFGS: 6 18:34:09 -33.129498 0.074657
BFGS: 7 18:34:09 -33.130957 0.042313
Step Time Energy fmax
BFGS: 0 18:34:09 -38.108665 0.095167
BFGS: 1 18:34:09 -38.109542 0.090901
BFGS: 2 18:34:09 -38.119363 0.103903
BFGS: 3 18:34:09 -38.120377 0.087528
BFGS: 4 18:34:10 -38.122368 0.078399
BFGS: 5 18:34:10 -38.123732 0.068549
BFGS: 6 18:34:10 -38.124840 0.063126
BFGS: 7 18:34:10 -38.125563 0.066969
BFGS: 8 18:34:10 -38.126100 0.049373
100%|██████████| 1/1 [00:02<00:00, 2.68s/it]100%|██████████| 1/1 [00:02<00:00, 2.69s/it]
Pd
0%| | 0/1 [00:00<?, ?it/s] Step Time Energy fmax
BFGS: 0 18:34:11 -70.160649 0.637749
BFGS: 1 18:34:11 -70.185883 0.514166
BFGS: 2 18:34:11 -70.238642 0.202178
BFGS: 3 18:34:11 -70.240303 0.193176
BFGS: 4 18:34:11 -70.247439 0.136893
BFGS: 5 18:34:11 -70.250340 0.103758
BFGS: 6 18:34:11 -70.252113 0.071683
BFGS: 7 18:34:11 -70.252969 0.062167
BFGS: 8 18:34:11 -70.253730 0.040142
Step Time Energy fmax
BFGS: 0 18:34:12 -76.126861 0.226787
BFGS: 1 18:34:12 -76.129897 0.202917
BFGS: 2 18:34:12 -76.143234 0.150957
BFGS: 3 18:34:12 -76.144932 0.125403
BFGS: 4 18:34:12 -76.149177 0.128488
BFGS: 5 18:34:13 -76.152035 0.102060
BFGS: 6 18:34:13 -76.154434 0.097361
BFGS: 7 18:34:13 -76.155611 0.079975
BFGS: 8 18:34:13 -76.156309 0.049423
100%|██████████| 1/1 [00:02<00:00, 2.69s/it]100%|██████████| 1/1 [00:02<00:00, 2.69s/it]
0%| | 0/1 [00:00<?, ?it/s] Step Time Energy fmax
BFGS: 0 18:34:13 -70.193620 0.457900
BFGS: 1 18:34:14 -70.207966 0.375579
BFGS: 2 18:34:14 -70.243018 0.185785
BFGS: 3 18:34:14 -70.244247 0.172445
BFGS: 4 18:34:14 -70.251215 0.078477
BFGS: 5 18:34:14 -70.252101 0.072906
BFGS: 6 18:34:14 -70.252950 0.052551
BFGS: 7 18:34:14 -70.253590 0.041703
Step Time Energy fmax
BFGS: 0 18:34:15 -75.926065 0.184330
BFGS: 1 18:34:15 -75.929168 0.164894
BFGS: 2 18:34:15 -75.939951 0.164991
BFGS: 3 18:34:15 -75.941728 0.149947
BFGS: 4 18:34:15 -75.947054 0.125716
BFGS: 5 18:34:15 -75.949696 0.117588
BFGS: 6 18:34:15 -75.951840 0.087773
BFGS: 7 18:34:15 -75.952947 0.071386
100%|██████████| 1/1 [00:02<00:00, 2.51s/it]100%|██████████| 1/1 [00:02<00:00, 2.51s/it]
BFGS: 8 18:34:16 -75.953493 0.035906
Pt
0%| | 0/1 [00:00<?, ?it/s] Step Time Energy fmax
BFGS: 0 18:34:16 -82.875791 1.001622
BFGS: 1 18:34:16 -82.933706 0.753713
BFGS: 2 18:34:16 -83.029080 0.343665
BFGS: 3 18:34:16 -83.033631 0.315219
BFGS: 4 18:34:17 -83.043725 0.217686
BFGS: 5 18:34:17 -83.048510 0.144960
BFGS: 6 18:34:17 -83.051139 0.085595
BFGS: 7 18:34:17 -83.052235 0.080541
BFGS: 8 18:34:17 -83.053000 0.071027
BFGS: 9 18:34:17 -83.053266 0.042011
Step Time Energy fmax
BFGS: 0 18:34:18 -88.766845 0.297396
BFGS: 1 18:34:18 -88.770224 0.257428
BFGS: 2 18:34:18 -88.780026 0.098764
BFGS: 3 18:34:18 -88.781392 0.101432
BFGS: 4 18:34:18 -88.785249 0.121378
BFGS: 5 18:34:18 -88.787298 0.095675
BFGS: 6 18:34:19 -88.788633 0.063882
BFGS: 7 18:34:19 -88.789397 0.055455
100%|██████████| 1/1 [00:03<00:00, 3.43s/it]100%|██████████| 1/1 [00:03<00:00, 3.43s/it]
BFGS: 8 18:34:19 -88.789992 0.047876
0%| | 0/1 [00:00<?, ?it/s] Step Time Energy fmax
BFGS: 0 18:34:19 -82.961449 0.691639
BFGS: 1 18:34:19 -82.988845 0.558770
BFGS: 2 18:34:20 -83.043712 0.215073
BFGS: 3 18:34:20 -83.045356 0.197420
BFGS: 4 18:34:20 -83.051504 0.074768
BFGS: 5 18:34:20 -83.052048 0.063783
BFGS: 6 18:34:21 -83.053208 0.026298
Step Time Energy fmax
BFGS: 0 18:34:21 -88.381493 0.203486
BFGS: 1 18:34:21 -88.384463 0.178577
BFGS: 2 18:34:21 -88.394170 0.103812
BFGS: 3 18:34:21 -88.395737 0.114229
BFGS: 4 18:34:21 -88.400248 0.112557
BFGS: 5 18:34:21 -88.402087 0.091300
BFGS: 6 18:34:21 -88.403049 0.065530
BFGS: 7 18:34:21 -88.403428 0.050625
100%|██████████| 1/1 [00:02<00:00, 2.52s/it]100%|██████████| 1/1 [00:02<00:00, 2.53s/it]
BFGS: 8 18:34:22 -88.403755 0.031912
Rh
0%| | 0/1 [00:00<?, ?it/s] Step Time Energy fmax
BFGS: 0 18:34:22 -100.178311 0.695372
BFGS: 1 18:34:22 -100.205470 0.605778
BFGS: 2 18:34:22 -100.274451 0.188595
BFGS: 3 18:34:22 -100.277839 0.131927
BFGS: 4 18:34:22 -100.286139 0.092537
BFGS: 5 18:34:23 -100.288426 0.063497
BFGS: 6 18:34:23 -100.289378 0.054372
BFGS: 7 18:34:23 -100.290038 0.049021
Step Time Energy fmax
BFGS: 0 18:34:23 -106.914346 0.219023
BFGS: 1 18:34:23 -106.918825 0.183724
BFGS: 2 18:34:23 -106.927823 0.092935
BFGS: 3 18:34:23 -106.928192 0.080084
100%|██████████| 1/1 [00:01<00:00, 1.97s/it]100%|██████████| 1/1 [00:01<00:00, 1.98s/it]
BFGS: 4 18:34:24 -106.929645 0.038195
0%| | 0/1 [00:00<?, ?it/s] Step Time Energy fmax
BFGS: 0 18:34:24 -100.158081 0.745159
BFGS: 1 18:34:24 -100.191365 0.622306
BFGS: 2 18:34:24 -100.275626 0.242940
BFGS: 3 18:34:24 -100.278650 0.184961
BFGS: 4 18:34:25 -100.287117 0.079709
BFGS: 5 18:34:25 -100.288603 0.075170
BFGS: 6 18:34:25 -100.289526 0.057056
BFGS: 7 18:34:25 -100.290225 0.053810
BFGS: 8 18:34:25 -100.290732 0.043520
Step Time Energy fmax
BFGS: 0 18:34:25 -106.879013 0.258383
BFGS: 1 18:34:25 -106.884265 0.206354
BFGS: 2 18:34:26 -106.894906 0.097875
BFGS: 3 18:34:26 -106.895276 0.085965
100%|██████████| 1/1 [00:02<00:00, 2.41s/it]100%|██████████| 1/1 [00:02<00:00, 2.41s/it]
BFGS: 4 18:34:26 -106.896697 0.029134
Ir
0%| | 0/1 [00:00<?, ?it/s] Step Time Energy fmax
BFGS: 0 18:34:26 -124.228111 1.174836
BFGS: 1 18:34:26 -124.302342 0.929052
BFGS: 2 18:34:26 -124.414171 0.175909
BFGS: 3 18:34:27 -124.417641 0.151208
BFGS: 4 18:34:27 -124.423796 0.050078
BFGS: 5 18:34:27 -124.424160 0.045541
Step Time Energy fmax
BFGS: 0 18:34:27 -130.607362 0.412837
BFGS: 1 18:34:27 -130.622208 0.291773
BFGS: 2 18:34:27 -130.641299 0.174542
BFGS: 3 18:34:27 -130.642829 0.164442
BFGS: 4 18:34:27 -130.651893 0.072355
BFGS: 5 18:34:27 -130.652870 0.088890
BFGS: 6 18:34:27 -130.654270 0.083088
BFGS: 7 18:34:28 -130.655168 0.047647
100%|██████████| 1/1 [00:01<00:00, 1.64s/it]100%|██████████| 1/1 [00:01<00:00, 1.64s/it]
0%| | 0/1 [00:00<?, ?it/s] Step Time Energy fmax
BFGS: 0 18:34:28 -124.221688 1.137423
BFGS: 1 18:34:28 -124.303038 0.897451
BFGS: 2 18:34:28 -124.414783 0.205397
BFGS: 3 18:34:28 -124.417803 0.206965
BFGS: 4 18:34:29 -124.423752 0.101232
BFGS: 5 18:34:29 -124.424200 0.068196
BFGS: 6 18:34:29 -124.424826 0.037612
Step Time Energy fmax
BFGS: 0 18:34:29 -130.494954 0.471648
BFGS: 1 18:34:29 -130.510728 0.339461
BFGS: 2 18:34:29 -130.528898 0.157427
BFGS: 3 18:34:29 -130.529649 0.147622
BFGS: 4 18:34:30 -130.534001 0.056945
BFGS: 5 18:34:30 -130.534283 0.060619
100%|██████████| 1/1 [00:02<00:00, 2.39s/it]100%|██████████| 1/1 [00:02<00:00, 2.40s/it]BFGS: 6 18:34:30 -130.534860 0.037316
'Elapsed time = 32.12632894515991 seconds'First, we compare the computed data and reference data. There is a systematic difference of about 0.5 eV due to the difference between RPBE and PBE functionals, and other subtle differences like lattice constant differences and reference energy differences. This is pretty typical, and an expected deviation.
plt.plot(refdata["fcc"], data["fcc"], "r.", label="fcc")
plt.plot(refdata["hcp"], data["hcp"], "b.", label="hcp")
plt.plot([-5.5, -3.5], [-5.5, -3.5], "k-")
plt.xlabel("Ref. data (DFT)")
plt.ylabel("UMA-OC20 prediction");
Next we compare the correlation between the hcp and fcc sites. Here we see the same trends. The data falls below the parity line because the hcp sites tend to be a little weaker binding than the fcc sites.
plt.plot(refdata["hcp"], refdata["fcc"], "r.")
plt.plot(data["hcp"], data["fcc"], ".")
plt.plot([-6, -1], [-6, -1], "k-")
plt.xlabel("$H_{ads, hcp}$")
plt.ylabel("$H_{ads, fcc}$")
plt.legend(["DFT (PBE)", "UMA-OC20"]);
Exercises¶
You can also explore a few other adsorbates: C, H, N.
Explore the higher coverages. The deviations from the reference data are expected to be higher, but relative differences tend to be better. You probably need fine tuning to improve this performance. This data set doesn’t have forces though, so it isn’t practical to do it here.
Next steps¶
In the next step, we consider some more complex adsorbates in nitrogen reduction, and how we can leverage OCP to automate the search for the most stable adsorbate geometry. See the next step.
Convergence study¶
In the adsorption energies section we discussed some possible reasons we might see a discrepancy. Here we investigate some factors that impact the computed energies.
In this section, the energies refer to the reaction 1/2 O2 -> O*.
Effects of number of layers¶
Slab thickness could be a factor. Here we relax the whole slab, and see by about 4 layers the energy is converged to ~0.02 eV.
for nlayers in [3, 4, 5, 6, 7, 8]:
slab = fcc111("Pt", size=(2, 2, nlayers), vacuum=10.0)
slab.pbc = True
slab.set_calculator(calc)
opt_slab = BFGS(slab, logfile=None)
opt_slab.run(fmax=0.05, steps=100)
slab_e = slab.get_potential_energy()
adslab = slab.copy()
add_adsorbate(adslab, "O", height=1.2, position="fcc")
adslab.pbc = True
adslab.set_calculator(calc)
opt_adslab = BFGS(adslab, logfile=None)
opt_adslab.run(fmax=0.05, steps=100)
adslab_e = adslab.get_potential_energy()
print(
f"nlayers = {nlayers}: {adslab_e - slab_e - atomic_reference_energies['O'] + re1:1.2f} eV"
)/tmp/ipykernel_13731/338101817.py:5: FutureWarning: Please use atoms.calc = calc
slab.set_calculator(calc)
/tmp/ipykernel_13731/338101817.py:14: FutureWarning: Please use atoms.calc = calc
adslab.set_calculator(calc)
nlayers = 3: -1.61 eV
nlayers = 4: -1.47 eV
nlayers = 5: -1.49 eV
nlayers = 6: -1.50 eV
nlayers = 7: -1.50 eV
nlayers = 8: -1.51 eV
Effects of relaxation¶
It is common to only relax a few layers, and constrain lower layers to bulk coordinates. We do that here. We only relax the adsorbate and the top layer.
This has a small effect (0.1 eV).
from ase.constraints import FixAtoms
for nlayers in [3, 4, 5, 6, 7, 8]:
slab = fcc111("Pt", size=(2, 2, nlayers), vacuum=10.0)
slab.set_constraint(FixAtoms(mask=[atom.tag > 1 for atom in slab]))
slab.pbc = True
slab.set_calculator(calc)
opt_slab = BFGS(slab, logfile=None)
opt_slab.run(fmax=0.05, steps=100)
slab_e = slab.get_potential_energy()
adslab = slab.copy()
add_adsorbate(adslab, "O", height=1.2, position="fcc")
adslab.set_constraint(FixAtoms(mask=[atom.tag > 1 for atom in adslab]))
adslab.pbc = True
adslab.set_calculator(calc)
opt_adslab = BFGS(adslab, logfile=None)
opt_adslab.run(fmax=0.05, steps=100)
adslab_e = adslab.get_potential_energy()
print(
f"nlayers = {nlayers}: {adslab_e - slab_e - atomic_reference_energies['O'] + re1:1.2f} eV"
)/tmp/ipykernel_13731/1426773950.py:8: FutureWarning: Please use atoms.calc = calc
slab.set_calculator(calc)
/tmp/ipykernel_13731/1426773950.py:18: FutureWarning: Please use atoms.calc = calc
adslab.set_calculator(calc)
nlayers = 3: -1.51 eV
nlayers = 4: -1.37 eV
nlayers = 5: -1.39 eV
nlayers = 6: -1.40 eV
nlayers = 7: -1.40 eV
nlayers = 8: -1.40 eV
Unit cell size¶
Coverage effects are quite noticeable with oxygen. Here we consider larger unit cells. This effect is large, and the results don’t look right, usually adsorption energies get more favorable at lower coverage, not less. This suggests fine-tuning could be important even at low coverages.
for size in [1, 2, 3, 4, 5]:
slab = fcc111("Pt", size=(size, size, 5), vacuum=10.0)
slab.set_constraint(FixAtoms(mask=[atom.tag > 1 for atom in slab]))
slab.pbc = True
slab.set_calculator(calc)
opt_slab = BFGS(slab, logfile=None)
opt_slab.run(fmax=0.05, steps=100)
slab_e = slab.get_potential_energy()
adslab = slab.copy()
add_adsorbate(adslab, "O", height=1.2, position="fcc")
adslab.set_constraint(FixAtoms(mask=[atom.tag > 1 for atom in adslab]))
adslab.pbc = True
adslab.set_calculator(calc)
opt_adslab = BFGS(adslab, logfile=None)
opt_adslab.run(fmax=0.05, steps=100)
adslab_e = adslab.get_potential_energy()
print(
f"({size}x{size}): {adslab_e - slab_e - atomic_reference_energies['O'] + re1:1.2f} eV"
)/tmp/ipykernel_13731/3371624330.py:7: FutureWarning: Please use atoms.calc = calc
slab.set_calculator(calc)
/tmp/ipykernel_13731/3371624330.py:17: FutureWarning: Please use atoms.calc = calc
adslab.set_calculator(calc)
(1x1): -0.20 eV
(2x2): -1.39 eV
(3x3): -1.43 eV
(4x4): -1.46 eV
(5x5): -1.46 eV
Summary¶
As with DFT, you should take care to see how these kinds of decisions affect your results, and determine if they would change any interpretations or not.
- Xu, Z., & Kitchin, J. R. (2014). Probing the Coverage Dependence of Site and Adsorbate Configurational Correlations on (111) Surfaces of Late Transition Metals. 10.1021/jp508805h