openfermion.utils.Grid

A multi-dimension grid of points with an assigned length scale.

Used in the notebooks

Used in the tutorials

This grid acts as a helper class for parallelpiped super cells. It tracks a mapping from indices to grid points and stores the associated reciprocal lattice with respect to the original real-space lattice. This enables calculations with non-trivial unit cells.

dimensions int

Number of spatial dimensions the grid occupys

length tuple of ints

d-length tuple specifying number of points along each dimension.

shifts list of ints

Integer shifts in position to center grid.

scale ndarray

Vectors defining the super cell being simulated, vectors are stored as columns in the matrix.

volume float

Total volume of the supercell parallelpiped.

num_points int

Total number of points in the grid.

reciprocal_scale ndarray

Vectors defining the reciprocal lattice. The vectors are stored as the columns in the matrix.

Methods

all_points_indices

View source

Returns: iterable[tuple[int]]: The index-coordinate tuple of each point in the grid.

grid_indices

View source

This function is the inverse of orbital_id.

Args
qubit_id int

The tensor factor to map to grid indices.

spinless bool

Whether to use the spinless model or not.

Returns
grid_indices numpy.ndarray[int]

The location of the qubit on the grid.

index_to_momentum_ints

View source

Args: index (tuple): d-dimensional tuple specifying index in the grid Returns: Integer momentum vector

momentum_ints_to_index

View source

Args: momentum_ints (tuple): d-dimensional tuple momentum integers Returns: d-dimensional tuples of indices

momentum_ints_to_value

View source

Args: momentum_ints (tuple): d-dimensional tuple momentum integers periodic (bool): Alias the momentum Returns: ndarray containing the momentum vector.

momentum_vector

View source

Given grid point coordinate, return momentum vector with dimensions.

Args
momentum_indices list

integers giving momentum indices. Allowed values are ints in [0, grid_length).

periodic bool

Wrap the momentum indices according to periodicity

Returns momentum_vector: A numpy array giving the momentum vector with dimensions.

orbital_id

View source

Return the tensor factor of a orbital with given coordinates and spin.

Args
grid_coordinates List or tuple of ints giving coordinates of grid element. Acceptable to provide an int(instead of tuple or list) for 1D case.
spin bool

0 means spin down and 1 means spin up. If None, assume spinless model.

Returns
tensor_factor int

tensor factor associated with provided orbital label.

position_vector

View source

Given grid point coordinate, return position vector with dimensions.

Args
position_indices (int|iterable[int]): List or tuple of integers giving grid point coordinate. Allowed values are ints in [0, grid_length).

Returns
position_vector (numpy.ndarray[float])

volume_scale

View source

Returns: float: The volume of a length-scale hypercube within the grid.

__eq__

View source

Return self==value.

__ne__

View source

Return self!=value.