matminer.descriptors package¶
Submodules¶
matminer.descriptors.add_descriptors module¶
-
class
matminer.descriptors.add_descriptors.
AddDescriptor
(df, formula_colname='pretty_formula', separator='_')¶ Code to add a descriptor column to a dataframe
-
__init__
(df, formula_colname='pretty_formula', separator='_')¶ - Args:
- df: dataframe to add the descriptor column to formula_colname: (str) name of the column containing the formula/composition separator: (str) separator to use in naming the new descriptor column
Returns: None
-
add_pmgdescriptor_column
(descriptor, stat_function, stat_name)¶ - Args:
- descriptor: (str) name of descriptor - must match the name in the source library stat_function: function to approximate the descriptor. For example, numpy.mean, numpy.std, etc. stat_name: (str) name of stat function to append to new descriptor column name
Returns: dataframe with appended descriptor column
-
matminer.descriptors.bandstructure_features module¶
-
matminer.descriptors.bandstructure_features.
absolute_band_positions_bpe
(bs, target_gap=None, **kwargs)¶ Absolute VBM and CBM positions with respect to branch point energy
- Args:
- bs: Bandstructure object target_gap: if a better band gap is known, shift band positions by this gap **kwargs: arguments to feed into branch point energy code
- Returns:
- (vbm, cbm) - tuple of floats
-
matminer.descriptors.bandstructure_features.
branch_point_energy
(bs, n_vb=1, n_cb=1)¶ Get the branch point energy as defined by: Schleife, Fuchs, Rodi, Furthmuller, Bechstedt, APL 94, 012104 (2009)
- Args:
- bs: (BandStructure) - uniform mesh bandstructure object n_vb: number of valence bands to include n_cb: number of conduction bands to include
Returns: (int) branch point energy on same energy scale as BS eigenvalues
matminer.descriptors.composition_features module¶
-
matminer.descriptors.composition_features.
band_center
(comp)¶ Estimate absolution position of band center using geometric mean of electronegativity Ref: Butler, M. a. & Ginley, D. S. Prediction of Flatband Potentials at Semiconductor-Electrolyte Interfaces from Atomic Electronegativities. J. Electrochem. Soc. 125, 228 (1978).
- Args:
- comp: (Composition)
Returns: (float) band center
-
matminer.descriptors.composition_features.
get_cohesive_energy
(comp)¶ Get cohesive energy of compound by subtracting elemental cohesive energies from the formation energy of the compund. Elemental cohesive energies are taken from http://www.knowledgedoor.com/2/elements_handbook/cohesive_energy.html. Most of them are taken from “Charles Kittel: Introduction to Solid State Physics, 8th edition. Hoboken, NJ: John Wiley & Sons, Inc, 2005, p. 50.”
- Args:
- comp: (str) compound composition, eg: “NaCl”
Returns: (float) cohesive energy of compound
-
matminer.descriptors.composition_features.
get_holder_mean
(data_lst, power)¶ Get Holder mean
- Args:
- data_lst: (list/array) of values power: (int/float) non-zero real number
Returns: Holder mean
-
matminer.descriptors.composition_features.
get_magpie_descriptor
(comp, descriptor_name)¶ Get descriptor data for elements in a compound from the Magpie data repository.
- Args:
comp: (str) compound composition, eg: “NaCl” descriptor_name: name of Magpie descriptor needed. Find the entire list at
Returns: (list) of descriptor values for each atom in the composition
-
matminer.descriptors.composition_features.
get_pymatgen_descriptor
(comp, prop)¶ Get descriptor data for elements in a compound from pymatgen.
- Args:
comp: (str) compound composition, eg: “NaCl” prop: (str) pymatgen element attribute, as defined in the Element class at
Returns: (list) of values containing descriptor floats for each atom in the compound
matminer.descriptors.structure_features module¶
-
matminer.descriptors.structure_features.
get_coulomb_matrix
(struct, diag_elems=False)¶ This function generates the Coulomb matrix, M, of the input structure (or molecule). The Coulomb matrix was put forward by Rupp et al. (Phys. Rev. Lett. 108, 058301, 2012) and is defined by off-diagonal elements M_ij = Z_i*Z_j/|R_i-R_j| and diagonal elements 0.5*Z_i^2.4, where Z_i and R_i denote the nuclear charge and the position of atom i, respectively.
- Args:
struct (Structure or Molecule): input structure (or molecule). diag_elems (bool): flag indicating whether (True) to use
the original definition of the diagonal elements; if set to False (default), the diagonal elements are set to zero.
Returns: (Nsites x Nsites matrix) Coulomb matrix.
-
matminer.descriptors.structure_features.
get_density
(s)¶
-
matminer.descriptors.structure_features.
get_min_relative_distances
(struct, cutoff=10.0)¶ This function determines the relative distance of each site to its closest neighbor. We use the relative distance, f_ij = r_ij / (r^atom_i + r^atom_j), as a measure rather than the absolute distances, r_ij, to account for the fact that different atoms/species have different sizes. The function uses the valence-ionic radius estimator implemented in pymatgen.
- Args:
struct (Structure): input structure. cutoff (float): (absolute) distance up to which tentative closest
neighbors (on the basis of relative distances) are to be determined.- Returns: ([float]) list of all minimum relative distances (i.e., for all
- sites).
-
matminer.descriptors.structure_features.
get_neighbors_of_site_with_index
(struct, n, p=None)¶ Determine the neighbors around the site that has index n in the input Structure object struct, given the approach defined by parameters p. All supported neighbor-finding approaches and listed and explained in the following. All approaches start by creating a tentative list of neighbors using a large cutoff radius defined in parameter dictionary p via key “cutoff”. “min_dist”: find nearest neighbor and its distance d_nn; consider all
neighbors which are within a distance of d_nn * (1 + delta), where delta is an additional parameter provided in the dictionary p via key “delta”.- “scaled_VIRE”: compute the radii, r_i, of all sites on the basis of
- the valence-ionic radius evaluator (VIRE); consider all neighbors for which the distance to the central site is less than the sum of the radii multiplied by an a priori chosen parameter, delta, (i.e., dist < delta * (r_central + r_neighbor)).
- “min_relative_VIRE”: same approach as “min_dist”, except that we
- use relative distances (i.e., distances divided by the sum of the atom radii from VIRE).
- “min_relative_OKeeffe”: same approach as “min_relative_VIRE”, except
- that we use the bond valence parameters from O’Keeffe’s bond valence method (J. Am. Chem. Soc. 1991, 3226-3229) to calculate relative distances.
- Args:
struct (Structure): input structure. n (int): index of site in Structure object for which
neighbors are to be determined.- p (dict): specification (via “approach” key; default is “min_dist”)
- and parameters of neighbor-finding approach. Default cutoff radius is 6 Angstrom (key: “cutoff”). Other default parameters are as follows. min_dist: “delta”: 0.15; min_relative_OKeeffe: “delta”: 0.05; min_relative_VIRE: “delta”: 0.05; scaled_VIRE: “delta”: 2.
- Returns: ([site]) list of sites that are considered to be nearest
- neighbors to site with index n in Structure object struct.
-
matminer.descriptors.structure_features.
get_okeeffe_distance_prediction
(el1, el2)¶ Returns an estimate of the bond valence parameter (bond length) using the derived parameters from ‘Atoms Sizes and Bond Lengths in Molecules and Crystals’ (O’Keeffe & Brese, 1991). The estimate is based on two experimental parameters: r and c. The value for r is based off radius, while c is (usually) the Allred-Rochow electronegativity. Values used are not generated from pymatgen, and are found in ‘okeeffe_params.json’.
- Args:
- el1, el2 (Element): two Element objects
- Returns:
- a float value of the predicted bond length
-
matminer.descriptors.structure_features.
get_okeeffe_params
(el_symbol)¶ Returns the elemental parameters related to atom size and electronegativity which are used for estimating bond-valence parameters (bond length) of pairs of atoms on the basis of data provided in ‘Atoms Sizes and Bond Lengths in Molecules and Crystals’ (O’Keeffe & Brese, 1991).
- Args:
- el_symbol (str): element symbol.
- Returns:
- (dict): atom-size (‘r’) and electronegativity-related (‘c’)
- parameter.
-
matminer.descriptors.structure_features.
get_order_parameter_stats
(struct, pneighs=None, convert_none_to_zero=True, delta_op=0.01)¶ Determine the order parameter statistics accumulated across all sites in Structure object struct using the get_order_parameters function.
- Args:
struct (Structure): input structure. pneighs (dict): specification and parameters of
neighbor-finding approach (see get_neighbors_of_site_with_index function for more details).- convert_none_to_zero (bool): flag indicating whether or not
- to convert None values in OPs to zero (cf., get_order_parameters function).
- delta_op (float): bin size of histogram that is computed
- in order to identify peak locations.
- Returns: ({}) dictionary, the keys of which represent
- the order parameter type (e.g., “bent5”, “tet”, “sq_pyr”) and the values of which are dictionaries carring the statistics (“min”, “max”, “mean”, “std”, “peak1”, “peak2”).
-
matminer.descriptors.structure_features.
get_order_parameters
(struct, pneighs=None, convert_none_to_zero=True)¶ Calculate all order parameters (OPs) for all sites in Structure object struct.
- Args:
struct (Structure): input structure. pneighs (dict): specification and parameters of
neighbor-finding approach (see get_neighbors_of_site_with_index function for more details).- convert_none_to_zero (bool): flag indicating whether or not
- to convert None values in OPs to zero.
- Returns: ([[float]]) matrix of all sites’ (1st dimension)
- order parameters (2nd dimension). 46 order parameters are computed per site: q_cn (coordination number), q_lin, 35 x q_bent (starting with a target angle of 5 degrees and, increasing by 5 degrees, until 175 degrees), q_tet, q_oct, q_bcc, q_2, q_4, q_6, q_reg_tri, q_sq, q_sq_pyr.
-
matminer.descriptors.structure_features.
get_packing_fraction
(s)¶
-
matminer.descriptors.structure_features.
get_prdf
(structure, cutoff=20.0, bin_size=0.1)¶ Compute the partial radial distribution function for a structure
The partial radial distribution function is the radial distibution function broken down for each pair of atom types
The PRDF was proposed as a structural descriptor by [Schutt et al.](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.89.205118)
- Args:
- structure: pymatgen structure object cutoff: (int/float) distance to calculate rdf up to bin_size: (int/float) size of bin to obtain rdf for
- Returns: (tuple) First element is a dict where keys are tuples of element names
- and values are PRDFs,
-
matminer.descriptors.structure_features.
get_rdf
(structure, cutoff=20.0, bin_size=0.1)¶ Calculate rdf fingerprint of a given structure
- Args:
- structure: pymatgen structure object cutoff: (int/float) distance to calculate rdf up to bin_size: (int/float) size of bin to obtain rdf for
Returns: (tuple of ndarray) first element is the normalized RDF, second is the inner radius of the RDF bin
-
matminer.descriptors.structure_features.
get_rdf_peaks
(rdf, rdf_bins, n_peaks=2)¶ Get location of highest peaks in rdf of a structure.
- Args:
- rdf: (ndarray) as output by the function “get_rdf” rdf_bins: (ndarray) inner radius of the rdf bin n_peaks: (int) Number of the top peaks to return
Returns: (ndarray) of distances highest peaks, listed by descending height
-
matminer.descriptors.structure_features.
get_redf
(struct, cutoff=None, dr=0.05)¶ This function permits the calculation of the crystal structure-inherent electronic radial distribution function (ReDF) according to Willighagen et al., Acta Cryst., 2005, B61, 29-36. The ReDF is a structure-integral RDF (i.e., summed over all sites) in which the positions of neighboring sites are weighted by electrostatic interactions inferred from atomic partial charges. Atomic charges are obtained from the ValenceIonicRadiusEvaluator class.
- Args:
struct (Structure): input Structure object. cutoff (float): distance up to which the ReDF is to be
calculated (default: longest diagaonal in primitive cell)dr (float): width of bins (“x”-axis) of ReDF (default: 0.05 A).
- Returns: (dict) a copy of the electronic radial distribution functions (ReDF) as a dictionary. The distance list
- (“x”-axis values of ReDF) can be accessed via key ‘distances’; the ReDF itself via key ‘redf’.
-
matminer.descriptors.structure_features.
get_vol_per_site
(s)¶
-
matminer.descriptors.structure_features.
site_is_of_motif_type
(struct, n, pneighs=None, thresh=None)¶ Returns the motif type of site with index n in structure struct; currently featuring “tetrahedral”, “octahedral”, “bcc”, and “cp” (close-packed: fcc and hcp). If the site is not recognized or if it has been recognized as two different motif types, the function labels the site as “unrecognized”.
- Args:
struct (Structure): input structure. n (int): index of site in Structure object for which motif type
is to be determined.- pneighs (dict): specification and parameters of neighbor-finding
- approach (cf., function get_neighbors_of_site_with_index).
- thresh (dict): thresholds for motif criteria (currently, required
- keys and their default values are “qtet”: 0.5, “qoct”: 0.5, “qbcc”: 0.5, “q6”: 0.4).
Returns: motif type (str).