chemparseplot.parse.trajectory.hdf5#

HDF5 NEB reader for ChemGP and gpridge output.

Added in version 1.2.0.

Changed in version 1.15.0: Every reader also takes a gpridge band.h5 and detects the layout from the groups present (:func:chemparseplot.parse.trajectory.band_h5.detect_layout). The readers take atomic_numbers and cell for files that store neither.

Reads neb_result.h5 (final converged path) and neb_history.h5 (per-step optimization history) produced by ChemGP’s Julia NEB optimizer.

These files contain pre-computed f_para and rxn_coord, so profile data can be read directly without recomputing the Henkelman-Jonsson tangent.

A gpridge band.h5 holds the converged band and every oracle evaluation of the run, but no per-step bands. Its f_para and rxn_coord are computed from the band, and its history is that one band. Its oracle evaluations can join a landscape (:func:observations_to_landscape_df).

Module Contents#

Functions#

_read_path_group

Extract arrays from an HDF5 path group.

_read_metadata_group

Read scalar/array metadata from an optional HDF5 metadata group.

_reconstruct_atoms

Rebuild ASE Atoms from flattened positions and metadata.

_path_to_profile_dat

Convert a typed path payload to eOn-style profile data.

_path_to_atoms_list

Reconstruct ASE atoms from a typed path payload and metadata.

_gpridge_result

A gpridge band as a ChemGP-shaped result, with computed path coordinates.

_is_gpridge

_with_structure

load_neb_result

Read a ChemGP neb_result.h5 file or a gpridge band.h5.

load_neb_history

Read a ChemGP neb_history.h5 file.

result_to_profile_dat

Convert a result HDF5 to a (5, N) profile array.

result_to_atoms_list

Reconstruct ASE Atoms from a result HDF5 file.

history_to_profile_dats

Convert a history HDF5 to a list of (5, N) profile arrays.

_ira_instance

_rmsd_gradient_projection

Least-squares (dE/dr, dE/dp) from Cartesian gradients.

observations_to_landscape_df

Place oracle evaluations on the RMSD landscape of a band.

history_to_landscape_df

Convert a history HDF5 to a landscape DataFrame.

Data#

API#

chemparseplot.parse.trajectory.hdf5.log#

‘getLogger(…)’

chemparseplot.parse.trajectory.hdf5.OBSERVATION_STEP#

None

chemparseplot.parse.trajectory.hdf5._read_path_group(grp: h5py.Group) → chemparseplot.parse.types.TrajectoryNebPath#

Extract arrays from an HDF5 path group.

Parameters:

grp – An h5py Group containing images, energies, gradients, f_para, and rxn_coord datasets.

Returns:

Named mapping with numpy arrays for each field.

chemparseplot.parse.trajectory.hdf5._read_metadata_group(grp: h5py.Group | None) → chemparseplot.parse.types.ParserAttrs#

Read scalar/array metadata from an optional HDF5 metadata group.

chemparseplot.parse.trajectory.hdf5._reconstruct_atoms(images: numpy.ndarray, atomic_numbers: numpy.ndarray | None, cell: numpy.ndarray | None, gradients: numpy.ndarray, energies: numpy.ndarray) → list[ase.Atoms]#

Rebuild ASE Atoms from flattened positions and metadata.

Each image’s positions are (ndof,) where ndof = 3 * n_atoms. A SinglePointCalculator is attached with energy and forces (-gradients).

Parameters:
  • images – Array of shape (n_images, ndof).

  • atomic_numbers – Optional array of shape (n_atoms,).

  • cell – Optional array of shape (9,) (flattened 3x3 cell).

  • gradients – Array of shape (n_images, ndof).

  • energies – Array of shape (n_images,).

Returns:

List of ASE Atoms objects with calculators attached.

chemparseplot.parse.trajectory.hdf5._path_to_profile_dat(path: chemparseplot.parse.types.TrajectoryNebPath) → numpy.ndarray#

Convert a typed path payload to eOn-style profile data.

chemparseplot.parse.trajectory.hdf5._path_to_atoms_list(path: chemparseplot.parse.types.TrajectoryNebPath, *, metadata: chemparseplot.parse.types.ParserAttrs) → list[ase.Atoms]#

Reconstruct ASE atoms from a typed path payload and metadata.

chemparseplot.parse.trajectory.hdf5._gpridge_result(h5_file: str, atomic_numbers, cell) → chemparseplot.parse.types.TrajectoryNebResult#

A gpridge band as a ChemGP-shaped result, with computed path coordinates.

chemparseplot.parse.trajectory.hdf5._is_gpridge(h5_file: str) → bool#
chemparseplot.parse.trajectory.hdf5._with_structure(metadata: chemparseplot.parse.types.ParserAttrs, atomic_numbers, cell) → chemparseplot.parse.types.ParserAttrs#
chemparseplot.parse.trajectory.hdf5.load_neb_result(h5_file: str, *, atomic_numbers=None, cell=None) → chemparseplot.parse.types.TrajectoryNebResult#

Read a ChemGP neb_result.h5 file or a gpridge band.h5.

Added in version 1.2.0.

Changed in version 1.15.0: Reads gpridge band files. atomic_numbers and cell override the file.

Parameters:
  • h5_file – Path to the HDF5 result file.

  • atomic_numbers – Atomic numbers in file order, for files without them.

  • cell – (3, 3) lattice vectors (or 9 values) for periodic systems.

Returns:

Structured result with keys path (from :func:_read_path_group), convergence (array mapping), and metadata (metadata mapping).

chemparseplot.parse.trajectory.hdf5.load_neb_history(h5_file: str) → list[chemparseplot.parse.types.TrajectoryNebPath]#

Read a ChemGP neb_history.h5 file.

Added in version 1.2.0.

Changed in version 1.15.0: A gpridge band file stores no per-step bands: its history is the converged band alone.

Parameters:

h5_file – Path to the HDF5 history file.

Returns:

List of typed path payloads (one per optimization step), sorted by step number. Each entry has the same structure as

func:

_read_path_group.

chemparseplot.parse.trajectory.hdf5.result_to_profile_dat(h5_file: str) → numpy.ndarray#

Convert a result HDF5 to a (5, N) profile array.

Added in version 1.2.0.

Layout matches eOn .dat format: [index, rxn_coord, energy, f_para, zeros].

Reads directly from pre-computed HDF5 fields – no tangent recomputation.

Parameters:

h5_file – Path to neb_result.h5 or a gpridge band.h5.

Returns:

Array of shape (5, n_images).

chemparseplot.parse.trajectory.hdf5.result_to_atoms_list(h5_file: str, *, atomic_numbers=None, cell=None) → list[ase.Atoms]#

Reconstruct ASE Atoms from a result HDF5 file.

Added in version 1.2.0.

Changed in version 1.15.0: Takes atomic_numbers and cell, and gpridge band files.

Parameters:

h5_file – Path to neb_result.h5 or a gpridge band.h5.

Returns:

List of Atoms with SinglePointCalculators attached.

chemparseplot.parse.trajectory.hdf5.history_to_profile_dats(h5_file: str) → list[numpy.ndarray]#

Convert a history HDF5 to a list of (5, N) profile arrays.

Added in version 1.2.0.

One array per optimization step, sorted by step number.

Parameters:

h5_file – Path to neb_history.h5.

Returns:

List of arrays, each of shape (5, n_images).

chemparseplot.parse.trajectory.hdf5._ira_instance()#
chemparseplot.parse.trajectory.hdf5._rmsd_gradient_projection(positions: numpy.ndarray, gradients: numpy.ndarray, *, ref: numpy.ndarray, prod: numpy.ndarray, rmsd_r: numpy.ndarray, rmsd_p: numpy.ndarray) → tuple[numpy.ndarray, numpy.ndarray]#

Least-squares (dE/dr, dE/dp) from Cartesian gradients.

With r = RMSD(x, ref) the Jacobian row is (x - ref) / (N r), taken in the frame the file stores (a band and its evaluations share it). The pair solves J^T g2 = g in the least-squares sense; a row on an endpoint (r or p zero) uses the other coordinate alone.

chemparseplot.parse.trajectory.hdf5.observations_to_landscape_df(observations, ref_atoms: ase.Atoms, prod_atoms: ase.Atoms, ira_kmax: float = 1.8, *, ira_instance=None, step: int = OBSERVATION_STEP)#

Place oracle evaluations on the RMSD landscape of a band.

Added in version 1.15.0.

r and p are the RMSDs from ref_atoms and prod_atoms (IRA), z is the evaluated energy, and grad_r, grad_p project each Cartesian gradient onto the two RMSD directions by least squares. Rows without an energy are dropped. step defaults to

Data:

OBSERVATION_STEP, below every band step, so a last landscape path still picks the band.

Parameters:

observations –

class:

~chemparseplot.parse.trajectory.band_h5.Observations.

Returns:

Polars DataFrame with columns [r, p, grad_r, grad_p, z, step].

chemparseplot.parse.trajectory.hdf5.history_to_landscape_df(h5_file: str, ira_kmax: float = 1.8, *, atomic_numbers=None, cell=None, observations: bool = False)#

Convert a history HDF5 to a landscape DataFrame.

Added in version 1.2.0.

Changed in version 1.15.0: Reads gpridge band files. observations=True adds the oracle evaluations of a gpridge file (:func:observations_to_landscape_df) as rows with step :data:OBSERVATION_STEP.

Reconstructs Atoms per step for RMSD coordinates, uses pre-computed f_para for synthetic gradients.

Parameters:
  • h5_file – Path to neb_history.h5 or a gpridge band.h5.

  • ira_kmax – Factor on the IRA basis cutoff.

  • atomic_numbers – Atomic numbers in file order, for files without them.

  • cell – (3, 3) lattice vectors (or 9 values) for periodic systems.

  • observations – Add the file’s oracle evaluations to the surface.

Returns:

Polars DataFrame with columns [r, p, grad_r, grad_p, z, step].