Finite-Difference Calculator

Module for \(FiniteDifferenceCalculator\).

class ase.calculators.fd.FiniteDifferenceCalculator(calc: BaseCalculator, eps_disp: float | None = 1e-06, eps_strain: float | None = 1e-06, *, force_consistent: bool = True)[source]

Wrapper calculator using the finite-difference method.

The forces and the stress are computed using the finite-difference method.

Added in version 3.24.0.

Parameters:
  • calc (BaseCalculator) – ASE Calculator object to be wrapped.

  • eps_disp (Optional[float], default 1e-6) – Displacement used for computing forces. If None, analytical forces are computed.

  • eps_strain (Optional[float], default 1e-6) – Strain used for computing stress. If None, analytical stress is computed.

  • force_consistent (bool, default True) – If True, the energies consistent with the forces are used for finite-difference calculations.

ase.calculators.fd.calculate_numerical_forces(atoms: Atoms, eps: float = 1e-06, iatoms: Iterable[int] | None = None, icarts: Iterable[int] | None = None, *, force_consistent: bool = False) ndarray[source]

Calculate forces numerically based on the finite-difference method.

Parameters:
  • atoms (Atoms) – ASE Atoms object.

  • eps (float, default 1e-6) – Displacement.

  • iatoms (Optional[Iterable[int]]) – Indices of atoms for which forces are computed. By default, all atoms are considered.

  • icarts (Optional[Iterable[int]]) – Indices of Cartesian coordinates for which forces are computed. By default, all three coordinates are considered.

  • force_consistent (bool, default False) – If True, the energies consistent with the forces are used for finite-difference calculations.

Returns:

forces – Forces computed numerically based on the finite-difference method.

Return type:

np.ndarray

ase.calculators.fd.calculate_numerical_stress(atoms: Atoms, eps: float = 1e-06, voigt: bool = True, *, force_consistent: bool = True) ndarray[source]

Calculate stress numerically based on the finite-difference method.

Parameters:
  • atoms (Atoms) – ASE Atoms object.

  • eps (float, default 1e-6) – Strain in the Voigt notation.

  • voigt (bool, default True) – If True, the stress is returned in the Voigt notation.

  • force_consistent (bool, default True) – If True, the energies consistent with the forces are used for finite-difference calculations.

Returns:

stress – Stress computed numerically based on the finite-difference method.

Return type:

np.ndarray