kliff.analyzers#

class kliff.analyzers.EnergyForcesRMSE(calculator, energy=True, forces=True)[source]#

Analyzer to compute the root-mean-square error (RMSE) for energy and forces.

The energy difference norm for a configuration is defined as:

e_\text{norm} = |e_\text{pred} - e_\text{ref}| / N,

where e_\text{pred} is the prediction of the total energy from the model, e_\text{ref} is the corresponding reference energy, and N is the number of atoms in the configuration. The division by N is applied only when normalize = True in run. Similarly, the forces difference norm for a configuration is defined as:

f_\text{norm} = || \bm f_\text{pred} - \bm f_\text{ref}|| / N,

where f_\text{pred} is the prediction of the forces on atoms from the model and f_\text{ref} is the corresponding reference forces, N is the number of atoms in the configuration. The division by N is applied only when normalize = True in run.

The RMSEs for energy and forces are defined as:

e_\text{RMSE} = \sqrt{ \frac{\sum_{m=1}^M e_\text{norm}^2}{M}}

and

f_\text{RMSE} = \sqrt{ \frac{\sum_{m=1}^M f_\text{norm}^2}{M}},

in which M is the total number of configurations in the dataset.

run(normalize=True, sort=None, path=None, verbose=1)[source]#

Run the RMSE analyzer.

Parameters
  • normalize (bool) – Whether to normalize the energy (forces) by the number of atoms in a configuration.

  • sort (str (optional)) – Sort per configuration information according to energy or forces. If None, no sort. This works only when per configuration information is requested, i.e. verbose > 0.

  • path (str (optional)) – Path to write out the results. If None, write to stdout, otherwise, write to the file specified by path. Note, if verbose==3, the difference of energy and forces will be written to a directory named energy_forces_RMSE-difference.

  • verbose (int (optional)) – Verbose level of the output info. Available values are: 0, 1, 2. If verbose=0, only output the energy and forces RMSEs for the dataset. If verbose==1, output the norms of the energy and forces for each configuration additionally. If verbose==2, output the difference of the energy and forces for each atom, and the information is written to extended XYZ files with the location specified by path.

class kliff.analyzers.Fisher(calculator)[source]#

Fisher information matrix.

Compute the Fisher information according to

..math::

I_{ij} = sum_m frac{partial bm f_m}{partial theta_i} cdot frac{partial bm f_m}{partial theta_j}

where f_m are the forces on atoms in configuration m, \theta_i is the ith model parameter. Derivatives are computed numerically using Ridders’ algorithm: https://en.wikipedia.org/wiki/Ridders%27_method

Parameters

calculator – A calculator object.

run(verbose=1)[source]#

Compute the Fisher information matrix and the standard deviation.

Parameters

verbose (int) – If 0, do not write out to file; if 1, write to a file named analysis_Fisher_info_matrix.txt.

Returns

  • I (2D array, shape(N, N)) – Fisher information matrix, where N is the number of parameters.

  • I_stdev (2D array, shape(N, N)) – Standard deviation of Fisher information matrix, where N is the number of parameters.