.. index:: pair: class; aux::Distance .. _doxid-classaux_1_1_distance: class aux::Distance =================== .. toctree:: :hidden: Overview ~~~~~~~~ Methods to calculate distances between atoms. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class Distance { public: // construction :target:`Distance`(); virtual :target:`~Distance`(); // methods void :ref:`dist_max1Dlog`(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, :ref:`gpr::FieldMatrixd`& dist); void :ref:`dist_rmsd`(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, :ref:`gpr::FieldMatrixd`& dist); void :ref:`dist_at`(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, const :ref:`gpr::FieldMatrixd`& lengthscale, :ref:`gpr::FieldMatrixd`& dist, bool take_sqrt = true); double :ref:`range_at`(const :ref:`gpr::Coord`& positions, const :ref:`gpr::AtomsConfiguration`& conf_info, const :ref:`gpr::FieldMatrixd`& lengthscale); void :ref:`dist_at_vec`(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, const :ref:`gpr::FieldMatrixd`& lengthscale, std::vector<:ref:`gpr::FieldMatrixd`>& dist); void :ref:`mindist_interatomic`(const :ref:`gpr::Coord`& x, const :ref:`gpr::AtomsConfiguration`& conf_info, :ref:`gpr::FieldMatrixd`& dist); void :ref:`dist_emd`(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, :ref:`gpr::FieldMatrixd`& dist); void :ref:`cacheInverseDistances`(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info); void :ref:`dist_at_cached`(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, const :ref:`gpr::FieldMatrixd`& lengthscale, :ref:`gpr::FieldMatrixd`& dist); void :ref:`dist_at_cached_sq`(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, const :ref:`gpr::FieldMatrixd`& lengthscale, :ref:`gpr::FieldMatrixd`& dist_sq); bool :target:`hasCachedDistances`() const; void :target:`clearCache`(); void :ref:`setFarFieldRadius`(double radius); double :target:`farFieldRadius`() const; void :ref:`setRadialFarFieldList`(bool enabled); bool :target:`radialFarFieldList`() const; std::uint64_t :ref:`radialListEntries`() const; bool :ref:`selectsRadialFarField`(const :ref:`gpr::AtomsConfiguration`& conf) const; }; .. _details-classaux_1_1_distance: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Methods to calculate distances between atoms. Methods ------- .. index:: pair: function; dist_max1Dlog .. _doxid-classaux_1_1_distance_1a5c0ddf1c7473aa2e5e3aff00786d5fc9: .. ref-code-block:: cpp :class: doxyrest-title-code-block void dist_max1Dlog(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, :ref:`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,...]. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - 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 * 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: pairtype indices for active frozen atoms (1 x N_fro) * conf_info.pairtype: pairtype indices for pairs of atomtypes (n_at x n_at) * conf_info.n_pt: number of active pairtypes * - dist - Matrix including the "distances" from configurations C to configurations C' (n1 x n2) .. index:: pair: function; dist_rmsd .. _doxid-classaux_1_1_distance_1af6603d2af089c8340f4b71307ac8338d: .. ref-code-block:: cpp :class: doxyrest-title-code-block void dist_rmsd(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, :ref:`gpr::FieldMatrixd`& dist) Calculates the aligned Root Mean Square Deviation (RMSD) between sets of configurations. .. index:: pair: function; dist_at .. _doxid-classaux_1_1_distance_1a5b4bfc0128ce94f106043cd3ca9eb7f5: .. ref-code-block:: cpp :class: doxyrest-title-code-block void dist_at(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, const :ref:`gpr::FieldMatrixd`& lengthscale, :ref:`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` ArrayXd map. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - 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 .. index:: pair: function; range_at .. _doxid-classaux_1_1_distance_1aefd0ab2c944317cf64db61130d6e12e4: .. ref-code-block:: cpp :class: doxyrest-title-code-block double range_at(const :ref:`gpr::Coord`& positions, const :ref:`gpr::AtomsConfiguration`& conf_info, const :ref:`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. .. index:: pair: function; dist_at_vec .. _doxid-classaux_1_1_distance_1a40c8330f0ae61e64f7501071214a20a3: .. ref-code-block:: cpp :class: doxyrest-title-code-block void dist_at_vec(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, const :ref:`gpr::FieldMatrixd`& lengthscale, std::vector<:ref:`gpr::FieldMatrixd`>& dist) Similar to *dist_at* but calculates vector of distances for every pair of moving and frozen atoms. .. note:: Same pre-computation optimisations as dist_at: x2 inverse distances are computed once per atom pair, frozen positions are cached outside inner loops. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - 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. .. index:: pair: function; mindist_interatomic .. _doxid-classaux_1_1_distance_1a958fb3c094ea8a93df6dbad45ccafdc4: .. ref-code-block:: cpp :class: doxyrest-title-code-block void mindist_interatomic(const :ref:`gpr::Coord`& x, const :ref:`gpr::AtomsConfiguration`& conf_info, :ref:`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,...]. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - 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 * 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: pairtype indices for active frozen atoms (1 x N_fro) * conf_info.pairtype: pairtype indices for pairs of atomtypes (n_at x n_at) * conf_info.n_pt: number of active pairtypes * - dist - matrix including the minimum interatomic distances for each moving atom in configurations C (n x N_mov) .. index:: pair: function; dist_emd .. _doxid-classaux_1_1_distance_1a96d62a9905d06ae709f1d5c21aaedc81: .. ref-code-block:: cpp :class: doxyrest-title-code-block void dist_emd(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, :ref:`gpr::FieldMatrixd`& dist) Calculates the Earth Mover's :ref:`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. .. index:: pair: function; cacheInverseDistances .. _doxid-classaux_1_1_distance_1a446978d1aa79c76142645bef570e3051: .. ref-code-block:: cpp :class: doxyrest-title-code-block void cacheInverseDistances(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`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 :ref:`dist_at_cached() ` will reuse the cached 1/r values and only apply the lengthscale weighting. .. index:: pair: function; dist_at_cached .. _doxid-classaux_1_1_distance_1a35611165570d0865c08d7267369304b6: .. ref-code-block:: cpp :class: doxyrest-title-code-block void dist_at_cached(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, const :ref:`gpr::FieldMatrixd`& lengthscale, :ref:`gpr::FieldMatrixd`& dist) Compute dist_at using cached inverse distances. Requires a prior call to :ref:`cacheInverseDistances() ` with the same positions. Only recomputes the lengthscale-weighted sum. Falls back to :ref:`dist_at() ` if cache is invalid. .. index:: pair: function; dist_at_cached_sq .. _doxid-classaux_1_1_distance_1a0fabb7c2a08b7821fedfdf369fced929: .. ref-code-block:: cpp :class: doxyrest-title-code-block void dist_at_cached_sq(const :ref:`gpr::Coord`& x1, const :ref:`gpr::Coord`& x2, const :ref:`gpr::AtomsConfiguration`& conf_info, const :ref:`gpr::FieldMatrixd`& lengthscale, :ref:`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. .. index:: pair: function; setFarFieldRadius .. _doxid-classaux_1_1_distance_1ae5fc46a30e3ecbebd8f709b3d5cd8ff7: .. ref-code-block:: cpp :class: doxyrest-title-code-block void 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. .. index:: pair: function; setRadialFarFieldList .. _doxid-classaux_1_1_distance_1a6116ee219066b7e57a37377b9fc87186: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setRadialFarFieldList(bool enabled) 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. .. index:: pair: function; radialListEntries .. _doxid-classaux_1_1_distance_1ae020d9778cbe62132eb91d1ff3774240: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::uint64_t radialListEntries() const Entries to the radial-list branch of dist_at and dist_at_vec. Stays zero while the direct loop is selected. .. index:: pair: function; selectsRadialFarField .. _doxid-classaux_1_1_distance_1a5b8372987b1129900b42f573b7853583: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool selectsRadialFarField(const :ref:`gpr::AtomsConfiguration`& conf) const True when this call uses the radial assembly. A pair cutoff always does. A far-field radius does only after setRadialFarFieldList(true).