pymatgen.analysis.chemenv.utils.coordination_geometry_utils module¶

class
Plane
(coefficients, p1=None, p2=None, p3=None)[source]¶ Bases:
object
Class used to describe a plane
Initializes a plane from the 4 coefficients a, b, c and d of ax + by + cz + d = 0 :param coefficients: abcd coefficients of the plane

TEST_2D_POINTS
= [array([ 0., 0.]), array([ 1., 0.]), array([ 0., 1.]), array([1., 0.]), array([ 0., 1.]), array([ 0., 2.]), array([ 2., 0.]), array([ 0., 2.]), array([2., 0.]), array([ 1., 1.]), array([ 2., 2.]), array([1., 1.]), array([2., 2.]), array([ 1., 2.]), array([ 1., 2.]), array([1., 2.]), array([1., 2.]), array([ 2., 1.]), array([ 2., 1.]), array([2., 1.]), array([2., 1.])]¶

a
¶

abcd
¶

b
¶

c
¶

coefficients
¶

crosses_origin
¶

d
¶

distance_to_origin
¶

distance_to_point
(point)[source]¶ Computes the absolute distance from the plane to the point :param point: :return:

indices_separate
(points, dist_tolerance)[source]¶ Returns three lists containing the indices of the points lying on one side of the plane, on the plane and on the other side of the plane. The dist_tolerance parameter controls the tolerance to which a point is considered to lie on the plane or not (distance to the plane) :param points: list of points :param dist_tolerance: tolerance to which a point is considered to lie on the plane or not (distance to the plane) :return: The lists of indices of the points on one side of the plane, on the plane and on the other side of the plane

is_in_list
(plane_list)[source]¶ Checks whether the plane is identical to one of the Planes in the plane_list list of Planes :param plane_list: List of Planes to be compared to :return: True if the plane is in the list, False otherwise

is_in_plane
(pp, dist_tolerance)[source]¶ Determines if point pp is in the plane within the tolerance dist_tolerance :param pp: point to be tested :param dist_tolerance: tolerance on the distance to the plane within which point pp is considered in the plane :return: True if pp is in the plane, False otherwise

is_same_plane_as
(plane)[source]¶ Checks whether the plane is identical to another Plane “plane” :param plane: Plane to be compared to :return: True if the two facets are identical, False otherwise

orthonormal_vectors
()[source]¶ Returns a list of three orthogonal vectors, the two first being parallel to the plane and the third one is the normal vector of the plane :return: List of orthogonal vectors :raise: ValueError if all the coefficients are zero or if there is some other strange error

project_and_to2dim
(pps, plane_center)[source]¶ Projects the list of points pps to the plane and changes the basis from 3D to the 2D basis of the plane :param pps: List of points to be projected :return: :raise:

project_and_to2dim_ordered_indices
(pps, plane_center='mean')[source]¶ Projects each points in the point list pps on plane and returns the indices that would sort the list of projected points in anticlockwise order :param pps: List of points to project on plane :return: List of indices that would sort the list of projected points


anticlockwise_sort
(pps)[source]¶ Sort a list of 2D points in anticlockwise order :param pps: List of points to be sorted :return: Sorted list of points

anticlockwise_sort_indices
(pps)[source]¶ Returns the indices that would sort a list of 2D points in anticlockwise order :param pps: List of points to be sorted :return: Indices of the sorted list of points

changebasis
(uu, vv, nn, pps)[source]¶ For a list of points given in standard coordinates (in terms of e1, e2 and e3), returns the same list expressed in the basis (uu, vv, nn), which is supposed to be orthonormal. :param uu: First vector of the basis :param vv: Second vector of the basis :param nn: Third vector of the bais :param pps: List of points in basis (e1, e2, e3) :return: List of points in basis (uu, vv, nn)

collinear
(p1, p2, p3=None, tolerance=0.25)[source]¶ Checks if the three points p1, p2 and p3 are collinear or not within a given tolerance. The collinearity is checked by computing the area of the triangle defined by the three points p1, p2 and p3. If the area of this triangle is less than (tolerance x largest_triangle), then the three points are considered collinear. The largest_triangle is defined as the right triangle whose legs are the two smallest distances between the three
Parameters:  p1 – First point
 p2 – Second point
 p3 – Third point (origin [0.0, 0.0, 0.0 if not given])
 tolerance – Area tolerance for the collinearity test (0.25 gives about 0.125 deviation from the line)
Returns: True if the three points are considered as collinear within the given tolerance, False otherwise

diamond_functions
(xx, yy, y_x0, x_y0)[source]¶  Method that creates two upper and lower functions based on points xx and yy as well as intercepts defined by
 y_x0 and x_y0. The resulting functions form kind of a distorted diamondlike structure aligned from point xx to point yy.
Schematically :
 xx is symbolized by x, yy is symbolized by y, y_x0 is equal to the distance from x to a, x_y0 is equal to the
 distance from x to b, the lines ap and bq are parallel to the line xy such that points p and q are obtained automatically.
 In case of an increasing diamond the lower function is xbq and the upper function is apy while in case of a
decreasing diamond, the lower function is apy and the upper function is xbq.
Parameters:  xx – First point
 yy – Second point
Returns: A dictionary with the lower and upper diamond functions.

function_comparison
(f1, f2, x1, x2, numpoints_check=500)[source]¶ Method that compares two functions
Parameters:  f1 – First function to compare
 f2 – Second function to compare
 x1 – Lower bound of the interval to compare
 x2 – Upper bound of the interval to compare
 numpoints_check – Number of points used to compare the functions
Returns:  Whether the function are equal (“=”), f1 is always lower than f2 (“<”), f1 is always larger than f2 (“>”),
f1 is always lower than or equal to f2 (“<”), f1 is always larger than or equal to f2 (“>”) on the interval [x1, x2]. If the two functions cross, a RuntimeError is thrown (i.e. we expect to compare functions that do not cross…)

is_anion_cation_bond
(valences, ii, jj)[source]¶ Checks if two given sites are an anion and a cation. :param valences: list of site valences :param ii: index of a site :param jj: index of another site :return: True if one site is an anion and the other is a cation (from the valences)

matrixMultiplication
(AA, BB)[source]¶ Performs the multiplication of two matrix of size 3x3 :param AA: One matrix of size 3x3 :param BB: Another matrix of size 3x3 :return: A matrix of size 3x3

matrixTimesVector
(MM, aa)[source]¶ Parameters:  MM – A matrix of size 3x3
 aa – A vector of size 3
Returns: A vector of size 3 which is the product of the matrix by the vector

my_solid_angle
(center, coords)[source]¶ Helper method to calculate the solid angle of a set of coords from the center.
Parameters:  center – Center to measure solid angle from.
 coords – List of coords to determine solid angle.
Returns: The solid angle.

quarter_ellipsis_functions
(xx, yy)[source]¶ Method that creates two quarterellipse functions based on points xx and yy. The ellipsis is supposed to be aligned with the axes. The two ellipsis pass through the two points xx and yy.
Parameters:  xx – First point
 yy – Second point
Returns: A dictionary with the lower and upper quarter ellipsis functions.

rectangle_surface_intersection
(rectangle, f_lower, f_upper, bounds_lower=None, bounds_upper=None, check=True, numpoints_check=500)[source]¶ Method to calculate the surface of the intersection of a rectangle (aligned with axes) and another surface defined by two functions f_lower and f_upper.
Parameters:  rectangle – Rectangle defined as : ((x1, x2), (y1, y2)).
 f_lower – Function defining the lower bound of the surface.
 f_upper – Function defining the upper bound of the surface.
 bounds_lower – Interval in which the f_lower function is defined.
 bounds_upper – Interval in which the f_upper function is defined.
 check – Whether to check if f_lower is always lower than f_upper.
 numpoints_check – Number of points used to check whether f_lower is always lower than f_upper
Returns: The surface of the intersection of the rectangle and the surface defined by f_lower and f_upper.

rotateCoords
(coords, R)[source]¶ Rotate the list of points using rotation matrix R :param coords: List of points to be rotated :param R: Rotation matrix :return: List of rotated points

separation_in_list
(separation_indices, separation_indices_list)[source]¶ Checks if the separation indices of a plane are already in the list :param separation_indices: list of separation indices (three arrays of integers) :param separation_indices_list: list of the list of separation indices to be compared to :return: True if the separation indices are already in the list, False otherwise

spline_functions
(lower_points, upper_points, degree=3)[source]¶ Method that creates two (upper and lower) spline functions based on points lower_points and upper_points.
Parameters:  lower_points – Points defining the lower function.
 upper_points – Points defining the upper function.
 degree – Degree for the spline function
Returns: A dictionary with the lower and upper spline functions.