pwtools.crys.scell_mask

pwtools.crys.scell_mask(nx, ny, nz, direc=1)[source]

Build a mask for the creation of a nx x ny x nz supercell (for 3d coordinates).

Return all possible permutations with repitition of the integers ix, iy, iz = 0, …, nx-1, ny-1, nz-1 . Dimensions can also be negative, in which case i = 0,-1,…,-n+1 . Parameter direc reverses the ordering.

Parameters:
  • nx (int)

  • ny (int)

  • nz (int)

  • direc (int) – 1 or -1, order mask 0,…,n-1 (cells placed “center to edge”) or reverse n-1,…,0 (“egde to center”)

Returns:

mask

Return type:

2d array, shape (nx*ny*nz, 3)

Examples

>>> # 2x2x2 supercell
>>> scell_mask(2,2,2)
array([[ 0.,  0.,  0.],
       [ 0.,  0.,  1.],
       [ 0.,  1.,  0.],
       [ 0.,  1.,  1.],
       [ 1.,  0.,  0.],
       [ 1.,  0.,  1.],
       [ 1.,  1.,  0.],
       [ 1.,  1.,  1.]])
>>> # 2x2x1 slab = "plane" of 4 cells
>>> scell_mask(2,2,1)
array([[ 0.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 1.,  0.,  0.],
       [ 1.,  1.,  0.]])
>>> # direction reversed
>>> scell_mask(2,2,1,direc=-1)
array([[ 1.,  1.,  0.],
       [ 1.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 0.,  0.,  0.]])