core.components.calculate.adsorption_runner#

Copyright (c) Meta Platforms, Inc. and affiliates.

This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.

Classes#

AdsorptionRunner

Relax an adsorbate+surface configuration to compute the adsorption energy.

Module Contents#

class core.components.calculate.adsorption_runner.AdsorptionRunner(calculator: ase.calculators.calculator.Calculator, input_data: fairchem.core.datasets.AseDBDataset, save_relaxed_atoms: bool = True, relax_surface: bool = False, optimizer_cls: type[ase.optimize.Optimizer] = LBFGS, fmax: float = 0.05, steps: int = 300)#

Bases: fairchem.core.components.calculate.CalculateRunner

Relax an adsorbate+surface configuration to compute the adsorption energy. The option to also relax a clean surface is also provided.

This class handles the relaxation of atomic structures using a specified calculator, processes the input data in chunks, and saves the results.

Input data is an AseDBDataset where each atoms object is organized as follows:

atoms: adsorbate+surface configuration atoms.info = {

gas_ref: float, dft_relaxed_adslab_energy: float, dft_relaxed_slab_energy: float, initial_slab_atoms: ase.Atoms, # Required if relax_surface=True

}

result_glob_pattern: ClassVar[str] = 'adsorption_*-*.json.gz'#
_save_relaxed_atoms#
fmax#
steps#
relax_surface#
optimizer_cls#
calculate(job_num: int = 0, num_jobs: int = 1) list[dict[str, Any]]#

Perform relaxation calculations on a subset of structures.

Splits the input data into chunks and processes the chunk corresponding to job_num.

Parameters:
  • job_num (int, optional) – Current job number in array job. Defaults to 0.

  • num_jobs (int, optional) – Total number of jobs in array. Defaults to 1.

Returns:

list[dict[str, Any]] - List of dictionaries containing calculation results

write_results(results: list[dict[str, Any]], results_dir: str, job_num: int = 0, num_jobs: int = 1) None#

Write calculation results to a compressed JSON file.

Parameters:
  • results – List of dictionaries containing elastic properties

  • results_dir – Directory path where results will be saved

  • job_num – Index of the current job

  • num_jobs – Total number of jobs

save_state(checkpoint_location: str, is_preemption: bool = False) bool#

Save the current state of the calculation to a checkpoint.

Parameters:
  • checkpoint_location (str) – Location to save the checkpoint

  • is_preemption (bool, optional) – Whether this save is due to preemption. Defaults to False.

Returns:

True if state was successfully saved, False otherwise

Return type:

bool

load_state(checkpoint_location: str | None) None#

Load a previously saved state from a checkpoint.

Parameters:

checkpoint_location (str | None) – Location of the checkpoint to load, or None if no checkpoint