mdsuite.utils.neighbour_list module¶
MDSuite: A Zincwarecode package.
License¶
This program and the accompanying materials are made available under the terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zincwarecode Project.
Contact Information¶
email: zincwarecode@gmail.com github: https://github.com/zincware web: https://zincwarecode.com/
Citation¶
If you use this module please cite us with:
Summary¶
- mdsuite.utils.neighbour_list.get_neighbour_list(positions: Tensor, cell=None, batch_size=None) Tensor [source]¶
Generate the neighbour list.
- Parameters:
positions (tf.Tensor) – Tensor with shape (n_confs, n_atoms, 3) representing the coordinates
cell (list) – If periodic boundary conditions are used, please supply the cell dimensions, e.g. [13.97, 13.97, 13.97]. If the cell is provided minimum image convention will be applied!
batch_size (int) – Has to be evenly divisible by the the number of configurations.
- Returns:
generator object which results all distances for the current batch of time steps
To get the real r_ij matrix for one time_step you can use the following – r_ij_mat = np.zeros((n_atoms, n_atoms, 3)) r_ij_mat[np.triu_indices(n_atoms, k = 1)] = get_neighbour_list(
*args
) r_ij_mat -= r_ij_mat.transpose(1, 0, 2)
- mdsuite.utils.neighbour_list.get_triplets(full_r_ij: Tensor, r_cut: float, n_atoms: int, n_batches=200, disable_tqdm=True) Tensor [source]¶
Compute the triple indices within a cutoff.
Mostly vectorized method to compute the triples inside the cutoff sphere. Therefore a matrix of all possible distances r_ijk over all timesteps (n_timesteps, n_atoms, n_atoms, n_atoms) is constructed. The first layer is identical to the r_ij matrix, all consecutive layers are shifted along the “j” axis which leads to the full r_ijk matrix.
To check for a triple, the depth can be converted into the third particle, yielding an index over all ijk indices
- Parameters:
full_r_ij (tf.Tensor) – The full distance matrix (r_ij and r_ji) with the shape (n_timesteps, n_atoms, n_atoms)
r_cut (float) – The cutoff for the maximal triple distance
n_atoms (int) – Number of atoms
n_batches (int) – Number of batches to split the computation of the triples in. A low number of batches can result in memory issues.
- Return type:
tf.Tensor
Warning
Using the @tf.function decorator can speed things up! But it can also lead to memory issues.