pyxtal.descriptor module

Module for crystal packing descriptor from energy decomposition

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

convert the x, y, z to spherical coordinates (phi, theta, r) phi: [-pi, pi] theta: [-pi/2, pi/2]

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:important points (pts;) –
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=[4, 6])[source]

Computes :param center: center xyz coordinate :param neighbors: a list of neighboring xyz coordinates :param weights: a list of weights for each neighbor

Returns:
numpy array(complex128), the complex vector qlm normalized
by the number of nearest neighbors
Return type:q
pyxtal.descriptor.sph2cart(phi, theta, r)[source]

convert spherical coordinates (phi, theta, r) to Cartesian (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

A class to handle the crystal packing descriptor from spherical image

Parameters:
  • xtal – pyxtal structure
  • model – ‘molecule’ or ‘contact’
  • max_d – maximum intermolecular distances
  • lmax – maximum bandwidth for spherical harmonic expansion
  • sigma – Gaussian width to project into the unit sphere
  • N – number of grid points on the unit sphere
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
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 the vectors (x, y, z) to the sphere representation (theta, phi)

Parameters:
  • xyzs – 3D xyz coordinates
  • radian – return in radian (otherwise degree)