virial_finite_diff#

mbgdml.stress.virial_finite_diff(Z, R, entity_ids, comp_ids, cell_vectors, mbe_pred, dh=0.0001, only_normal_stress=False)[source]#

Approximates the virial stress of a periodic cell with vectors \(\mathbf{h}\) using a finite difference scheme.

\[W_{ij} = \frac{E_{h_{ij} + \Delta h} - E_{h_{ij} - \Delta h}}{2 \Delta h}\]
Parameters:
  • Z (numpy.ndarray, ndim: 1) – Atomic numbers of all atoms in the system with respect to R.

  • R (numpy.ndarray, shape: (N, len(Z), 3)) – Cartesian coordinates of N structures to predict.

  • entity_ids (numpy.ndarray, shape: (N,)) – Integers specifying which atoms belong to which entities.

  • comp_ids (numpy.ndarray, shape: (N,)) – Relates each entity_id to a fragment label. Each item’s index is the label’s entity_id.

  • cell_vectors (numpy.ndarray, shape: (3, 3)) – The three cell vectors.

  • mbe_pred (mbgdml.mbe.mbePredict) – Initialized many-body expansion predictor.

  • dh (float, default: 1e-4) – Forward and backward displacement for the cell vectors.

  • only_normal_stress (bool) – Only compute normal (xx, yy, and zz) stress.

Returns:

(shape: (3, 3)) - Virial stress in units of energy.

Return type:

numpy.ndarray

Notes

Code adapted from here.