sphractal.utils

Module Contents

Functions

estDuration(func)

Return time taken to run a function.

getMinMaxXYZ(atomsXYZ)

Return the minimum and maximum values of each dimension of a set of coordinates.

readInp(filePath[, radType])

Parse an xyz or a lmp file.

allDirVecs()

Return a list of vectors corresponding to the standard 26 directions from a point.

findNN(atomsRad, atomsXYZ, minXYZ, maxXYZ, maxAtomRad)

Compute the nearest neighbour list and average bond length for each atom.

findTetras(tetraVtxsIdxs, r, alpha)

Return tetrahedrons with their circumsphere radii smaller than a specified alpha value.

rmDupTris(tris)

Remove triangles that occur twice (internal triangles).

alphaShape(atomsXYZ, tetraVtxsIdxs, alpha)

Return points that form the surface using alpha shape algorithm.

findSurf(atomsXYZ, atomsNeighIdxs[, option, alpha, bulkCN])

Return the indices of surface atoms.

findAtomNeighs(neighIdxs, atomsSurfIdxs)

Divide a list of atomic neighbours into two based on whether they lie on the surface.

calcDist(p1, p2)

Return Euclidean distance between two points.

getOrdSurfNeighCombs(surfNeighDists, surfNeighIdxs)

Compute ID pairs of a set of neighbouring atoms, ordered by distance from a given point.

closestSurfAtoms(pointXYZ, surfNeighIdxs, atomsXYZ, ...)

Return two closest surface atom pairs from a given point, that are neighbour of each other.

oppositeInnerAtoms(pointXYZ, atom1XYZ, atomNeighIdxs, ...)

Return whether a point lies opposite of the average coordinates of neighbouring inner atoms of a given atom.

sphractal.utils.estDuration(func)[source]

Return time taken to run a function.

sphractal.utils.getMinMaxXYZ(atomsXYZ)[source]

Return the minimum and maximum values of each dimension of a set of coordinates.

sphractal.utils.readInp(filePath, radType='atomic')[source]

Parse an xyz or a lmp file.

sphractal.utils.allDirVecs()[source]

Return a list of vectors corresponding to the standard 26 directions from a point.

sphractal.utils.findNN(atomsRad, atomsXYZ, minXYZ, maxXYZ, maxAtomRad, radMult=1.2, calcBL=False)[source]

Compute the nearest neighbour list and average bond length for each atom.

Parameters:
  • atomsRad (1D ndarray of floats) – Radius of each atom.

  • atomsXYZ (2D ndarray of floats) – Cartesian coordinates of each atom.

  • minXYZ (1D ndarray of floats) – Minimum values of each dimension in the Cartesian space.

  • maxXYZ (1D ndarray of floats) – Maximum values of each dimension in the Cartesian space.

  • maxAtomRad (Union[int,float]) – Maximum value of atomic radius.

  • radMult (Union[int,float]) – Multiplier to the atomic radii.

  • calcBL (bool, optional) – Whether to compute the average bond length for each atom.

Returns:

  • atomsNeighIdxsPadded (2D ndarray of ints) – Neighbour atoms indices of each atom, padded with -1 for fixed number of columns.

  • atomsAvgBondLen (1D ndarray of floats) – Average bond lengths for each each.

sphractal.utils.findTetras(tetraVtxsIdxs, r, alpha)[source]

Return tetrahedrons with their circumsphere radii smaller than a specified alpha value.

sphractal.utils.rmDupTris(tris)[source]

Remove triangles that occur twice (internal triangles).

sphractal.utils.alphaShape(atomsXYZ, tetraVtxsIdxs, alpha)[source]

Return points that form the surface using alpha shape algorithm.

Algorithm modified from https://stackoverflow.com/questions/26303878/alpha-shapes-in-3d Radius of the sphere fitting inside the tetrahedral < alpha (http://mathworld.wolfram.com/Circumsphere.html)

sphractal.utils.findSurf(atomsXYZ, atomsNeighIdxs, option='alphaShape', alpha=3.0, bulkCN=12)[source]

Return the indices of surface atoms.

Parameters:
  • atomsXYZ (2D ndarray of floats) – Cartesian coordinates of each atom.

  • atomsNeighIdxs (2D ndarray of ints) – Neighbour atoms indices of each atom.

  • option ({'alphaShape', 'convexHull', 'numNeigh'}, optional) – Algorithm to identify the spheres on the surface. ‘convexHull’ tends to identify less surface atoms; ‘numNeigh’ tends to identify more surface atoms. ‘alphaShape’ is a generalisation of ‘convexHull’.

  • alpha (Union[int, float], optional) – ‘alpha’ for the alpha shape algorithm, only used if ‘option’ is ‘alphaShape’.

  • bulkCN (int, optional) – Minimum number of neighbouring atoms for a non-surface atom.

Returns:

atomsSurfIdxs – Indices of surface atoms.

Return type:

1D ndarray of ints

Notes

Other alternatives include: - https://dl.acm.org/doi/abs/10.1145/2073304.2073339 - https://onlinelibrary.wiley.com/doi/pdf/10.1002/jcc.25384 - https://www.jstage.jst.go.jp/article/tmrsj/45/4/45_115/_article

sphractal.utils.findAtomNeighs(neighIdxs, atomsSurfIdxs)[source]

Divide a list of atomic neighbours into two based on whether they lie on the surface.

sphractal.utils.calcDist(p1, p2)[source]

Return Euclidean distance between two points.

sphractal.utils.getOrdSurfNeighCombs(surfNeighDists, surfNeighIdxs)[source]

Compute ID pairs of a set of neighbouring atoms, ordered by distance from a given point.

sphractal.utils.closestSurfAtoms(pointXYZ, surfNeighIdxs, atomsXYZ, atomsNeighIdxs)[source]

Return two closest surface atom pairs from a given point, that are neighbour of each other.

sphractal.utils.oppositeInnerAtoms(pointXYZ, atom1XYZ, atomNeighIdxs, atomsSurfIdxs, atomsXYZ, atomsNeighIdxs)[source]

Return whether a point lies opposite of the average coordinates of neighbouring inner atoms of a given atom.