Introduction to atomate2
mainpymatgen and fireworks ecosystems. The project focuses on automating tasks like structure optimization, band structure calculations, and property prediction.repository·main·Indexed 43 days ago
https://github.com/materialsproject/atomate2An open-source Python library for performing complex materials science workflows. It leverages pymatgen, custodian, and jobflow to automate large-scale materials property computations, such as electronic band structures, phonons, and defect formation energy diagrams, primarily using VASP and ABINIT.
pymatgen and fireworks ecosystems. The project focuses on automating tasks like structure optimization, band structure calculations, and property prediction.atomate2 includes a set of applications within its GitHub source that use core tools to build focused workflows, such as a MOF (Metal-Organic Framework) screening pipeline.
Some community-maintained extensions include:
atomate2 features).atomate2 provides a wide range of pre-defined VASP workflows for various materials science tasks. These include:
A TaskDocument (or TaskDoc) is a dictionary-based schema used to collect and store all information related to a specific computational chemistry calculation run.
It serves as a practical way to transfer data between different jobs in a workflow. For example, if a subsequent step requires the structure or the directory path from a previous job, you can access them via taskdoc.structure and taskdoc.dir_name.
The atomate2 library provides two distinct ways to interact with machine learning interatomic forcefields (MLFFs) via the Atomic Simulation Environment (ASE):
ase module: Use this for high-level tasks and general simulation workflows. This includes geometry optimization, molecular dynamics (MD), and nudged elastic band (NEB) calculations. It is based around general ASE Calculators.forcefields module: Use this for developing concrete, specialized implementations of workflows. Examples include harmonic phonon calculations, Grüneisen parameter calculations, and ApproxNEB.When ase introduces new features (like the MTKNPT NPT MD barostat), atomate2 typically updates its ase module to adopt these as defaults.
A Builder (provided by the maggma toolkit) is a data processing step used to build data pipelines. It follows a specific lifecycle to transform data from a Store into processed output documents.
To implement a custom Builder, you must implement three core methods:
get_items(): Retrieves raw data from the source store(s).process_item(item): Handles the input items and creates the output document.update_targets(items): Updates the target store(s) with the newly processed results.class Builder(MSONable, metaclass=ABCMeta):
"""
Base Builder class
At minimum this class should implement:
get_items - Get items from the sources
update_targets - Updates the sources with results
Multiprocessing and MPI processing can be used if all
the data processing is limited to process_items
"""
"""[...]"""
@abstractmethod
def get_items(self) -> Iterable:
def process_item(self, item: Any) -> Any:
@abstractmethod
def update_targets(self, items: List):The output key within a JobStoreDocument contains the specific results of a calculation. For VASP calculations, this is known as a TaskDoc. While the schema varies by calculation type, TaskDoc models are hierarchical and share several common top-level keys:
Contains basic structural information:
nsites: Number of sites.composition: Full material composition.elements: List of elements.formula_pretty: Cleaned formula string.chemsys: Dash-delimited element string.structure: The final output structure as a serialized pymatgen.Structure object.builder_meta: Information about the software versions used (e.g., emmet_version, pymatgen_version).task_type: A standardized label for the calculation (e.g., "Structure Optimization").task_label: A user-definable label.dir_name: Path to the calculation directory.run_stats: Computational resource usage (walltime, CPU time, memory, etc.).input: Summarized final input data (e.g., Structure, INCAR settings, pseudopotentials).output: Summary of final results (e.g., energy, energy_per_atom, bandgap, structure).orig_inputs: The original inputs provided by the user (useful for provenance if custodian modified settings).custodian: A list of corrections or changes made during the calculation.calcs_reversed: A list containing inputs and outputs for all calculation steps in reverse order (index [0] is the most recent step). This section is designed to capture all information available in a VASP OUTCAR or vasprun.xml.{
"task_type": "Structure Optimization",
"task_label": "relax",
"dir_name": "/path/to/job",
"run_stats": {
"average_memory": 0,
"max_memory": 241584,
"elapsed_time": 18.833,
"system_time": 1.114,
"user_time": 16.166,
"total_time": 17.28,
"cores": 40
},
"input": { ... },
"output": { ... },
"calcs_reversed": [ ... ]
}A core architectural principle of atomate2 is the complete decoupling of workflow definitions from the job managers used to execute them.
atomate2 and jobflow abstractions. This code remains identical regardless of where it is run.Because of this separation, atomate2 workflows are portable. You can develop and test a workflow using a local manager (often using mocked calls to executables) and then deploy the exact same workflow to a high-performance computing cluster via a manager like FireWorks without changing your atomate2 code.
Every Job run in atomate2 is stored as a JobStoreDocument. This document follows a standard schema that ensures consistency across all jobs. Key fields include:
uuid: A unique identifier for the Job.output: The actual calculation results (the contents of the Job).completed_at: Timestamp of job completion.name: The name of the job (e.g., "relax").@module, @class, @version: Metadata used to re-create the document model from a dictionary.index: An integer index.metadata: A dictionary for additional metadata.hosts: A list of host identifiers.These schemas are implemented using pydantic.BaseModel, providing data type validation (e.g., guaranteeing name is a str).
[
{
"uuid":"c2b5eb7d-838b-4dee-896f-95f21867b62b",
"index":1,
"output":{...},
"completed_at":"2024-05-19T17:13:46.400349",
"metadata":{},
"hosts":["dbaebabf-134d-426a-b91c-15abf799da65"],
"name":"relax",
"@module":"jobflow.core.schemas",
"@class":"JobStoreDocument",
"@version":"0.1.17"
}
]atomate2 uses MongoDB to store calculation results and workflow state details (when using FireWorks).
jobflow later.If your compute nodes cannot reach the MongoDB server due to firewalls, consider:
mongo-proxy to forward connections.In classical molecular dynamics (MD) simulations, representing the intermediate state is complex because systems require velocities and forces in addition to elements, coordinates, and box vectors.
Atomate2 uses the openff.interchange.Interchange object as the primary data contract. This object catalogs necessary system properties and provides a standardized interface to various MD engines. The Interchange object is the core entity passed between different stages (jobs) of an Atomate2 OpenMM workflow.
An InputSet is a dict-like container used to manage and write input files for various computational codes (e.g., VASP, Q-Chem, LAMMPS). It is a core class from pymatgen used within atomate2 to handle the setup of calculation parameters.
Key capabilities:
.write_input(directory, ...) to generate the actual files on disk..from_directory(directory) classmethod to reconstruct an InputSet from existing files.VaspInputSet) provide an .is_valid property to check for conflicting settings before running a calculation.For specific codes, use the corresponding InputGenerator classes to create predefined 'recipes' for tasks like structural relaxation or band structure calculations.
class InputSet(MSONable, MutableMapping):
def write_input(
self,
directory: str | Path,
make_dir: bool = True,
overwrite: bool = True,
zip_inputs: bool = False,
):
"""Write Inputs to one or more files."""
pass
@classmethod
def from_directory(cls, directory: str | Path):
"""Construct an InputSet from a directory of one or more files."""
pass