core.calculate.ase_calculator#

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.

Exceptions#

MixedPBCError

Specific exception example.

AllZeroUnitCellError

Specific exception example.

NoAtoms

Specific exception example.

Classes#

FAIRChemCalculator

Base-class for all ASE calculators.

Module Contents#

class core.calculate.ase_calculator.FAIRChemCalculator(predict_unit: fairchem.core.units.mlip_unit.mlip_unit.MLIPPredictUnit, task_name: fairchem.core.units.mlip_unit.api.inference.UMATask | None = None, seed: int = 41)#

Bases: ase.calculators.calculator.Calculator

Base-class for all ASE calculators.

A calculator must raise PropertyNotImplementedError if asked for a property that it can’t calculate. So, if calculation of the stress tensor has not been implemented, get_stress(atoms) should raise PropertyNotImplementedError. This can be achieved simply by not including the string ‘stress’ in the list implemented_properties which is a class member. These are the names of the standard properties: ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.

implemented_properties = []#

Properties calculator can handle (energy, forces, …)

predictor#
calc_property_to_model_key_mapping#
a2g#
property task_name: str#
_reset_calc_key_mapping(task_name: str) None#

Create a map of calculator keys to predictor output keys based on whats available in the model.

Parameters:

task_name (str) – The name of the task to use.

check_state(atoms: ase.Atoms, tol: float = 1e-15) list#

Check for any system changes since the last calculation.

Parameters:
  • atoms (ase.Atoms) – The atomic structure to check.

  • tol (float) – Tolerance for detecting changes.

Returns:

A list of changes detected in the system.

Return type:

list

calculate(atoms: ase.Atoms, properties: list[str], system_changes: list[str]) None#

Perform the calculation for the given atomic structure.

Parameters:
  • atoms (Atoms) – The atomic structure to calculate properties for.

  • properties (list[str]) – The list of properties to calculate.

  • system_changes (list[str]) – The list of changes in the system.

Notes

  • charge must be an integer representing the total charge on the system and can range from -100 to 100.

  • spin must be an integer representing the spin multiplicity and can range from 0 to 100.

  • If task_name=”omol”, and charge or spin are not set in atoms.info, they will default to 0.

  • charge and spin are currently only used for the omol head.

  • The free_energy is simply a copy of the energy and is not the actual electronic free energy. It is only set for ASE routines/optimizers that are hard-coded to use this rather than the energy key.

_check_atoms_pbc(atoms) None#

Check for invalid PBC conditions

Parameters:

atoms (ase.Atoms) – The atomic structure to check.

_validate_charge_and_spin(atoms: ase.Atoms) None#

Validate and set default values for charge and spin.

Parameters:

atoms (Atoms) – The atomic structure containing charge and spin information.

exception core.calculate.ase_calculator.MixedPBCError(message='Attempted to guess PBC for an atoms object, but the atoms object has PBC set to True for some dimensions but not others. Please ensure that the atoms object has PBC set to True for all dimensions.')#

Bases: ValueError

Specific exception example.

message#
exception core.calculate.ase_calculator.AllZeroUnitCellError(message='Atoms object claims to have PBC set, but the unit cell is identically 0. Please ensure that the atoms object has a non-zero unit cell.')#

Bases: ValueError

Specific exception example.

message#
exception core.calculate.ase_calculator.NoAtoms(message='Atoms object has no atoms inside.')#

Bases: ValueError

Specific exception example.

message#