site_analysis.polyhedral_site

class PolyhedralSite(vertex_indices: List[int], label: Optional[str] = None)[source]

Bases: site_analysis.site.Site

Describes a site defined by the polyhedral volume enclosed by a set of vertex atoms.

index

Numerical ID, intended to be unique to each site.

Type:int
label (`str`

optional): Optional string given as a label for this site. Default is None.

contains_atoms

List of the atoms contained by this site in the structure last processed.

Type:list
trajectory

List of sites this atom has visited at each timestep?

Type:list
points

List of fractional coordinates for atoms assigned as occupying this site.

Type:list
transitions

Stores observed transitions from this site to other sites. Format is {index: count} with index giving the index of each destination site, and count giving the number of observed transitions to this site.

Type:collections.Counter
vertex_indices

List of integer indices for the vertex atoms (counting from 0).

Type:list(int)
label

Optional label for the site.

Type:str, optional
as_dict() → Dict[KT, VT][source]

Json-serializable dict representation of this Site.

Parameters:None
Returns:(dict)
assign_vertex_coords(structure: pymatgen.core.structure.Structure) → None[source]

Assign fractional coordinates to the polyhedra vertices from the corresponding atom positions in a pymatgen Structure.

Parameters:structure (Structure) – The pymatgen Structure used to assign the vertices fractional coordinates.
Returns:None

Notes

This method assumes the coordinates of the vertices may have changed, so unsets the Delaunay tesselation for this site.

centre() → numpy.ndarray[source]

Returns the fractional coordinates of the centre point of this polyhedral site.

Parameters:None
Returns:(3,) numpy array.
Return type:(np.array)
cn

Coordination number for this site, defined as the number of vertices

Convenience property for coordination_number()

Returns:int
contains_atom(atom: site_analysis.atom.Atom, algo: Optional[str] = 'simplex', *args, **kwargs) → bool[source]

Test whether an atom is inside this polyhedron.

Parameters:
  • atom (Atom) – The atom to test.
  • algo (str, optional) – Select the algorithm to us. Options are ‘simplex’ and ‘sn’. See the documentation for the contains_point() method for more details. Default is ‘simplex’.
Returns:

bool

contains_point(x: numpy.ndarray, structure: Optional[pymatgen.core.structure.Structure] = None, algo: str = 'simplex', *args, **kwargs) → bool[source]

Test whether a specific point is enclosed by this polyhedral site.

Parameters:
  • x (np.array) – Fractional coordinates of the point to test (length 3 numpy array).
  • structure (Structure, optional) – Optional pymatgen Structure. If provided, the vertex coordinates for this polyhedral site will be assigned using this structure. Default is None.
  • algo (str) –

    Select the algorithm for testing whether a point is contained by the site:

    simplex: Use scipy.spatial.Delaunay.find_simplex to test if any of
    the simplices that make up this polyhedron contain the point.
    sn: Compute the sign of the surface normal for each polyhedron
    face with respect to the point, to test if the point lies “inside” every face.
Returns:

bool

contains_point_simplex(x: numpy.ndarray) → bool[source]

Test whether one or more points are inside this site, by checking whether these points are contained inside the simplices of the Delaunay tesselation defined by the vertex coordinates.

Parameters:x (np.array) – Fractional coordinates for one or more points, as a (3x1) or (3xN) numpy array.
Returns:bool
contains_point_sn(x_list: numpy.ndarray) → bool[source]

Test whether one or more points are inside this site, by calculating the sign of the surface normal for each face with respect to each point.

Parameters:x (np.array) – Fractional coordinates for one or more points, as a (3x1) or (3xN) numpy array.
Returns:bool

Note

This method could be made more efficient by caching the surface_normal vectors and in-face vectors.

This is also a possible target for optimisation with f2py etc.

coordination_number

Coordination number for this site, defined as the number of vertices

Returns:int
delaunay

Delaunay tessellation of the vertex coordinates for this site.

This is calculated the first time the attribute is requested, and then stored for reuse, unless the site is reset.

Returns:scipy.spatial.Delaunay
classmethod from_dict(d)[source]

Create a Site object from a dict representation.

Parameters:d (dict) – The dict representation of this Site.
Returns:(Site)
get_vertex_species(structure: pymatgen.core.structure.Structure) → List[str][source]

Returns a list of species strings for the vertex atoms of this polyhedral site.

Parameters:structure (Structure) – Pymatgen Structure used to assign species to each vertex atom.
Returns:List of species strings of the vertex atoms.
Return type:(list(str))
reset() → None[source]

Reset the trajectory for this site.

Resets the contains_atoms and trajectory attributes to empty lists.

Vertex coordinates and Delaunay tesselation are unset.

Parameters:None
Returns:None
classmethod sites_from_vertex_indices(vertex_indices, label=None)[source]