mstk.topology.UnitCell

class mstk.topology.UnitCell(box=None)

UnitCell represents the periodic boundary condition of simulation system.

Both rectangular and triclinic unit cells are supported by this class. However, almost all other modules in mstk only support rectangular cell.

Parameters:

box (array_like, optional) – box can be array_like of shape (3,), (2,3) or (3,3). If its shape is (3,), then it will be treated as the lengths of a rectangular box. If its shape is (2,3), then it will be treated as the lengths and angles of a triclinic box. The angles are in unit of radian. If its shape is (3,3), then it will be treated as the box vectors. If not provided, the cell will be initialized with all elements of box vectors equal to zero.

Methods

__init__([box])

calc_lengths_angles_from_vectors(vectors)

Convert periodic box vectors to lengths and angles.

calc_vectors_from_lengths_angles(lengths, angles)

Convert box lengths and angles to periodic box vectors.

get_size()

The diagonal values of the box vectors.

set_box(box)

Set the unit cell with lengths or (lengths and angles) or full vectors.

Attributes

angles

The angles formed between the three edges of the unit cell, in unit of radian.

is_rectangular

Whether or not this unit cell is rectangular.

lengths

The lengths of three edges of the unit cell.

vectors

The box vectors of the unit cell.

volume

The volume of the unit cell.

set_box(box)

Set the unit cell with lengths or (lengths and angles) or full vectors.

Parameters:

box (array_like or None) – See the argument box of constructor for detailed explanations.

property vectors

The box vectors of the unit cell.

The box vectors is a 3*3 matrix [[Vxx, Vxy, Vxz], [Vyx, Vyy, Vyz], [Vzx, Vzy, Vzz]]. Several criterion will be satisfied: Vxy = Vxz = Vyz = 0; Vxx > 2*Vyx; Vxx > 2*Vzx; Vyy > 2*Vzy.

Returns:

vectors – The shape of box vectors is (3,3)

Return type:

array_like

get_size()

The diagonal values of the box vectors.

Returns:

size – The shape of the size vector is (3,)

Return type:

array_like

property volume

The volume of the unit cell.

Returns:

volume

Return type:

float

property lengths

The lengths of three edges of the unit cell.

Returns:

lengths – The shape of the length vector is (3,)

Return type:

array_like

property angles

The angles formed between the three edges of the unit cell, in unit of radian.

Returns:

angles – The shape of the angle vector is (3,)

Return type:

array_like

property is_rectangular

Whether or not this unit cell is rectangular.

Returns:

is

Return type:

bool

static calc_vectors_from_lengths_angles(lengths, angles)

Convert box lengths and angles to periodic box vectors.

Parameters:
  • lengths (array_like) – Length vector in shape of (3,)

  • angles (array_like) – Angle vector in shape of (3,) in unit o radian

Returns:

vectors – Box vectors in shape of (3,3)

Return type:

array_like

static calc_lengths_angles_from_vectors(vectors)

Convert periodic box vectors to lengths and angles.

Parameters:

vectors (array_like) – Box vectors in shape of (3,3)

Returns:

  • lengths (array_like) – Length vector in shape of (3,)

  • angles (array_like) – Angle vector in shape of (3,) in unit of radian