gpridge.ase_bridge ================== .. py:module:: gpridge.ase_bridge .. autoapi-nested-parse:: ASE overlay helpers for gpridge step / compute surface. Geometry and oracle wiring shared by :class:`~gpridge.neb.GPNEB`, :mod:`gpridge.session`, and optional pyeonclient bridges. Typical path:: from gpridge.ase_bridge import ( path_matrix_from_images, neb_oracle_from_calculator, apply_gpneb_result, ) Attributes ---------- .. autoapisummary:: gpridge.ase_bridge.ase_potential gpridge.ase_bridge.OracleFn Functions --------- .. autoapisummary:: gpridge.ase_bridge.atoms_config_from_ase gpridge.ase_bridge.observation_from_ase gpridge.ase_bridge.require_ase gpridge.ase_bridge.path_matrix_from_images gpridge.ase_bridge.apply_path_matrix gpridge.ase_bridge.images_from_endpoints gpridge.ase_bridge.neb_oracle_from_calculator gpridge.ase_bridge.dimer_force_fn_from_calculator gpridge.ase_bridge.apply_gpneb_result gpridge.ase_bridge.make_atoms_configuration Module Contents --------------- .. py:function:: atoms_config_from_ase(atoms, frozen_indices=None) Create an :class:`AtomsConfiguration` from an ASE ``Atoms`` object. :param atoms: ASE Atoms object. :type atoms: :py:class:`ase.Atoms` :param frozen_indices: Indices of atoms to mark as frozen. If ``None``, all atoms are treated as moving. :type frozen_indices: :py:class:`array-like` of :py:class:`int`, *optional* :returns: **atoms_config** :rtype: :py:class:`~gpridge._core.AtomsConfiguration` .. py:function:: observation_from_ase(atoms_list) Create an :class:`Observation` from a list of ASE ``Atoms`` objects. Each Atoms object supplies energy and forces via ``atoms.get_potential_energy()`` / ``atoms.get_forces()``. :param atoms_list: Atoms objects with calculators attached. :type atoms_list: :py:class:`list` of :py:class:`ase.Atoms` :returns: **obs** :rtype: :py:class:`~gpridge._core.Observation` .. py:data:: ase_potential .. py:data:: OracleFn Signature of an oracle. It takes flat positions and returns the energy and the flat gradient. .. py:function:: require_ase() Import ASE or raise with install hint. .. py:function:: path_matrix_from_images(images: Sequence[Any]) -> numpy.ndarray Stack ASE Atoms positions into (n_images, 3*n_atoms) float64. .. py:function:: apply_path_matrix(images: Sequence[Any], path: numpy.ndarray, *, energies: Optional[Sequence[float]] = None) -> None Write path matrix rows into ASE Atoms positions (and optional energy info). .. py:function:: images_from_endpoints(reactant: Any, product: Any, n_intermediate: int, *, path_method: str = 'idpp', spring_constant: float = 0.1, sidpp_alpha: float = 0.33) -> List[Any] Build ASE image list from endpoints via C++ path init. :param reactant: ASE Atoms (or objects with get_positions / copy / set_positions). :param product: ASE Atoms (or objects with get_positions / copy / set_positions). :param n_intermediate: Number of interior images (excluding endpoints). :param path_method: linear | idpp | idpp_collective | sidpp | sidpp_geodesic. .. py:function:: neb_oracle_from_calculator(template: Any, calculator: Any, *, gp: Any = None, observers: Any = None) -> OracleFn Build ``(positions_flat) -> (energy, gradient)`` for ``gp_neb`` / ``run_ocineb``. Gradient is ``-forces`` (C++ NEB convention). When *gp* is given, each evaluation is appended via ``gp.add_evaluated_observation``. When *observers* (a :class:`gpridge._observers.OracleObservers`) is given, each evaluation is reported to it. .. py:function:: dimer_force_fn_from_calculator(template: Any, calculator: Any, *, gp: Any = None, observers: Any = None) ``PotentialWrapper`` callback: writes forces in place, returns energy. *gp* and *observers* receive each evaluation as in :func:`neb_oracle_from_calculator`. .. py:function:: apply_gpneb_result(images: Sequence[Any], result: Any) -> None Push ``GPNEBResult`` geometries and energies into ASE images. .. py:function:: make_atoms_configuration(atoms: Any, *, gp_params: Optional[dict] = None, frozen_indices=None) Build and fully initialize :class:`AtomsConfiguration` for gp_neb.