dynsight.soap.soap_distance¶
- dynsight.soap.soap_distance(v_1, v_2)[source]¶
Computes the Kernel SOAP distance between two SOAP spectra.
The SOAP distance is calculated with:
\[d(\vec{v_1},\vec{v_2}) = \sqrt{2-2\frac{\vec{v_1}\cdot\vec{v_2}}{||\vec{v_1}||\cdot||\vec{v_2}||}}\]This is equivalent to:
\[\begin{split}d(\vec{v_1},\vec{v_2})=\sqrt{2-2\hat{v_1}\cdot\hat{v_2}} = \sqrt{\hat{v_1}\cdot\hat{v_1}+\hat{v_2}\cdot\hat{v_2}-2\hat{v_1} \cdot\hat{v_2}} = \\ \sqrt{(\hat{v_1}-\hat{v_2})\cdot(\hat{v_1}-\hat{v_2})} = ||\hat{v_1}-\hat{v_2}||\end{split}\]This represents the Euclidean distance between the versors.
- Parameters:
v_1 (NDArray[np.float64]) – SOAP spectra.
v_2 (NDArray[np.float64]) – SOAP spectra.
- Returns:
the SOAP distances between the input spectra.
- Return type:
NDArray[np.float64]
Example
import numpy as np import MDAnalysis from dynsight.soap import saponify_trajectory, soap_distance univ = MDAnalysis.Universe(path / "trajectory.xyz") cutoff = 2.0 soap = saponify_trajectory(univ, cutoff, soap_respectpbc=False) soap_dist = soap_distance(soap[0][0], soap[0][1])