pwtools.crys.kgrid

pwtools.crys.kgrid(cell, **kwds)[source]

Calculate k-point grid for given real-space cell or grid spacing from grid size.

This is a convenience and backward compat function which does grid_in_cell(recip_cell(cell), **kwds).

Parameters:
  • cell (array (3,3)) – Real space unit cell.

  • **kwds (See grid_in_cell()) –

Return type:

See grid_in_cell().

Notes

  • Since the reciprocal cell is calculated with recip_cell, h=0.5 1/Ang seems to produce a sufficiently dense grid for insulators. Metals need a finer k-grid for electrons.

Examples

>>> import numpy as np
>>> from pwtools.crys import kgrid
>>> cell = np.diag([5,5,8])
>>> kgrid(cell, h=0.5)
array([3, 3, 2])
>>> # see effective grid spacing
>>> kgrid(cell, h=0.5, fullout=True)
(array([3, 3, 2]), array([ 0.41887902,  0.41887902,  0.39269908]))
>>> # reverse: effective grid spacing for given size
>>> kgrid(cell, size=[3,3,2])
array([ 0.41887902,  0.41887902,  0.39269908])
>>> # even grid
>>> kgrid(cell, h=0.5, even=True)
array([4, 4, 2])
>>> # big cell, at least Gamma with minpoints=1
>>> kgrid(cell*10, h=0.5)
array([1, 1, 1])
>>> # Create MP mesh
>>> ase.dft.monkhorst_pack(kgrid(cell, h=0.5))
>>> # cell: 1 Ang side length, recip cell 2*pi/Ang side length,
>>> # unit of h: 1/Ang
>>> crys.recip_cell(np.identity(3))
array([[ 6.28318531,  0.        ,  0.        ],
       [ 0.        ,  6.28318531,  0.        ],
       [ 0.        ,  0.        ,  6.28318531]])
>>> kgrid(np.identity(3), h=pi, fullout=True)
(array([2, 2, 2]), array([ 3.14159265,  3.14159265,  3.14159265]))