gpridge._api

Core convenience functions for running GPR dimer searches.

Functions

default_parameters()

Return a dict of all InputParameters, dimer settings included.

preset_parameters([name])

Return a parameter dict with preset values for common use cases.

default_gpr_parameters()

Return a dict of GP-relevant parameters with sensible defaults.

from_rgpot(pot)

Wrap an rgpot-style PES as a PotentialWrapper.

install_dimer_kernel(dimer, gp[, init_data])

Install a saved kernel onto a dimer that has already been initialized.

run_dimer(params, initial_obs, mid_point_obs, ...[, ...])

Run an atomic dimer saddle point search.

Module Contents

gpridge._api.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 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 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.

Return type:

dict

gpridge._api.preset_parameters(name='default')

Return a parameter dict with preset values for common use cases.

Presets override specific keys of default_parameters():

  • "default" – same as default_parameters()

  • "fast" – fewer iterations, looser convergence

  • "accurate" – more iterations, tighter convergence

Parameters:

name (str) – Preset name.

Returns:

params

Return type:

dict

gpridge._api.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 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.

Return type:

dict

gpridge._api.from_rgpot(pot)

Wrap an rgpot-style PES as a 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<RgPot>) overloads or the C++-only from_rgpot(shared_ptr<rgpot::PotentialBase>). 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.

Parameters:

pot (object or callable) – Bound C++ PotentialBase, or an rgpot-style callable.

Return type:

PotentialWrapper

gpridge._api.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.

gpridge._api.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.

Parameters:
  • params (dict) –

    Parameter dictionary. Start from 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

  • initial_obs (Observation) – 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)).

  • mid_point_obs (Observation) – Observation at the dimer mid-point (same field layout as initial_obs but with a single row).

  • orientation (numpy.ndarray) – Initial dimer orientation, shape (1, 3*N_moving).

  • atoms_config (AtomsConfiguration) – 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).

  • potential_fn (callable or PotentialWrapper) – An EON-style callback fn(positions, atomic_numbers, forces, box) -> energy, or a PotentialWrapper (including one from from_rgpot()).

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()

Return type:

AtomicDimer