ramannoodle.structure

Classes and functions for atomic structures and structural symmetries.

class ramannoodle.structure.ReferenceStructure(atomic_numbers, lattice, positions, symprec=1e-05, angle_tolerance=-1.0)

Bases: object

Reference crystal structure, typically used by polarizability models.

Parameters:
  • atomic_numbers (list[int]) – List of length N where N is the number of atoms.

  • lattice (ndarray[Any, dtype[float64]]) – (Å) Array with shape (3,3).

  • positions (ndarray[Any, dtype[float64]]) – (fractional) Array with shape (N,3).

  • symprec (float) – (Å) Distance tolerance for symmetry search (spglib).

  • angle_tolerance (float) – (°) Angle tolerance for symmetry search (spglib).

Raises:

SymmetryException – Structural symmetry determination failed.

get_atom_indexes(atom_symbols)

Return atom indexes with matching symbols.

Parameters:

atom_symbols (str | list[str]) – If integer or list of integers, specifies atom indexes. If string or list of strings, specifies atom symbols. Mixtures of indexes and symbols are allowed.

Return type:

list[int]

get_cart_direction(direction)

Convert a (fractional) direction into cartesian coordinates.

Parameters:

direction (ndarray[Any, dtype[float64]]) – (fractional) Array with shape (3,).

Return type:

ndarray[Any, dtype[float64]]

Returns:

(Å) Array with shape (3,).

get_cart_displacement(displacement)

Convert a (fractional) displacement into Cartesian coordinates.

Parameters:

displacement (ndarray[Any, dtype[float64]]) – (fractional) Array with shape (…,N,3) where N is the number of atoms.

Return type:

ndarray[Any, dtype[float64]]

Returns:

(Å) Array with shape (…,N,3).

get_equivalent_atom_dict()

Get dictionary of equivalent atoms indexes.

Return type:

dict[int, list[int]]

Returns:

atom index –> list of equivalent atom indexes

get_equivalent_displacements(displacement)

Calculate symmetrically equivalent displacements.

Parameters:

displacement (ndarray[Any, dtype[float64]]) – (fractional) Array with shape (N,3) where N is the number of atoms.

Return type:

list[dict[str, list[ndarray[Any, dtype[float64]]]]]

Returns:

List of dictionaries containing displacements and transformations, accessed using the ‘displacements’ and ‘transformations’ keys. Displacements within each dictionary will be collinear, corresponding to the same degree of freedom. The provided transformations are those that transform displacement into that degree of freedom. Displacements are in fractional coordinates.

get_frac_direction(cart_direction)

Convert a Cartesian direction into fractional coordinates.

Parameters:

cart_direction (ndarray[Any, dtype[float64]]) – (Å) Array with shape (3,).

Return type:

ndarray[Any, dtype[float64]]

Returns:

(fractional) Array with shape (3,).

get_frac_displacement(cart_displacement)

Convert a Cartesian displacement into fractional coordinates.

Parameters:

cart_displacement (ndarray[Any, dtype[float64]]) – (Å) Array with shape (N,3) where N is the number of atoms.

Return type:

ndarray[Any, dtype[float64]]

Returns:

(fractional) Array with shape (N,3).

property atomic_numbers: list[int]

Get (a copy of) atomic numbers.

property lattice: ndarray[Any, dtype[float64]]

Get (a copy of) lattice.

Returns:

Å | Array with shape (3,3).

property num_atoms: int

Get number of atoms.

property num_nonequivalent_atoms: int

Get number of nonequivalent atoms.

property positions: ndarray[Any, dtype[float64]]

Get (a copy of) fractional positions.

Returns:

(fractional) Array with shape (N,3) where N is the number of atoms.

ramannoodle.structure.get_ast_displaced_positions(ref_structure, atom_index, cart_direction, amplitudes)

Return displaced positions with a single atom displaced along a direction.

Parameters:
  • ref_structure (ReferenceStructure) – Reference structure containing N atoms.

  • atom_index (int)

  • cart_direction (ndarray[Any, dtype[float64]]) – (Å) Array with shape (3,). The magnitude of the direction vector is ignored, only the direction is used.

  • amplitudes (ndarray[Any, dtype[float64]]) – (Å) Array with shape (M,).

Return type:

list[ndarray[Any, dtype[float64]]]

Returns:

(fractional) List of length M containing arrays with shape (N,3).

ramannoodle.structure.get_displaced_positions(ref_structure, cart_displacement, amplitudes)

Return positions displaced along a certain displacement.

Parameters:
  • ref_structure (ReferenceStructure) – Reference structure containing N atoms.

  • cart_displacement (ndarray[Any, dtype[float64]]) – (Å) Array with shape (N,3). The magnitude of the displacement is ignored, only the direction is used.

  • amplitudes (ndarray[Any, dtype[float64]]) – (Å) Array with shape (M,).

Return type:

list[ndarray[Any, dtype[float64]]]

Returns:

(fractional) List of length M containing arrays with shape (N,3).

ramannoodle.structure.write_ast_displaced_structures(ref_structure, atom_index, cart_direction, amplitudes, filepaths, file_format, overwrite=False)

Write displaced structures with a single atom displaced along a direction.

Parameters:
Return type:

None

ramannoodle.structure.write_displaced_structures(ref_structure, cart_displacement, amplitudes, filepaths, file_format, overwrite=False)

Write displaced structures to files.

Parameters:
Return type:

None

Submodules

ramannoodle.structure.utils module

Utility functions for structures.

ramannoodle.structure.utils.apply_pbc(positions)

Return fractional positions such that all coordinates are between 0 and 1.

Parameters:

positions (ndarray[Any, dtype[float64]]) – (fractional) Array with shape (N,3) where N is the number of atoms.

Return type:

ndarray[Any, dtype[float64]]

Returns:

(fractional) Array with shape (N,3).

ramannoodle.structure.utils.apply_pbc_displacement(displacement)

Return fractional displacement such as all coordinates are between -0.5 and 0.5.

Parameters:

displacement (ndarray[Any, dtype[float64]]) – (fractional) Array with shape (N,3) where N is the number of atoms.

Return type:

ndarray[Any, dtype[float64]]

Returns:

(fractional) Array with shape (N,3).

ramannoodle.structure.utils.calc_displacement(positions_1, positions_2)

Calculate minimum displacement between two fractional positions.

Displacement is from positions_1 to positions_2. Respects periodic boundary conditions.

Parameters:
  • positions_1 (ndarray[Any, dtype[float64]]) – (fractional) Array with shape (N,3) where N is the number of atoms.

  • positions_2 (ndarray[Any, dtype[float64]]) – (fractional) Array with shape (N,3).

Return type:

ndarray[Any, dtype[float64]]

Returns:

(fractional) Array with shape (N,3).

ramannoodle.structure.utils.displace_positions(positions, displacement)

Displace positions, respecting periodic boundary conditions.

Parameters:
  • positions (ndarray[Any, dtype[float64]]) – (fractional) Array with shape (N,3) where N is the number of atoms.

  • displacement (ndarray[Any, dtype[float64]]) – (fractional) Array with shape (N,3).

Return type:

ndarray[Any, dtype[float64]]

Returns:

(fractional) Array with shape (N,3).

ramannoodle.structure.utils.transform_positions(positions, rotation, translation)

Transform positions.

Respects periodic boundary conditions.

Parameters:
  • positions (ndarray[Any, dtype[float64]]) – (fractional) Array with shape (N,3) where N is the number of atoms

  • rotation (ndarray[Any, dtype[float64]]) – Array with shape (3,3).

  • translation (ndarray[Any, dtype[float64]]) – (fractional) Array with shape (3,).

Return type:

ndarray[Any, dtype[float64]]

Returns:

(fractional) Array with shape (N,3).