.. index:: pair: namespace; aux .. _doxid-namespaceaux: namespace aux ============= .. toctree:: :hidden: namespace_aux_distance.rst struct_aux_AtomSignature.rst struct_aux_ChainRealignStats.rst struct_aux_EndpointAlignResult.rst struct_aux_InverseDistanceCache.rst struct_aux_LebedevNode.rst struct_aux_OracleOrientation.rst class_aux_AuxiliaryFunctionality.rst class_aux_Distance.rst class_aux_Gradient.rst class_aux_ProblemSetUp.rst Overview ~~~~~~~~ .. ref-code-block:: cpp :class: doxyrest-overview-code-block namespace aux { // namespaces namespace :ref:`aux::distance`; // structs struct :ref:`AtomSignature`; struct :ref:`ChainRealignStats`; struct :ref:`EndpointAlignResult`; struct :ref:`InverseDistanceCache`; struct :ref:`LebedevNode`; struct :ref:`OracleOrientation`; // classes class :ref:`AuxiliaryFunctionality`; class :ref:`Distance`; class :ref:`Gradient`; class :ref:`ProblemSetUp`; // global functions :ref:`ChainRealignStats` :ref:`realignChainToPredecessors`(:ref:`gpr::neb::NEBPath`& path, const std::vector& atomic_numbers, std::vector>* image_ids, double kmax_factor = 1.8); std::pair<:ref:`gpr::Coord`, :ref:`gpr::FieldMatrixIdx`> :target:`get_canonical_configuration`(const :ref:`gpr::Coord`& x_in, const :ref:`gpr::FieldMatrixIdx`& types_in); double :ref:`solve_assignment_problem`(const Eigen::MatrixXd& cost_matrix); std::vector :ref:`solve_assignment_indices`(const Eigen::MatrixXd& cost_matrix); double :target:`calculate_aligned_rmsd`(const :ref:`gpr::Coord`& P, const :ref:`gpr::Coord`& Q); const double* :target:`farFieldCentre`(const :ref:`gpr::AtomsConfiguration`& conf, Eigen::Index atom); void :target:`farFieldDifference`(const :ref:`gpr::geometry::PairBox`& box, const double centre[3], const double left[3], const double right[3], double delta[3]); void :target:`addFarSource`(double tensor[3][3], const double r[3], double weight); double :target:`farQuadratic`(const double tensor[3][3], const double delta[3]); void :target:`farContract`(const double tensor[3][3], const double delta[3], double out[3]); bool :target:`farFromCentre`(const :ref:`gpr::geometry::PairBox`& box, const double centre[3], const double frozen[3], double radius); :ref:`EndpointAlignResult` :ref:`alignProductToReactant`(const Eigen::VectorXd& reactant_positions, const Eigen::VectorXd& product_positions, const std::vector& reactant_types, const std::vector& product_types, double kmax_factor = 1.8); :ref:`EndpointAlignResult` :ref:`alignProductToReactantMinDist`(const Eigen::VectorXd& reactant_positions, const Eigen::VectorXd& product_positions, const std::vector& reactant_types, const std::vector& product_types); Eigen::VectorXd :ref:`unwrapEndpointsMinimumImage`(const Eigen::VectorXd& reactant_positions, const Eigen::VectorXd& product_positions, const std::array& cell); :ref:`EndpointAlignResult` :ref:`alignProductPeriodicMinImage`(const Eigen::VectorXd& reactant_positions, const Eigen::VectorXd& product_positions, const std::vector& reactant_types, const std::vector& product_types, const std::array& cell); Eigen::VectorXd :ref:`kabschAlignProductToReactant`(const Eigen::VectorXd& reactant_positions, const Eigen::VectorXd& product_positions); double :ref:`rigidAlignedRmsd`(const Eigen::VectorXd& reference, const Eigen::VectorXd& mobile); void :target:`lebedevAddOrbit`(std::vector<:ref:`LebedevNode`>& nodes, double x, double y, double z, double weight); std::vector<:ref:`LebedevNode`> :ref:`lebedevLaikovGrid`(int order); double :target:`lebedevWeightSum`(int order); Eigen::Matrix3d :ref:`lebedevNodeRotation`(const :ref:`LebedevNode`& node); :ref:`OracleOrientation` :ref:`orientGeometryForOracle`(const Eigen::VectorXd& positions, const Eigen::VectorXd& reference, const std::vector& types, bool align, double kmax_factor); void :target:`pullForcesToCallerFrame`(double* forces, long n_atoms, const Eigen::Matrix3d& rotation); template void :ref:`averageOverLebedev`(long n_atoms, const double* positions, int order, Eval eval, double* energy, double* forces, double* energy_noise, double* force_noise); } // namespace aux .. _details-namespaceaux: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Global Functions ---------------- .. index:: pair: function; realignChainToPredecessors .. _doxid-namespaceaux_1ae710f657af7ba1bde2e83ed0c8e55a83: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`ChainRealignStats` realignChainToPredecessors(:ref:`gpr::neb::NEBPath`& path, const std::vector& atomic_numbers, std::vector>* image_ids, double kmax_factor = 1.8) IRA-align every interior image of ``path`` onto its predecessor. Sequential sweep i = 1 .. numImages()-2: image i is matched onto the already-processed image i-1, so frames compose along the chain. Endpoints stay untouched (they are fixed by the NEB and the product endpoint already went through the startup endpoint assignment). Identity assignments are skipped entirely (bit-equal no-op), so a drift-free chain passes through unchanged. For a non-identity assignment the image positions become R \* x[perm] + t, the stored gradient (if evaluated) co-rotates as R \* g[perm] (gradients are covariant under rigid motion and follow their atoms under permutation; the energy is invariant), and the per-image id row in ``image_ids`` (when non-null and sized to the path) is permuted alongside so write-out restores the original atom identities. .. index:: pair: function; solve_assignment_problem .. _doxid-namespaceaux_1a5e337d28118f12d3783689a44b587ce5: .. ref-code-block:: cpp :class: doxyrest-title-code-block double solve_assignment_problem(const Eigen::MatrixXd& cost_matrix) Solves the assignment problem using the Hungarian algorithm. Given a cost matrix, this function finds the minimum cost assignment of workers to jobs, which is equivalent to finding the minimum total distance when pairing atoms of the same type. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - cost_matrix - A square matrix where cost_matrix(i, j) is the cost of assigning worker i to job j. .. rubric:: Returns: The minimum total cost of the optimal assignment. .. index:: pair: function; solve_assignment_indices .. _doxid-namespaceaux_1a2f06439d92f8efb5bbc366810e0fc137: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector solve_assignment_indices(const Eigen::MatrixXd& cost_matrix) Like solve_assignment_problem, but returns the optimal assignment. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - cost_matrix - A square matrix where cost_matrix(i, j) is the cost of assigning worker i to job j. .. rubric:: Returns: result[i] = column (job) assigned to row (worker) i. Empty on an empty or non-square / non-finite cost matrix. .. index:: pair: function; alignProductToReactant .. _doxid-namespaceaux_1ab107aa27ed9630498bb90348383f1a27: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`EndpointAlignResult` alignProductToReactant(const Eigen::VectorXd& reactant_positions, const Eigen::VectorXd& product_positions, const std::vector& reactant_types, const std::vector& product_types, double kmax_factor = 1.8) Match the product endpoint onto the reactant frame. Coordinates are flat 3N arrays (xyzxyz), which is exactly the Fortran-side (3, nat) column-major layout libira expects. Types are atomic numbers per endpoint in that endpoint's own file order. kmax_factor is libira_match's km_factor (must exceed 1.0; the IRA examples and eOn's tests use values in [1.0, 10.0], default 1.8). When the assignment comes back as the identity (permutation[i] == i, rotation within 1e-9 of I, translation within 1e-9 of 0) the result sets identity=true and leaves ``aligned`` empty: consistently ordered inputs pass through without picking up floating-point noise from the rotation product. Collinear molecules (e.g. HCN) have no IRA rotation basis, so libira_match reports "no basis could be found"; the helper then falls back to libira_cshda_svd (geometric-center CShDA assignment + single-shot SVD), which resolves permutations and translations in an already rotation-consistent frame exactly the scrambled-order endpoint case. .. index:: pair: function; alignProductToReactantMinDist .. _doxid-namespaceaux_1a65721d90293e46ee93c1ddfcf2622a8e: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`EndpointAlignResult` alignProductToReactantMinDist(const Eigen::VectorXd& reactant_positions, const Eigen::VectorXd& product_positions, const std::vector& reactant_types, const std::vector& product_types) Endpoint correspondence by minimum total displacement, computed consistently. Anchors the rigid alignment to the IDENTITY atom correspondence (a Kabsch rotation over the input pairing), then solves the type-constrained minimum-total-distance assignment (Hungarian) in that fixed frame. Decoupling the rotation from the permutation is what makes the result consistent: a free-rotation RMSD/Hausdorff search (IRA) co-optimises both and shuffles a reaction's equivalent atoms into a lower-score but chemically wrong reordering. Minimising total distance in the identity-anchored frame re-pairs atoms that are closer to a different partner; the re-pairing is kept only when the permutation maps the covalent bond graph (Cordero radii, 1.2 tolerance) of the reactant or of the product onto itself, so equivalent atoms of an endpoint may be renamed while the reaction stays that of the supplied ordering. Endpoints that do not list the same elements in the same order have no supplied correspondence and take the assignment. Needs no IRA: pure :ref:`Eigen ` Kabsch + Hungarian, so it is always available and deterministic. Returns identity=true for a bit-equal pass-through. .. index:: pair: function; unwrapEndpointsMinimumImage .. _doxid-namespaceaux_1a7060ee136d6eb50149d2685d383316af: .. ref-code-block:: cpp :class: doxyrest-title-code-block Eigen::VectorXd unwrapEndpointsMinimumImage(const Eigen::VectorXd& reactant_positions, const Eigen::VectorXd& product_positions, const std::array& cell) Place each product atom on the minimum image relative to the reactant atom in the same slot. No rotation and no permutation: a periodic cell is not free to rotate, and a fixed atom stays on its site. .. index:: pair: function; alignProductPeriodicMinImage .. _doxid-namespaceaux_1a1cba3db93c8451f5bbdd7775efc1e521: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`EndpointAlignResult` alignProductPeriodicMinImage(const Eigen::VectorXd& reactant_positions, const Eigen::VectorXd& product_positions, const std::vector& reactant_types, const std::vector& product_types, const std::array& cell) Same correspondence as alignProductToReactantMinDist, with minimum-image distances and no rigid rotation. ``aligned`` is the unwrapped product. .. index:: pair: function; kabschAlignProductToReactant .. _doxid-namespaceaux_1a139e4dffad31a4b78018347099ef66c0: .. ref-code-block:: cpp :class: doxyrest-title-code-block Eigen::VectorXd kabschAlignProductToReactant(const Eigen::VectorXd& reactant_positions, const Eigen::VectorXd& product_positions) Rigid (rotation + translation) alignment of the product endpoint onto the reactant frame using the identity atom correspondence (rgmin's rgmin_rigid_align, the Horn quaternion solution of the Wahba problem, over flat 3N xyzxyz coordinates). Unlike alignProductToReactant this never permutes atoms. A reaction whose endpoints are written in a rotated or translated frame (e.g. a .con where the heavy atoms appear swapped end-to-end, as in the HCN / HNC isomerisation) still interpolates physically because the rigid transform removes the spurious frame difference; at the same time the input atom identities are preserved, so a reaction whose endpoints share an atom-type multiset (the migrating vs spectator hydrogens of a tautomerisation) is never re-indexed into a different reaction. Rigid motion is an energy-invariant symmetry operation, so the product's internal geometry is unchanged. Returns the flat 3N aligned product. On a size mismatch or an empty / non-multiple-of-three input the product is returned unchanged. .. index:: pair: function; rigidAlignedRmsd .. _doxid-namespaceaux_1ae5ea4b82fb6bd7593a0d8d213627bfd6: .. ref-code-block:: cpp :class: doxyrest-title-code-block double rigidAlignedRmsd(const Eigen::VectorXd& reference, const Eigen::VectorXd& mobile) RMSD after the same rigid alignment, sqrt(sum_i norm(R m_i + t - r_i)^2 / n_atoms) in the given atom order. NaN on a size mismatch, an empty or non-multiple-of-three input, or a non-finite coordinate. .. index:: pair: function; lebedevLaikovGrid .. _doxid-namespaceaux_1af5ccb23c6cdd8d63a820eb7b23498168: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector<:ref:`LebedevNode`> lebedevLaikovGrid(int order) ``order`` is 6, 14, or 26. Any other value throws. .. index:: pair: function; lebedevNodeRotation .. _doxid-namespaceaux_1ad63a7f6be4e90c7030d403a9f5a6cbae: .. ref-code-block:: cpp :class: doxyrest-title-code-block Eigen::Matrix3d lebedevNodeRotation(const :ref:`LebedevNode`& node) Proper rotation taking e_z to the node. Identity for the north pole. .. index:: pair: function; orientGeometryForOracle .. _doxid-namespaceaux_1aada6d10e141cf96653bf80e3ce11c090: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`OracleOrientation` orientGeometryForOracle(const Eigen::VectorXd& positions, const Eigen::VectorXd& reference, const std::vector& types, bool align, double kmax_factor) Rigid frame for one oracle energy evaluation. When ``align`` is false the returned coordinates are ``positions`` unchanged (a rotated copy of an identical geometry stays rotated). When ``align`` is true, IRA matches ``positions`` onto ``reference``. A non-identity atom permutation is rejected and the identity-paired Kabsch rotation is used instead, so a reacting image is never reindexed. An identity match returns ``positions`` bit-equal. .. index:: pair: function; averageOverLebedev .. _doxid-namespaceaux_1a28fa7766d7056f2ff16f9e9937185630: .. ref-code-block:: cpp :class: doxyrest-title-code-block template void averageOverLebedev(long n_atoms, const double* positions, int order, Eval eval, double* energy, double* forces, double* energy_noise, double* force_noise) Weighted mean of evaluations at the Lebedev node rotations. ``eval(pos, forces, energy, energy_noise, force_noise)`` sees one rotated copy; forces it writes are in that copy's frame.