CatBench: Benchmark Framework of Machine Learning Interatomic Potentials for Adsorption Energy Predictions in Heterogeneous Catalysis
Project description
CatBench
CatBench: Benchmark Framework of Machine Learning Interatomic Potentials in Adsorption Energy Predictions
Installation
pip install catbench
Overview
CatBench is a comprehensive benchmark framework designed to evaluate Machine Learning Interatomic Potentials (MLIPs) for adsorption energy or other reaction energy predictions. It provides tools for data processing, model evaluation, and result analysis.
Usage Workflow
1. Data Processing
CatBench supports two types of data sources:
- A. Direct from Catalysis-Hub
- B. User-calculated VASP Dataset
A. Direct from Catalysis-Hub
# Import the catbench package
import catbench
# Process data from Catalysis-Hub
# Single tag
catbench.cathub_preprocess("Catalysis-Hub_Dataset_tag")
# Multiple tags
catbench.cathub_preprocess(["Catalysis-Hub_Dataset_tag1", "Catalysis-Hub_Dataset_tag2"])
Example:
# Single tag example
catbench.cathub_preprocess("AraComputational2022")
# Multiple tags example
catbench.cathub_preprocess(["AraComputational2022", "AlonsoStrain2023"])
When combining multiple benchmarks, the same adsorbate species might be recognized differently due to variations in naming conventions across different datasets (e.g., *HO vs *OH for hydroxyl group). To address this issue, you can use the adsorbate_integration parameter to unify these different naming conventions. If no integration is needed, you can simply use the benchmark_name parameter alone:
# When no integration is needed, just use benchmark_name
catbench.cathub_preprocess(["Catalysis-Hub_Dataset_tag1", "Catalysis-Hub_Dataset_tag2"])
# When integration is needed
catbench.cathub_preprocess(
["Catalysis-Hub_Dataset_tag1", "Catalysis-Hub_Dataset_tag2"],
adsorbate_integration={'HO': 'OH'}
)
# You can add multiple integration pairs
catbench.cathub_preprocess(
["Catalysis-Hub_Dataset_tag1", "Catalysis-Hub_Dataset_tag2"],
adsorbate_integration={
'HO': 'OH',
'O2H': 'OOH',
'CO2H': 'COOH'
}
)
B. User-calculated VASP Dataset
For CatBench simulation on your VASP datasets, prepare your data hierarchy as follows:
The data structure should include:
- Gas references (
gas/) containing VASP output files for gas phase molecules- Note: Gas molecule folders must end with 'gas' (e.g.,
H2gas/,H2Ogas/)
- Note: Gas molecule folders must end with 'gas' (e.g.,
- Surface systems (
system1/,system2/, etc.) containing:- Each system represents a collection of reaction energies based on the same slab (e.g.,
system1/for Pt111,system2/for Ni111) - Clean slab calculations (
slab/) - Adsorbate-surface systems organized by adsorbate type (
H/,OH/, etc.)- Under each adsorbate directory, you can create subdirectories with any names to represent different configurations
- Each configuration directory should contain the VASP output files
- Each system represents a collection of reaction energies based on the same slab (e.g.,
Important Notes:
- Each directory must contain CONTCAR and OSZICAR files. Note that other VASP output files will be deleted during processing, so please ensure your original files are preserved.
- When using
process_outputfunction, it will automatically clean up (delete) all files except CONTCAR and OSZICAR. Therefore, it is strongly recommended to:- Keep your original data folder untouched
- Create a copy of your data folder
- Run
process_outputon the copied folder
- When benchmarking on user dataset, you must set
rate=0inexecute_benchmarkfunction to preserve the original atomic constraints from your calculations.
data/
├── gas/
│ ├── H2gas/
│ │ ├── CONTCAR
│ │ ├── OSZICAR
│ │ └── ...
│ └── H2Ogas/
│ ├── CONTCAR
│ ├── OSZICAR
│ └── ...
├── system1/ (e.g., Pt111/)
│ ├── slab/
│ │ ├── CONTCAR
│ │ ├── OSZICAR
│ │ └── ...
│ ├── H/
│ │ ├── 1/
│ │ │ ├── CONTCAR
│ │ │ ├── OSZICAR
│ │ │ └── ...
│ │ └── 2/
│ │ ├── CONTCAR
│ │ ├── OSZICAR
│ │ └── ...
│ └── OH/
│ ├── 1/
│ │ ├── CONTCAR
│ │ ├── OSZICAR
│ │ └── ...
│ └── 2/
│ ├── CONTCAR
│ ├── OSZICAR
│ └── ...
└── system2/ (e.g., Ni111/)
├── slab/
│ ├── CONTCAR
│ ├── OSZICAR
│ └── ...
├── H/
│ ├── 1/
│ │ ├── CONTCAR
│ │ ├── OSZICAR
│ │ └── ...
│ └── 2/
│ ├── CONTCAR
│ ├── OSZICAR
│ └── ...
└── OH/
├── 1/
│ ├── CONTCAR
│ ├── OSZICAR
│ └── ...
└── 2/
├── CONTCAR
├── OSZICAR
└── ...
Then process using:
import catbench
# Define coefficients for calculating adsorption energies
# For each adsorbate, specify coefficients based on the reaction equation:
# Example for H*:
# E_ads(H*) = E(H*) - E(slab) - 1/2 E(H2_gas)
# Example for OH*:
# E_ads(OH*) = E(OH*) - E(slab) + 1/2 E(H2_gas) - E(H2O_gas)
coeff_setting = {
"H": {
"slab": -1, # Coefficient for clean surface
"adslab": 1, # Coefficient for adsorbate-surface system
"H2gas": -1/2, # Coefficient for H2 gas reference
},
"OH": {
"slab": -1, # Coefficient for clean surface
"adslab": 1, # Coefficient for adsorbate-surface system
"H2gas": +1/2, # Coefficient for H2 gas reference
"H2Ogas": -1, # Coefficient for H2O gas reference
},
}
# This will clean up directories and keep only CONTCAR and OSZICAR files
catbench.process_output("data", coeff_setting)
catbench.userdata_preprocess("data")
The coefficient setting allows flexible definition of reaction energies, enabling benchmarking of various types of reactions beyond adsorption.
For example, you can benchmark the prediction performance for oxygen vacancy formation energy as follows:
# Example: Oxygen vacancy formation energy calculation
coeff_setting = {
"Ov": {
"slab": -1, # Coefficient for clean surface
"adslab": 1, # Coefficient for slab with oxygen vacancy
"O2gas": 1/2, # Coefficient for O2 gas reference (vacancy formation)
}
}
# This will clean up directories and keep only CONTCAR and OSZICAR files
catbench.process_output("data", coeff_setting)
catbench.userdata_preprocess("data")
2. Execute Benchmark
A. General Benchmark
This is a general benchmark setup. The range() value determines the number of repetitions for reproducibility testing. If reproducibility testing is not needed, it can be set to 1.
Note: This benchmark is only compatible with MLIP models that output total system energy. For example, OC20 MLIP models that are trained to directly predict adsorption energies cannot be used with this framework.
import catbench
from your_calculator import your_MLIP_Calculator
# Prepare calculator list
calc_num = 5 # Number of calculations for reproducibility testing. Can be adjusted based on available computational resources.
calculators = []
print("Calculators Initializing...")
for i in range(calc_num):
print(f"{i}th calculator")
calc = your_MLIP_Calculator(...)
calculators.append(calc)
config = {
"MLIP_name": "your MLIP name", # Required: Name of your MLIP model (e.g., "MACE", "CHGNet", "UMA", "yourmodel_w_dataset1", "yourmodel_tuned_1"). You can use any abbreviation that identifies your model.
"benchmark": "your benchmark dataset pkl name", # Required: Name of the .pkl file in the raw_data directory
"rate": 0.5, # Optional: For cathub data, can be any value. For user VASP data, must be set to 0
... # For detailed configuration options, see the Configuration Options section at the bottom of this document.
}
catbench.execute_benchmark(calculators, **config)
After execution, the following files and directories will be created:
- A
resultdirectory is created to store all calculation outputs. - Inside the
resultdirectory, subdirectories are created for each MLIP. - Each MLIP's subdirectory contains:
gases/: Gas reference molecules for adsorption energy calculationslog/: Slab and adslab calculation logstraj/: Slab and adslab trajectory files{MLIP_name}_gases.json: Gas molecules energies{MLIP_name}_anomaly_detection.json: Anomaly detection status for each adsorption data{MLIP_name}_result.json: Raw data (energies, calculation times, anomaly detection, slab displacements, etc.)
B. OC20 MLIP Benchmark
Since OC20 project MLIP models are trained to predict adsorption energies directly rather than total energies, they are handled with a separate function.
import catbench
from your_calculator import your_MLIP_Calculator
# Prepare calculator list
calc_num = 5 # Number of calculations for reproducibility testing. Can be adjusted based on available computational resources.
calculators = []
print("Calculators Initializing...")
for i in range(calc_num):
print(f"{i}th calculator")
calc = your_MLIP_Calculator(...)
calculators.append(calc)
config = {
"MLIP_name": "your MLIP name", # Required: Name of your MLIP model (e.g., "MACE", "CHGNet", "UMA", "yourmodel_w_dataset1", "yourmodel_tuned_1"). You can use any abbreviation that identifies your model.
"benchmark": "your benchmark dataset pkl name", # Required: Name of the .pkl file in the raw_data directory
"rate": 0.5, # Optional: For cathub data, can be any value. For user VASP data, must be set to 0
... # For detailed configuration options, see the Configuration Options section at the bottom of this document.
}
catbench.execute_benchmark_OC20(calculators, **config)
The overall usage is similar to the general benchmark, but each MLIP will only have the following subdirectories:
log/: Slab and adslab calculation logstraj/: Slab and adslab trajectory files{MLIP_name}_anomaly_detection.json: Anomaly detection status for each adsorption data{MLIP_name}_result.json: Raw data (energies, calculation times, anomaly detection, slab displacements, etc.)
C. Single-point Calculation Benchmark
import catbench
from your_calculator import your_MLIP_Calculator
# Prepare calculator list
calc_num = 5 # Number of calculations for reproducibility testing. Can be adjusted based on available computational resources.
calculators = []
print("Calculators Initializing...")
for i in range(calc_num):
print(f"{i}th calculator")
calc = your_MLIP_Calculator(...)
calculators.append(calc)
config = {
"MLIP_name": "your MLIP name", # Required: Name of your MLIP model (e.g., "MACE", "CHGNet", "UMA", "yourmodel_w_dataset1", "yourmodel_tuned_1"). You can use any abbreviation that identifies your model.
"benchmark": "your benchmark dataset pkl name", # Required: Name of the .pkl file in the raw_data directory
... # For detailed configuration options, see the Configuration Options section at the bottom of this document.
}
catbench.execute_benchmark_single(calculator, **config)
3. Analysis
import catbench
config = {
... # For detailed configuration options, see the Configuration Options section at the bottom of this document.
}
catbench.analysis_MLIPs(**config)
The analysis function processes the calculation data stored in the result directory and generates:
-
A
plot/directory:- Parity plots for each MLIP model
- Combined parity plots for comparison
- Performance visualization plots
-
An Excel file
{directory_name}_Benchmarking_Analysis.xlsx:- Comprehensive performance metrics for all MLIP models
- Statistical analysis of predictions
- Model-specific details and parameters
Single-point Calculation Analysis
import catbench
config = {
... # For detailed configuration options, see the Configuration Options section at the bottom of this document.
}
catbench.analysis_MLIPs_single(**config)
Outputs
1. Adsorption Energy Parity Plot (mono_version & multi_version)
You can plot adsorption energy parity plots for each adsorbate across all MLIPs, either simply or by adsorbate.
2. Comprehensive Performance Table
View various metrics for all MLIPs.
3. Anomaly Analysis
See how anomalies are detected for all MLIPs.
4. Analysis by Adsorbate
Observe how each MLIP predicts for each adsorbate.
Configuration Options
execute_benchmark / execute_benchmark_OC20
| Option | Description | Default |
|---|---|---|
| MLIP_name | Name of your MLIP | Required |
| benchmark | Name of benchmark dataset. Use "multiple_tag" for combined datasets, or specific tag name for single dataset | Required |
| F_CRIT_RELAX | Force convergence criterion | 0.05 |
| N_CRIT_RELAX | Maximum number of steps | 999 |
| rate | Fix ratio for surface atoms (0: use original constraints, >0: fix atoms from bottom up to specified ratio) | 0.5 |
| disp_thrs_slab | Displacement threshold for slab | 1.0 |
| disp_thrs_ads | Displacement threshold for adsorbate | 1.5 |
| again_seed | Seed variation threshold | 0.2 |
| damping | Damping factor for optimization | 1.0 |
| gas_distance | Cell size for gas molecules (if a number is provided, it sets the cell size as a cube with that length (Å)) | False |
| optimizer | Optimization algorithm | "LBFGS" |
| restart | Set to True when resuming interrupted calculations. | False |
execute_benchmark_single
| Option | Description | Default |
|---|---|---|
| MLIP_name | Name of your MLIP | Required |
| benchmark | Name of benchmark dataset. Use "multiple_tag" for combined datasets, or specific tag name for single dataset | Required |
| gas_distance | Cell size for gas molecules (if a number is provided, it sets the cell size as a cube with that length (Å)) | False |
| optimizer | Optimization algorithm for gas molecule relaxation | "LBFGS" |
| restart | Set to True when resuming interrupted calculations. | False |
analysis_MLIPs
| Option | Description | Default |
|---|---|---|
| Benchmarking_name | Name for output files | Current directory name |
| calculating_path | Path to result directory | "./result" |
| MLIP_list | List of MLIPs to analyze | All MLIPs in result directory |
| target_adsorbates | Target adsorbates to analyze | All adsorbates |
| specific_color | Color for plots | "black" |
| min | Axis minimum | Auto-calculated |
| max | Axis maximum | Auto-calculated |
| figsize | Figure size | (9, 8) |
| mark_size | Marker size | 100 |
| linewidths | Line width | 1.5 |
| dpi | Plot resolution | 300 |
| legend_off | Toggle legend | False |
| error_bar_display | Toggle error bars | False |
| font_setting | Font setting (Eg: ["/Users/user/Library/Fonts/Helvetica.ttf", "sans-serif"]) |
False |
License
This project is licensed under the MIT License - see the LICENSE file for details.
Citation
This work will be published soon.
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 catbench-0.1.30.tar.gz.
File metadata
- Download URL: catbench-0.1.30.tar.gz
- Upload date:
- Size: 25.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3919b37e9c209bff4df1d8cac994f21bcddfabff5bb61a2b466a654fb06783ff
|
|
| MD5 |
9b34eb61cd3a2c5a8836a86258b5b0fd
|
|
| BLAKE2b-256 |
727bf4cd7b2e26e9d32fcfd1fdba0a124c3c96cc5aad87402a5457e84285e79f
|
Provenance
The following attestation bundles were made for catbench-0.1.30.tar.gz:
Publisher:
publish.yml on JinukMoon/CatBench
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
catbench-0.1.30.tar.gz -
Subject digest:
3919b37e9c209bff4df1d8cac994f21bcddfabff5bb61a2b466a654fb06783ff - Sigstore transparency entry: 215406938
- Sigstore integration time:
-
Permalink:
JinukMoon/CatBench@8acadc538c4518b8a8c51b4aa577b032872536d7 -
Branch / Tag:
refs/tags/v0.1.30 - Owner: https://github.com/JinukMoon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8acadc538c4518b8a8c51b4aa577b032872536d7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file catbench-0.1.30-py3-none-any.whl.
File metadata
- Download URL: catbench-0.1.30-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b80e8fa4b3ae936aa02b73614dcc79b6e5daadfb5ccff9cc0760a381eeafd74
|
|
| MD5 |
0aa43ea38a82298cc5a0032a4ef9aae0
|
|
| BLAKE2b-256 |
9b654bc9e55b066201e185b09dc00ec6cccfc45f79aca7969c9a18ace56417ec
|
Provenance
The following attestation bundles were made for catbench-0.1.30-py3-none-any.whl:
Publisher:
publish.yml on JinukMoon/CatBench
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
catbench-0.1.30-py3-none-any.whl -
Subject digest:
5b80e8fa4b3ae936aa02b73614dcc79b6e5daadfb5ccff9cc0760a381eeafd74 - Sigstore transparency entry: 215406939
- Sigstore integration time:
-
Permalink:
JinukMoon/CatBench@8acadc538c4518b8a8c51b4aa577b032872536d7 -
Branch / Tag:
refs/tags/v0.1.30 - Owner: https://github.com/JinukMoon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8acadc538c4518b8a8c51b4aa577b032872536d7 -
Trigger Event:
push
-
Statement type: