matador.fingerprints package

Submodules

matador.fingerprints.fingerprint module

This file implements the base class for all “fingerprints”, which here refers to any object derived from purely structural features of a crystal, e.g. pair distribution functions (PDF) or simulated powder X-ray diffraction (PXRD) spectra.

matador.fingerprints.fingerprint.njit(f)
class matador.fingerprints.fingerprint.Fingerprint(doc, lazy=True, *args, **kwargs)[source]

Bases: ABC

fingerprint = None
default_key = None
abstract calculate()[source]
class matador.fingerprints.fingerprint.FingerprintFactory(cursor, required_inds=None, debug=False, **fprint_args)[source]

Bases: ABC

This class computes Fingerprint objects from a list of structures, using multiprocessing to perform calculations concurrently. The computed fingerprints are stored in each structure’s dictionary under the default key defined by the Fingerprint objects.

Note

The number of processes used to concurrency is set by the following hierarchy: $SLURM_NTASKS -> $OMP_NUM_THREADS -> psutil.cpu_count(logical=False).

nprocs

number of concurrent processes to be used.

Type:

int

Compute PDFs over n processes, where n is set by either $SLURM_NTASKS, $OMP_NUM_THREADS or physical core count.

Parameters:
  • cursor (list of dict) – list of matador structures

  • fingerprint (Fingerprint) – class to compute for each structure

Keyword Arguments:
  • pdf_args (dict) – arguments to pass to the fingerprint calculator

  • required_inds (list(int)) – indices in cursor to skip.

fingerprint = None
default_key = None

matador.fingerprints.pdf module

This submodule defines classes for computing, combining and convolving pair distribution functions.

matador.fingerprints.pdf.njit(f)
class matador.fingerprints.pdf.PDF(doc, lazy=False, **kwargs)[source]

Bases: Fingerprint

This class implements the calculation and comparison of pair distribution functions.

r_space

1-D array containing real space grid

Type:

ndarray

gr

1-D array containing total PDF

Type:

ndarray

dr

real-space grid spacing in Å

Type:

float

rmax

extent of real-space grid in Å

Type:

float

label

structure label

Type:

str

elem_gr

dict with pairs of element symbol keys, containing 1-D arrays of projected PDFs (if calculated)

Type:

dict

number_density

number density for renormalisation and comparison with other PDFs

Type:

float

kwargs

arguments used to create PDF

Type:

dict

Initialise parameters and run PDF (unless lazy=True).

Parameters:

doc (dict) – matador document to calculate PDF of

Keyword Arguments:
  • dr (float) – bin width for PDF (Angstrom) (DEFAULT: 0.01)

  • gaussian_width (float) – width of Gaussian smearing (Angstrom) (DEFAULT: 0.01)

  • num_images (int/str) – number of unit cell images include in PDF calculation (DEFAULT: ‘auto’)

  • max_num_images (int) – cutoff number of unit cells before crashing (DEFAULT: 50)

  • rmax (float) – maximum distance cutoff for PDF (Angstrom) (DEFAULT: 15)

  • projected (bool) – optionally calculate the element-projected PDF

  • standardize (bool) – standardize cell before calculating PDF

  • lazy (bool) – if True, calculator is not called when initializing PDF object

  • timing (bool) – if True, print the total time taken to calculate the PDF

calc_pdf()[source]

Wrapper to calculate PDF with current settings.

calculate()[source]

Alias for self.calc_pdf.

get_sim_distance(pdf_b, projected=False)[source]

Return the similarity between two PDFs.

pdf()[source]

Return G(r) and the r_space for easy plotting.

plot_projected_pdf(**kwargs)[source]

Plot projected PDFs.

Keyword Arguments:
  • keys (list) – plot only a subset of projections, e.g. [(‘K’, )].

  • other_pdfs (list of PDF) – other PDFs to plot.

plot(**kwargs)[source]

Plot PDFs.

Keyword Arguments:

other_pdfs (list of PDF) – other PDFs to add to the plot.

class matador.fingerprints.pdf.PDFFactory(cursor, required_inds=None, debug=False, **fprint_args)[source]

Bases: FingerprintFactory

This class computes PDF objects from a list of structures, as concurrently as possible. The PDFs are stored under the pdf key inside each structure dict.

nprocs

number of concurrent processes.

Type:

int

Compute PDFs over n processes, where n is set by either $SLURM_NTASKS, $OMP_NUM_THREADS or physical core count.

Parameters:
  • cursor (list of dict) – list of matador structures

  • fingerprint (Fingerprint) – class to compute for each structure

Keyword Arguments:
  • pdf_args (dict) – arguments to pass to the fingerprint calculator

  • required_inds (list(int)) – indices in cursor to skip.

default_key = 'pdf'
fingerprint

alias of PDF

class matador.fingerprints.pdf.PDFOverlap(pdf_a, pdf_b, projected=False)[source]

Bases: object

Calculate the PDFOverlap between two PDF objects, pdf_a and pdf_b, with number density rescaling.

pdf_a

first PDF to compare.

Type:

PDF

pdf_b

second PDF to compare.

Type:

PDF

fine_dr

fine grid scale on which to compare.

Type:

float

similarity_distance

“distance” between PDFs.

Type:

float

overlap_int

the value of the overlap integral.

Type:

float

Perform the overlap and similarity distance calculations.

Parameters:
  • pdf_a (PDF) – first PDF to compare.

  • pdf_b (PDF) – second PDF to compare.

Keyword Arguments:

projected – if True, attempt to use projected PDFs.

pdf_overlap()[source]

Calculate the overlap of two PDFs via a simple meshed sum of their difference.

projected_pdf_overlap()[source]

Calculate the overlap of two projected PDFs via a simple meshed sum of their difference.

plot_diff()[source]

Simple plot for comparing two PDFs.

plot_projected_diff()[source]

Simple plot for comparing two projected PDFs.

class matador.fingerprints.pdf.CombinedProjectedPDF(pdf_cursor)[source]

Bases: object

Take some computed PDFs and add them together.

Create CombinedPDF object from list of PDFs.

Parameters:

pdf_cursor (list of PDF) – list of PDF objects to combine.

plot_projected_pdf()[source]

Plot the combined PDF.

matador.fingerprints.pxrd module

matador.fingerprints.similarity module