aiida_chemshell.calculations.utils module

A collection of smaller utility AiiDA CalcFunctions.

aiida_chemshell.calculations.utils.combine_into_extended_xyz(**kwargs: StructureData | TrajectoryData | Float | ArrayData) SinglefileData

Collate a batch of single-point results into one extended XYZ file.

The keyword nodes are sorted by type into three parallel lists: structures (from StructureData, or each frame of a TrajectoryData), energies (Float) and, optionally, force arrays (ArrayData). They are then written out as an extended XYZ file with an ‘Energy=’ label per frame and, when forces are supplied, a ‘force’ property column. The lists are paired positionally, so the caller is responsible for passing matched sets of nodes (equal numbers of structures, energies and, if used, arrays).

Parameters:

**kwargs (StructureData | TrajectoryData | Float | ArrayData) – Arbitrary keyword arguments whose values are the result nodes to combine. Only the values are used; the keys are ignored. Forces are read from the ‘gradients’ array of any ArrayData node.

Returns:

A SinglefileData node wrapping the combined ‘chemshell_batch_workchain.extxyz’ file.

Return type:

SinglefileData

Raises:

ValueError – If an unsupported node type is passed, if no structures are provided, or if the numbers of structures, energies and (when given) arrays do not match.

aiida_chemshell.calculations.utils.create_dictionary(atoms, energies) Dict

Collate a series of isolated atom energies into a dictionary output.

aiida_chemshell.calculations.utils.extract_structures_from_xyz(file: SinglefileData) dict[str, StructureData]

Split a multi-frame XYZ file into individual StructureData nodes.

Each frame in the (optionally extended) XYZ file is parsed into its own StructureData node. Extended XYZ ‘Lattice=’ and ‘pbc=’ fields on the comment line are honoured when present; frames without them are treated as non-periodic.

Parameters:

file (SinglefileData) – A SinglefileData node wrapping an XYZ (or extended XYZ) file that may contain one or more frames.

Returns:

A mapping of output link labels to StructureData nodes, one per frame. Keys are of the form ‘<filename>_frame_<index>’ (zero-indexed, with spaces in the filename replaced by underscores). As a calcfunction return value, this dictionary is registered as a namespace of output nodes.

Return type:

dict[str, StructureData]

Raises:

Exception – If the file is not valid XYZ, is truncated, or contains a malformed atom line.