LatticeBase

class sknano.core.crystallography.LatticeBase(nd=None, cell_matrix=None, orientation_matrix=None, offset=None)[source] [edit on github][source]

Bases: sknano.core.strings.TabulateMixin, sknano.core.meta.BaseClass

Base class for crystallographic lattice objects.

Parameters:
  • nd (int) –
  • cell_matrix (array_like) –
  • orientation_matrix (array_like, optional) –
  • offset (array_like, optional) –

Attributes

bounding_box region bounding_box.
cell Alias for cell_matrix.
cell_matrix Matrix of lattice row vectors.
centroid Region centroid.
fmtstr Format string.
fractional_matrix Transformation matrix to convert from cartesian coordinates to fractional coordinates.
matrix Alias for cell_matrix.
metric_tensor Metric tensor.
offset Lattice offset.
ortho_matrix Transformation matrix to convert from fractional coordinates to cartesian coordinates.
region Parallelepiped defined by lattice vectors.

Methods

cartesian_to_fractional(ccoords) Convert cartesian coordinate to fractional coordinate.
fractional_diff(fcoords1, fcoords2) Compute difference between fractional coordinates.
fractional_to_cartesian(fcoords) Convert fractional coordinate to cartesian coordinate.
rotate(**kwargs) Rotate unit cell.
todict() Return dict of constructor parameters.
translate(t) Translate lattice.
wrap_cartesian_coordinate(p[, epsilon, pbc]) Wrap cartesian coordinate to lie within unit cell.
wrap_cartesian_coordinates(points[, ...]) Wrap array of cartesian coordinates to lie within unit cell.
wrap_fractional_coordinate(p[, epsilon, pbc]) Wrap fractional coordinate to lie within unit cell.
wrap_fractional_coordinates(points[, ...]) Wrap array of fractional coordinates to lie within unit cell.

Attributes Summary

bounding_box region bounding_box.
cell Alias for cell_matrix.
cell_matrix Matrix of lattice row vectors.
centroid Region centroid.
fractional_matrix Transformation matrix to convert from cartesian coordinates to fractional coordinates.
matrix Alias for cell_matrix.
metric_tensor Metric tensor.
offset Lattice offset.
ortho_matrix Transformation matrix to convert from fractional coordinates to cartesian coordinates.
region Parallelepiped defined by lattice vectors.

Methods Summary

cartesian_to_fractional(ccoords) Convert cartesian coordinate to fractional coordinate.
fractional_diff(fcoords1, fcoords2) Compute difference between fractional coordinates.
fractional_to_cartesian(fcoords) Convert fractional coordinate to cartesian coordinate.
rotate(**kwargs) Rotate unit cell.
translate(t) Translate lattice.
wrap_cartesian_coordinate(p[, epsilon, pbc]) Wrap cartesian coordinate to lie within unit cell.
wrap_cartesian_coordinates(points[, ...]) Wrap array of cartesian coordinates to lie within unit cell.
wrap_fractional_coordinate(p[, epsilon, pbc]) Wrap fractional coordinate to lie within unit cell.
wrap_fractional_coordinates(points[, ...]) Wrap array of fractional coordinates to lie within unit cell.

Attributes Documentation

bounding_box

region bounding_box.

cell

Alias for cell_matrix.

cell_matrix

Matrix of lattice row vectors.

Same as the matrix transpose of the matrix product LatticeBase.orientation_matrix \(\times\) LatticeBase.ortho_matrix:

\[\begin{split}[A] = ([R][M])^T \begin{pmatrix} \mathbf{a}\\ \mathbf{b}\\ \mathbf{c} \end{pmatrix} =([R][\mathbf{a}\,\mathbf{b}\,\mathbf{c}])^T\end{split}\]
centroid

Region centroid.

fractional_matrix

Transformation matrix to convert from cartesian coordinates to fractional coordinates.

The fractional matrix \([Q]\) is given by the inverse of the orthogonal matrix \([M]\) (see: ortho_matrix), i.e. \([Q]=[M]^{-1}\)

\[\begin{split}[Q] = [M]^{-1} =\begin{pmatrix} 1/a & -1/a\tan\gamma & (\cos\alpha\cos\gamma - \cos\beta)/ a\phi\sin\gamma\\ 0 & 1/b\sin\gamma & (\cos\beta\cos\gamma - \cos\alpha)/ b\phi\sin\gamma\\ 0 & 0 & \sin\gamma/c\phi \end{pmatrix}\end{split}\]

where:

\[\begin{split}\begin{align*} \phi &= \frac{V}{abc}\\ &=\sqrt{1 - \cos^2\alpha - \cos^2\beta - \cos^2\gamma + 2\cos\alpha\cos\beta\cos\gamma}\\ &=\sin\alpha\sin\beta\sin\gamma^* \end{align*}\end{split}\]

where \(V\) is the volume of the unit cell.

matrix

Alias for cell_matrix.

metric_tensor

Metric tensor.

offset

Lattice offset.

ortho_matrix

Transformation matrix to convert from fractional coordinates to cartesian coordinates.

\[\begin{split}[M] = \begin{pmatrix} \mathbf{a} & \mathbf{b} & \mathbf{c} \end{pmatrix} = \begin{pmatrix} a & b\cos\gamma & c\cos\beta\\ 0 & b\sin\gamma & c(\cos\alpha - \cos\beta\cos\gamma)/\sin\gamma\\ 0 & 0 & c\sin\alpha\sin\beta\sin\gamma^*/\sin\gamma \end{pmatrix}\end{split}\]
region

Parallelepiped defined by lattice vectors.

Methods Documentation

cartesian_to_fractional(ccoords)[source] [edit on github][source]

Convert cartesian coordinate to fractional coordinate.

Parameters:ccoords (array_like) –
Returns:
Return type:ndarray
fractional_diff(fcoords1, fcoords2)[source] [edit on github][source]

Compute difference between fractional coordinates.

See also

core.crystallography.pbc_diff

fractional_to_cartesian(fcoords)[source] [edit on github][source]

Convert fractional coordinate to cartesian coordinate.

Parameters:fcoords (array_like) –
Returns:
Return type:ndarray
rotate(**kwargs)[source] [edit on github][source]

Rotate unit cell.

Parameters:
  • angle (float) –
  • axis (Vector, optional) –
  • anchor_point (Point, optional) –
  • rot_point (Point, optional) –
  • to_vector (from_vector,) –
  • degrees (bool, optional) –
  • transform_matrix (ndarray) –

See also

core.math.rotate

translate(t)[source] [edit on github][source]

Translate lattice.

Parameters:t (Vector) –

See also

core.math.translate

wrap_cartesian_coordinate(p, epsilon=1e-08, pbc=None)[source] [edit on github][source]

Wrap cartesian coordinate to lie within unit cell.

Parameters:p (array_like) –
Returns:
Return type:ndarray
wrap_cartesian_coordinates(points, epsilon=1e-08, pbc=None)[source] [edit on github][source]

Wrap array of cartesian coordinates to lie within unit cell.

Parameters:p (array_like) –
Returns:
Return type:ndarray
wrap_fractional_coordinate(p, epsilon=1e-08, pbc=None)[source] [edit on github][source]

Wrap fractional coordinate to lie within unit cell.

Parameters:p (array_like) –
Returns:
Return type:ndarray
wrap_fractional_coordinates(points, epsilon=1e-08, pbc=None)[source] [edit on github][source]

Wrap array of fractional coordinates to lie within unit cell.

Parameters:p (array_like) –
Returns:
Return type:ndarray