cell

A module containing the Cell class.

Summary

Classes:

Cell

Class for storing unit cell parameters.

Reference

class Cell(
x: Real = 1.7976931348623157e+308,
y: Real = 1.7976931348623157e+308,
z: Real = 1.7976931348623157e+308,
alpha: Real = 90,
beta: Real = 90,
gamma: Real = 90,
)[source]

Bases: _StandardPropertiesMixin

Class for storing unit cell parameters.

A cell object can be initialized with the following parameters:

Parameters:
  • x (Real) – The length of the first box vector.

  • y (Real) – The length of the second box vector.

  • z (Real) – The length of the third box vector.

  • alpha (Real, optional) – The angle between the second and third box vector.

  • beta (Real, optional) – The angle between the first and third box vector.

  • gamma (Real, optional) – The angle between the first and second box vector.

Notes

A vacuum cell can be created by calling Cell(), which is equivalent to Cell(x=sys.float_info.max, y=sys.float_info.max, z=sys.float_info.max, alpha=90, beta=90, gamma=90).

__eq__(
other: Any,
) Bool[source]

Checks if the Cell is equal to another Cell.

Parameters:

other (Cell) – The Cell to compare with.

Returns:

True if the Cells are equal, False otherwise.

Return type:

Bool

__repr__() str[source]

Returns a string representation of the Cell.

Returns:

A string representation of the Cell.

Return type:

str

__str__() str[source]

Returns a string representation of the Cell.

Returns:

A string representation of the Cell.

Return type:

str

image(
pos: NpnDNumberArray,
) NpnDNumberArray[source]

Images the given position(s) into the unit cell.

This class can be used to image positions of arbitrary shape into the unit cell. The shape of the input is preserved. The only requirement is that the last dimension of the input is 3, representing the x, y and z coordinates of the position(s).

Parameters:

pos (NpnDNumberArray) – The position to get the image of.

Returns:

imaged_positions – The image of the position(s) in the unit cell.

Return type:

NpnDNumberArray

classmethod init_from_box_matrix(
box_matrix: Np2x2NumberArray,
) Cell[source]

Initializes a Cell object from a box matrix.

Parameters:

box_matrix (Np3x3NumberArray) – The box matrix.

Returns:

The Cell object.

Return type:

Cell

isclose(
other: Any,
rtol: PositiveReal = 1e-09,
atol: PositiveReal = 0.0,
) Bool[source]

Checks if the Cell is close to another Cell.

Parameters:
  • other (Cell) – The Cell to compare with.

  • rtol (PositiveReal, optional) – The relative tolerance parameter. Default is 1e-9.

  • atol (PositiveReal, optional) – The absolute tolerance parameter. Default is 0.0.

Returns:

True if the Cells are close, False otherwise.

Return type:

Bool

setup_box_matrix() Np2x2NumberArray[source]

Calculates the box matrix from the given parameters.

Returns:

box matrix – The box matrix.

Return type:

Np3x3NumberArray

property alpha: Real

The angle between the second and third box vector.

Type:

Real

property beta: Real

The angle between the first and third box vector.

Type:

Real

property bounding_edges: Np2DNumberArray

The 8 corners of the bounding box of the unit cell.

Type:

Np2DNumberArray

property box_angles: Np1DNumberArray

The angles between the box vectors.

When setting the box angles, the box matrix is recalculated.

Type:

Np1DNumberArray

property box_lengths: Np1DNumberArray

The lengths of the box vectors.

When setting the box lengths, the box matrix is recalculated.

Type:

Np1DNumberArray

property box_matrix: Np2x2NumberArray

The box matrix.

Type:

Np3x3NumberArray

property gamma: Real

The angle between the first and second box vector.

Type:

Real

property inverse_box_matrix: Np2x2NumberArray

The inverse box matrix.

Type:

Np3x3NumberArray

property is_vacuum: bool

Returns whether the unit cell is a vacuum.

Type:

bool

property volume: Real

The volume of the unit cell.

Type:

volume

property x: Real

The length of the first box vector.

Type:

Real

property y: Real

The length of the second box vector.

Type:

Real

property z: Real

The length of the third box vector.

Type:

Real

class Cells

A type hint for a list of cells

alias of Annotated[list, Is[lambda list: all((isinstance(atom, Cell) for atom in list))]]