Methods to calculate distances between atoms. More...
#include <gpr/auxiliary/Distance.h>
Public Member Functions | |
| Distance () | |
| virtual | ~Distance () |
| void | dist_max1Dlog (const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, gpr::FieldMatrixd &dist) |
| Give the maximum difference in the logarithmic inter-atomic distances between atomic configurations C and C'. | |
| void | dist_rmsd (const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, gpr::FieldMatrixd &dist) |
| Calculates the aligned Root Mean Square Deviation (RMSD) between sets of configurations. | |
| void | dist_at (const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, const gpr::FieldMatrixd &lengthscale, gpr::FieldMatrixd &dist, bool take_sqrt=true) |
| Give the distance between two atomic configurations as defined in the special GPstuff covariance function 'gpcf_matern32at'. | |
| double | range_at (const gpr::Coord &positions, const gpr::AtomsConfiguration &conf_info, const gpr::FieldMatrixd &lengthscale) |
| void | dist_at_vec (const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, const gpr::FieldMatrixd &lengthscale, std::vector< gpr::FieldMatrixd > &dist) |
| Similar to dist_at but calculates vector of distances for every pair of moving and frozen atoms. | |
| void | mindist_interatomic (const gpr::Coord &x, const gpr::AtomsConfiguration &conf_info, gpr::FieldMatrixd &dist) |
| Give the distance from each moving atom to its nearest neighbour atom in configuration C. | |
| void | dist_emd (const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, gpr::FieldMatrixd &dist) |
| Calculates the Earth Mover's Distance between sets of configurations. | |
| void | cacheInverseDistances (const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info) |
| Pre-compute and cache raw inverse distances for given positions. | |
| void | dist_at_cached (const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, const gpr::FieldMatrixd &lengthscale, gpr::FieldMatrixd &dist) |
| Compute dist_at using cached inverse distances. | |
| void | dist_at_cached_sq (const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, const gpr::FieldMatrixd &lengthscale, gpr::FieldMatrixd &dist_sq) |
| Like dist_at_cached but returns SQUARED distances (skips final sqrt). | |
| bool | hasCachedDistances () const |
| void | clearCache () |
| void | setFarFieldRadius (double radius) |
| double | farFieldRadius () const |
| void | setRadialFarFieldList (bool enabled) |
| bool | radialFarFieldList () const |
| std::uint64_t | radialListEntries () const |
| bool | selectsRadialFarField (const gpr::AtomsConfiguration &conf) const |
Methods to calculate distances between atoms.
Definition at line 154 of file Distance.h.
| aux::Distance::Distance | ( | ) |
Definition at line 295 of file Distance.cpp.
|
virtual |
Definition at line 297 of file Distance.cpp.
| void aux::Distance::cacheInverseDistances | ( | const gpr::Coord & | x1, |
| const gpr::Coord & | x2, | ||
| const gpr::AtomsConfiguration & | conf_info ) |
Pre-compute and cache raw inverse distances for given positions.
Call this once when positions are set (before an optimization loop). Subsequent calls to dist_at_cached() will reuse the cached 1/r values and only apply the lengthscale weighting.
Definition at line 1085 of file Distance.cpp.
|
inline |
Definition at line 354 of file Distance.h.
| void aux::Distance::dist_at | ( | const gpr::Coord & | x1, |
| const gpr::Coord & | x2, | ||
| const gpr::AtomsConfiguration & | conf_info, | ||
| const gpr::FieldMatrixd & | lengthscale, | ||
| gpr::FieldMatrixd & | dist, | ||
| bool | take_sqrt = true ) |
Give the distance between two atomic configurations as defined in the special GPstuff covariance function 'gpcf_matern32at'.
The distance between configurations C and C' is based on the changes of the inter-atomic distances:
dist(C,C') = sqrt(2 SUM_{i<j}{[(1/r_ij-1/r_ij')/l_ij]^2}), where r_ij and r_ij' are the distances between atoms i and j in configurations C and C', respectively, and l_ij is the lengthscale of the corresponding atom pair type.
The input vectors x1 and x2 are assumed to be row vectors including the gpr::Coordinates of the moving atoms: [x_1,y_1,z_1,x_2,y_2,z_2,...].
The parameter 'conf_info' is a structure array including necessary information about the configurations: conf_info.conf_fro: gpr::Coordinates of active frozen atoms (N_fro x 3) conf_info.atomtype_mov: atomtype indices for moving atoms (1 x N_mov) conf_info.atomtype_fro: atomtype indices for active frozen atoms (1 x N_fro) Atomtypes must be indexed as 1,2,...,n_at (may include also inactive atomtypes). conf_info.pairtype: pairtype indices for pairs of atomtypes (n_at x n_at) conf_info.n_pt: number of active pairtypes Active pairtypes are indexed as 0,1,2,...,n_pt-1. Inactive pairtypes are given index -1.
| x1 | gpr::Coordinates of the moving atoms in configurations C (n1 x 3*N_mov) |
| x2 | gpr::Coordinates of the moving atoms in configurations C' (n2 x 3*N_mov) |
| conf_info | structure array including information about the configurations necessary for the GP model |
| lengthscale | lengthscales for different atom pair types (1 x n_pt) |
| dist | matrix including the distances between configurations C and C' (n1 x n2) |
| take_sqrt | Return distances when true and squared distances otherwise |
Definition at line 620 of file Distance.cpp.
| void aux::Distance::dist_at_cached | ( | const gpr::Coord & | x1, |
| const gpr::Coord & | x2, | ||
| const gpr::AtomsConfiguration & | conf_info, | ||
| const gpr::FieldMatrixd & | lengthscale, | ||
| gpr::FieldMatrixd & | dist ) |
Compute dist_at using cached inverse distances.
Requires a prior call to cacheInverseDistances() with the same positions. Only recomputes the lengthscale-weighted sum. Falls back to dist_at() if cache is invalid.
Definition at line 1214 of file Distance.cpp.
| void aux::Distance::dist_at_cached_sq | ( | const gpr::Coord & | x1, |
| const gpr::Coord & | x2, | ||
| const gpr::AtomsConfiguration & | conf_info, | ||
| const gpr::FieldMatrixd & | lengthscale, | ||
| gpr::FieldMatrixd & | dist_sq ) |
Like dist_at_cached but returns SQUARED distances (skips final sqrt).
The SexpatCF covariance kernels take these to avoid the sqrt + square roundtrip.
Definition at line 1230 of file Distance.cpp.
| void aux::Distance::dist_at_vec | ( | const gpr::Coord & | x1, |
| const gpr::Coord & | x2, | ||
| const gpr::AtomsConfiguration & | conf_info, | ||
| const gpr::FieldMatrixd & | lengthscale, | ||
| std::vector< gpr::FieldMatrixd > & | dist ) |
Similar to dist_at but calculates vector of distances for every pair of moving and frozen atoms.
| x1 | First set of configurations, with moving coordinates in each row. |
| x2 | Second set of configurations, with frozen coordinates in each row. |
| conf_info | Atom counts and pair-type metadata for the structures. |
| lengthscale | Length scale associated with each pair type. |
| dist | Output distance matrices organized by pair type. |
Definition at line 796 of file Distance.cpp.
| void aux::Distance::dist_emd | ( | const gpr::Coord & | x1, |
| const gpr::Coord & | x2, | ||
| const gpr::AtomsConfiguration & | conf_info, | ||
| gpr::FieldMatrixd & | dist ) |
Calculates the Earth Mover's Distance between sets of configurations.
This method is fully permutation-invariant without needing a canonicalization step. It solves the assignment problem for each atom type to find the minimum "work" required to transform one configuration into another.
Definition at line 1018 of file Distance.cpp.
| void aux::Distance::dist_max1Dlog | ( | const gpr::Coord & | x1, |
| const gpr::Coord & | x2, | ||
| const gpr::AtomsConfiguration & | conf_info, | ||
| gpr::FieldMatrixd & | dist ) |
Give the maximum difference in the logarithmic inter-atomic distances between atomic configurations C and C'.
It returns the maximum absolute logarithmic change in any interatomic distance. For atoms i,j this is abs(log(r_ij'/r_ij)), where r_ij and r_ij' are their distances in configurations C and C'.
The input vectors x1 and x2 are assumed to be row vectors including the gpr::Coordinates of the moving atoms: [x_1,y_1,z_1,x_2,y_2,z_2,...].
| x1 | gpr::Coordinates of the moving atoms in configurations C (n1 x 3*N_mov) |
| x2 | gpr::Coordinates of the moving atoms in configurations C' (n2 x 3*N_mov) |
| conf_info | Structure array including information about the configurations necessary for the GP model
|
| dist | Matrix including the "distances" from configurations C to configurations C' (n1 x n2) |
Definition at line 462 of file Distance.cpp.
| void aux::Distance::dist_rmsd | ( | const gpr::Coord & | x1, |
| const gpr::Coord & | x2, | ||
| const gpr::AtomsConfiguration & | conf_info, | ||
| gpr::FieldMatrixd & | dist ) |
Calculates the aligned Root Mean Square Deviation (RMSD) between sets of configurations.
Definition at line 410 of file Distance.cpp.
|
inlinenodiscard |
Definition at line 363 of file Distance.h.
|
inline |
Definition at line 350 of file Distance.h.
| void aux::Distance::mindist_interatomic | ( | const gpr::Coord & | x, |
| const gpr::AtomsConfiguration & | conf_info, | ||
| gpr::FieldMatrixd & | dist ) |
Give the distance from each moving atom to its nearest neighbour atom in configuration C.
The input vectors in x are assumed to be row vectors including the gpr::Coordinates of the moving atoms: [x_1,y_1,z_1,x_2,y_2,z_2,...].
| x | gpr::Coordinates of the moving atoms in configurations C (n x 3*N_mov) |
| conf_info | structure array including information about the configurations necessary for the GP model
|
| dist | matrix including the minimum interatomic distances for each moving atom in configurations C (n x N_mov) |
Definition at line 958 of file Distance.cpp.
|
inlinenodiscard |
Definition at line 377 of file Distance.h.
|
inlinenodiscard |
Entries to the radial-list branch of dist_at and dist_at_vec. Stays zero while the direct loop is selected.
Definition at line 384 of file Distance.h.
| double aux::Distance::range_at | ( | const gpr::Coord & | positions, |
| const gpr::AtomsConfiguration & | conf_info, | ||
| const gpr::FieldMatrixd & | lengthscale ) |
Maximum pair-feature distance over the distinct coordinate rows. Observation/channel tags after the moving coordinates are ignored. Repeated energy and gradient rows do not enlarge the geometry work.
Definition at line 533 of file Distance.cpp.
|
inlinenodiscard |
True when this call uses the radial assembly. A pair cutoff always does. A far-field radius does only after setRadialFarFieldList(true).
Definition at line 391 of file Distance.h.
| void aux::Distance::setFarFieldRadius | ( | double | radius | ) |
Moving-frozen pairs at or beyond radius from atoms_mov.positions use the dipole tensor about that fixed model reference. Query coordinates use its local minimum-image chart. Zero keeps every pair exact.
Definition at line 299 of file Distance.cpp.
|
inline |
The radial far-field list is opt-in. The direct loop is the default at every size. The list is slower than that loop at every size measured in docs/verification/far-field-ladder.txt, from 63 through 32000 atoms. Nothing above 32000 atoms was measured.
Definition at line 372 of file Distance.h.