Other utilities¶

acat.utilities.
neighbor_shell_list
(atoms, dx=0.3, neighbor_number=1, different_species=False, mic=False, radius=None, span=False)[source]¶ Make dict of neighboring shell atoms for both periodic and nonperiodic systems. Possible to return neighbors from defined neighbor shell e.g. 1st, 2nd, 3rd by changing the neighbor number. Essentially returns a unit disk (or ring) graph.
 Parameters
atoms (ase.Atoms object) – Accept any ase.Atoms object. No need to be builtin.
dx (float, default 0.3) – Buffer to calculate nearest neighbor pairs.
neighbor_number (int, default 1) – Neighbor shell number.
different_species (bool, default False) – Whether each neighbor pair are different species.
mic (bool, default False) – Whether to apply minimum image convention. Remember to set mic=True for periodic systems.
radius (float, default None) – The radius of each shell. Works exactly as a conventional neighbor list when specified. If not specified, use covalent radii instead.
span (bool, default False) – Whether to include all neighbors spanned within the shell. Returns a unit disk graph if True, otherwise returns a unit ring graph.

acat.utilities.
get_adj_matrix
(neighborlist)[source]¶ Returns an adjacency matrix from a neighborlist object.
 Parameters
neighborlist (dict) – A neighborlist (dictionary) that contains keys of each atom index and values of their neighbor atom indices.

acat.utilities.
get_mic
(p1, p2, cell, pbc=[1, 1, 0], max_cell_multiple=100000.0, return_squared_distance=False)[source]¶ A highly efficient function for getting all vectors from p1 to p2. Also able to calculate the squared distance using the minimum image convention (mic). This function is useful when you want to constantly calculate mic between two given positions. Please use ase.geometry.find_mic if you want to calculate an array of vectors all at a time (useful for e.g. neighborlist).
 Parameters
p1 (numpy.array) – The 3D Cartesian coordinate of the position 1.
p2 (numpy.array) – The 3D Cartesian coordinate of the position 2.
cell (numpy.array) – The 3D parallel epipedal unit cell.
pbc (numpy.array or list, default [1, 1, 0]) – Whether cell is periodic in each direction.
max_cell_multiple (int, default 1e5) – A large number to account for the maximum repetitions of each of the lattice vectors. The minimum number of repetitions is hence calculated by the algorithm using the intersection of a sphere and the unit cell.
return_squared_distance (bool, default False) – Whether to return the squared mic distance instead of the mic vector.

acat.utilities.
cart_to_frac
(atoms)[source]¶ Convert Cartesian coordinates to fractional coordinates.

acat.utilities.
hash_composition
(nodes)[source]¶ A hashing function to generate an unique identifier of the composition considering selfsymmetry. Note that this function only accepts a sequence of connected nodes.

acat.utilities.
get_close_atoms
(atoms, cutoff=0.5, mic=False, delete=False)[source]¶ Get a list of close atoms and delete one set of them if requested. Identify all atoms that lie within the cutoff radius of each other.
 Parameters
atoms (ase.Atoms object) – Accept any ase.Atoms object. No need to be builtin.
cutoff (float, default 0.5) – The cutoff radius. Two atoms are too close if the distance between them is less than this cutoff
mic (bool, default False) – Whether to apply minimum image convention. Remember to set mic=True for periodic systems.
delete (bool, default False) – Whether to delete one set of the close atoms.

acat.utilities.
atoms_too_close
(atoms, cutoff=0.5, mic=False)[source]¶ Check if there are atoms that are too close to each other.
 Parameters
atoms (ase.Atoms object) – Accept any ase.Atoms object. No need to be builtin.
cutoff (float, default 0.5) – The cutoff radius. Two atoms are too close if the distance between them is less than this cutoff
mic (bool, default False) – Whether to apply minimum image convention. Remember to set mic=True for periodic systems.

acat.utilities.
atoms_too_close_after_addition
(atoms, n_added, cutoff=1.5, mic=False)[source]¶ Check if there are atoms that are too close to each other after adding some new atoms.
 Parameters
atoms (ase.Atoms object) – Accept any ase.Atoms object. No need to be builtin.
n_added (int) – Number of newly added atoms.
cutoff (float, default 1.5) – The cutoff radius. Two atoms are too close if the distance between them is less than this cutoff
mic (bool, default False) – Whether to apply minimum image convention. Remember to set mic=True for periodic systems.

acat.utilities.
get_angle_between
(v1, v2)[source]¶ Returns the angle in radians between vectors ‘v1’ and ‘v2’.
 Parameters
v1 (numpy.array) – Vector 1.
v2 (numpy.array) – Vector 2.

acat.utilities.
get_rejection_between
(v1, v2)[source]¶ Calculate the vector rejection of vector ‘v1’ perpendicular to vector ‘v2’.
 Parameters
v1 (numpy.array) – Vector 1.
v2 (numpy.array) – Vector 2.

acat.utilities.
get_rotation_matrix
(v1, v2)[source]¶ Return the rotation matrix R that rotates unit vector v1 onto unit vector v2.
 Parameters
v1 (numpy.array) – Vector 1.
v2 (numpy.array) – Vector 2.

acat.utilities.
get_rodrigues_rotation_matrix
(axis, angle)[source]¶ Return the Rodrigues rotation matrix associated with counterclockwise rotation about the given axis by an angle.
 Parameters
axis (numpy.array) – The axis (vector) to rotate around with.
angle (numpy.array) – The angle (in radians) to rotate around.

acat.utilities.
get_total_masses
(symbol)[source]¶ Get the total molar mass given the chemical symbol of a molecule.
 Parameters
symbol (str) – Chemical symbol of the molecule.

acat.utilities.
string_fragmentation
(adsorbate)[source]¶ A function for generating a fragment list (list of strings) from a given adsorbate (string).
 Parameters
adsorbate (str) – The string of the adsorbate molecule.

acat.utilities.
orthogonal_transform
(atoms, transform_cell=True, eps=1e05)[source]¶ Transform a nonorthogonal cell to an orthogonal cell.

acat.utilities.
ratios_from_atoms
(atoms)[source]¶ Return a list of ratios for each element from the atoms.
 Parameters
atoms (ase.Atoms object) –

acat.utilities.
numbers_from_ratios
(sum_numbers, ratios)[source]¶ Return the number of atoms for each element from ratios.
 Parameters
sum_numbers (int) – The total number of atoms
ratios (list) – A list of ratios for different elements

acat.utilities.
dag_from_ucg
(adj_matrix, sources, return_depths=False)[source]¶ Takes the adjacency matrix of an undirected cyclic graph (UCG) and the indices of the starting nodes, returns an adjacency list represeting the corresponding shortestpaths directed acyclic graph (DAG).
 Parameters
adj_matrix (np.ndarray or list of lists) – The adjacency matrix of the UCG.
sources (list of strs) – The indices of the starting nodes for the DAG.
return_depths (bool, default False) – Whether to also return the node indices at each walking depth (in ascending order) together with the DAG.

acat.utilities.
sort_atoms_by_ref_atoms
(atoms, ref_atoms, mic=False)[source]¶ Sort a structure based on a reference structure. This could be super useful when restarting DFT relaxation in VASP since VASP always shuffles the atom indices when starting a new run. Each pair of atoms after sorting is a closest pair. Note that the number of atmos of the structures must be the same. The cells of the two periodic structures must be the same.

acat.utilities.
draw_graph
(G, savefig='graph.png', layout='spring', *args, **kwargs)[source]¶ Draw the graph using matplotlib.pyplot.
 Parameters
G (networkx.Graph object) – The graph object
savefig (str, default 'graph.png') – The name of the figure to be saved.
layout (str, default 'spring') – The graph layout supported by networkx. E.g. ‘spring’, ‘graphviz’, ‘random’, etc.