tensorial.geometry package#

Submodules#

tensorial.geometry.distances module#

tensorial.geometry.distances.Edges#

alias of Edge

class tensorial.geometry.distances.NeighbourFinder[source]#

Bases: ABC

abstractmethod get_neighbours(positions, max_neighbours=None)[source]#

Get the neighbour list for the given positions

Parameters:
  • positions (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • max_neighbours (int)

Return type:

NeighbourList

class tensorial.geometry.distances.NeighbourList[source]#

Bases: ABC

An interface that represents a neighbour list

abstractmethod get_edges()[source]#

Get the edges representing all neighbours

Return type:

Edge

abstract property max_neighbours: int#

Get the maximum number of neighbours in this list

abstract property num_particles: int#

Get the number of neighbours in this list

tensorial.geometry.jax_neighbours module#

class tensorial.geometry.jax_neighbours.NeighbourFinder[source]#

Bases: Module, NeighbourFinder

estimate_neighbours(positions)[source]#

Estimate the number of neighbours per particle

Parameters:

positions (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

Return type:

int

get_neighbours(positions, max_neighbours=None)[source]#

Get the neighbour list for the given positions

Parameters:
  • positions (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • max_neighbours (int)

Return type:

NeighbourList

class tensorial.geometry.jax_neighbours.NeighbourList(neighbours, cell_indices, actual_max_neighbours=-1, finder=None)[source]#

Bases: Module, NeighbourList

Parameters:
  • neighbours (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • cell_indices (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • actual_max_neighbours (Array)

  • finder (NeighbourFinder)

actual_max_neighbours: int#
cell_indices: Array#
property did_overflow: bool#

Returns True if the list could not accommodate all the neighbours. The actual number needed is stored in actual_max_neighbours

get_edges()[source]#

Get the edges representing all neighbours

Return type:

Edge

list_overflow()[source]#
Return type:

bool

property max_neighbours: int#

Get the maximum number of neighbours in this list

neighbours: Array#
property num_particles: int#

Get the number of neighbours in this list

reallocate(positions)[source]#
Parameters:

positions (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

Return type:

NeighbourList

class tensorial.geometry.jax_neighbours.OpenBoundary(cutoff, include_self=False)[source]#

Bases: NeighbourFinder

Parameters:

cutoff (Number)

estimate_neighbours(positions)[source]#

Estimate the number of neighbours per particle

Parameters:

positions (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

Return type:

int

get_neighbours(positions, max_neighbours=None)[source]#

Get the neighbour list for the given positions

Parameters:
  • positions (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • max_neighbours (int)

Return type:

NeighbourList

class tensorial.geometry.jax_neighbours.PeriodicBoundary(cell, cutoff, pbc=None, *, max_cell_multiples=10000, include_self=False, include_images=True)[source]#

Bases: NeighbourFinder

Parameters:
  • cell (Union[Float[Array, '3 3'], Float[ndarray, '3 3']])

  • cutoff (Number)

  • pbc (Optional[Union[tuple[bool, bool, bool], Bool[Array, '3'], Bool[ndarray, '3'], Bool[TypedNdArray, '3']]])

  • max_cell_multiples (int)

estimate_neighbours(positions)[source]#

Estimate the number of neighbours per particle

Parameters:

positions (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

Return type:

int

get_neighbours(positions, max_neighbours=None)[source]#

Get the neighbour list for the given positions

Parameters:
  • positions (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • max_neighbours (int)

Return type:

NeighbourList

tensorial.geometry.jax_neighbours.generate_positions(cell, positions, cell_shifts)[source]#
Parameters:
  • cell (Array)

  • positions (Array)

  • cell_shifts (Array)

Return type:

Array

tensorial.geometry.jax_neighbours.get_cell_list(cell, cutoff, pbc=(True, True, True), max_cell_multiples=10000)[source]#
Parameters:
  • cell (Union[Float[Array, '3 3'], Float[ndarray, '3 3']])

  • cutoff (Number)

  • pbc (Optional[Union[tuple[bool, bool, bool], Bool[Array, '3'], Bool[ndarray, '3'], Bool[TypedNdArray, '3']]])

  • max_cell_multiples (int)

Return type:

tuple[Array, Array]

tensorial.geometry.jax_neighbours.neighbour_finder(cutoff, cell=None, pbc=None, include_self=False, **kwargs)[source]#
Parameters:
  • cutoff (Number)

  • cell (Optional[Union[Float[Array, '3 3'], Float[ndarray, '3 3']]])

  • pbc (Optional[Union[tuple[bool, bool, bool], Bool[Array, '3'], Bool[ndarray, '3'], Bool[TypedNdArray, '3']]])

  • include_self (bool)

Return type:

NeighbourFinder

tensorial.geometry.jax_neighbours.neighbours_mask_aabb(centre, neighbours, cutoff)[source]#

Get the indices of all points that are within a cutoff sphere centred on centre with a radius cutoff using the Axis Aligned Bounding Box method

Parameters:
  • centre (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • neighbours (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • cutoff (float)

Return type:

Array

tensorial.geometry.jax_neighbours.neighbours_mask_direct(centre, neighbours, cutoff)[source]#

Get the indices of all points that are within a cutoff sphere centred on centre with a radius cutoff by calculating all distance vector norms and masking those within the cutoff

Parameters:
  • centre (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • neighbours (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • cutoff (float)

Return type:

Array

tensorial.geometry.np_neighbours module#

class tensorial.geometry.np_neighbours.OpenBoundary(cutoff, include_self=False)[source]#

Bases: NeighbourFinder

Parameters:
  • cutoff (Number)

  • include_self (bool)

get_neighbours(positions, max_neighbours=None)[source]#

Get the neighbour list for the given positions

Parameters:
  • positions (Union[Float[Array, 'N 3'], Float[ndarray, 'N 3']])

  • max_neighbours (int)

Return type:

NeighbourList

class tensorial.geometry.np_neighbours.PeriodicBoundary(cell, cutoff, pbc, *, include_self=False, include_images=True)[source]#

Bases: NeighbourFinder

Parameters:
  • cell – the unit cell

  • cutoff – the cutoff radius that defines if an atom is a neighbour or not

  • pbc – specifies which unit cell vectors are to be considered periodic

  • include_self – include an atom as its own neighbour within the central unit cell

  • include_images – include images of an atom in periodic repetitions of the central unit cell as neighbours

  • cell (Union[Float[Array, '3 3'], Float[ndarray, '3 3']])

  • cutoff (Number)

  • pbc (Union[tuple[bool, bool, bool], Bool[Array, '3'], Bool[ndarray, '3'], Bool[TypedNdArray, '3']])

get_neighbours(positions, max_neighbours=None)[source]#

Get the neighbour list for the given positions

Parameters:
  • positions (Union[Float[Array, 'N 3'], Float[ndarray, 'N 3']])

  • max_neighbours (int)

Return type:

NeighbourList

tensorial.geometry.np_neighbours.neighbour_finder(cutoff, cell=None, pbc=None, include_self=False, **kwargs)[source]#
Parameters:
  • cutoff (Number)

  • cell (Optional[Union[Float[Array, '3 3'], Float[ndarray, '3 3']]])

  • pbc (Optional[Union[tuple[bool, bool, bool], Bool[Array, '3'], Bool[ndarray, '3'], Bool[TypedNdArray, '3']]])

  • include_self (bool)

Return type:

NeighbourFinder

tensorial.geometry.unit_cells module#

tensorial.geometry.unit_cells.cell_volume(cell)[source]#
Parameters:

cell (Union[Float[Array, '3 3'], Float[ndarray, '3 3']])

Return type:

Array

tensorial.geometry.unit_cells.get_cell_multiple_range(cell, cell_vector, cutoff)[source]#
Parameters:
  • cell (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • cell_vector (int)

  • cutoff (float)

Return type:

tuple[int, int]

tensorial.geometry.unit_cells.get_cell_multiple_ranges(cell, cutoff, pbc=(True, True, True))[source]#
Parameters:
  • cell (Union[Float[Array, '3 3'], Float[ndarray, '3 3']])

  • cutoff (float)

  • pbc (Optional[Union[tuple[bool, bool, bool], Bool[Array, '3'], Bool[ndarray, '3'], Bool[TypedNdArray, '3']]])

Return type:

tuple[tuple[int, int], tuple[int, int], tuple[int, int]]

tensorial.geometry.unit_cells.get_edge_vectors(positions, edges, cell)[source]#
Parameters:
  • positions (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • edges (Edge)

  • cell (Union[Float[Array, '3 3'], Float[ndarray, '3 3']])

Return type:

Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray]

tensorial.geometry.unit_cells.get_max_cell_vector_repetitions(cell, cell_vector, cutoff)[source]#

Given a unit cell defined by three vectors this will return the number of multiples of the vector indexed by cell_vector that are needed to reach the edge of a sphere with radius cutoff. This tells you what multiple of cell vectors you need to go up to (when rounded up to the nearest integer) in order to fully cover all points in the sphere, in teh given cell vector direction.

Parameters:
  • cell (Union[Float[Array, '3 3'], Float[ndarray, '3 3']])

  • cell_vector (int)

  • cutoff (float)

Return type:

float

tensorial.geometry.unit_cells.get_num_plane_repetitions_to_bound_sphere(radius, volume, cross_len)[source]#
Parameters:
  • radius (float)

  • volume (float)

  • cross_len (float)

Return type:

float

tensorial.geometry.unit_cells.sphere_volume(radius)[source]#
Parameters:

radius (float)

Return type:

float

Module contents#

tensorial.geometry.Edges#

alias of Edge

class tensorial.geometry.NeighbourFinder[source]#

Bases: ABC

abstractmethod get_neighbours(positions, max_neighbours=None)[source]#

Get the neighbour list for the given positions

Parameters:
  • positions (Union[Array, ndarray, bool, number, bool, int, float, complex, TypedNdArray])

  • max_neighbours (int)

Return type:

NeighbourList

class tensorial.geometry.NeighbourList[source]#

Bases: ABC

An interface that represents a neighbour list

abstractmethod get_edges()[source]#

Get the edges representing all neighbours

Return type:

Edge

abstract property max_neighbours: int#

Get the maximum number of neighbours in this list

abstract property num_particles: int#

Get the number of neighbours in this list

class tensorial.geometry.OpenBoundary(cutoff, include_self=False)[source]#

Bases: NeighbourFinder

Parameters:
  • cutoff (Number)

  • include_self (bool)

get_neighbours(positions, max_neighbours=None)[source]#

Get the neighbour list for the given positions

Parameters:
  • positions (Union[Float[Array, 'N 3'], Float[ndarray, 'N 3']])

  • max_neighbours (int)

Return type:

NeighbourList

class tensorial.geometry.PeriodicBoundary(cell, cutoff, pbc, *, include_self=False, include_images=True)[source]#

Bases: NeighbourFinder

Parameters:
  • cell – the unit cell

  • cutoff – the cutoff radius that defines if an atom is a neighbour or not

  • pbc – specifies which unit cell vectors are to be considered periodic

  • include_self – include an atom as its own neighbour within the central unit cell

  • include_images – include images of an atom in periodic repetitions of the central unit cell as neighbours

  • cell (Union[Float[Array, '3 3'], Float[ndarray, '3 3']])

  • cutoff (Number)

  • pbc (Union[tuple[bool, bool, bool], Bool[Array, '3'], Bool[ndarray, '3'], Bool[TypedNdArray, '3']])

get_neighbours(positions, max_neighbours=None)[source]#

Get the neighbour list for the given positions

Parameters:
  • positions (Union[Float[Array, 'N 3'], Float[ndarray, 'N 3']])

  • max_neighbours (int)

Return type:

NeighbourList

tensorial.geometry.neighbour_finder(cutoff, cell=None, pbc=None, include_self=False, **kwargs)[source]#
Parameters:
  • cutoff (Number)

  • cell (Optional[Union[Float[Array, '3 3'], Float[ndarray, '3 3']]])

  • pbc (Optional[Union[tuple[bool, bool, bool], Bool[Array, '3'], Bool[ndarray, '3'], Bool[TypedNdArray, '3']]])

  • include_self (bool)

Return type:

NeighbourFinder