Skip to content

An error occurs when I follow the AdsorbML Tutorial #1755

@LeehansoL-123

Description

@LeehansoL-123

Python version

3.12.3

fairchem-core version

2.13.0

pytorch version

2.8.0

cuda version

12.8

Operating system version

No response

Minimal example

# The exact code from fairchem/docs/catalysts/examples_tutorials/adsorbml_walkthrough.md

from __future__ import annotations

import pandas as pd
from fairchem.data.oc.core import Adsorbate, Bulk, Slab

bulk_src_id = "mp-30"
adsorbate_smiles = "*CO"

bulk = Bulk(bulk_src_id_from_db=bulk_src_id)
adsorbate = Adsorbate(adsorbate_smiles_from_db=adsorbate_smiles)
slabs = Slab.from_bulk_get_specific_millers(bulk=bulk, specific_millers=(1, 1, 1))

# There may be multiple slabs with this miller index.
# For demonstrative purposes we will take the first entry.
slab = slabs[0]


from ase.optimize import LBFGS
from fairchem.core import FAIRChemCalculator, pretrained_mlip
from fairchem.core.components.calculate.recipes.adsorbml import run_adsorbml

predictor = pretrained_mlip.get_predict_unit("uma-s-1p1")
calc = FAIRChemCalculator(predictor, task_name="oc20")
print(adsorbate.atoms)
outputs = run_adsorbml(
    slab=slab,
    adsorbate=adsorbate,
    calculator=calc,
    optimizer_cls=LBFGS,
    fmax=0.1,
    steps=20,  # Increase to 200 for practical application, 20 is used for demonstrations
    num_placements=10,  # Increase to 100 for practical application, 10 is used for demonstrations
    reference_ml_energies=True,  # True if using a total energy model (i.e. UMA)
    relaxed_slab_atoms=None,
    place_on_relaxed_slab=False,
)

# visualizing the bug
print(adsorbate)
print(outputs["adslabs"][0]["atoms"])

from ase.visualize import view
aaa = outputs["adslabs"][0]["atoms"]

view(aaa)

Current behavior

Image as output, Adsorbate changed as N2H4

Expected Behavior

Adsorbate should be CO

Relevant files to reproduce this bug

fairchem/docs/catalysts/examples_tutorials/adsorbml_walkthrough.md

In the run_adsorbml() function, replacing adsorbate=adsorbate with adsorbate=adsorbate_smiles resolves the issue and ensures the code runs correctly.

Please update the tutorial code to prevent confusion for other users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions