HTMACat.catkit.gen.utils package

Submodules

HTMACat.catkit.gen.utils.connectivity module

HTMACat.catkit.gen.utils.connectivity.get_cutoff_neighbors(atoms, cutoff=None, scale_cov_radii=1.2, atol=1e-08)[source]

Return the connectivity matrix from a simple radial cutoff. Multi-bonding occurs through periodic boundary conditions.

Parameters:
atomsatoms object

Atoms object with the periodic boundary conditions and unit cell information to use.

cutofffloat

Cutoff radius to use when determining neighbors.

scale_cov_radiifloat

Value close to 1 to scale the covalent radii used for automated cutoff values.

atol: float

Absolute tolerance to use when computing distances.

Returns:
connectivityndarray (n, n)

Number of edges formed between atoms in a system.

HTMACat.catkit.gen.utils.connectivity.get_voronoi_neighbors(atoms, cutoff=5.0, return_distances=False)[source]

Return the connectivity matrix from the Voronoi method. Multi-bonding occurs through periodic boundary conditions.

Parameters:
atomsatoms object

Atoms object with the periodic boundary conditions and unit cell information to use.

cutofffloat

Radius of maximum atomic bond distance to consider.

Returns:
connectivityndarray (n, n)

Number of edges formed between atoms in a system.

HTMACat.catkit.gen.utils.coordinates module

HTMACat.catkit.gen.utils.coordinates.expand_cell(atoms, cutoff=None, padding=None)[source]

Return Cartesian coordinates atoms within a supercell which contains repetitions of the unit cell which contains at least one neighboring atom.

Parameters:
atomsAtoms object

Atoms with the periodic boundary conditions and unit cell information to use.

cutofffloat

Radius of maximum atomic bond distance to consider.

paddingndarray (3,)

Padding of repetition of the unit cell in the x, y, z directions. e.g. [1, 0, 1].

Returns:
indexndarray (N,)

Indices associated with the original unit cell positions.

coordsndarray (N, 3)

Cartesian coordinates associated with positions in the supercell.

offsetsndarray (M, 3)

Integer offsets of each unit cell.

HTMACat.catkit.gen.utils.coordinates.get_integer_enumeration(N=3, span=[0, 2])[source]

Return the enumerated array of a span of integer values. These enumerations are limited to the length N.

For the default span of [0, 2], the enumeration equates to the corners of an N-dimensional hypercube.

Parameters:
Nint

Length of enumerated lists to produce.

spanlist | slice

The range of integers to be considered for enumeration.

Returns:
enumerationndarray (M, N)

Enumeration of the requested integers.

HTMACat.catkit.gen.utils.coordinates.get_unique_coordinates(atoms, axis=2, tag=False, tol=0.001)[source]

Return unique coordinate values of a given atoms object for a specified axis.

Parameters:
atomsobject

Atoms object to search for unique values along.

axisint (0, 1, or 2)

Look for unique values along the x, y, or z axis.

tagbool

Assign ASE-like tags to each layer of the slab.

tolfloat

The tolerance to search for unique values within.

Returns:
valuesndarray (n,)

Array of unique positions in fractional coordinates.

HTMACat.catkit.gen.utils.coordinates.get_unique_xy(xyz_coords, cutoff=0.1)[source]

Return the unique coordinates of an atoms object for the requrested atoms indices. Z-coordinates are projected to maximum z-coordinate by default.

Parameters:
xyz_coordsndarray (n, 3)

Cartesian coordinates to identify unique xy positions from.

cutofffloat

Distance in Angstrons to consider xy-coordinate unique within.

Returns:
xy_posndarray (m, 3)

Unique xy coordinates projected onto a maximal z coordinate.

HTMACat.catkit.gen.utils.coordinates.matching_coordinates(position, comparators, tol=1e-08)[source]

Get the indices of all points in a comparator list that are equal to a given position (with a tolerance), taking into account periodic boundary conditions (adaptation from Pymatgen).

This will only accept a Cartesian coordinate scheme. TODO: merge this with matching_sites.

Parameters:
positionlist (3,)

Fractional coordinate to compare to list.

comparatorslist (3, N)

Fractional coordinates to compare against.

tolfloat

Absolute tolerance.

Returns:
matchlist (N,)

Indices of matches.

HTMACat.catkit.gen.utils.coordinates.matching_sites(position, comparators, tol=1e-08)[source]

Get the indices of all points in a comparator list that are equal to a given position (with a tolerance), taking into account periodic boundary conditions (adaptation from Pymatgen).

This will only accept a fractional coordinate scheme.

Parameters:
positionlist (3,)

Fractional coordinate to compare to list.

comparatorslist (3, n)

Fractional coordinates to compare against.

tolfloat

Absolute tolerance.

Returns:
matchlist (n,)

Indices of matches.

HTMACat.catkit.gen.utils.coordinates.trilaterate(centers, r, zvector=None)[source]

Find the intersection of two or three spheres. In the case of two sphere intersection, the z-coordinate is assumed to be an intersection of a plane whose normal is aligned with the points and perpendicular to the positive z-coordinate.

If more than three spheres are supplied, the centroid of the points is returned (no radii used).

Parameters:
centerslist | ndarray (n, 3)

Cartesian coordinates representing the center of each sphere

rlist | ndarray (n,)

The radii of the spheres.

zvectorndarray (3,)

The vector associated with the upward direction for under-specified coordinations (1 and 2).

Returns:
intersectionndarray (3,)

The point where all spheres/planes intersect.

HTMACat.catkit.gen.utils.graph module

HTMACat.catkit.gen.utils.graph.connectivity_to_edges(connectivity, indices=None)[source]

Convert a Numpy connectivity matrix into a list of NetworkX compatible edges.

HTMACat.catkit.gen.utils.graph.isomorphic_molecules(graph0, graph1)[source]

Check whether two molecule graphs are isomorphic.

HTMACat.catkit.gen.utils.utilities module

HTMACat.catkit.gen.utils.utilities.ext_gcd(a, b)[source]

Extension of greatest common divisor.

HTMACat.catkit.gen.utils.utilities.get_atomic_numbers(formula, return_count=False)[source]

Return the atomic numbers associated with a chemical formula.

Parameters:
formulastring

A chemical formula to parse into atomic numbers.

return_countbool

Return the count of each element in the formula.

Returns:
numbersndarray (n,)

Element numbers in associated species.

countsndarray (n,)

Count of each element in a species.

HTMACat.catkit.gen.utils.utilities.get_reference_energies(species, energies)[source]

Get reference energies for the elements in a set of molecules.

Parameters:
specieslist (n,)

Chemical formulas for each molecular species.

energieslist (n,)

Total energies associated with each species.

Returns:
elementsndarray (n,)

Atomic elements associated with all species.

referencesndarray (n,)

Reference energies associated with each element.

HTMACat.catkit.gen.utils.utilities.list_gcd(values)[source]

Return the greatest common divisor of a list of values.

HTMACat.catkit.gen.utils.utilities.parse_slice(slice_name)[source]

Return a correctly parsed slice from input of varying types.

HTMACat.catkit.gen.utils.utilities.running_mean(array, N=5)[source]

Calculate the running mean of array for N instances.

Parameters:
arrayarray_like | ndarray (N,)

Array of values to have a average taken from.

Nint

Number of values to take an average with.

Returns:
running_meanndarray (N + 1,)

Mean value of the running average.

HTMACat.catkit.gen.utils.utilities.to_gratoms(atoms, edges=None)[source]

Convert and atom object to a gratoms object.

HTMACat.catkit.gen.utils.utils_mdnm module

HTMACat.catkit.gen.utils.utils_mdnm.mol_to_graph(self, m)[source]

Convert a molecule object to a graph.

Parameters:
mmol

The RDKit molecule object to be converted into a networkx graph.

Returns:
GGraph

The networkx Graph object derived from m.

HTMACat.catkit.gen.utils.utils_mdnm.solve_normal_vector_linearsvc(coords, bond_idx, take_into_account_idx=None)[source]

Solve the adsorption direction of the given species using SVM. Returns the direction that should be rotated into [001] of the slab model.

Parameters:
coordsnumpy.ndarray

The coordinates of all atoms in the species.

bond_idxint

The index of the atom to be placed on the adsorption sites.

take_into_account_idxlist

The list of atom indices should be as close as possible to the surface. If it is not None, the geometric center of these atoms will act as the symmetry center.

Returns:
veclist

The normal vector of the decision boundary.

flag_linearly_separablelist

Record whether the extended coordinates are linearly separable.

HTMACat.catkit.gen.utils.vectors module

HTMACat.catkit.gen.utils.vectors.get_basis_vectors(coordinates)[source]

Return a set of basis vectors for a given array of 3D coordinates.

Parameters:
coordinatesarray_like (3, 3) | (2, 3)

Cartesian coordinates to determine the basis of. If only 2 positions are given 3rd is chosen as the positive y-axis.

Returns:
basis_vectorsndarray (3, 3)

Automatically generated basis vectors from the given positions.

HTMACat.catkit.gen.utils.vectors.get_reciprocal_vectors(atoms)[source]

Return the reciprocal lattice vectors to a atoms unit cell.

HTMACat.catkit.gen.utils.vectors.plane_normal(xyz)[source]

Return the surface normal vector to a plane of best fit.

Parameters:
xyzndarray (n, 3)

3D points to fit plane to.

Returns:
vecndarray (1, 3)

Unit vector normal to the plane of best fit.

Module contents

HTMACat.catkit.gen.utils.connectivity_to_edges(connectivity, indices=None)[source]

Convert a Numpy connectivity matrix into a list of NetworkX compatible edges.

HTMACat.catkit.gen.utils.expand_cell(atoms, cutoff=None, padding=None)[source]

Return Cartesian coordinates atoms within a supercell which contains repetitions of the unit cell which contains at least one neighboring atom.

Parameters:
atomsAtoms object

Atoms with the periodic boundary conditions and unit cell information to use.

cutofffloat

Radius of maximum atomic bond distance to consider.

paddingndarray (3,)

Padding of repetition of the unit cell in the x, y, z directions. e.g. [1, 0, 1].

Returns:
indexndarray (N,)

Indices associated with the original unit cell positions.

coordsndarray (N, 3)

Cartesian coordinates associated with positions in the supercell.

offsetsndarray (M, 3)

Integer offsets of each unit cell.

HTMACat.catkit.gen.utils.ext_gcd(a, b)[source]

Extension of greatest common divisor.

HTMACat.catkit.gen.utils.get_atomic_numbers(formula, return_count=False)[source]

Return the atomic numbers associated with a chemical formula.

Parameters:
formulastring

A chemical formula to parse into atomic numbers.

return_countbool

Return the count of each element in the formula.

Returns:
numbersndarray (n,)

Element numbers in associated species.

countsndarray (n,)

Count of each element in a species.

HTMACat.catkit.gen.utils.get_basis_vectors(coordinates)[source]

Return a set of basis vectors for a given array of 3D coordinates.

Parameters:
coordinatesarray_like (3, 3) | (2, 3)

Cartesian coordinates to determine the basis of. If only 2 positions are given 3rd is chosen as the positive y-axis.

Returns:
basis_vectorsndarray (3, 3)

Automatically generated basis vectors from the given positions.

HTMACat.catkit.gen.utils.get_cutoff_neighbors(atoms, cutoff=None, scale_cov_radii=1.2, atol=1e-08)[source]

Return the connectivity matrix from a simple radial cutoff. Multi-bonding occurs through periodic boundary conditions.

Parameters:
atomsatoms object

Atoms object with the periodic boundary conditions and unit cell information to use.

cutofffloat

Cutoff radius to use when determining neighbors.

scale_cov_radiifloat

Value close to 1 to scale the covalent radii used for automated cutoff values.

atol: float

Absolute tolerance to use when computing distances.

Returns:
connectivityndarray (n, n)

Number of edges formed between atoms in a system.

HTMACat.catkit.gen.utils.get_integer_enumeration(N=3, span=[0, 2])[source]

Return the enumerated array of a span of integer values. These enumerations are limited to the length N.

For the default span of [0, 2], the enumeration equates to the corners of an N-dimensional hypercube.

Parameters:
Nint

Length of enumerated lists to produce.

spanlist | slice

The range of integers to be considered for enumeration.

Returns:
enumerationndarray (M, N)

Enumeration of the requested integers.

HTMACat.catkit.gen.utils.get_reciprocal_vectors(atoms)[source]

Return the reciprocal lattice vectors to a atoms unit cell.

HTMACat.catkit.gen.utils.get_reference_energies(species, energies)[source]

Get reference energies for the elements in a set of molecules.

Parameters:
specieslist (n,)

Chemical formulas for each molecular species.

energieslist (n,)

Total energies associated with each species.

Returns:
elementsndarray (n,)

Atomic elements associated with all species.

referencesndarray (n,)

Reference energies associated with each element.

HTMACat.catkit.gen.utils.get_unique_coordinates(atoms, axis=2, tag=False, tol=0.001)[source]

Return unique coordinate values of a given atoms object for a specified axis.

Parameters:
atomsobject

Atoms object to search for unique values along.

axisint (0, 1, or 2)

Look for unique values along the x, y, or z axis.

tagbool

Assign ASE-like tags to each layer of the slab.

tolfloat

The tolerance to search for unique values within.

Returns:
valuesndarray (n,)

Array of unique positions in fractional coordinates.

HTMACat.catkit.gen.utils.get_unique_xy(xyz_coords, cutoff=0.1)[source]

Return the unique coordinates of an atoms object for the requrested atoms indices. Z-coordinates are projected to maximum z-coordinate by default.

Parameters:
xyz_coordsndarray (n, 3)

Cartesian coordinates to identify unique xy positions from.

cutofffloat

Distance in Angstrons to consider xy-coordinate unique within.

Returns:
xy_posndarray (m, 3)

Unique xy coordinates projected onto a maximal z coordinate.

HTMACat.catkit.gen.utils.get_voronoi_neighbors(atoms, cutoff=5.0, return_distances=False)[source]

Return the connectivity matrix from the Voronoi method. Multi-bonding occurs through periodic boundary conditions.

Parameters:
atomsatoms object

Atoms object with the periodic boundary conditions and unit cell information to use.

cutofffloat

Radius of maximum atomic bond distance to consider.

Returns:
connectivityndarray (n, n)

Number of edges formed between atoms in a system.

HTMACat.catkit.gen.utils.isomorphic_molecules(graph0, graph1)[source]

Check whether two molecule graphs are isomorphic.

HTMACat.catkit.gen.utils.list_gcd(values)[source]

Return the greatest common divisor of a list of values.

HTMACat.catkit.gen.utils.matching_coordinates(position, comparators, tol=1e-08)[source]

Get the indices of all points in a comparator list that are equal to a given position (with a tolerance), taking into account periodic boundary conditions (adaptation from Pymatgen).

This will only accept a Cartesian coordinate scheme. TODO: merge this with matching_sites.

Parameters:
positionlist (3,)

Fractional coordinate to compare to list.

comparatorslist (3, N)

Fractional coordinates to compare against.

tolfloat

Absolute tolerance.

Returns:
matchlist (N,)

Indices of matches.

HTMACat.catkit.gen.utils.matching_sites(position, comparators, tol=1e-08)[source]

Get the indices of all points in a comparator list that are equal to a given position (with a tolerance), taking into account periodic boundary conditions (adaptation from Pymatgen).

This will only accept a fractional coordinate scheme.

Parameters:
positionlist (3,)

Fractional coordinate to compare to list.

comparatorslist (3, n)

Fractional coordinates to compare against.

tolfloat

Absolute tolerance.

Returns:
matchlist (n,)

Indices of matches.

HTMACat.catkit.gen.utils.mol_to_graph(self, m)[source]

Convert a molecule object to a graph.

Parameters:
mmol

The RDKit molecule object to be converted into a networkx graph.

Returns:
GGraph

The networkx Graph object derived from m.

HTMACat.catkit.gen.utils.parse_slice(slice_name)[source]

Return a correctly parsed slice from input of varying types.

HTMACat.catkit.gen.utils.plane_normal(xyz)[source]

Return the surface normal vector to a plane of best fit.

Parameters:
xyzndarray (n, 3)

3D points to fit plane to.

Returns:
vecndarray (1, 3)

Unit vector normal to the plane of best fit.

HTMACat.catkit.gen.utils.running_mean(array, N=5)[source]

Calculate the running mean of array for N instances.

Parameters:
arrayarray_like | ndarray (N,)

Array of values to have a average taken from.

Nint

Number of values to take an average with.

Returns:
running_meanndarray (N + 1,)

Mean value of the running average.

HTMACat.catkit.gen.utils.solve_normal_vector_linearsvc(coords, bond_idx, take_into_account_idx=None)[source]

Solve the adsorption direction of the given species using SVM. Returns the direction that should be rotated into [001] of the slab model.

Parameters:
coordsnumpy.ndarray

The coordinates of all atoms in the species.

bond_idxint

The index of the atom to be placed on the adsorption sites.

take_into_account_idxlist

The list of atom indices should be as close as possible to the surface. If it is not None, the geometric center of these atoms will act as the symmetry center.

Returns:
veclist

The normal vector of the decision boundary.

flag_linearly_separablelist

Record whether the extended coordinates are linearly separable.

HTMACat.catkit.gen.utils.to_gratoms(atoms, edges=None)[source]

Convert and atom object to a gratoms object.

HTMACat.catkit.gen.utils.trilaterate(centers, r, zvector=None)[source]

Find the intersection of two or three spheres. In the case of two sphere intersection, the z-coordinate is assumed to be an intersection of a plane whose normal is aligned with the points and perpendicular to the positive z-coordinate.

If more than three spheres are supplied, the centroid of the points is returned (no radii used).

Parameters:
centerslist | ndarray (n, 3)

Cartesian coordinates representing the center of each sphere

rlist | ndarray (n,)

The radii of the spheres.

zvectorndarray (3,)

The vector associated with the upward direction for under-specified coordinations (1 and 2).

Returns:
intersectionndarray (3,)

The point where all spheres/planes intersect.