Adsorption Based on ASE.
Project description
Adsorption
A Python package for simulating molecular adsorption on clusters or surfaces, built on top of ASE (Atomic Simulation Environment).
Overview
The adsorption package provides tools for placing and optimizing adsorbates (molecules or atoms) on surface or cluster substrates. It automates the process of:
- Generating adsorption sites on surfaces/clusters
- Placing adsorbates at optimal positions and orientations
- Performing geometry optimization using two-stage relaxation
- Running high-throughput adsorption studies with Ray Tune
Features
-
Multiple Adsorption Strategies:
RawAdsorption: Places adsorbates based on geometric site analysis (top, bridge, hollow sites)DirectAdsorption: Uses Fibonacci lattice sampling for comprehensive orientation exploration
-
Flexible Adsorbate Input:
- ASE
Atomsobjects - Chemical symbols (e.g.,
"O","C") - Molecule names recognized by ASE (e.g.,
"H2O","CO") - SMILES strings (e.g.,
"C=C-C-C-C-C")
- ASE
-
Two-Stage Optimization:
- First stage: Fixed substrate + bond length constraints on adsorbate
- Second stage: Full relaxation of the entire system
-
High-Throughput Screening:
- Integration with Ray Tune for parallel optimization
- Automatic grid generation for systematic adsorption site exploration
Installation
pip install adsorption
Or using pixi:
pixi install
Quick Start
Basic Usage
from ase.cluster import Octahedron
from adsorption import RawAdsorption, DirectAdsorption
# Create a copper cluster
cluster = Octahedron("Cu", 10)
# Method 1: RawAdsorption (geometric site-based)
ads = RawAdsorption(calculator=None) # Replace with actual calculator
result, stage = ads(
atoms=cluster,
adsorbate="CO",
core=[303, 334, 464], # FCC hollow site
)
# Method 2: DirectAdsorption (Fibonacci lattice sampling)
ads = DirectAdsorption(calculator=None, nfibonacci=100)
result, stage = ads(
atoms=cluster,
adsorbate="C6H6", # Benzene
core=[454], # Top site
)
Command Line Interface
The package provides a CLI tool for running high-throughput adsorption studies:
adsorption-tune -cn config.yaml
Example configuration (config.yaml):
output: ./outputs
calculator:
_target_: ase.calculators.emt.EMT
adsorption:
nfibonacci: 100
max_steps_for_first_stage: 100
max_steps_for_second_stage: 100
max_force: 0.05
system:
atoms:
_target_: ase.build.fcc111
symbol: Cu
size: [10, 10, 5]
vacuum: 15
core: [454]
gas: C6H6
Architecture
Core Components
adsorption/
├── _abc/
│ ├── _interface.py # Abstract base class (AdsorptionABC)
│ └── _dataclass.py # Data structures (Point, Vector, Site)
├── _interfaces/
│ ├── _raw.py # RawAdsorption implementation
│ └── _direct.py # DirectAdsorption implementation
└── runner/
├── _cli.py # Command-line interface
├── _tune.py # Ray Tune integration
└── _plot.py # Visualization utilities
Key Classes
AdsorptionABC (Abstract Base Class)
The abstract base class that defines the common interface and optimization workflow:
-
Two-stage optimization:
- Stage 1: Fixes substrate atoms, applies bond length constraints to adsorbate
- Stage 2: Full relaxation without constraints
-
Adsorbate parsing: Converts various input types (string, Atom, Atoms, Gas) to ASE Atoms
RawAdsorption
Places adsorbates based on geometric analysis of adsorption sites:
- Automatically identifies neighbor atoms around the core site
- Calculates optimal adsorption direction based on site geometry
- Supports top, bridge, and hollow sites
Parameters:
adsorbate_index: Index of anchoring atom in adsorbate (or"com"for center of mass)nbr1hop: First-neighbor shell indices (auto-detected if not provided)core: Core atom indices defining the adsorption site
DirectAdsorption
Uses Fibonacci lattice sampling for comprehensive orientation exploration:
- Generates uniform sampling points on a sphere
- Supports custom grid definitions for both adsorbate and substrate
- Ideal for high-throughput screening
Parameters:
nfibonacci: Number of Fibonacci lattice points (default: 1000)grid_core: Custom grid for substrate orientationsgrid_ads: Custom grid for adsorbate orientationsdistance: Adsorbate-substrate distance
Data Structures
Site
Represents an adsorption site with:
neighbor: List of neighboring atom positionscore: List of core atom positionscenter: Calculated center of the sitedirection: Optimal adsorption direction vector
Examples
Example 1: Benzene on Cu(111) Surface
from ase.build import fcc111
from adsorption import DirectAdsorption
from ase.calculators.emt import EMT
# Create Cu(111) surface
surface = fcc111("Cu", size=(10, 10, 5), vacuum=15, orthogonal=True)
# Initialize adsorption calculator
ads = DirectAdsorption(
calculator=EMT(),
nfibonacci=100,
max_steps_for_first_stage=100,
max_steps_for_second_stage=100,
)
# Place benzene on surface
result, stage = ads(
atoms=surface,
adsorbate="C6H6",
core=[454], # Surface site index
)
Example 2: CO on Copper Cluster
from ase.cluster import Octahedron
from adsorption import RawAdsorption
# Create octahedral Cu cluster
cluster = Octahedron("Cu", 10)
# Place CO on FCC hollow site
ads = RawAdsorption(calculator=None)
result, stage = ads(
atoms=cluster,
adsorbate="CO",
core=[303, 334, 464], # FCC hollow site
adsorbate_index=0, # Anchor on carbon atom
)
High-Throughput Screening
The tune_adsorption function enables parallel exploration of multiple adsorption configurations:
from pathlib import Path
from adsorption.runner._tune import tune_adsorption
from ase.build import fcc111
surface = fcc111("Cu", size=(10, 10, 5), vacuum=15)
results = tune_adsorption(
cfg=config, # DictConfig with calculator and adsorption settings
atoms=surface,
adsorbate="C6H6",
core=[454],
nsamples=100, # Number of random samples
output=Path("./results"),
)
Results are saved as:
.xyzfiles with energy and optimization stage in filename.pngvisualization files with multiple viewing angles
Dependencies
- ASE: Atomic Simulation Environment for atom manipulation
- graphatoms: Graph-based atom system utilities
- Ray Tune: Distributed hyperparameter optimization
- Hydra: Configuration management
- NumPy: Numerical computations
- Pydantic: Data validation
Development
Running Tests
pixi run test
# or
pytest -s -vv
Code Style
The project uses:
- Ruff for linting and formatting
- Google-style docstrings
- Line length: 80 characters
License
GPL-3.0-or-later
Author
LiuGaoyong (liugaoyong_88@163.com)
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adsorption-0.1.0.tar.gz.
File metadata
- Download URL: adsorption-0.1.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
416c5916283e55ccd984551138a3028f130b754b96f93266a51ee79208d1c89e
|
|
| MD5 |
425cdc44899071dfe05b1c08bfd27114
|
|
| BLAKE2b-256 |
8300652e120711472543da35d323e4c9f73026d3b48507c0fc48866b526ff483
|
Provenance
The following attestation bundles were made for adsorption-0.1.0.tar.gz:
Publisher:
wheel.yml on LiuGaoyong/Adsorption
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
adsorption-0.1.0.tar.gz -
Subject digest:
416c5916283e55ccd984551138a3028f130b754b96f93266a51ee79208d1c89e - Sigstore transparency entry: 1755672313
- Sigstore integration time:
-
Permalink:
LiuGaoyong/Adsorption@0221af8728c9154ebb723b6f2c19f063936505d2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/LiuGaoyong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheel.yml@0221af8728c9154ebb723b6f2c19f063936505d2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file adsorption-0.1.0-py3-none-any.whl.
File metadata
- Download URL: adsorption-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
840b9d98fb462493ec642fbfed2908dc5a222f6f29228eb9ea303f43bd82d09e
|
|
| MD5 |
d2fd6028d3c902140319779a02074135
|
|
| BLAKE2b-256 |
509a2de189b66046d58b2f43a9b3b4b2b0f13a7ceec0df483f85477245d9529e
|
Provenance
The following attestation bundles were made for adsorption-0.1.0-py3-none-any.whl:
Publisher:
wheel.yml on LiuGaoyong/Adsorption
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
adsorption-0.1.0-py3-none-any.whl -
Subject digest:
840b9d98fb462493ec642fbfed2908dc5a222f6f29228eb9ea303f43bd82d09e - Sigstore transparency entry: 1755672357
- Sigstore integration time:
-
Permalink:
LiuGaoyong/Adsorption@0221af8728c9154ebb723b6f2c19f063936505d2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/LiuGaoyong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheel.yml@0221af8728c9154ebb723b6f2c19f063936505d2 -
Trigger Event:
push
-
Statement type: