MLIP evaluation functions
Helpers for evaluating machine-learned interatomic potentials: dimer-curve energy prediction, energy/force prediction over a list of structures, and parity plots against reference data.
eval_plot(reference_data, predicted_data, ax=None)
Plot a density-colored parity plot of predicted vs. reference data, annotated with RMSE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference_data
|
array - like
|
The reference (e.g. DFT) values. |
required |
predicted_data
|
array - like
|
The predicted (e.g. MLIP) values. |
required |
ax
|
Axes
|
Axes to plot on. Defaults to the current axes. |
None
|
Returns:
| Type | Description |
|---|---|
|
matplotlib.collections.PathCollection: The scatter plot artist. |
Source code in src/vitrum/mlip_functions.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
get_dimer_radial_energy(calc, formula, cutoff=8, num_data_points=100)
Calculate the predicted energy of a dimer as a function of separation distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
calc
|
Calculator
|
The (MLIP) calculator to evaluate energies with. |
required |
formula
|
str
|
The two-atom chemical formula of the dimer, e.g. "OO". |
required |
cutoff
|
float
|
Maximum separation distance to sample, in Angstrom. Defaults to 8. |
8
|
num_data_points
|
int
|
Number of distances to sample between 0.1 and cutoff. Defaults to 100. |
100
|
Returns:
| Type | Description |
|---|---|
|
Tuple[np.ndarray, List[float]]: The sampled distances and the corresponding predicted energies. |
Source code in src/vitrum/mlip_functions.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
get_pred_energy_forces(atoms, calc)
Calculate predicted per-atom energies and forces for a list of structures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
atoms
|
List[Atoms]
|
The structures to evaluate. |
required |
calc
|
Calculator
|
The (MLIP) calculator to evaluate energies/forces with. |
required |
Returns:
| Type | Description |
|---|---|
|
Tuple[List[float], np.ndarray]: Per-structure energy per atom, and a flattened array of all predicted forces. |
Source code in src/vitrum/mlip_functions.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
min_max_val(array1, array2)
Find the combined minimum and maximum value across two arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array1
|
array - like
|
The first array. |
required |
array2
|
array - like
|
The second array. |
required |
Returns:
| Type | Description |
|---|---|
|
List[float]: A two-element list, [min_val, max_val]. |
Source code in src/vitrum/mlip_functions.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |