mod metatensor_export

module metatensor_export

Export ConFrame data as metatensor TensorBlock instances.

Available behind the metatensor Cargo feature. The block layout mirrors the metatensor convention: rows are samples (one per atom), and columns are properties (x, y, z for vector quantities or a single column for scalars).

Users that want a TensorMap keyed by species can build one on top of these blocks; the choice of “per-species block” vs “single block with species as a sample column” is user-specific, so we expose the building blocks rather than baking in one convention.

Functions

fn frame_energies_block(frame: &ConFrame) -> Result<Option<TensorBlock>, metatensor::Error>

Builds a TensorBlock with shape [N, 1] carrying the per-atom energy contributions. Returns Ok(None) if the frame did not carry an energies section.

fn frame_forces_block(frame: &ConFrame) -> Result<Option<TensorBlock>, metatensor::Error>

Builds a TensorBlock with shape [N, 3] carrying the per-atom forces. Returns Ok(None) if the frame did not carry a forces section.

fn frame_positions_block(frame: &ConFrame) -> Result<TensorBlock, metatensor::Error>

Builds a TensorBlock with shape [N, 3] carrying the per-atom xyz coordinates from frame. Samples are labelled atom_id (the post-grouping index from the file’s column 5), properties are labelled xyz with values 0, 1, 2.

Returns the underlying metatensor error if the C library rejects the labels or array shape.

fn frame_velocities_block(frame: &ConFrame) -> Result<Option<TensorBlock>, metatensor::Error>

Builds a TensorBlock with shape [N, 3] carrying the per-atom velocity vectors. Returns Ok(None) when the frame has no velocity data; users should not assume the block exists for every frame.