File input and output
Use the file type appropriate to the data: a structure trajectory, a sampled scalar field, and an electronic wavefunction are different records.
Structure and trajectory files
Section titled “Structure and trajectory files”from atomli.io import read, write
atoms = read("optimized.xyz")frames = read("adsorption-fixed-host.extxyz", ":")final = frames[-1]write("final.xyz", final)Saved adsorption optimization trajectory and force history
Download the trajectory · Associated calculation record
The same file can be inspected without recomputing forces:
from atomli.visualize import view
view(frames).write_html("trajectory.html")Suffixes usually select the structure format. Verify cell vectors, PBC, masses, tags, and required per-atom arrays after conversion. A structure export should not be assumed to preserve calculator state or every constraint.
PDB, mmCIF, and SDF use native molecular parsers.
These formats attach residue identity, formal charges, and chemical bonds to atoms.topology.
HDF5, JSON, and native trajectories preserve this topology.
Use the biomolecular guide for preparation and capped region extraction.
Background output
Section titled “Background output”Trajectory, Checkpoint, and ConsoleLogger submit owned snapshots to Rust workers.
Encoding and file writes run on those workers.
Snapshot capture remains synchronous.
Both frame count and estimated owned bytes bound pending output.
from atomli.io import Trajectory
with Trajectory("md.traj", "w", atoms, every_steps=20) as trajectory: dyn.attach(trajectory.write) dyn.run(1000)Trajectory output uses background mode by default.
Its default queue holds at most 128 frames and 64 MiB of estimated snapshot data.
The default overflow policy raises an error.
flush(), close(), and context exit wait for accepted output.
Use explicit close to observe worker errors.
read(), write(), and iread() are synchronous interfaces.
iread() currently loads all frames before yielding.
These functions do not provide an asyncio interface.
Keep native Python structures and writers on their creating thread.
Supported MD drivers also accept run(steps, background=True).
Rust runs the calculation and retains its calculator.
The notebook kernel delivers output callbacks on the Python owner thread.
The native callback queue has two slots and preserves every requested output event.
Call job.wait() in terminal scripts to deliver events and flush output.
Scalar fields
Section titled “Scalar fields”from atomli.io import read_cube, read_fieldfrom atomli.visualize import view_field
density = read_cube("density.cube", kind="electron_density")# Use read_field("density.h5", kind="electron_density") for an HDF5 field.view_field(atoms, density, isovalue=0.06).write_html("density.html")Scalar field loaded with grid metadata and rendered as a sectioned isosurface
Keep value units, origin, voxel vectors, shape, electron representation, and the matching atomic geometry. Equal array dimensions do not establish grid alignment. The field guide includes orbital phase and ESP coloring.
Electronic wavefunctions
Section titled “Electronic wavefunctions”atoms.calc.write_wavefunction("wavefunction.h5", format="hdf5")For a structure with native constraints, export the electronic payload and keep the constraint definition separately:
from pathlib import Path
payload = atoms.calc.get_wavefunction(format="hdf5", atoms=atoms)Path("wavefunction.h5").write_bytes(payload)The electronic payload does not provide a complete constrained-workflow restart.
Use supported checkpoint interfaces for restart state, and retain the Python
configuration and atom ordering. A wavefunction HDF5 file is not a sampled-field
HDF5 file for read_field.
Calculation provenance
Section titled “Calculation provenance”The adsorption workflow keeps structure frames, constraint indices, raw/projected force residuals, absolute energy terms, wavefunction, analytical Hessian, and volumetric snapshots in one directory. Its manifest identifies each interactive output and its underlying data file.