magnon.common

Attributes

default_distance_tol

Default precision used in determining equivalent distances, value = 1e-5

Functions

normalize_scaled_coordinate(r[, distance_tolerance])

Normalizes a scaled coordinate vector or an array of scaled coordinates

modulo_lattice(x[, distance_tol])

Reduces a lattice vector x modulo 1, ensuring that values numerically close to 1 or 0 are wrapped to 0.

squared_distance(a, b)

Computes squared Euclidean distance between two points.

find_site_index(position, scaled_atom_positions[, ...])

Given a position in scaled coordinates, find the equivalent site index in the unit cell.

lattice_translation_vector(r_ij_scaled, r_i_scaled, ...)

Returns the integer lattice translation vector T of an arbitrary vector r_scaled.

reciprocal_lattice(lattice)

Compute reciprocal lattice basis vectors from lattice vectors.

Module Contents

magnon.common.default_distance_tol = 1e-05

Default precision used in determining equivalent distances, value = 1e-5

magnon.common.normalize_scaled_coordinate(r, distance_tolerance=default_distance_tol)

Normalizes a scaled coordinate vector or an array of scaled coordinates to the range [0, 1) for each component.

Parameters:
  • r (array_like) – A scaled coordinate vector or an array of scaled coordinates

  • distance_tolerance (float) – Precision used for rounding near cell boundaries.

Returns:

A normalized scaled coordinate vector or an array of normalized scaled coordinates

Return type:

numpy.ndarray, dtype = np.float64

magnon.common.modulo_lattice(x, distance_tol=default_distance_tol)

Reduces a lattice vector x modulo 1, ensuring that values numerically close to 1 or 0 are wrapped to 0.

Parameters:
  • x (array_like) – A lattice vector

  • distance_tol (float) – Precision used for rounding near cell boundaries.

Returns:

A reduced lattice vector x modulo 1

Return type:

numpy.ndarray

magnon.common.squared_distance(a, b)

Computes squared Euclidean distance between two points.

Parameters:
  • a (array_like) – Coordinates of the first point

  • b (array_like) – Coordinates of the second point

Returns:

Squared Euclidean norm of distance vector \(a-b\).

Return type:

float

magnon.common.find_site_index(position, scaled_atom_positions, distance_tol=default_distance_tol)

Given a position in scaled coordinates, find the equivalent site index in the unit cell.

Parameters:
  • position (array_like) – A scaled coordinate vector to search for

  • scaled_atom_positions (array_like) – An array of scaled coordinates in which to search

  • distance_tol (float) – Precision used for determining equivalent positions

Raises:

ValueError – If a matching site could not be found

Returns:

The index of site which matches the coordinates

Return type:

int

magnon.common.lattice_translation_vector(r_ij_scaled, r_i_scaled, r_j_scaled, distance_tol=default_distance_tol)

Returns the integer lattice translation vector T of an arbitrary vector r_scaled.

Parameters:
  • r_ij_scaled (array_like) – A scaled distance vector from position i to position j.

  • r_i_scaled (array_like) – The scaled coordinates of point i

  • r_j_scaled (array_like) – The scaled coordinates of point j

  • distance_tol (float) – Precision used for checking if a value is an integer

Raises:

ValueError – If the three vectors are inconsistent and do not result in an integer scaled lattice translation vector

Returns:

The integer lattice translation vector

Return type:

numpy.ndarray, dtype = int

magnon.common.reciprocal_lattice(lattice)

Compute reciprocal lattice basis vectors from lattice vectors.

Parameters:

lattice (array_like) – A 3x3 array of lattice basis vectors; each row is a vector

Returns:

A 3x3 array of reciprocal lattice basis vectors; each row is a vector

Return type:

numpy.ndarray