structuretoolkit.analyse.strain.get_strain

Contents

structuretoolkit.analyse.strain.get_strain#

structuretoolkit.analyse.strain.get_strain(structure: Atoms, ref_structure: Atoms, num_neighbors: int | None = None, only_bulk_type: bool = False, return_object: bool = False) ndarray | Strain[source]#

Calculate local strain of each atom following the Lagrangian strain tensor:

strain = (F^T x F - 1)/2

where F is the atomic deformation gradient.

Parameters:
  • structure (ase.atoms.Atoms) – strained structures

  • ref_structure (ase.atoms.Atoms) – Reference bulk structure (against which the strain is calculated)

  • num_neighbors (int) – Number of neighbors to take into account to calculate the local frame. If not specified, it is estimated based on cna analysis (only available if the bulk structure is bcc, fcc or hcp).

  • only_bulk_type (bool) – Whether to calculate the strain of all atoms or only for those which cna considers has the same crystal structure as the bulk. Those which have a different crystal structure will get 0 strain.

Returns:

Strain tensors

Return type:

((n_atoms, 3, 3)-array)

Example:

>>> from ase.build import bulk
>>> import structuretoolkit as st
>>> bulk = bulk('Fe', cubic=True)
>>> structure = st.get_strain(bulk, np.random.random((3,3))*0.1, return_box=True)
>>> Strain(structure, bulk).strain

Attention

Differs from Atoms.apply_strain()! This strain is not the same as the strain applied in Atoms.apply_strain, which multiplies the strain tensor (plus identity matrix) with the basis vectors, while here it follows the definition given by the Lagrangian strain tensor. For small strain values they give similar results (i.e. when strain**2 can be neglected).