Intro to adsorption energies#
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.
You do have to be careful in the details though. Some OCP model/checkpoint combinations return a total energy like density functional theory would, but some return an “adsorption energy” directly. You have to know which one you are using. In this example, the model we use returns an “adsorption energy”.
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-O
DFT 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* + H2
It 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 UMA
Then, the adsorption energy for
1/2O2 + * -> O*
is just re1 + re2.
Based on https://atct.anl.gov/Thermochemical%20Data/version%201.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
Get 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.
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-1p1")
calc = FAIRChemCalculator(predictor, task_name="oc20")
WARNING:root:device was not explicitly set, using device='cuda'.
/home/runner/work/_tool/Python/3.12.12/x64/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py:2249: UnsupportedFieldAttributeWarning: The 'repr' attribute with value False was provided to the `Field()` function, which has no effect in the context it was used. 'repr' is field-specific metadata, and can only be attached to a model field using `Annotated` metadata or by assignment. This may have happened because an `Annotated` type alias using the `type` statement was used, or if the `Field()` function was attached to a single member of a union type.
warnings.warn(
/home/runner/work/_tool/Python/3.12.12/x64/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py:2249: UnsupportedFieldAttributeWarning: The 'frozen' attribute with value True was provided to the `Field()` function, which has no effect in the context it was used. 'frozen' is field-specific metadata, and can only be attached to a model field using `Annotated` metadata or by assignment. This may have happened because an `Annotated` type alias using the `type` statement was used, or if the `Field()` function was attached to a single member of a union type.
warnings.warn(
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_3398/3752951811.py:17: FutureWarning: Please use atoms.calc = calc
slab.set_calculator(calc)
Step Time Energy fmax
BFGS: 0 07:02:49 -104.695193 0.711414
BFGS: 1 07:02:49 -104.753188 0.608871
BFGS: 2 07:02:49 -104.906054 0.369514
BFGS: 3 07:02:49 -104.938753 0.439860
BFGS: 4 07:02:49 -105.016137 0.464029
BFGS: 5 07:02:49 -105.076559 0.356131
BFGS: 6 07:02:49 -105.112618 0.189549
BFGS: 7 07:02:50 -105.126757 0.045521
Step Time Energy fmax
BFGS: 0 07:02:50 -110.048787 1.757515
BFGS: 1 07:02:50 -110.230722 0.986430
/tmp/ipykernel_3398/3752951811.py:22: FutureWarning: Please use atoms.calc = calc
adslab.set_calculator(calc)
BFGS: 2 07:02:50 -110.379365 0.731520
BFGS: 3 07:02:50 -110.430299 0.807331
BFGS: 4 07:02:50 -110.543682 0.692002
BFGS: 5 07:02:50 -110.617478 0.492741
BFGS: 6 07:02:50 -110.673464 0.666975
BFGS: 7 07:02:50 -110.721680 0.710481
BFGS: 8 07:02:50 -110.756904 0.443809
BFGS: 9 07:02:50 -110.769294 0.214548
BFGS: 10 07:02:51 -110.772451 0.091726
BFGS: 11 07:02:51 -110.772963 0.062470
BFGS: 12 07:02:51 -110.773256 0.046208
-1.4724996287652696
It 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. http://dx.doi.org/10.1021/jp508805h
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 eV
Then, 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.263842000000002
Next, 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)
Step Time Energy fmax
BFGS: 0 07:02:53 -82.862062 1.000262
BFGS: 1 07:02:53 -82.918113 0.752920
/tmp/ipykernel_3398/647904475.py:10: FutureWarning: Please use atoms.calc = calc
slab.set_calculator(calc)
BFGS: 2 07:02:53 -83.011694 0.335858
BFGS: 3 07:02:53 -83.016495 0.303118
BFGS: 4 07:02:54 -83.024496 0.224952
BFGS: 5 07:02:54 -83.030036 0.152568
BFGS: 6 07:02:54 -83.033360 0.088617
BFGS: 7 07:02:54 -83.034469 0.065751
BFGS: 8 07:02:54 -83.035207 0.068687
BFGS: 9 07:02:54 -83.035564 0.046752
Step Time Energy fmax
BFGS: 0 07:02:54 -88.770343 0.313007
BFGS: 1 07:02:54 -88.773632 0.271644
/tmp/ipykernel_3398/647904475.py:14: FutureWarning: Please use atoms.calc = calc
adslab.set_calculator(calc)
BFGS: 2 07:02:54 -88.784462 0.104459
BFGS: 3 07:02:54 -88.786014 0.101422
BFGS: 4 07:02:54 -88.788520 0.106434
BFGS: 5 07:02:54 -88.790479 0.089528
BFGS: 6 07:02:55 -88.791959 0.095977
BFGS: 7 07:02:55 -88.792654 0.099424
BFGS: 8 07:02:55 -88.793171 0.077827
BFGS: 9 07:02:55 -88.793672 0.036068
-4.164108134014293
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 07:02:55 -48.910948 0.646351
BFGS: 1 07:02:55 -48.934031 0.539303
/tmp/ipykernel_3398/1356342052.py:33: FutureWarning: Please use atoms.calc = calc
slab.set_calculator(calc)
BFGS: 2 07:02:55 -49.000044 0.280104
BFGS: 3 07:02:55 -49.002373 0.251321
BFGS: 4 07:02:55 -49.008810 0.158917
BFGS: 5 07:02:55 -49.013986 0.134404
BFGS: 6 07:02:56 -49.016868 0.071532
BFGS: 7 07:02:56 -49.017634 0.051270
BFGS: 8 07:02:56 -49.018011 0.047563
Step Time Energy fmax
BFGS: 0 07:02:56 -55.204221 0.339047
BFGS: 1 07:02:56 -55.206662 0.267937
/tmp/ipykernel_3398/1356342052.py:37: FutureWarning: Please use atoms.calc = calc
adslab.set_calculator(calc)
BFGS: 2 07:02:56 -55.213711 0.159973
BFGS: 3 07:02:56 -55.215873 0.166171
BFGS: 4 07:02:56 -55.219671 0.116800
BFGS: 5 07:02:56 -55.221812 0.079429
BFGS: 6 07:02:56 -55.223358 0.075345
BFGS: 7 07:02:56 -55.224363 0.090270
BFGS: 8 07:02:56 -55.225515 0.098904
BFGS: 9 07:02:57 -55.226528 0.068613
BFGS: 10 07:02:57 -55.226976 0.043008
100%|██████████| 1/1 [00:01<00:00, 1.79s/it]
100%|██████████| 1/1 [00:01<00:00, 1.80s/it]
0%| | 0/1 [00:00<?, ?it/s]
Step Time Energy fmax
BFGS: 0 07:02:57 -48.936503 0.552695
BFGS: 1 07:02:57 -48.954084 0.470533
BFGS: 2 07:02:57 -49.008577 0.210998
BFGS: 3 07:02:57 -49.009768 0.197685
BFGS: 4 07:02:57 -49.017746 0.041122
Step Time Energy fmax
BFGS: 0 07:02:57 -55.119069 0.305598
BFGS: 1 07:02:57 -55.120918 0.239016
BFGS: 2 07:02:57 -55.125707 0.129256
BFGS: 3 07:02:57 -55.127339 0.147621
BFGS: 4 07:02:58 -55.130404 0.128457
BFGS: 5 07:02:58 -55.132311 0.102952
BFGS: 6 07:02:58 -55.133382 0.051707
BFGS: 7 07:02:58 -55.133851 0.056098
BFGS: 8 07:02:58 -55.134359 0.071287
BFGS: 9 07:02:58 -55.135044 0.069399
BFGS: 10 07:02:58 -55.135575 0.039832
100%|██████████| 1/1 [00:01<00:00, 1.45s/it]
100%|██████████| 1/1 [00:01<00:00, 1.45s/it]
Ag
0%| | 0/1 [00:00<?, ?it/s]
Step Time Energy fmax
BFGS: 0 07:02:58 -33.034314 0.634820
BFGS: 1 07:02:58 -33.053469 0.551048
BFGS: 2 07:02:58 -33.120907 0.172006
BFGS: 3 07:02:59 -33.122779 0.157333
BFGS: 4 07:02:59 -33.124184 0.143368
BFGS: 5 07:02:59 -33.126944 0.112449
BFGS: 6 07:02:59 -33.130775 0.110652
BFGS: 7 07:02:59 -33.133993 0.067497
BFGS: 8 07:02:59 -33.134832 0.034873
Step Time Energy fmax
BFGS: 0 07:02:59 -38.173508 0.097997
BFGS: 1 07:02:59 -38.174434 0.094378
BFGS: 2 07:02:59 -38.184914 0.084328
BFGS: 3 07:02:59 -38.185729 0.085566
BFGS: 4 07:02:59 -38.189162 0.084992
BFGS: 5 07:02:59 -38.191040 0.067033
BFGS: 6 07:03:00 -38.192308 0.088075
BFGS: 7 07:03:00 -38.193217 0.075882
BFGS: 8 07:03:00 -38.193680 0.041042
100%|██████████| 1/1 [00:01<00:00, 1.62s/it]
100%|██████████| 1/1 [00:01<00:00, 1.62s/it]
0%| | 0/1 [00:00<?, ?it/s]
Step Time Energy fmax
BFGS: 0 07:03:00 -33.056750 0.557366
BFGS: 1 07:03:00 -33.071228 0.489413
BFGS: 2 07:03:00 -33.126398 0.123822
BFGS: 3 07:03:00 -33.127308 0.112958
BFGS: 4 07:03:00 -33.128516 0.097372
BFGS: 5 07:03:00 -33.130259 0.079537
BFGS: 6 07:03:00 -33.133158 0.076346
BFGS: 7 07:03:00 -33.134743 0.040736
Step Time Energy fmax
BFGS: 0 07:03:01 -38.102025 0.093075
BFGS: 1 07:03:01 -38.102856 0.088837
BFGS: 2 07:03:01 -38.111090 0.134764
BFGS: 3 07:03:01 -38.112011 0.120329
BFGS: 4 07:03:01 -38.115304 0.063924
BFGS: 5 07:03:01 -38.116160 0.056432
BFGS: 6 07:03:01 -38.116716 0.058497
BFGS: 7 07:03:01 -38.117589 0.073172
BFGS: 8 07:03:01 -38.118457 0.057440
BFGS: 9 07:03:01 -38.118835 0.026071
100%|██████████| 1/1 [00:01<00:00, 1.62s/it]
100%|██████████| 1/1 [00:01<00:00, 1.63s/it]
Pd
0%| | 0/1 [00:00<?, ?it/s]
Step Time Energy fmax
BFGS: 0 07:03:02 -70.165062 0.631446
BFGS: 1 07:03:02 -70.189910 0.508128
BFGS: 2 07:03:02 -70.241649 0.191934
BFGS: 3 07:03:02 -70.243347 0.182565
BFGS: 4 07:03:02 -70.248575 0.144555
BFGS: 5 07:03:02 -70.251930 0.115934
BFGS: 6 07:03:02 -70.254308 0.074837
BFGS: 7 07:03:02 -70.255205 0.059446
BFGS: 8 07:03:02 -70.255943 0.041112
Step Time Energy fmax
BFGS: 0 07:03:02 -76.130241 0.213656
BFGS: 1 07:03:02 -76.133242 0.190340
BFGS: 2 07:03:02 -76.148718 0.169655
BFGS: 3 07:03:03 -76.150812 0.152265
BFGS: 4 07:03:03 -76.154317 0.130498
BFGS: 5 07:03:03 -76.157060 0.106085
BFGS: 6 07:03:03 -76.159304 0.088137
BFGS: 7 07:03:03 -76.160431 0.080481
BFGS: 8 07:03:03 -76.161130 0.064472
BFGS: 9 07:03:03 -76.161615 0.042973
100%|██████████| 1/1 [00:01<00:00, 1.71s/it]
100%|██████████| 1/1 [00:01<00:00, 1.72s/it]
0%| | 0/1 [00:00<?, ?it/s]
Step Time Energy fmax
BFGS: 0 07:03:03 -70.197712 0.454636
BFGS: 1 07:03:03 -70.211775 0.373893
BFGS: 2 07:03:03 -70.245976 0.178178
BFGS: 3 07:03:03 -70.247163 0.164572
BFGS: 4 07:03:04 -70.253349 0.078702
BFGS: 5 07:03:04 -70.254511 0.075505
BFGS: 6 07:03:04 -70.255271 0.058124
BFGS: 7 07:03:04 -70.255844 0.036952
Step Time Energy fmax
BFGS: 0 07:03:04 -75.892387 0.169439
BFGS: 1 07:03:04 -75.895234 0.150802
BFGS: 2 07:03:04 -75.906632 0.144095
BFGS: 3 07:03:04 -75.908423 0.135675
BFGS: 4 07:03:04 -75.912427 0.129045
BFGS: 5 07:03:04 -75.915495 0.108691
BFGS: 6 07:03:04 -75.917927 0.075326
BFGS: 7 07:03:05 -75.918956 0.067258
BFGS: 8 07:03:05 -75.919478 0.044583
100%|██████████| 1/1 [00:01<00:00, 1.54s/it]
100%|██████████| 1/1 [00:01<00:00, 1.54s/it]
Pt
0%| | 0/1 [00:00<?, ?it/s]
Step Time Energy fmax
BFGS: 0 07:03:05 -82.862062 1.000262
BFGS: 1 07:03:05 -82.918113 0.752916
BFGS: 2 07:03:05 -83.011693 0.335872
BFGS: 3 07:03:05 -83.016496 0.303118
BFGS: 4 07:03:05 -83.024493 0.224971
BFGS: 5 07:03:05 -83.030036 0.152587
BFGS: 6 07:03:05 -83.033361 0.088636
BFGS: 7 07:03:05 -83.034469 0.065740
BFGS: 8 07:03:05 -83.035206 0.068689
BFGS: 9 07:03:06 -83.035564 0.046780
Step Time Energy fmax
BFGS: 0 07:03:06 -88.770343 0.310364
BFGS: 1 07:03:06 -88.773626 0.271878
BFGS: 2 07:03:06 -88.784511 0.102836
BFGS: 3 07:03:06 -88.786010 0.101569
BFGS: 4 07:03:06 -88.788656 0.106169
BFGS: 5 07:03:06 -88.790576 0.087635
BFGS: 6 07:03:06 -88.792009 0.097927
BFGS: 7 07:03:06 -88.792675 0.099377
BFGS: 8 07:03:06 -88.793202 0.075838
BFGS: 9 07:03:06 -88.793699 0.036175
100%|██████████| 1/1 [00:01<00:00, 1.80s/it]
100%|██████████| 1/1 [00:01<00:00, 1.80s/it]
0%| | 0/1 [00:00<?, ?it/s]
Step Time Energy fmax
BFGS: 0 07:03:07 -82.946996 0.675644
BFGS: 1 07:03:07 -82.973149 0.546705
BFGS: 2 07:03:07 -83.026505 0.203005
BFGS: 3 07:03:07 -83.028071 0.183988
BFGS: 4 07:03:07 -83.033699 0.083375
BFGS: 5 07:03:07 -83.034396 0.061089
BFGS: 6 07:03:07 -83.035121 0.048394
Step Time Energy fmax
BFGS: 0 07:03:07 -88.350562 0.234982
BFGS: 1 07:03:07 -88.353606 0.203898
BFGS: 2 07:03:07 -88.362975 0.117118
BFGS: 3 07:03:07 -88.364343 0.121256
BFGS: 4 07:03:08 -88.368503 0.090211
BFGS: 5 07:03:08 -88.370483 0.073254
BFGS: 6 07:03:08 -88.371786 0.075264
BFGS: 7 07:03:08 -88.372317 0.079591
BFGS: 8 07:03:08 -88.372732 0.061398
BFGS: 9 07:03:08 -88.373020 0.027153
100%|██████████| 1/1 [00:01<00:00, 1.54s/it]
100%|██████████| 1/1 [00:01<00:00, 1.54s/it]
Rh
0%| | 0/1 [00:00<?, ?it/s]
Step Time Energy fmax
BFGS: 0 07:03:08 -100.192566 0.688933
BFGS: 1 07:03:08 -100.218240 0.600213
BFGS: 2 07:03:08 -100.286835 0.174727
BFGS: 3 07:03:08 -100.289767 0.129385
BFGS: 4 07:03:08 -100.298132 0.066628
BFGS: 5 07:03:09 -100.299264 0.053472
BFGS: 6 07:03:09 -100.299779 0.045078
Step Time Energy fmax
BFGS: 0 07:03:09 -106.921794 0.203149
BFGS: 1 07:03:09 -106.924542 0.168768
BFGS: 2 07:03:09 -106.930976 0.052503
BFGS: 3 07:03:09 -106.931584 0.045557
100%|██████████| 1/1 [00:01<00:00, 1.03s/it]
100%|██████████| 1/1 [00:01<00:00, 1.03s/it]
0%| | 0/1 [00:00<?, ?it/s]
Step Time Energy fmax
BFGS: 0 07:03:09 -100.171741 0.714774
BFGS: 1 07:03:09 -100.203866 0.626030
BFGS: 2 07:03:09 -100.287846 0.263190
BFGS: 3 07:03:09 -100.290543 0.195990
BFGS: 4 07:03:09 -100.297166 0.080367
BFGS: 5 07:03:10 -100.299033 0.056464
BFGS: 6 07:03:10 -100.299772 0.043876
Step Time Energy fmax
BFGS: 0 07:03:10 -106.876840 0.168839
BFGS: 1 07:03:10 -106.879419 0.139489
BFGS: 2 07:03:10 -106.885547 0.071259
BFGS: 3 07:03:10 -106.886238 0.064285
BFGS: 4 07:03:10 -106.886582 0.054974
BFGS: 5 07:03:10 -106.886842 0.043056
100%|██████████| 1/1 [00:01<00:00, 1.20s/it]
100%|██████████| 1/1 [00:01<00:00, 1.20s/it]
Ir
0%| | 0/1 [00:00<?, ?it/s]
Step Time Energy fmax
BFGS: 0 07:03:10 -124.235610 1.189926
BFGS: 1 07:03:10 -124.310839 0.937187
BFGS: 2 07:03:11 -124.422188 0.140818
BFGS: 3 07:03:11 -124.425270 0.133750
BFGS: 4 07:03:11 -124.429598 0.060602
BFGS: 5 07:03:11 -124.430258 0.038671
Step Time Energy fmax
BFGS: 0 07:03:11 -130.605623 0.371710
BFGS: 1 07:03:11 -130.616144 0.265926
BFGS: 2 07:03:11 -130.630320 0.110655
BFGS: 3 07:03:11 -130.633614 0.094379
BFGS: 4 07:03:11 -130.634276 0.075700
BFGS: 5 07:03:11 -130.634989 0.065726
BFGS: 6 07:03:11 -130.636197 0.083045
BFGS: 7 07:03:11 -130.636656 0.075161
BFGS: 8 07:03:12 -130.637048 0.047468
100%|██████████| 1/1 [00:01<00:00, 1.37s/it]
100%|██████████| 1/1 [00:01<00:00, 1.37s/it]
0%| | 0/1 [00:00<?, ?it/s]
Step Time Energy fmax
BFGS: 0 07:03:12 -124.227592 1.165685
BFGS: 1 07:03:12 -124.311476 0.915619
BFGS: 2 07:03:12 -124.422557 0.165148
BFGS: 3 07:03:12 -124.425477 0.200267
BFGS: 4 07:03:12 -124.428763 0.168862
BFGS: 5 07:03:12 -124.430254 0.088399
BFGS: 6 07:03:12 -124.430559 0.041800
Step Time Energy fmax
BFGS: 0 07:03:12 -130.496158 0.405790
BFGS: 1 07:03:12 -130.507203 0.267016
BFGS: 2 07:03:12 -130.518616 0.126416
BFGS: 3 07:03:13 -130.522316 0.080270
BFGS: 4 07:03:13 -130.523181 0.066553
BFGS: 5 07:03:13 -130.523453 0.056621
BFGS: 6 07:03:13 -130.524511 0.055660
BFGS: 7 07:03:13 -130.524677 0.042703
100%|██████████| 1/1 [00:01<00:00, 1.37s/it]
100%|██████████| 1/1 [00:01<00:00, 1.37s/it]
'Elapsed time = 18.09273600578308 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 Calculating adsorption energies 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_3398/338101817.py:5: FutureWarning: Please use atoms.calc = calc
slab.set_calculator(calc)
/tmp/ipykernel_3398/338101817.py:14: FutureWarning: Please use atoms.calc = calc
adslab.set_calculator(calc)
nlayers = 3: -1.58 eV
nlayers = 4: -1.47 eV
nlayers = 5: -1.47 eV
nlayers = 6: -1.46 eV
nlayers = 7: -1.47 eV
nlayers = 8: -1.47 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_3398/1426773950.py:8: FutureWarning: Please use atoms.calc = calc
slab.set_calculator(calc)
/tmp/ipykernel_3398/1426773950.py:18: FutureWarning: Please use atoms.calc = calc
adslab.set_calculator(calc)
nlayers = 3: -1.47 eV
nlayers = 4: -1.35 eV
nlayers = 5: -1.35 eV
nlayers = 6: -1.34 eV
nlayers = 7: -1.35 eV
nlayers = 8: -1.35 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_3398/3371624330.py:7: FutureWarning: Please use atoms.calc = calc
slab.set_calculator(calc)
/tmp/ipykernel_3398/3371624330.py:17: FutureWarning: Please use atoms.calc = calc
adslab.set_calculator(calc)
(1x1): -0.12 eV
(2x2): -1.35 eV
(3x3): -1.38 eV
(4x4): -1.41 eV
(5x5): -1.42 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.