kliff.legacy.descriptors¶
- class kliff.legacy.descriptors.Descriptor(cut_dists, cut_name, hyperparams, normalize=True, dtype=<class 'numpy.float32'>)[source]¶
Base class of atomic environment descriptors.
Process dataset to generate fingerprints. This is the base class for all descriptors, so it should not be used directly. Instead, descriptors built on top of this such as
SymmetryFunctionandBispectrumcan be used to transform the atomic environment information into fingerprints.- Parameters:
cut_dists (
Dict[str,float]) – Cutoff distances, with key of the form A-B where A and B are species string, and value should be a float. Example: cut_dists = {‘C-C’: 5.0}cut_name (
str) – Name of the cutoff function, such as cos, P3, and P7.hyperparams (
Union[Dict,str]) – A dictionary of the hyperparams of the descriptor or a string to select the predefined hyperparams.normalize (
bool) – If True, the fingerprints is centered and normalized: zeta = (zeta - mean(zeta)) / stdev(zeta)dtype – np.dtype Data type of the generated fingerprints, such as np.float32 and np.float64.
- size¶
int Length of the fingerprint vector.
- mean¶
list Mean of the fingerprints.
- stdev¶
list Standard deviation of the fingerprints.
- generate_fingerprints(configs, fit_forces=False, fit_stress=False, fingerprints_filename='fingerprints.pkl', fingerprints_mean_stdev_filename=None, use_welford_method=False, nprocs=1)[source]¶
Convert all configurations to their fingerprints.
- Parameters:
configs (
List[Configuration]) – Dataset configurationsfit_forces (
bool) – Whether to compute the gradient of fingerprints w.r.t. atomic coordinates so as to compute forces.fit_stress (
bool) – Whether to compute the gradient of fingerprints w.r.t. atomic coordinates so as to compute stress.use_welford_method (
bool) – Whether to compute mean and standard deviation using the Welford method, which is memory efficient. See https://en.wikipedia.org/wiki/Algorithms_for_calculating_variancefingerprints_filename (
Union[Path,str]) – Path to dump fingerprints to a pickle file.fingerprints_mean_stdev_filename (
Union[str,Path,None]) – Path to dump the mean and standard deviation of the fingerprints as a pickle file. If normalize=False for the descriptor, this is ignored.nprocs (
int) – Number of processes used to generate the fingerprints. If 1, run in serial mode, otherwise nprocs processes will be forked via multiprocessing to do the work.
- transform(conf, fit_forces=False, fit_stress=False)[source]¶
Transform atomic coords to atomic environment descriptor values.
- Parameters:
conf (
Configuration) – atomic configurationfit_forces (
bool) – Whether to fit forces, so as to compute gradients of fingerprints w.r.t. coordsfit_stress (
bool) – Whether to fit stress, so as to compute gradients of fingerprints w.r.t. coords
- Returns:
- Descriptor values. 2D array with shape (num_atoms, num_descriptors),
where num_atoms is the number of atoms in the configuration, and num_descriptors is the size of the descriptor vector (depending on the choice of the hyperparameters).
- dzeta_dr: Gradient of the descriptor w.r.t. atomic coordinates. 4D array if
grad is True, otherwise None. Shape: (num_atoms, num_descriptors, num_atoms, 3), where num_atoms and num_descriptors has the same meanings as described in zeta, and 3 denotes the 3D space for the Cartesian coordinates.
- dzeta_ds: Gradient of the descriptor w.r.t. virial stress component. 2D
array of shape (num_atoms, num_descriptors, 6), where num_atoms and num_descriptors has the same meanings as described in zeta, and 6 denote the virial stress component in Voigt notation, see https://en.wikipedia.org/wiki/Voigt_notation
- Return type:
zeta