tightbinder.crystal.Crystal#

class Crystal(bravais_lattice=None, motif=None)[source]#

Bases: object

Implementation of Crystal class. Defaults to square lattice if no input is given.

Parameters:
  • bravais_lattice (Union[list, ndarray]) – List with the bravais vectors

  • motif (Union[list, ndarray]) – List with positions and chemical species of atoms of the motif

Methods

add_atom

Method to add one atom from a numbered species into a specific position.

add_atoms

Method to add a list of atoms of specified species at some positions.

brillouin_zone_mesh

Routine to compute a mesh of the first Brillouin zone using the Monkhorst-Pack algorithm.

compute_unit_cell_area

Method to compute the area of the unit cell.

crystal_center

Method to compute the geometric center of the crystal from the positions of the atoms of the motif.

crystallographic_group

Determines the crystallographic group associated to the material from the configuration file.

determine_high_symmetry_points

Routine to compute high symmetry points depending on the dimension of the system.

high_symmetry_path

Routine to generate a path in reciprocal space along the high symmetry points (HSPs) indicated.

identify_convex_hull

Deprecated in favour of identify_motif_edges.

identify_motif_edges

Method to obtain the indices of the outermost atoms of the motif.

plot_2d_crystal

Method to visualize the crystalline structure (Bravais lattice + motif) in two dimensions.

plot_crystal

Method to visualize the crystalline structure (Bravais lattice + motif).

reciprocal_lattice

Routine to compute the reciprocal lattice basis vectors from the Bravais lattice basis.

remove_atom

Method to remove the atom at the specified index from the motif.

remove_atoms

Method to remove the atoms specified in a list with all their indices.

update

Routine to initialize or update the intrinsic attributes of the Crystal class whenever the Bravais lattice is changed.

visualize

Method to render a 3d visualization of the crystal using the self.vpython library.

Attributes

bravais_lattice

motif

ndim

add_atom(position, species=0)[source]#

Method to add one atom from a numbered species into a specific position.

Parameters:
  • position (Union[list, ndarray]) – Array with atom coordinaes. Must be three-dimensional.

  • species (int) – Index of corresponding chemical species. Defaults to 0.

Return type:

None

add_atoms(atoms, species=None)[source]#

Method to add a list of atoms of specified species at some positions. Built on top of method add_atom.

Parameters:
  • atoms (Union[list, ndarray]) – List of length n, containing the positions of each atom.

  • species (list) – List with the indices of the chemical species. If None, all default to zero.

Return type:

None

brillouin_zone_mesh(mesh)[source]#

Routine to compute a mesh of the first Brillouin zone using the Monkhorst-Pack algorithm.

Parameters:

mesh (list) – List with the number of kpoints along each axis.

Return type:

ndarray

Returns:

Array with all kpoints, nk x 3

compute_unit_cell_area()[source]#

Method to compute the area of the unit cell. TODO: Adapt for 1D and 3D

Return type:

float

Returns:

Value of unit cell area.

crystal_center()[source]#

Method to compute the geometric center of the crystal from the positions of the atoms of the motif. Calculated as the average of all atomic positions.

Return type:

ndarray

Returns:

Numpy array with the cartesian coordinates of the center

crystallographic_group()[source]#

Determines the crystallographic group associated to the material from the configuration file. NOTE: Only the group associated to the Bravais lattice, reduced symmetry due to presence of motif is not taken into account. Its purpose is to provide a path in k-space to plot the band structure. Workflow is the following: First determine length and angles between basis vectors. Then we separate by dimensionality: first we check angles, and then length to determine the crystal group.

Return type:

None

determine_high_symmetry_points()[source]#

Routine to compute high symmetry points depending on the dimension of the system. These symmetry points will be used to plot the band structure along the main reciprocal paths of the system (irreducible BZ). Returns a dictionary with pairs {letter denoting high symmetry point: its coordinates}

Return type:

None

high_symmetry_path(nk, points)[source]#

Routine to generate a path in reciprocal space along the high symmetry points (HSPs) indicated. The HSPs must be within those corresponding to the associated symmetry group, otherwise the method will throw an error.

Parameters:
  • nk (int) – Number of kpoints in the path. They are evenly distributed between HSPs.

  • points (List[str]) – List of labels of desired HSPs.

Return type:

list

Returns:

List of kpoints following the path specified with the labels.

identify_convex_hull(loop=6)[source]#

Deprecated in favour of identify_motif_edges. Method to obtain the atoms that correspond to the edges of the system. This method uses directly the ConvexHull method from Scipy to identify the outmost points of the motif. Compute the ConvexHull three times, each time removing the points detected in the previous iteration.

NB: If given 3d points, they must not be coplanar for the algorithm to work. If they are, then the points must be given as 2d

Parameters:

loop (int) – Number of times the ConvexHull is applied, to increase number of points in the edge.

Return type:

ndarray

Returns:

Indices of atoms belonging to edges of motif.

identify_motif_edges(alpha=0.4, ndim=2)[source]#

Method to obtain the indices of the outermost atoms of the motif. Note that this method returns exclusively the outermost atoms, independently of the boundary conditions. To take into account boundary conditions, one should call identify_boundary() from System. NB: Currently works only in 2D

Parameters:
  • alpha (float) – This parameters tunes the shape of the boundary. For alpha=0, the boundary is a convex hull; as alpha increases the boundary becomes more concave. Default value is 0.4

  • ndim (int) – Dimension of the boundary. If the system lies on a plane, the boundary is two-dimensional, so ndim = 2 (default value).

Return type:

ndarray

Returns:

Indices of atoms in the boundary.

Raises:
  • AssertionError – Crystal dimension different from two raises error.

  • ValueError – Crystal motif must have at least three atoms. Raised by Delaunay class.

plot_2d_crystal(ax=None, fontsize=10, size=10)[source]#

Method to visualize the crystalline structure (Bravais lattice + motif) in two dimensions. If the crystal is 3D, it will plot only the x, y coordinates.

Parameters:
  • ax – Axis to plot the projection of the crystal. If None, creates one.

  • fontsize (int) – Size of labels. Defaults to 10.

  • size (int) – Size of markers. Defaults to 10.

Return type:

None

plot_crystal(cell_number=1, crystal_name='')[source]#

Method to visualize the crystalline structure (Bravais lattice + motif).

Parameters:
  • cell_number (int) – Number of cells appended in each direction with respect to the origin. Defaults to 1.

  • crystal_name (str) – Name of the crystal. Defaults to the empty string.

Return type:

None

reciprocal_lattice()[source]#

Routine to compute the reciprocal lattice basis vectors from the Bravais lattice basis. The algorithm is based on the fact that a_idot b_j=2PIdelta_ij, which can be written as a linear system of equations to solve for b_j. Resulting vectors have 3 components independently of the dimension of the vector space they span.

Return type:

None

remove_atom(index)[source]#

Method to remove the atom at the specified index from the motif. Note that this method does not remove existing bonds corresponding to the removed atom.

Parameters:

index (int) – Index of atom to be removed.

Return type:

None

remove_atoms(indices)[source]#

Method to remove the atoms specified in a list with all their indices. Built upon the method remove_atom.

Parameters:

indices (list) – List with the indices of the atoms to be removed.

Return type:

None

update()[source]#

Routine to initialize or update the intrinsic attributes of the Crystal class whenever the Bravais lattice is changed.

Return type:

None

visualize()[source]#

Method to render a 3d visualization of the crystal using the self.vpython library.

Return type:

None