pwtools.crys.volume_cell

pwtools.crys.volume_cell(cell)[source]

Volume of the unit cell from cell vectors. Calculates the triple product:

np.dot(np.cross(a,b), c) == det(cell)

of the basis vectors a,b,c contained in cell. Note that (mathematically) the vectors can be either the rows or the cols of cell.

Parameters:

cell (array, shape (3,3)) – Matrix with basis vectors as rows.

Returns:

volume, unit

Return type:

[a]**3

Examples

>>> a = [1,0,0]; b = [2,3,0]; c = [1,2,3.];
>>> m = np.array([a,b,c])
>>> volume_cell(m)
9.0
>>> volume_cell(m.T)
9.0
>>> m = rand(3,3)
>>> volume_cell(m)
0.11844733769775126
>>> volume_cell(m.T)
0.11844733769775123
>>> np.linalg.det(m)
0.11844733769775125
>>> np.linalg.det(m.T)
0.11844733769775125