chemparseplot.parse.eon.con_io#
Public readcon-backed CON/convel helpers for eOn parsers.
All .con / .convel I/O in chemparseplot goes through this module.
readcon stays an optional extra (chemparseplot[neb]). Import errors
surface only when these helpers are called. Writers omit precision and leave
canonical off, which is RoundTrip on readcon>=0.17.1. Corpus selection
opens stores read-only and decodes selected frames as they are consumed.
Added in version 1.8.1.
Module Contents#
Functions#
Return True when path looks like an eOn CON/convel file. |
|
Copy a frame through the |
|
Read all frames from a CON/convel file as |
|
Yield CON frames without retaining the complete trajectory. |
|
Yield selected stored frames in trajectory and frame-index order. |
|
Open (or create) a readcon-db observation archive for writing. |
|
Stored frame index of an observation archive, or |
|
Frames of one trajectory of a corpus and its trajectory metadata. |
|
Every observation of an archive as arrays in the writer’s atom order. |
|
Return the stored total energy in eV without evaluating a potential. |
|
Read all frames from a CON/convel file as ASE |
|
Read the first CON frame and stop. Later frames are not parsed. |
|
Read the first frame of a CON file as an ASE |
|
Return Cartesian positions in Angstrom using the declared length unit. |
|
Return a |
|
Return a |
|
Fill empty ASE box headers so a multi-frame file re-parses. |
|
Write |
|
Convert ASE |
Data#
API#
- chemparseplot.parse.eon.con_io.__all__#
[‘CON_SUFFIXES’, ‘frame_energy_ev’, ‘frame_positions_angstrom’, ‘frame_with_energy’, ‘frame_with_pos…
- chemparseplot.parse.eon.con_io.CON_SUFFIXES#
(‘.con’, ‘.convel’)
- chemparseplot.parse.eon.con_io._READCON_HINT#
“readcon is required for CON I/O. Install with: pip install ‘chemparseplot[neb]’ (readcon>=0.17.1)”
- chemparseplot.parse.eon.con_io.is_con_path(path: str | pathlib.Path) bool[source]#
Return True when path looks like an eOn CON/convel file.
- chemparseplot.parse.eon.con_io._clone_frame(frame: Any) Any[source]#
Copy a frame through the
ConFrameconstructor so Atom sections travel.
- chemparseplot.parse.eon.con_io.read_con_frames(path: str | pathlib.Path) list[Any][source]#
Read all frames from a CON/convel file as
readcon.ConFrameobjects.
- chemparseplot.parse.eon.con_io.iter_con_frames(path: str | pathlib.Path) collections.abc.Iterator[Any][source]#
Yield CON frames without retaining the complete trajectory.
- chemparseplot.parse.eon.con_io.iter_corpus_frames(path: str | pathlib.Path, *, trajectory: int | None = None, require_energy: bool = False, require_forces: bool = False) collections.abc.Iterator[Any][source]#
Yield selected stored frames in trajectory and frame-index order.
The corpus is opened read-only. Frame decoding is lazy; selection retains only the trajectory and frame keys, including for compressed stores.
- chemparseplot.parse.eon.con_io.observation_archive_writer(directory: str | pathlib.Path, atomic_numbers: collections.abc.Sequence[int], cell: collections.abc.Sequence[float]) Any[source]#
Open (or create) a readcon-db observation archive for writing.
Returns
readcon_db.ObservationArchivefor one fixed composition: atomic_numbers in caller order and cell the three orthorhombic box lengths. Rows are appended withappend(positions, forces, energy).Added in version 1.15.0.
- chemparseplot.parse.eon.con_io.read_observation_frame(directory: str | pathlib.Path, index: int = 0) Any | None[source]#
Stored frame index of an observation archive, or
Nonepast the end.directory is the archive directory or its
observations.rdb. The frame is in stored (type-grouped) order; its atom ids are the writer’s atom order. The archive is opened read-only and closed again.Added in version 1.15.0.
- chemparseplot.parse.eon.con_io.read_corpus_trajectory(path: str | pathlib.Path, trajectory: int | None = None) tuple[list[Any], dict[str, Any] | None][source]#
Frames of one trajectory of a corpus and its trajectory metadata.
trajectory defaults to the lowest trajectory id, which is the band in gpridge’s
band.con.corpus. The metadata is the dictset_trajectory_metadatastored, orNonewhen none was stored or the installed readcon-db predates trajectory metadata.Added in version 1.15.0.
- chemparseplot.parse.eon.con_io.read_observation_rows(directory: str | pathlib.Path) dict[str, Any][source]#
Every observation of an archive as arrays in the writer’s atom order.
Returns
positionsandforcesof shape(n, natoms, 3),energies(NaN where a row has none),atomic_numbersandcell((3, 3)from the first row). directory is the archive directory or itsobservations.rdb.Added in version 1.15.0.
- chemparseplot.parse.eon.con_io._lattice(lengths: collections.abc.Sequence[float], angles: collections.abc.Sequence[float]) numpy.ndarray[source]#
- chemparseplot.parse.eon.con_io.frame_energy_ev(frame: Any) float | None[source]#
Return the stored total energy in eV without evaluating a potential.
- chemparseplot.parse.eon.con_io.read_con_as_ase(path: str | pathlib.Path) list[source]#
Read all frames from a CON/convel file as ASE
Atomsobjects.
- chemparseplot.parse.eon.con_io.read_first_frame(path: str | pathlib.Path) Any[source]#
Read the first CON frame and stop. Later frames are not parsed.
- chemparseplot.parse.eon.con_io.read_first_atoms(path: str | pathlib.Path)[source]#
Read the first frame of a CON file as an ASE
Atomsobject.
- chemparseplot.parse.eon.con_io.frame_positions_angstrom(frame: Any) numpy.ndarray[source]#
Return Cartesian positions in Angstrom using the declared length unit.
- chemparseplot.parse.eon.con_io.frame_with_energy(frame: Any, energy: float) Any[source]#
Return a
ConFramecopy with the supplied total energy in eV.The stored number uses the frame’s declared energy unit. Geometry, atom sections, and their unit declarations are retained.
ConFrame.set_energyvalidates that the stored value is finite.
- chemparseplot.parse.eon.con_io.frame_with_positions(frame: Any, positions: Any) Any[source]#
Return a
ConFramecopy with Cartesian positions replaced.Each
Atomrow is copied and onlyx/y/zare written.fixed,atom_id,mass, velocities, forces, displacements, and spreads stay. That is correct for an unmoved slice or a pure translation. It is the wrong helper fordisplacement.con: a rotation or a reorder must drop those sections and let eOn recompute them.
- chemparseplot.parse.eon.con_io._normalize_box_headers(frame: Any) Any[source]#
Fill empty ASE box headers so a multi-frame file re-parses.
ConFrame.from_aseoften yields empty header lines. A single frame still reads, but a later frame then stops at the velocity section. Frames that already have a non-empty header are returned unchanged, so a restart rewrite stays byte-identical.
- chemparseplot.parse.eon.con_io.write_con_frames(path: str | pathlib.Path, frames: collections.abc.Sequence[Any]) pathlib.Path[source]#
Write
ConFrameobjects to path viareadcon.write_con.Precision is omitted and canonical stays off. There is no corpus write.
- chemparseplot.parse.eon.con_io.write_atoms_as_con(path: str | pathlib.Path, atoms_list: collections.abc.Sequence[Any], *, energies: collections.abc.Sequence[float | None] | None = None) pathlib.Path[source]#
Convert ASE
Atomsthat were never aConFrameand write CON.Optional energies (eV) are attached per frame with
- Func:
frame_with_energy.from_asedrops displacements and spreads. ASE tags become atom ids only when they are distinct and non-negative; otherwise ids are sequential. Two atoms of one symbol whose masses disagree past the reader tolerance fail atbuild. Precision is omitted and canonical stays off. Empty box headers are filled so a multi-frame file re-parses.