elaston.tools module

elaston.tools.C_from_voigt(C_in: ndarray, {'units': '=C'}], inverse: bool = False) ndarray, {'units': '=C'}][source]

Convert elastic tensor in Voigt notation to matrix notation.

Parameters:
  • C_in (numpy.ndarray) – Elastic tensor in Voigt notation.

  • inverse (bool) – Whether to use the inverse Voigt notation.

Returns:

Elastic tensor in matrix notation.

Return type:

numpy.ndarray

elaston.tools.C_to_voigt(C_in: ndarray, {'units': '=C'}]) ndarray, {'units': '=C'}][source]

Convert elastic tensor in matrix notation to Voigt notation.

Parameters:

C_in (numpy.ndarray) – Elastic tensor in matrix notation.

Returns:

Elastic tensor in Voigt notation.

Return type:

numpy.ndarray

elaston.tools.box_to_crystal(tensor: ndarray, orientation: ndarray, axes: ndarray | None = None) ndarray[source]

Translate a tensor given in the box coordinate system to the crystal coordinate system. Crystal coordinates are (usually) given by [[1, 0, 0], [0, 1, 0], [0, 0, 1]] and box coordinates are given by the lattice vectors, such as [[1, 1, 1], [1, -1, 0], [1, -2, 1]].

Parameters:
  • tensor (np.ndarray) – Tensor to be rotated.

  • orientation (np.ndarray) – Orientation matrix.

  • axes (np.ndarray) – Axes to rotate.

elaston.tools.crystal_to_box(tensor: ndarray, orientation: ndarray, axes: ndarray | None = None) ndarray[source]

Translate a tensor given in the crystal coordinate system to the box coordinate system. Crystal coordinates are (usually) given by [[1, 0, 0], [0, 1, 0], [0, 0, 1]] and box coordinates are given by the lattice vectors, such as [[1, 1, 1], [1, -1, 0], [1, -2, 1]].

Parameters:
  • tensor (np.ndarray) – Tensor to be rotated.

  • orientation (np.ndarray) – Orientation matrix.

  • axes (np.ndarray) – Axes to rotate.

elaston.tools.get_compliance_tensor(elastic_tensor: ndarray, {'units': '=C'}], voigt: bool = False) ndarray, {'units': '=1/C'}][source]
elaston.tools.get_plane(T: ndarray) tuple[ndarray, ndarray][source]

Get a plane perpendicular to a vector.

Selects the standard basis vector least aligned with T as a reference to ensure a deterministic, well-conditioned result for any input direction.

Parameters:

T (numpy.ndarray) – A unit vector or array of unit vectors (…, 3).

Returns:

A pair of vectors that span the plane perpendicular to T.

Return type:

tuple

elaston.tools.index_from_voigt(i: int, j: int) int[source]

Convert Voigt notation to matrix index.

Parameters:
  • i (int) – Voigt index.

  • j (int) – Voigt index.

Returns:

Matrix index.

Return type:

int

elaston.tools.normalize(x: ndarray) ndarray[source]

Normalize a vector or an array of vectors.

Parameters:

x (numpy.ndarray) – A vector or an array of vectors.

Returns:

Normalized vector or array of vectors.

Return type:

numpy.ndarray

elaston.tools.orthonormalize(vectors: list) ndarray[source]

Orthonormalize a set of vectors.

Parameters:

vectors (list) – A list of vectors.

Returns:

An orthonormal basis.

Return type:

numpy.ndarray

elaston.tools.voigt_average(C_11: Annotated[float, {'units': '=C'}], C_12: Annotated[float, {'units': '=C'}], C_44: Annotated[float, {'units': '=C'}]) ndarray, {'units': '=C'}][source]

Make isotropic elastic tensor from C_11, C_12, and C_44.