pythtb.Mesh.build_grid#

Mesh.build_grid(shape, gamma_centered=False, k_endpoints=False, lambda_endpoints=True, lambda_start=0.0, lambda_stop=1.0)[source]#

Build a regular Monkhorst-Pack k-space and lambda space grid.

The grid is a uniform array that has a sampling axis for each dimension in the combined \((k, \lambda)\)-space (Monkhorst-Pack mesh).

Warning

This function is not suitable for creating paths or irregular meshes. An example of when not to use it is if you have a 2D k-space model and are using a mesh of values along \(k_y\) for a given \(k_x\) value, or vice versa. In such cases, you should use build_path() or build_custom() instead.

Parameters:
shapelist or tuple of int with size len(axis_types)

The number of points along each axis.

gamma_centeredbool, list[bool] optional

If True, center the k-space grid at the Gamma point. This makes the grid axes go from -0.5 to 0.5. One may also specify a list of booleans to control the centering for each k-axis.

k_endpointsbool, list[bool], optional

If True, include the endpoints of the k-space grid. One may also specify a list of booleans to control the inclusion of endpoints for each k-axis.

lambda_endpointsbool, list[bool], optional

If True, include the endpoints of the lambda space grid. One may also specify a list of booleans to control the inclusion of endpoints for each lambda-axis.

lambda_startfloat, list[float], optional

The starting point for the lambda space grid. If not specified, defaults to 0.0. One may also specify a list of floats to control the starting point for each lambda-axis.

lambda_stopfloat, list[float], optional

The stopping point for the lambda space grid. If not specified, defaults to 1.0. One may also specify a list of floats to control the stopping point for each lambda-axis.

Notes

  • The k-points (in reduced units) range from \([0, 1)\), unless gamma_centered = True, in which case they range from \([-0.5, 0.5)\). The endpoints are included if k_endpoints flag is set to True (default is False).

  • The lambda points range from lambda_start to lambda_stop along the lambda axes. If these are not specified, they will default to 0 and 1 respectively. The endpoints are included if lambda_endpoints flag is set to True (default is True).

  • This function populates the .points and .flat attributes. After calling this function, the .points attribute will be shape (*mesh_shape, dim_k+dim_lambda), while the .flat attribute will be the flattened version (np.prod(*mesh_shape), dim_k+dim_lambda).

Examples

We can create a full grid by specifying the shape of the grid.

>>> mesh = Mesh(axis_types=['k', 'k'])
>>> mesh.build_grid(shape=(10, 10), gamma_centered=True)
>>> mesh.grid.shape
(10, 10, 2)

Or suppose we have a 3D k-space model with an additional lambda dimension.

>>> mesh = Mesh(axis_types=['k', 'k', 'k', 'l'])
>>> mesh.build_grid(shape=(10, 10, 10, 100), gamma_centered=True)
>>> mesh.grid.shape
(10, 10, 10, 100, 4)

Since we have a gamma-centered grid, the k-axes go from [-0.5, 0.5) non-inclusive. The endpoints for the lambda axis are included by default.

>>> mesh.grid[0, 0, 0, 0, 0]
array([-0.5, -0.5, -0.5,  0. ])
>>> mesh.grid[-1, -1, -1, -1, -1]
array([ 0.49,  0.49,  0.49,  1. ])