chemparseplot.parse.trajectory.band_h5#
NEB bands from gpridge’s readcon output and from HDF5 band files.
Added in version 1.15.0.
gpridge (gprn) writes its band as readcon files: --write-con band.con
(one frame per image with energy and forces, the run summary on the first
frame under neb_summary), the same frames in the corpus
band.con.corpus, and every oracle evaluation in the observation archive
(obs-archive, the active training set in obs-archive/training).
- func:
read_bandand :func:read_observationsread those first.
The HDF5 readers here are for files that hold the band in HDF5: ChemGP’s
files, gpridge’s optional --full-h5 output (schema neb-band/1, the
ChemGP layout plus 2-D /training, /summary and /trace), and
band.h5 files of older gpridge runs. The default gpridge band.h5
(schema gprn-gp-trace/1) holds only the GP trace, not the band.
Two programs wrote a NEB band to HDF5 with different groups.
ChemGP (neb_result.h5, neb_history.h5)
/path/{images, gradients} of shape (n_images, 3N),
/path/{energies, f_para, rxn_coord} of shape (n_images,),
/metadata/{atomic_numbers, cell, converged, oracle_calls, max_energy_image}, /convergence/<series>, and in a history file
/steps/<NNN>/ groups shaped like /path.
gpridge (gprn band.h5)
/converged/<i>/{positions, gradient} of shape (3N,) and
/converged/<i>/energy of shape (1,), /summary/<name> scalars
of shape (1,), and /training/{n_rows, dof, positions, gradients, energies}: the training set of the run, row-major. Older gpridge runs
only; the file stores no atomic numbers and no cell.
- func:
read_bandreads either layout into a :class:NebBandand- func:
read_observationsreads the gpridge training set into- class:
Observations. Both convert toreadcon.ConFrameobjects (:func:band_frames, :func:observation_frames) and the observations go into a readcon-db observation archive with :func:write_observation_archive, the same store gpridge writes during a run. :func:convert_layoutwrites one layout from the other.
When a gpridge file is read without atomic_numbers,
- func:
discover_structurelooks beside it for the observation archive (obs-archive) and then for a CON file with the same stem (band.con). Units are those of the file: angstrom and eV.
Module Contents#
Classes#
One band: positions, energies and gradients of every image. |
|
Oracle evaluations: one row per evaluated configuration. |
Functions#
Return :data: |
|
Atomic numbers in the writer’s order (atom ids) and the cell of a frame. |
|
Atomic numbers and cell for a band file from the files beside it. |
|
Read the final band from gpridge’s readcon output or an HDF5 file. |
|
Read oracle evaluations: an observation archive or an HDF5 |
|
Stored row of each atom in the writer’s order (atom ids), or identity. |
|
Write a band as gpridge’s |
|
One |
|
One |
|
Append the observations to a readcon-db observation archive. |
|
Cumulative distance and parallel force (improved tangent) of a band. |
|
Write the band (and the gpridge training set) of src in layout to. |
Data#
API#
- chemparseplot.parse.trajectory.band_h5.log#
‘getLogger(…)’
- chemparseplot.parse.trajectory.band_h5.__all__#
[‘CHEMGP’, ‘GPRIDGE’, ‘READCON’, ‘NebBand’, ‘Observations’, ‘band_frames’, ‘convert_layout’, ‘detect…
- chemparseplot.parse.trajectory.band_h5.CHEMGP#
‘chemgp’
- chemparseplot.parse.trajectory.band_h5.GPRIDGE#
‘gpridge’
- chemparseplot.parse.trajectory.band_h5.READCON#
‘readcon’
- chemparseplot.parse.trajectory.band_h5.NEB_BAND_SCHEMA#
‘neb-band/1’
- chemparseplot.parse.trajectory.band_h5.GP_TRACE_SCHEMA#
‘gprn-gp-trace/1’
- chemparseplot.parse.trajectory.band_h5.Layout#
None
- chemparseplot.parse.trajectory.band_h5._FREE_PADDING#
10.0
- chemparseplot.parse.trajectory.band_h5._ORTHO_TOL#
1e-08
- chemparseplot.parse.trajectory.band_h5._MATRIX_NDIM#
2
- class chemparseplot.parse.trajectory.band_h5.NebBand#
One band: positions, energies and gradients of every image.
positionsandgradientshave shape(n_images, natoms, 3).cellis a(3, 3)matrix of lattice vectors (rows), orNonefor a free molecule.atomic_numbersisNonewhen neither the file nor the caller gave them.summaryholds the scalar results the file records (barrier, oracle calls, convergence).- positions: numpy.ndarray#
None
- energies: numpy.ndarray#
None
- class chemparseplot.parse.trajectory.band_h5.Observations#
Oracle evaluations: one row per evaluated configuration.
positionsandgradientshave shape(n_rows, natoms, 3)andenergiesshape(n_rows,). A row whose energy the writer did not record holds NaN.- positions: numpy.ndarray#
None
- energies: numpy.ndarray#
None
- gradients: numpy.ndarray#
None
- property forces: numpy.ndarray#
- chemparseplot.parse.trajectory.band_h5._h5py()#
- chemparseplot.parse.trajectory.band_h5._is_readcon_path(path: str | pathlib.Path) bool#
- chemparseplot.parse.trajectory.band_h5.detect_layout(path: str | pathlib.Path) str#
Return :data:
READCON, :data:CHEMGPor :data:GPRIDGE.A CON file or a readcon-db corpus directory is :data:
READCON. An HDF5 file is :data:CHEMGP(also gpridge--full-h5, schemaneb-band/1) or :data:GPRIDGE(older gpridgeband.h5) from the groups present.- Raises:
ValueError – when the HDF5 file has neither layout’s groups, or holds only the gpridge GP trace.
- chemparseplot.parse.trajectory.band_h5._cell_from_lengths_angles(lengths, angles) numpy.ndarray#
- chemparseplot.parse.trajectory.band_h5._lengths_angles(cell: numpy.ndarray) tuple[list[float], list[float]]#
- chemparseplot.parse.trajectory.band_h5._structure_from_frame(frame) tuple[numpy.ndarray, numpy.ndarray]#
Atomic numbers in the writer’s order (atom ids) and the cell of a frame.
- chemparseplot.parse.trajectory.band_h5.discover_structure(h5_file: str | pathlib.Path) tuple[numpy.ndarray, numpy.ndarray] | None#
Atomic numbers and cell for a band file from the files beside it.
Looks for the observation archive gpridge writes next to the band (
obs-archive, or any directory holdingobservations.rdb), then a CON file with the band’s stem (band.con). Atomic numbers follow the stored atom ids, which are the writer’s atom order. ReturnsNonewhen nothing is found or readcon / readcon-db is not installed.
- chemparseplot.parse.trajectory.band_h5._resolve_structure(h5_file, natoms, *, atomic_numbers, cell, file_z, file_cell)#
- chemparseplot.parse.trajectory.band_h5._read_chemgp_band(f) tuple[dict, numpy.ndarray | None, numpy.ndarray | None]#
- chemparseplot.parse.trajectory.band_h5.read_band(h5_file: str | pathlib.Path, *, atomic_numbers=None, cell=None) chemparseplot.parse.trajectory.band_h5.NebBand#
Read the final band from gpridge’s readcon output or an HDF5 file.
h5_file may be a CON file (
band.con), a readcon-db corpus (band.con.corpus), or an HDF5 file in the ChemGP,neb-band/1or older gpridge layout. A ChemGP history file without/pathgives its last step.atomic_numbersandcell((3, 3), or three orthorhombic lengths) take precedence over the file’s metadata and over- Func:
discover_structure.
- chemparseplot.parse.trajectory.band_h5.read_observations(h5_file: str | pathlib.Path, *, atomic_numbers=None, cell=None) chemparseplot.parse.trajectory.band_h5.Observations#
Read oracle evaluations: an observation archive or an HDF5
/training.h5_file may be a readcon-db observation archive (gpridge’s
obs-archiveholds every evaluation,obs-archive/trainingthe final training set), or an HDF5 file with/training(gpridge--full-h5as 2-D rows, older gpridgeband.h5as flat rows).- Raises:
ValueError – for an HDF5 file without
/training.
- chemparseplot.parse.trajectory.band_h5._file_order(frame) numpy.ndarray#
Stored row of each atom in the writer’s order (atom ids), or identity.
- chemparseplot.parse.trajectory.band_h5._read_readcon_band(path, *, atomic_numbers=None, cell=None) chemparseplot.parse.trajectory.band_h5.NebBand#
- chemparseplot.parse.trajectory.band_h5._read_archive_observations(path, *, atomic_numbers=None, cell=None) chemparseplot.parse.trajectory.band_h5.Observations#
- chemparseplot.parse.trajectory.band_h5.write_band_con(band: chemparseplot.parse.trajectory.band_h5.NebBand, path: str | pathlib.Path) pathlib.Path#
Write a band as gpridge’s
--write-confile.One frame per image with energy, forces,
neb_band/neb_beadandrole(reactant, intermediate, climbing, product; the climbing image issummary["max_energy_image"]when the summary has it), and the band summary on the first frame underneb_summary. Converts an older gpridgeband.h5(whose band holds only the moving atoms) into the readcon output a current run writes.
- chemparseplot.parse.trajectory.band_h5._frame(readcon, positions, forces, *, energy, z, cell, metadata, moving=None)#
- chemparseplot.parse.trajectory.band_h5._readcon()#
- chemparseplot.parse.trajectory.band_h5.band_frames(band: chemparseplot.parse.trajectory.band_h5.NebBand) list[Any]#
One
readcon.ConFrameper image, with energy and forces.Atoms keep the file’s order as their
atom_id. The metadata carriesneb_bead(the image index) andneb_band0. A band without a cell is written in a box with 10 angstrom padding andpbcall false.
- chemparseplot.parse.trajectory.band_h5.observation_frames(obs: chemparseplot.parse.trajectory.band_h5.Observations) list[Any]#
One
readcon.ConFrameper oracle evaluation, in evaluation order.
- chemparseplot.parse.trajectory.band_h5.write_observation_archive(obs: chemparseplot.parse.trajectory.band_h5.Observations, directory: str | pathlib.Path) int#
Append the observations to a readcon-db observation archive.
directoryis the archive directory (observations.rdbis created inside it), as gpridge’s--gp-observation-archivewrites it, soreadcon_db.ArchiveReader(directory)reads the rows back in caller atom order. Rows without an energy are skipped. The archive stores an orthorhombic box: a non-orthorhombic cell raisesValueErrorand a free molecule gets a box around every row with 10 angstrom padding.- Returns:
the number of rows written.
- chemparseplot.parse.trajectory.band_h5.path_coordinates(band: chemparseplot.parse.trajectory.band_h5.NebBand) tuple[numpy.ndarray, numpy.ndarray]#
Cumulative distance and parallel force (improved tangent) of a band.
- chemparseplot.parse.trajectory.band_h5._write_chemgp(f, band: chemparseplot.parse.trajectory.band_h5.NebBand, obs: chemparseplot.parse.trajectory.band_h5.Observations | None) None#
- chemparseplot.parse.trajectory.band_h5._write_training(f, obs: chemparseplot.parse.trajectory.band_h5.Observations) None#
- chemparseplot.parse.trajectory.band_h5._write_gpridge(f, band: chemparseplot.parse.trajectory.band_h5.NebBand, obs: chemparseplot.parse.trajectory.band_h5.Observations | None) None#
- chemparseplot.parse.trajectory.band_h5.convert_layout(src: str | pathlib.Path, dst: str | pathlib.Path, to: chemparseplot.parse.trajectory.band_h5.Layout, *, atomic_numbers=None, cell=None) pathlib.Path#
Write the band (and the gpridge training set) of src in layout to.
gpridge to ChemGP computes
rxn_coord(cumulative distance) andf_para(force on the improved tangent) and stores the atomic numbers and cell found by :func:read_band. The/traininggroup is copied as it is, so the ChemGP file keeps the oracle evaluations. ChemGP to gpridge writes/convergedand the/summaryscalars it can derive. dst must not exist.