pyxtal.descriptor module

Module for crystal packing descriptor from energy decomposition

pyxtal.descriptor.cart2sph(x, y, z)[source]

Convert Cartesian coordinates (x, y, z) to spherical coordinates (phi, theta, r)

Parameters:
  • x – Cartesian coordinates

  • y – Cartesian coordinates

  • z – Cartesian coordinates

Returns:

azimuthal angle in [-pi, pi] theta: polar angle in [-pi/2, pi/2] r: radius

Return type:

phi

pyxtal.descriptor.correlation(coef1, coef2, angle=None, s=0)[source]

Compute the correlation between to sph coefs

Parameters:
  • coef1 – sph coefficients 1

  • coef2 – sph coefficients 2

  • angle – [alpha, beta, gamma]

  • s – starting index of coefs

Returns:

distance scaled in [0, 1]

pyxtal.descriptor.correlation_go(coef1, coef2, M=6, s=0, d_cut=0.92)[source]

global optimization of two coefs based on quasi random sampling

Parameters:
  • coef1 – sph coefficients 1

  • coef2 – sph coefficients 2

  • M – 2^M sampling points

  • s – starting index of coefs

Returns:

distance scaled in [0, 1]

pyxtal.descriptor.correlation_opt(coef1, coef2, angle, s=0)[source]

Compute the correlation between two sph coefs

Parameters:
  • coef1 – sph coefficients 1

  • coef2 – sph coefficients 2

  • angle – [alpha, beta, gamma]

  • s – starting index of coefs

Returns:

distance scaled in [0, 1]

pyxtal.descriptor.expand_sph(pts, l_max, norm=4, csphase=-1)[source]
pyxtal.descriptor.fibonacci_sphere(N=1000)[source]

Sampling the sphere grids

Parameters:

N – number of pts to generate

Returns:

3D points array in Cartesian coordinates

pyxtal.descriptor.get_alignment(pts, degrees=True)[source]

Here we define the equator is the plane with three most important neighbors. Get the required rotation angles to get that representation.

Parameters:

points (pts; important)

Returns:

[alpha, beta, gamma]

Return type:

angles

class pyxtal.descriptor.orientation_order(xtal, max_CN=14)[source]

Bases: object

Computes the Steinhardt orientation order parameters

Parameters:
  • xtal – pyxtal structure

  • max_d – maximum intermolecular distances

  • lmax – maximum bandwidth for spherical harmonic expansion

get_neighbors()[source]

get neighboring molecules

Returns:

[N, 3] array, (theta, phi, eng)

Return type:

pts

get_parameters(ls=None)[source]

Computes the orientation order parameters q_l for given l values.

Parameters:

ls – list of integers, the l values to compute q_l. Default is [4,6]

Returns:

list of float, the computed q_l values

Return type:

qs

pyxtal.descriptor.sph2cart(phi, theta, r)[source]

Convert spherical coordinates (phi, theta, r) to Cartesian coordinates (x, y, z)

Parameters:
  • phi – azimuthal angle in radians

  • theta – polar angle in radians

  • r – radius

Returns:

Cartesian coordinates

Return type:

x, y, z

class pyxtal.descriptor.spherical_image(xtal, model='molecule', max_d=10, factor=2.2, lmax=13, sigma=0.1, N=10000)[source]

Bases: object

align(M=6)[source]

Align spherical image in a way that three most important contributions are parallel to the equatorial plane. Experimental stage now!

Parameters:

M – number of power in quasi random sampling

calculate_density(pt, xyzs)[source]

calculate the projected density on the unit sphere

get_contacts()[source]

Compute the spherical images from the neighboring distances

Returns:

[N, 3] array, (theta, phi, eng)

Return type:

pts

get_molecules()[source]

compute the spherical images from neighboring molecules

Returns:

[N, 3] array, (theta, phi, eng)

Return type:

pts

get_similarity(sph2, M=6, cutoff=0.95)[source]

Compute the similarity matrix between two sphs

Parameters:
  • sph2 – the 2nd sph class

  • M – number of power in quasi random sampling

  • cutoff – cutoff similarity to terminate search early

plot_real_image(id=0)[source]

Plot the real molecular contacts in the crystal

plot_sph_images(lmax=None, figname=None, molecule=False)[source]

Plot the spherical images in both 3d and 2d

Parameters:
  • lmax – maximum truncation

  • figname – name of figure file

  • molecule – draw 2D molecule diagram or not

pysh
rotate(alpha=0, beta=0, gamma=0)[source]

uniformly rotate the coefs

Parameters:
  • alpha – rotation in degrees

  • beta – rotation in degress

  • gamma – rotation in degress

pyxtal.descriptor.xyz2sph(xyzs, radian=True)[source]

Convert vectors (x, y, z) to spherical coordinates (theta, phi)

Parameters:
  • xyzs – numpy array of 3D Cartesian coordinates

  • radian – If True, return angles in radians. If False, return in degrees (default True)

Returns:

numpy array of shape (N, 2) containing (theta, phi) angles

Return type:

pts