Skip to content

Grids

Each grid comes in three types, by whether its values and vectors are real (d) or complex (c): dd, dc and cc. They have the same methods, so only the dc type, the usual one for phonons, is shown in full. Interpolation grids explains how the grids differ.

Structured mesh

BZMeshQdc

BZMeshQdc(brillouin_zone: BrillouinZone, max_size: float = -1.0, num_levels: int = 3, max_points: int = -1)

A structured tetrahedral mesh of a Brillouin zone's irreducible part

A grid of the reciprocal lattice, divided finely enough for max_size, is clipped exactly to the irreducible zone.

Parameters:

  • brillouin_zone (BrillouinZone) –

    The zone whose irreducible part the mesh fills.

  • max_size (float, optional (default: -1), default: -1.0 ) –

    The largest tetrahedron volume, in cubic reciprocal Angstrom, which sets the grid spacing; if not positive, the grid is the reciprocal lattice itself. Each grid cell holds six tetrahedra, so max_size = node_volume_fraction / 6 gives about as many vertices as a BZTrellisQdc with that node_volume_fraction, and brillouin_zone.ir_polyhedron.volume / (6 * points) gives roughly 1.5 to 3 times points vertices, the most for small meshes.

  • num_levels (int, default: 3 ) –

    Unused; kept for compatibility.

  • max_points (int, optional (default: -1), default: -1 ) –

    If positive, the grid is coarsened until its estimated number of vertices is at most this, with a RuntimeWarning (see refinement_limited).

Methods:

Attributes:

BrillouinZone property

BrillouinZone: BrillouinZone

bytes_per_point property

bytes_per_point: int

Return the memory required per interpolation point result in bytes

holds_triangulation property

holds_triangulation: bool

Whether the triangulation that refinement works on is in memory (see release_triangulation)

invA property

invA: ndarray[float64]

normalizes_vectors property

normalizes_vectors: bool

Whether interpolated eigenvectors are normalized, given the stored data; see set_vector_normalization

refinable property

refinable: bool

Whether the mesh can be refined; a mesh read from a file written before refinement existed can't be

refinement_limited property

refinement_limited: bool

Whether max_points made the mesh coarser than max_size asked for

rlu property

rlu: ndarray[float64]

tetrahedra property

tetrahedra: ndarray[uint32]

values property

values: ndarray[float64]

Return a shared view of the stored eigenvalues

vector_metric property

vector_metric: list[float]

The diagonal metric used to normalize eigenvectors; empty for the identity

vector_normalization property

vector_normalization: str

When eigenvectors are normalized: "automatic" (the default), "on" or "off"

vectors property

vectors: ndarray[complex128]

Return a shared view of the stored eigenvectors

from_file staticmethod

from_file(filename: str, entry: str = 'BZMeshQdc') -> BZMeshQdc

Load an object from an HDF5 file

Parameters:

  • filename (str) –

    The full path specification for the file to read from

  • entry (str, default: 'BZMeshQdc' ) –

    The group path, e.g., "my/cool/grid", where to read from inside the file, with a default equal to the object Class name

Returns:

  • clsObj –

fill

fill(values_data: ndarray[float64], values_elements: ndarray[int32], vectors_data: ndarray[complex128], vectors_elements: ndarray[int32], sort: bool = False) -> None
fill(values_data: ndarray[float64], values_elements: ndarray[int32], values_weights: ndarray[float64], vectors_data: ndarray[complex128], vectors_elements: ndarray[int32], vectors_weights: ndarray[float64], sort: bool = False) -> None
fill(values_data: ndarray[float64], values_elements: ndarray[int32], vectors_data: ndarray[complex128], vectors_elements: ndarray[int32], sort: bool = False) -> None

Provide data required for interpolation to the grid without cost information.

.. Note .. ---- .. This method should probably be followed by set_cost_info prior to .. any attempt to interpolate the data in the grid.

Parameters:

  • values_data ([`numpy.ndarray`][numpy.ndarray]) –

    The eigenvalue data to be stored in the grid. The first dimension must be equal in size to the number of grid-vertices. If two dimensional the second dimension is interpreted as all information for a single mode flattened and concatenated into (scalars, vectors, matrices) -- in that order. If more than two dimensional, the second dimension indexes modes and higher dimensions will be flattened as if row ordered and must flatten into a concatenated list of (scalars, vectors, matrices). If the provided array can be interpreted as a contiguous row-ordered two dimensional array it will be used in place, otherwise a copy will be made.

  • values_elements (ndarray[int32]) –

    A multi-purpose vector containing, in order:

    • the number of scalar-like eigenvalue elements,
    • the number of vector-like eigenvalue elements (must be \(3\times N\)),
    • the number of matrix-like eigenvalue elements (must be \(9\times N\)),
    • an integer RotatesLike value denoting how the vector-like and matrix-like parts transform under application of a symmetry operation (see note below).
    • an integer LengthUnit value denoting what units the vector-like and matrix-like parts are in (see note below).
  • vectors_data ([`numpy.ndarray`][numpy.ndarray]) –

    The eigenvector data to be stored in the grid. Same shape restrictions as values_data

  • vectors_elements (ndarray[int32]) –

    Like values_elements but for the eigenvectors

  • sort (logical (default ``False``), default: False ) –

    Whether the equivalent-mode permutations should be (re)determined following the update to the flags and weights.

Note

Mapping of integers to RotatesLike values:

value RotatesLike
0 vector
1 pseudovector
2 Gamma

Integer values outside of the mapped range (or missing) are replaced by 0.

Mapping of integers to LengthUnit values:

value LengthUnit
0 none
1 angstrom
2 inverse_angstrom
3 real_lattice
4 reciprocal_lattice

Integer values outside of the mapped range (or missing) are replaced by 3.

Phonon eigenvectors (RotatesLike Gamma) must use the "cell" phase convention, in which they are periodic in reciprocal space. Eigenvectors in the "atom" convention, which phonopy uses, give wrong results without an error; see phase_convention for how to convert them.

ir_interpolate_at

ir_interpolate_at(Q: ndarray[float64], useparallel: bool = False, threads: int = -1, do_not_move_points: bool = False) -> tuple[numpy.ndarray[numpy.float64], numpy.ndarray[numpy.complex128]]

Perform linear interpolation of the stored data at irreducible equivalent points

The irreducible first Brillouin zone is the part of reciprocal space which is invariant under application of the integer translations and the pointgroup operations of a reciprocal space lattice. This method finds points equivalent to the input within the irreducible first Brillouin zone and then interpolates pre-stored information to provide an estimate at the found positions.

Parameters:

  • Q ([`numpy.ndarray`][numpy.ndarray]) –

    A two dimensional array with Q.shape[1] == 3 containing the positions at which an interpolated result is required, expressed in units of the reciprocal lattice.

  • useparallel (bool, default: False ) –

    Whether a serial or parallel code should be utilised

  • threads (int, default: -1 ) –

    How many parallel threads should be utilised; if this value is less than one, the BRILLE_NUM_THREADS environment variable sets the number, or one thread per logical core is used if it is not set.

  • do_not_move_points (bool, default: False ) –

    If True the provided Q points must already lie within the first Brillouin zone. No check is made to verify this requirement and if any Q lie outside of the gridded volume out-of-bounds errors may result in bad data or runtime errors.

Returns:

  • tuple –

    The interpolated eigenvalues and eigenvectors at the equivalent irreducible first Brillouin zone points. The shape of each output will depend on the shape of the data provided to the fill method. i If the filled eigenvalues were of shape [N_grid_points, N_modes, A, ..., B], the eigenvectors were of shape [N_grid_points, N_modes, C, ..., D], and the provided points of shape [N_Q_points, 3] then the output shapes will be [N_Q_points, N_modes, A, ..., B] and [N_Q_points, N_modes, C, ..., D] for the eigenvalues and eigenvectors, respectively.

refine

refine(where: Any = None, values: Any = None, vectors: Any = None, resolution: float | None = None, points_per_resolution: float = 2.0) -> numpy.ndarray[numpy.float64]

Refine the mesh by bisecting tetrahedra; existing vertices keep their indices and data.

Parameters:

  • where (Any, default: None ) –

    As for refinement_points, which gives the points this adds.

  • resolution (Any, default: None ) –

    As for refinement_points, which gives the points this adds.

  • points_per_resolution (Any, default: None ) –

    As for refinement_points, which gives the points this adds.

  • values (ndarray, default: None ) –

    If the mesh holds data (after fill), the data for the new vertices, laid out per point as the filled data and for exactly the points refinement_points returns, in that order. Not allowed before the mesh is filled.

  • vectors (ndarray, default: None ) –

    If the mesh holds data (after fill), the data for the new vertices, laid out per point as the filled data and for exactly the points refinement_points returns, in that order. Not allowed before the mesh is filled.

Returns:

  • ndarray –

    The new vertices, shape (N, 3), in relative lattice units, appended to rlu in this order.

Note

The mode permutations found by sort are reset; sort again after refining if needed.

refinement_points

refinement_points(where: Any = None, resolution: float | None = None, points_per_resolution: float = 2.0) -> numpy.ndarray[numpy.float64]

The points that refine would add, without changing the mesh.

Evaluate your model at these points and compare with ir_interpolate_at there to decide whether refining is worth it; then pass the model's values to refine with the same arguments.

Parameters:

  • where (None, bool array or int array, default: None ) –

    The tetrahedra to split: all of them (None), those where a boolean mask with one entry per tetrahedron is true, or those with the given indices. Neighbouring tetrahedra are split as needed to keep the mesh conforming, and split edges on the zone boundary are split with their symmetry equivalents, so that equivalent zone faces keep matching.

  • resolution (float, default: None ) –

    The resolution limit, in inverse Angstrom. No edge is split to below resolution / points_per_resolution: a tetrahedron whose longest edge is at most twice that is left whole.

  • points_per_resolution (float, optional (default: 2), default: 2.0 ) –

    How finely to resolve resolution.

Returns:

  • ndarray –

    The new vertices, shape (N, 3), in relative lattice units like rlu. refine appends them to the vertices in this order.

release_triangulation

release_triangulation() -> None

Free the memory refinement holds between refinements.

After refine (or refinement_points) the mesh keeps the triangulation refinement works on, several times the memory of the mesh itself. This frees it. The mesh is unchanged and can still be refined: the triangulation is rebuilt when next needed, which costs a build of the mesh plus a replay of the refinements made so far.

set_flags_weights

set_flags_weights(values_flags: ndarray[int32], values_weights: ndarray[float64], vectors_flags: ndarray[int32], vectors_weights: ndarray[float64], sort: bool = False) -> None

Set RotatesLike, LengthUnit and cost functions plus relative cost weights for the values and vectors stored in the object

Parameters:

  • values_flags ((integer, vector - like)) –

    One or more values indicating the RotatesLike value for the eigenvalues stored in the object, the ~brille._brille.LengthUnit value, plus which cost function to use when comparing stored eigenvalues at neighbouring grid points for scalar- and vector-like eigenvalues.

  • values_weights ((float, vector - like)) –

    The relative cost weights between scalar-, vector-, and matrix- like eigenvalue elements stored in the grid

  • vectors_flags ((integer, vector - like)) –

    One or more values indicating the RotatesLike value for the eigenvalues stored in the object, the ~brille._brille.LengthUnit value, plus which cost function to use when comparing stored eigenvectors at neighbouring grid points for scalar- and vector-like eigenvectors.

  • vectors_weights ((float, vector - like)) –

    The relative cost weights between scalar-, vector-, and matrix- like eigenvector elements stored in the grid

  • sort (bool, default: False ) –

    Whether the equivalent-mode permutations should be (re)determined following the update to the flags and weights.

Note

Mapping of integers to RotatesLike values:

value RotatesLike
0 vector
1 pseudovector
2 Gamma

Mapping of integers to LengthUnit values:

value LengthUnit
0 none
1 angstrom
2 inverse_angstrom
3 real_lattice
4 reciprocal_lattice

Mapping of integers to scalar cost function:

value function(x,y)
0 magnitude(x-y)

Mapping of integers to vector cost function:

value function(vec_x, vec_y)
0 sin(hermitian_angle(vec_x, vec_y))
1 vector_distance(vec_x, vec_y)
2 1 - vector_product(vec_x, vec_y)
3 vector_angle(vec_x, vec_y)
4 hermitian_angle(vec_x, vec_y)

Integer values outside of the mapped range (or missing) are replaced by 0.

set_vector_normalization

set_vector_normalization(normalize: bool | None = True, metric: list[float] | None = None) -> None

Choose when interpolated eigenvectors are scaled to unit norm

Linear interpolation between unit eigenvectors gives vectors shorter than one wherever neighbouring eigenvectors differ, so structure factors computed from them come out too small. Normalization scales each interpolated branch \(v\) to \(v/\sqrt{|\langle v|M|v\rangle|}\).

By default it is automatic: eigenvectors stored in Cartesian units (LengthUnit angstrom or inverse_angstrom, as Euphonic stores them) are normalized, and those in lattice units, whose length depends on the lattice, are not. The choice survives fill and saving to HDF5.

Parameters:

  • normalize (bool or None, default: True ) –

    True always normalizes, and raises a RuntimeError for eigenvectors in lattice units; False never does; None restores the automatic default.

  • metric ((float, vector - like), default: None ) –

    A diagonal metric \(M\), one weight per element of a branch (for phonons, \(3N\)). The default is the identity, the ordinary norm. For Bogoliubov (spin-wave) vectors use \(\eta=\mathrm{diag}(1,\ldots,1,-1,\ldots,-1)\); the sign of \(\langle v|\eta|v\rangle\) is kept.

sort

sort() -> None

to_file

to_file(filename: str, entry: str = 'BZMeshQdc', flags: str = 'ac') -> bool

Save the object to an HDF5 file

Parameters:

  • filename (str) –

    The full path specification for the file to write into

  • entry (str, default: 'BZMeshQdc' ) –

    The group path, e.g., "my/cool/grid", where to write inside the file, with a default equal to the object Class name

  • flags (str, default: 'ac' ) –

    The HDF5 permissions to use when opening the file. Default 'a' writes to an existing file -- if entry exists in the file it is overwritten.

Note

Possible flags are:

flags meaning HDF equivalent
'r' read H5F_ACC_RDONLY
'x' write, error if exists H5F_ACC_EXCL
'a' write, append to file H5F_ACC_RDWR
'c' write, error if exists H5F_ACC_CREAT
't' write, replace existing H5F_ACC_TRUNC

Returns:

  • bool –

    Indication of writing success.

BZMeshQdd

BZMeshQdd(brillouin_zone: BrillouinZone, max_size: float = -1.0, num_levels: int = 3, max_points: int = -1)

A structured tetrahedral mesh of a Brillouin zone's irreducible part

A grid of the reciprocal lattice, divided finely enough for max_size, is clipped exactly to the irreducible zone.

Parameters:

  • brillouin_zone (BrillouinZone) –

    The zone whose irreducible part the mesh fills.

  • max_size (float, optional (default: -1), default: -1.0 ) –

    The largest tetrahedron volume, in cubic reciprocal Angstrom, which sets the grid spacing; if not positive, the grid is the reciprocal lattice itself. Each grid cell holds six tetrahedra, so max_size = node_volume_fraction / 6 gives about as many vertices as a BZTrellisQdc with that node_volume_fraction, and brillouin_zone.ir_polyhedron.volume / (6 * points) gives roughly 1.5 to 3 times points vertices, the most for small meshes.

  • num_levels (int, default: 3 ) –

    Unused; kept for compatibility.

  • max_points (int, optional (default: -1), default: -1 ) –

    If positive, the grid is coarsened until its estimated number of vertices is at most this, with a RuntimeWarning (see refinement_limited).

BZMeshQcc

BZMeshQcc(brillouin_zone: BrillouinZone, max_size: float = -1.0, num_levels: int = 3, max_points: int = -1)

A structured tetrahedral mesh of a Brillouin zone's irreducible part

A grid of the reciprocal lattice, divided finely enough for max_size, is clipped exactly to the irreducible zone.

Parameters:

  • brillouin_zone (BrillouinZone) –

    The zone whose irreducible part the mesh fills.

  • max_size (float, optional (default: -1), default: -1.0 ) –

    The largest tetrahedron volume, in cubic reciprocal Angstrom, which sets the grid spacing; if not positive, the grid is the reciprocal lattice itself. Each grid cell holds six tetrahedra, so max_size = node_volume_fraction / 6 gives about as many vertices as a BZTrellisQdc with that node_volume_fraction, and brillouin_zone.ir_polyhedron.volume / (6 * points) gives roughly 1.5 to 3 times points vertices, the most for small meshes.

  • num_levels (int, default: 3 ) –

    Unused; kept for compatibility.

  • max_points (int, optional (default: -1), default: -1 ) –

    If positive, the grid is coarsened until its estimated number of vertices is at most this, with a RuntimeWarning (see refinement_limited).

Hybrid trellis

BZTrellisQdc

BZTrellisQdc(brillouin_zone: BrillouinZone, node_volume_fraction: float = 0.1, always_triangulate: bool = False)
BZTrellisQdc(brillouin_zone: BrillouinZone, node_volume_fraction: float, always_triangulate: bool, approx_config: ApproxConfig)
BZTrellisQdc(brillouin_zone: BrillouinZone, node_volume_fraction: float = 0.1, always_triangulate: bool = False)

A trellis of cubic nodes over a Brillouin zone's irreducible part

Parameters:

  • brillouin_zone (BrillouinZone) –

    The zone whose irreducible part the trellis fills.

  • node_volume_fraction (float, optional (default: 0.1), default: 0.1 ) –

    Despite its name, a volume in cubic reciprocal Angstrom, not a fraction: the volume of one cubic node, which sets the trellis spacing. To size the trellis by its number of points use brillouin_zone.ir_polyhedron.volume / points, which gives roughly 1.3 to 2 times points vertices.

  • always_triangulate (bool, optional (default: False), default: False ) –

    Divide every node into tetrahedra, not only those the zone boundary cuts.

Methods:

Attributes:

BrillouinZone property

BrillouinZone: BrillouinZone

bytes_per_point property

bytes_per_point: int

Return the memory required per interpolation point result in bytes

inner_invA property

inner_invA: ndarray[float64]

inner_rlu property

inner_rlu: ndarray[float64]

invA property

invA: ndarray[float64]

normalizes_vectors property

normalizes_vectors: bool

Whether interpolated eigenvectors are normalized, given the stored data; see set_vector_normalization

outer_invA property

outer_invA: ndarray[float64]

outer_rlu property

outer_rlu: ndarray[float64]

rlu property

rlu: ndarray[float64]

tetrahedra property

tetrahedra: list[Annotated[list[int], FixedSize(4)]]

values property

values: ndarray[float64]

Return a shared view of the stored eigenvalues

vector_metric property

vector_metric: list[float]

The diagonal metric used to normalize eigenvectors; empty for the identity

vector_normalization property

vector_normalization: str

When eigenvectors are normalized: "automatic" (the default), "on" or "off"

vectors property

vectors: ndarray[complex128]

Return a shared view of the stored eigenvectors

from_file staticmethod

from_file(filename: str, entry: str = 'BZTrellisQdc') -> BZTrellisQdc

Load an object from an HDF5 file

Parameters:

  • filename (str) –

    The full path specification for the file to read from

  • entry (str, default: 'BZTrellisQdc' ) –

    The group path, e.g., "my/cool/grid", where to read from inside the file, with a default equal to the object Class name

Returns:

  • clsObj –

all_node_types

all_node_types() -> list[NodeType]

fill

fill(values_data: ndarray[float64], values_elements: ndarray[int32], vectors_data: ndarray[complex128], vectors_elements: ndarray[int32], sort: bool = False) -> None
fill(values_data: ndarray[float64], values_elements: ndarray[int32], values_weights: ndarray[float64], vectors_data: ndarray[complex128], vectors_elements: ndarray[int32], vectors_weights: ndarray[float64], sort: bool = False) -> None
fill(values_data: ndarray[float64], values_elements: ndarray[int32], vectors_data: ndarray[complex128], vectors_elements: ndarray[int32], sort: bool = False) -> None

Provide data required for interpolation to the grid without cost information.

.. Note .. ---- .. This method should probably be followed by set_cost_info prior to .. any attempt to interpolate the data in the grid.

Parameters:

  • values_data ([`numpy.ndarray`][numpy.ndarray]) –

    The eigenvalue data to be stored in the grid. The first dimension must be equal in size to the number of grid-vertices. If two dimensional the second dimension is interpreted as all information for a single mode flattened and concatenated into (scalars, vectors, matrices) -- in that order. If more than two dimensional, the second dimension indexes modes and higher dimensions will be flattened as if row ordered and must flatten into a concatenated list of (scalars, vectors, matrices). If the provided array can be interpreted as a contiguous row-ordered two dimensional array it will be used in place, otherwise a copy will be made.

  • values_elements (ndarray[int32]) –

    A multi-purpose vector containing, in order:

    • the number of scalar-like eigenvalue elements,
    • the number of vector-like eigenvalue elements (must be \(3\times N\)),
    • the number of matrix-like eigenvalue elements (must be \(9\times N\)),
    • an integer RotatesLike value denoting how the vector-like and matrix-like parts transform under application of a symmetry operation (see note below).
    • an integer LengthUnit value denoting what units the vector-like and matrix-like parts are in (see note below).
  • vectors_data ([`numpy.ndarray`][numpy.ndarray]) –

    The eigenvector data to be stored in the grid. Same shape restrictions as values_data

  • vectors_elements (ndarray[int32]) –

    Like values_elements but for the eigenvectors

  • sort (logical (default ``False``), default: False ) –

    Whether the equivalent-mode permutations should be (re)determined following the update to the flags and weights.

Note

Mapping of integers to RotatesLike values:

value RotatesLike
0 vector
1 pseudovector
2 Gamma

Integer values outside of the mapped range (or missing) are replaced by 0.

Mapping of integers to LengthUnit values:

value LengthUnit
0 none
1 angstrom
2 inverse_angstrom
3 real_lattice
4 reciprocal_lattice

Integer values outside of the mapped range (or missing) are replaced by 3.

Phonon eigenvectors (RotatesLike Gamma) must use the "cell" phase convention, in which they are periodic in reciprocal space. Eigenvectors in the "atom" convention, which phonopy uses, give wrong results without an error; see phase_convention for how to convert them.

interpolate_at

interpolate_at(Q: ndarray[float64], useparallel: bool = False, threads: int = -1, do_not_move_points: bool = False) -> tuple[numpy.ndarray[numpy.float64], numpy.ndarray[numpy.complex128]]

Perform linear interpolation of the stored data at equivalent points

The first Brillouin zone is the part of reciprocal space which is invariant under application of the integer translations of a reciprocal space lattice. This method finds points equivalent to the input within the first Brillouin zone and then interpolates pre-stored information to provide an estimate at the found positions.

Parameters:

  • Q ([`numpy.ndarray`][numpy.ndarray]) –

    A two dimensional array with Q.shape[1] == 3 containing the positions at which an interpolated result is required, expressed in units of the reciprocal lattice.

  • useparallel (bool, default: False ) –

    Whether a serial or parallel code should be utilised

  • threads (int, default: -1 ) –

    How many parallel threads should be utilised; if this value is less than one, the BRILLE_NUM_THREADS environment variable sets the number, or one thread per logical core is used if it is not set.

  • do_not_move_points (bool, default: False ) –

    If True the provided Q points must already lie within the first Brillouin zone. No check is made to verify this requirement and if any Q lie outside of the gridded volume out-of-bounds errors may result in bad data or runtime errors.

Returns:

  • tuple –

    The interpolated eigenvalues and eigenvectors at the equivalent first Brillouin zone points. The shape of each output will depend on the shape of the data provided to the fill method. If the filled eigenvalues were of shape [N_grid_points, N_modes, A, ..., B], the eigenvectors were of shape [N_grid_points, N_modes, C, ..., D], and the provided points of shape [N_Q_points, 3] then the output shapes will be [N_Q_points, N_modes, A, ..., B] and [N_Q_points, N_modes, C, ..., D] for the eigenvalues and eigenvectors, respectively.

ir_interpolate_at

ir_interpolate_at(Q: ndarray[float64], useparallel: bool = False, threads: int = -1, do_not_move_points: bool = False) -> tuple[numpy.ndarray[numpy.float64], numpy.ndarray[numpy.complex128]]

Perform linear interpolation of the stored data at irreducible equivalent points

The irreducible first Brillouin zone is the part of reciprocal space which is invariant under application of the integer translations and the pointgroup operations of a reciprocal space lattice. This method finds points equivalent to the input within the irreducible first Brillouin zone and then interpolates pre-stored information to provide an estimate at the found positions.

Parameters:

  • Q ([`numpy.ndarray`][numpy.ndarray]) –

    A two dimensional array with Q.shape[1] == 3 containing the positions at which an interpolated result is required, expressed in units of the reciprocal lattice.

  • useparallel (bool, default: False ) –

    Whether a serial or parallel code should be utilised

  • threads (int, default: -1 ) –

    How many parallel threads should be utilised; if this value is less than one, the BRILLE_NUM_THREADS environment variable sets the number, or one thread per logical core is used if it is not set.

  • do_not_move_points (bool, default: False ) –

    If True the provided Q points must already lie within the first Brillouin zone. No check is made to verify this requirement and if any Q lie outside of the gridded volume out-of-bounds errors may result in bad data or runtime errors.

Returns:

  • tuple –

    The interpolated eigenvalues and eigenvectors at the equivalent irreducible first Brillouin zone points. The shape of each output will depend on the shape of the data provided to the fill method. i If the filled eigenvalues were of shape [N_grid_points, N_modes, A, ..., B], the eigenvectors were of shape [N_grid_points, N_modes, C, ..., D], and the provided points of shape [N_Q_points, 3] then the output shapes will be [N_Q_points, N_modes, A, ..., B] and [N_Q_points, N_modes, C, ..., D] for the eigenvalues and eigenvectors, respectively.

node_at

node_at(subscript: Annotated[list[int], FixedSize(3)]) -> Polyhedron

node_at_type

node_at_type(subscript: Annotated[list[int], FixedSize(3)]) -> NodeType

node_containing

node_containing(Q: ndarray[float64]) -> Polyhedron

node_containing_type

node_containing_type(Q: ndarray[float64]) -> NodeType

set_flags_weights

set_flags_weights(values_flags: ndarray[int32], values_weights: ndarray[float64], vectors_flags: ndarray[int32], vectors_weights: ndarray[float64], sort: bool = False) -> None

Set RotatesLike, LengthUnit and cost functions plus relative cost weights for the values and vectors stored in the object

Parameters:

  • values_flags ((integer, vector - like)) –

    One or more values indicating the RotatesLike value for the eigenvalues stored in the object, the ~brille._brille.LengthUnit value, plus which cost function to use when comparing stored eigenvalues at neighbouring grid points for scalar- and vector-like eigenvalues.

  • values_weights ((float, vector - like)) –

    The relative cost weights between scalar-, vector-, and matrix- like eigenvalue elements stored in the grid

  • vectors_flags ((integer, vector - like)) –

    One or more values indicating the RotatesLike value for the eigenvalues stored in the object, the ~brille._brille.LengthUnit value, plus which cost function to use when comparing stored eigenvectors at neighbouring grid points for scalar- and vector-like eigenvectors.

  • vectors_weights ((float, vector - like)) –

    The relative cost weights between scalar-, vector-, and matrix- like eigenvector elements stored in the grid

  • sort (bool, default: False ) –

    Whether the equivalent-mode permutations should be (re)determined following the update to the flags and weights.

Note

Mapping of integers to RotatesLike values:

value RotatesLike
0 vector
1 pseudovector
2 Gamma

Mapping of integers to LengthUnit values:

value LengthUnit
0 none
1 angstrom
2 inverse_angstrom
3 real_lattice
4 reciprocal_lattice

Mapping of integers to scalar cost function:

value function(x,y)
0 magnitude(x-y)

Mapping of integers to vector cost function:

value function(vec_x, vec_y)
0 sin(hermitian_angle(vec_x, vec_y))
1 vector_distance(vec_x, vec_y)
2 1 - vector_product(vec_x, vec_y)
3 vector_angle(vec_x, vec_y)
4 hermitian_angle(vec_x, vec_y)

Integer values outside of the mapped range (or missing) are replaced by 0.

set_vector_normalization

set_vector_normalization(normalize: bool | None = True, metric: list[float] | None = None) -> None

Choose when interpolated eigenvectors are scaled to unit norm

Linear interpolation between unit eigenvectors gives vectors shorter than one wherever neighbouring eigenvectors differ, so structure factors computed from them come out too small. Normalization scales each interpolated branch \(v\) to \(v/\sqrt{|\langle v|M|v\rangle|}\).

By default it is automatic: eigenvectors stored in Cartesian units (LengthUnit angstrom or inverse_angstrom, as Euphonic stores them) are normalized, and those in lattice units, whose length depends on the lattice, are not. The choice survives fill and saving to HDF5.

Parameters:

  • normalize (bool or None, default: True ) –

    True always normalizes, and raises a RuntimeError for eigenvectors in lattice units; False never does; None restores the automatic default.

  • metric ((float, vector - like), default: None ) –

    A diagonal metric \(M\), one weight per element of a branch (for phonons, \(3N\)). The default is the identity, the ordinary norm. For Bogoliubov (spin-wave) vectors use \(\eta=\mathrm{diag}(1,\ldots,1,-1,\ldots,-1)\); the sign of \(\langle v|\eta|v\rangle\) is kept.

sort

sort() -> None

to_file

to_file(filename: str, entry: str = 'BZTrellisQdc', flags: str = 'ac') -> bool

Save the object to an HDF5 file

Parameters:

  • filename (str) –

    The full path specification for the file to write into

  • entry (str, default: 'BZTrellisQdc' ) –

    The group path, e.g., "my/cool/grid", where to write inside the file, with a default equal to the object Class name

  • flags (str, default: 'ac' ) –

    The HDF5 permissions to use when opening the file. Default 'a' writes to an existing file -- if entry exists in the file it is overwritten.

Note

Possible flags are:

flags meaning HDF equivalent
'r' read H5F_ACC_RDONLY
'x' write, error if exists H5F_ACC_EXCL
'a' write, append to file H5F_ACC_RDWR
'c' write, error if exists H5F_ACC_CREAT
't' write, replace existing H5F_ACC_TRUNC

Returns:

  • bool –

    Indication of writing success.

BZTrellisQdd

BZTrellisQdd(brillouin_zone: BrillouinZone, node_volume_fraction: float = 0.1, always_triangulate: bool = False)
BZTrellisQdd(brillouin_zone: BrillouinZone, node_volume_fraction: float, always_triangulate: bool, approx_config: ApproxConfig)
BZTrellisQdd(brillouin_zone: BrillouinZone, node_volume_fraction: float = 0.1, always_triangulate: bool = False)

A trellis of cubic nodes over a Brillouin zone's irreducible part

Parameters:

  • brillouin_zone (BrillouinZone) –

    The zone whose irreducible part the trellis fills.

  • node_volume_fraction (float, optional (default: 0.1), default: 0.1 ) –

    Despite its name, a volume in cubic reciprocal Angstrom, not a fraction: the volume of one cubic node, which sets the trellis spacing. To size the trellis by its number of points use brillouin_zone.ir_polyhedron.volume / points, which gives roughly 1.3 to 2 times points vertices.

  • always_triangulate (bool, optional (default: False), default: False ) –

    Divide every node into tetrahedra, not only those the zone boundary cuts.

BZTrellisQcc

BZTrellisQcc(brillouin_zone: BrillouinZone, node_volume_fraction: float = 0.1, always_triangulate: bool = False)
BZTrellisQcc(brillouin_zone: BrillouinZone, node_volume_fraction: float, always_triangulate: bool, approx_config: ApproxConfig)
BZTrellisQcc(brillouin_zone: BrillouinZone, node_volume_fraction: float = 0.1, always_triangulate: bool = False)

A trellis of cubic nodes over a Brillouin zone's irreducible part

Parameters:

  • brillouin_zone (BrillouinZone) –

    The zone whose irreducible part the trellis fills.

  • node_volume_fraction (float, optional (default: 0.1), default: 0.1 ) –

    Despite its name, a volume in cubic reciprocal Angstrom, not a fraction: the volume of one cubic node, which sets the trellis spacing. To size the trellis by its number of points use brillouin_zone.ir_polyhedron.volume / points, which gives roughly 1.3 to 2 times points vertices.

  • always_triangulate (bool, optional (default: False), default: False ) –

    Divide every node into tetrahedra, not only those the zone boundary cuts.

Nested mesh

BZNestQdc

BZNestQdc(brillouin_zone: BrillouinZone, max_volume: float, max_branchings: int = 5)
BZNestQdc(brillouin_zone: BrillouinZone, number_density: int, max_branchings: int = 5)
BZNestQdc(brillouin_zone: BrillouinZone, max_volume: float, max_branchings: int = 5)

Methods:

Attributes:

BrillouinZone property

BrillouinZone: BrillouinZone

all_invA property

all_invA: ndarray[float64]

all_rlu property

all_rlu: ndarray[float64]

bytes_per_point property

bytes_per_point: int

Return the memory required per interpolation point result in bytes

invA property

invA: ndarray[float64]

normalizes_vectors property

normalizes_vectors: bool

Whether interpolated eigenvectors are normalized, given the stored data; see set_vector_normalization

rlu property

rlu: ndarray[float64]

tetrahedra property

tetrahedra: list[Annotated[list[int], FixedSize(4)]]

values property

values: ndarray[float64]

Return a shared view of the stored eigenvalues

vector_metric property

vector_metric: list[float]

The diagonal metric used to normalize eigenvectors; empty for the identity

vector_normalization property

vector_normalization: str

When eigenvectors are normalized: "automatic" (the default), "on" or "off"

vectors property

vectors: ndarray[complex128]

Return a shared view of the stored eigenvectors

from_file staticmethod

from_file(filename: str, entry: str = 'BZNestQdc') -> BZNestQdc

Load an object from an HDF5 file

Parameters:

  • filename (str) –

    The full path specification for the file to read from

  • entry (str, default: 'BZNestQdc' ) –

    The group path, e.g., "my/cool/grid", where to read from inside the file, with a default equal to the object Class name

Returns:

  • clsObj –

fill

fill(values_data: ndarray[float64], values_elements: ndarray[int32], vectors_data: ndarray[complex128], vectors_elements: ndarray[int32], sort: bool = False) -> None
fill(values_data: ndarray[float64], values_elements: ndarray[int32], values_weights: ndarray[float64], vectors_data: ndarray[complex128], vectors_elements: ndarray[int32], vectors_weights: ndarray[float64], sort: bool = False) -> None
fill(values_data: ndarray[float64], values_elements: ndarray[int32], vectors_data: ndarray[complex128], vectors_elements: ndarray[int32], sort: bool = False) -> None

Provide data required for interpolation to the grid without cost information.

.. Note .. ---- .. This method should probably be followed by set_cost_info prior to .. any attempt to interpolate the data in the grid.

Parameters:

  • values_data ([`numpy.ndarray`][numpy.ndarray]) –

    The eigenvalue data to be stored in the grid. The first dimension must be equal in size to the number of grid-vertices. If two dimensional the second dimension is interpreted as all information for a single mode flattened and concatenated into (scalars, vectors, matrices) -- in that order. If more than two dimensional, the second dimension indexes modes and higher dimensions will be flattened as if row ordered and must flatten into a concatenated list of (scalars, vectors, matrices). If the provided array can be interpreted as a contiguous row-ordered two dimensional array it will be used in place, otherwise a copy will be made.

  • values_elements (ndarray[int32]) –

    A multi-purpose vector containing, in order:

    • the number of scalar-like eigenvalue elements,
    • the number of vector-like eigenvalue elements (must be \(3\times N\)),
    • the number of matrix-like eigenvalue elements (must be \(9\times N\)),
    • an integer RotatesLike value denoting how the vector-like and matrix-like parts transform under application of a symmetry operation (see note below).
    • an integer LengthUnit value denoting what units the vector-like and matrix-like parts are in (see note below).
  • vectors_data ([`numpy.ndarray`][numpy.ndarray]) –

    The eigenvector data to be stored in the grid. Same shape restrictions as values_data

  • vectors_elements (ndarray[int32]) –

    Like values_elements but for the eigenvectors

  • sort (logical (default ``False``), default: False ) –

    Whether the equivalent-mode permutations should be (re)determined following the update to the flags and weights.

Note

Mapping of integers to RotatesLike values:

value RotatesLike
0 vector
1 pseudovector
2 Gamma

Integer values outside of the mapped range (or missing) are replaced by 0.

Mapping of integers to LengthUnit values:

value LengthUnit
0 none
1 angstrom
2 inverse_angstrom
3 real_lattice
4 reciprocal_lattice

Integer values outside of the mapped range (or missing) are replaced by 3.

Phonon eigenvectors (RotatesLike Gamma) must use the "cell" phase convention, in which they are periodic in reciprocal space. Eigenvectors in the "atom" convention, which phonopy uses, give wrong results without an error; see phase_convention for how to convert them.

ir_interpolate_at

ir_interpolate_at(Q: ndarray[float64], useparallel: bool = False, threads: int = -1, do_not_move_points: bool = False) -> tuple[numpy.ndarray[numpy.float64], numpy.ndarray[numpy.complex128]]

Perform linear interpolation of the stored data at irreducible equivalent points

The irreducible first Brillouin zone is the part of reciprocal space which is invariant under application of the integer translations and the pointgroup operations of a reciprocal space lattice. This method finds points equivalent to the input within the irreducible first Brillouin zone and then interpolates pre-stored information to provide an estimate at the found positions.

Parameters:

  • Q ([`numpy.ndarray`][numpy.ndarray]) –

    A two dimensional array with Q.shape[1] == 3 containing the positions at which an interpolated result is required, expressed in units of the reciprocal lattice.

  • useparallel (bool, default: False ) –

    Whether a serial or parallel code should be utilised

  • threads (int, default: -1 ) –

    How many parallel threads should be utilised; if this value is less than one, the BRILLE_NUM_THREADS environment variable sets the number, or one thread per logical core is used if it is not set.

  • do_not_move_points (bool, default: False ) –

    If True the provided Q points must already lie within the first Brillouin zone. No check is made to verify this requirement and if any Q lie outside of the gridded volume out-of-bounds errors may result in bad data or runtime errors.

Returns:

  • tuple –

    The interpolated eigenvalues and eigenvectors at the equivalent irreducible first Brillouin zone points. The shape of each output will depend on the shape of the data provided to the fill method. i If the filled eigenvalues were of shape [N_grid_points, N_modes, A, ..., B], the eigenvectors were of shape [N_grid_points, N_modes, C, ..., D], and the provided points of shape [N_Q_points, 3] then the output shapes will be [N_Q_points, N_modes, A, ..., B] and [N_Q_points, N_modes, C, ..., D] for the eigenvalues and eigenvectors, respectively.

set_flags_weights

set_flags_weights(values_flags: ndarray[int32], values_weights: ndarray[float64], vectors_flags: ndarray[int32], vectors_weights: ndarray[float64], sort: bool = False) -> None

Set RotatesLike, LengthUnit and cost functions plus relative cost weights for the values and vectors stored in the object

Parameters:

  • values_flags ((integer, vector - like)) –

    One or more values indicating the RotatesLike value for the eigenvalues stored in the object, the ~brille._brille.LengthUnit value, plus which cost function to use when comparing stored eigenvalues at neighbouring grid points for scalar- and vector-like eigenvalues.

  • values_weights ((float, vector - like)) –

    The relative cost weights between scalar-, vector-, and matrix- like eigenvalue elements stored in the grid

  • vectors_flags ((integer, vector - like)) –

    One or more values indicating the RotatesLike value for the eigenvalues stored in the object, the ~brille._brille.LengthUnit value, plus which cost function to use when comparing stored eigenvectors at neighbouring grid points for scalar- and vector-like eigenvectors.

  • vectors_weights ((float, vector - like)) –

    The relative cost weights between scalar-, vector-, and matrix- like eigenvector elements stored in the grid

  • sort (bool, default: False ) –

    Whether the equivalent-mode permutations should be (re)determined following the update to the flags and weights.

Note

Mapping of integers to RotatesLike values:

value RotatesLike
0 vector
1 pseudovector
2 Gamma

Mapping of integers to LengthUnit values:

value LengthUnit
0 none
1 angstrom
2 inverse_angstrom
3 real_lattice
4 reciprocal_lattice

Mapping of integers to scalar cost function:

value function(x,y)
0 magnitude(x-y)

Mapping of integers to vector cost function:

value function(vec_x, vec_y)
0 sin(hermitian_angle(vec_x, vec_y))
1 vector_distance(vec_x, vec_y)
2 1 - vector_product(vec_x, vec_y)
3 vector_angle(vec_x, vec_y)
4 hermitian_angle(vec_x, vec_y)

Integer values outside of the mapped range (or missing) are replaced by 0.

set_vector_normalization

set_vector_normalization(normalize: bool | None = True, metric: list[float] | None = None) -> None

Choose when interpolated eigenvectors are scaled to unit norm

Linear interpolation between unit eigenvectors gives vectors shorter than one wherever neighbouring eigenvectors differ, so structure factors computed from them come out too small. Normalization scales each interpolated branch \(v\) to \(v/\sqrt{|\langle v|M|v\rangle|}\).

By default it is automatic: eigenvectors stored in Cartesian units (LengthUnit angstrom or inverse_angstrom, as Euphonic stores them) are normalized, and those in lattice units, whose length depends on the lattice, are not. The choice survives fill and saving to HDF5.

Parameters:

  • normalize (bool or None, default: True ) –

    True always normalizes, and raises a RuntimeError for eigenvectors in lattice units; False never does; None restores the automatic default.

  • metric ((float, vector - like), default: None ) –

    A diagonal metric \(M\), one weight per element of a branch (for phonons, \(3N\)). The default is the identity, the ordinary norm. For Bogoliubov (spin-wave) vectors use \(\eta=\mathrm{diag}(1,\ldots,1,-1,\ldots,-1)\); the sign of \(\langle v|\eta|v\rangle\) is kept.

sort

sort() -> None

to_file

to_file(filename: str, entry: str = 'BZNestQdc', flags: str = 'ac') -> bool

Save the object to an HDF5 file

Parameters:

  • filename (str) –

    The full path specification for the file to write into

  • entry (str, default: 'BZNestQdc' ) –

    The group path, e.g., "my/cool/grid", where to write inside the file, with a default equal to the object Class name

  • flags (str, default: 'ac' ) –

    The HDF5 permissions to use when opening the file. Default 'a' writes to an existing file -- if entry exists in the file it is overwritten.

Note

Possible flags are:

flags meaning HDF equivalent
'r' read H5F_ACC_RDONLY
'x' write, error if exists H5F_ACC_EXCL
'a' write, append to file H5F_ACC_RDWR
'c' write, error if exists H5F_ACC_CREAT
't' write, replace existing H5F_ACC_TRUNC

Returns:

  • bool –

    Indication of writing success.

BZNestQdd

BZNestQdd(brillouin_zone: BrillouinZone, max_volume: float, max_branchings: int = 5)
BZNestQdd(brillouin_zone: BrillouinZone, number_density: int, max_branchings: int = 5)
BZNestQdd(brillouin_zone: BrillouinZone, max_volume: float, max_branchings: int = 5)

BZNestQcc

BZNestQcc(brillouin_zone: BrillouinZone, max_volume: float, max_branchings: int = 5)
BZNestQcc(brillouin_zone: BrillouinZone, number_density: int, max_branchings: int = 5)
BZNestQcc(brillouin_zone: BrillouinZone, max_volume: float, max_branchings: int = 5)

Helpers

RotatesLike

RotatesLike(value: int)
Enumeration indicating how vector and matrix values transform

Members:

vector : Rotates like a vector

pseudovector : Rotates like a pseudovector

Gamma : Rotates like a (real space) phonon eigenvector

Attributes:

Gamma class-attribute

Gamma: RotatesLike

pseudovector class-attribute

pseudovector: RotatesLike

vector class-attribute

vector: RotatesLike

name property

name: str

value property

value: int

SortingStatus

SortingStatus(sorted: bool, locked: bool, visits: int)

An object representing the status of a single object under sorting.

Internally may be represented as a single unsigned integer where two or more bits are reserved for various flags, or as a set of boolean values and an integer.

Attributes:

locked property

locked: bool

Return the locked flag

sorted property

sorted: bool

Return the sorted flag

visits property

visits: int

Return the visit count