gpridge._api ============ .. py:module:: gpridge._api .. autoapi-nested-parse:: Core convenience functions for running GPR dimer searches. Functions --------- .. autoapisummary:: gpridge._api.default_parameters gpridge._api.preset_parameters gpridge._api.default_gpr_parameters gpridge._api.from_rgpot gpridge._api.install_dimer_kernel gpridge._api.run_dimer Module Contents --------------- .. py:function:: default_parameters() Return a dict of all InputParameters, dimer settings included. The dimer keys (separation, rotation and translation methods, tolerances, phase limits) carry the values ``gprd`` runs with, from :func:`gpridge._core.canonical_dimer_parameters`. ``prior_mu``, ``prior_nu``, and ``prior_s2`` default to the published Student-t values (0, 20, and 1), both in the literal dict and in that update. Zero is not a sentinel: the densities divide by ``prior_nu`` and ``prior_s2``. ``initialize()`` copies this initial triple onto the Student-t magnitude, Gaussian length-scale, and log-normal priors; during data-bearing hyperparameter fitting, ``setHyperparameters()`` overwrites Student-t ``s2`` with ``target_variance`` and Gaussian ``s2`` with ``seed_length_scale_**2`` so the scales do not remain shared. The remaining keys are neutral placeholders that a search fills in (coordinates, cell, GP hyperparameters). Modify the returned dict and pass it to :func:`run_dimer`. The keys correspond directly to the ``InputParameters`` struct fields in the C++ code. Array-valued parameters (``R_init``, ``G_init``, ``orient_init``, ``param_trans``, ``dist_sp``, ``cell_dimensions``) must be numpy arrays of the correct size. :returns: **params** -- A dictionary with all default parameter values. :rtype: :py:class:`dict` .. py:function:: preset_parameters(name='default') Return a parameter dict with preset values for common use cases. Presets override specific keys of :func:`default_parameters`: - ``"default"`` -- same as :func:`default_parameters` - ``"fast"`` -- fewer iterations, looser convergence - ``"accurate"`` -- more iterations, tighter convergence :param name: Preset name. :type name: :py:class:`str` :returns: **params** :rtype: :py:class:`dict` .. py:function:: default_gpr_parameters() Return a dict of GP-relevant parameters with sensible defaults. This is the minimal parameter set needed to construct and train a :class:`GaussianProcessRegression` model without running a dimer search. Modify the returned dict and pass it to ``GaussianProcessRegression.initialize()``. :returns: **params** -- Dictionary with GP-specific default parameter values. :rtype: :py:class:`dict` .. py:function:: from_rgpot(pot) Wrap an rgpot-style PES as a :class:`~gpridge.PotentialWrapper`. ``pot`` is a bound ``rgpot::PotentialBase`` or a callable matching rgpot ``operator()``:: pot(positions, atomic_numbers, cell) -> (energy, forces) # or (energy, forces, energy_variance) # or (energy, forces, energy_variance, force_noise_rms) This is the Python hook for ``PotentialWrapper::from_rgpot``. C++ callers use the templated ``from_rgpot(RgPot&)`` / ``from_rgpot(shared_ptr)`` overloads or the C++-only ``from_rgpot(shared_ptr)``. rgpot does not publish nanobind types; a real C++ pot is held through that base. The returned wrapper is the same type-erased PES the CLI attaches. :param pot: Bound C++ PotentialBase, or an rgpot-style callable. :type pot: :py:class:`object` or :py:class:`callable` :rtype: :py:class:`PotentialWrapper` .. py:function:: install_dimer_kernel(dimer, gp, init_data=None) Install a saved kernel onto a dimer that has already been initialized. A path loads that file. A fitted GaussianProcess is written and then loaded, so its hyperparameters move with its rows. An unfitted model with no path leaves the dimer's own kernel in place and does not ask the dimer for a model. A file whose kernel describes a different search leaves that kernel in place too: the seed rows were already given to the dimer, which is how the command-line search treats the same file. .. py:function:: run_dimer(params, initial_obs, mid_point_obs, orientation, atoms_config, potential_fn, *, gp=None, init_data=None) Run an atomic dimer saddle point search. This is a convenience wrapper that creates the C++ objects and executes the GPR dimer algorithm in a single call. :param params: Parameter dictionary. Start from :func:`default_parameters` (which carries the settings ``gprd`` runs with) and override the keys you need. The keys that matter most are: - ``dimer_sep`` -- dimer separation distance - ``T_dimer`` -- force convergence threshold - ``num_bigiter`` -- max outer iterations - ``num_iter`` -- max inner iterations - ``method_rot`` -- rotation method (``"LBFGS_alg"``) - ``method_trans`` -- translation method (``"LBFGS_alg"``) - ``param_trans`` -- ``[step_length, max_step_length]`` - ``cell_dimensions`` -- 3x3 cell as flat 9-element array - ``cell_periodic`` -- periodic axes a, b, c as three ints; the minimum image acts along the periodic ones only :type params: :py:class:`dict` :param initial_obs: Initial observation data. Set ``R`` to the initial coordinates (shape ``(N_obs, 3*N_atoms)``), ``E`` to energies (shape ``(N_obs, 1)``), and ``G`` to gradients (shape ``(N_obs, 3*N_atoms)``). :type initial_obs: :py:class:`~gpridge._core.Observation` :param mid_point_obs: Observation at the dimer mid-point (same field layout as *initial_obs* but with a single row). :type mid_point_obs: :py:class:`~gpridge._core.Observation` :param orientation: Initial dimer orientation, shape ``(1, 3*N_moving)``. :type orientation: :py:class:`numpy.ndarray` :param atoms_config: Atomic configuration. Set ``positions`` (shape ``(1, 3*N_atoms)``), ``is_frozen`` (shape ``(1, N_atoms)``, dtype uint8), ``id`` (shape ``(1, N_atoms)``, dtype uint32), and ``atomic_nrs`` (shape ``(1, N_atoms)``, dtype int32). :type atoms_config: :py:class:`~gpridge._core.AtomsConfiguration` :param potential_fn: An EON-style callback ``fn(positions, atomic_numbers, forces, box) -> energy``, or a :class:`~gpridge.PotentialWrapper` (including one from :func:`from_rgpot`). :type potential_fn: :py:class:`callable` or :py:class:`PotentialWrapper` :returns: **dimer** -- The dimer object after the search. Check ``get_converged()`` and ``get_termination_reason()`` before you use the geometry. Retrieve results with: - ``dimer.get_final_energy()`` - ``dimer.get_final_coord_of_mid_point()`` - ``dimer.get_final_gradient_at_mid_point()`` - ``dimer.get_final_curvature()`` - ``dimer.get_total_force_calls()`` - ``dimer.get_iterations()`` :rtype: :py:class:`AtomicDimer`