maxwelllink.tools.xyz_helper module¶
XYZ readers shared by the molecular drivers: one geometry, or one frame per molecule.
- maxwelllink.tools.xyz_helper.read_xyz(path)[source]¶
Read the first frame of an XYZ file.
- Parameters:
path (str) – Path to the file.
- Returns:
elements (list of str) – Element symbol of every atom, in file order.
positions (numpy.ndarray of float, shape (n_atom, 3)) – Coordinates in Angstrom.
- maxwelllink.tools.xyz_helper.read_xyz_frames(path)[source]¶
Read a single- or multi-frame XYZ file (
n_atom/ comment / atom lines, repeated).Drivers given such a file as
batch_xyzstart moleculemfrom framem, so every frame must list the same atoms in the same order.- Parameters:
path (str) – Path to the file.
- Returns:
elements (list of str) – Element symbols, the same in every frame.
positions (numpy.ndarray of float, shape (n_frames, n_atom, 3)) – Coordinates of every frame in Angstrom.
- Raises:
ValueError – If the file holds no frame, or a frame lists other atoms than the first.
- maxwelllink.tools.xyz_helper.read_xyz_trajectory(path, num)[source]¶
Read a trajectory a driver wrote with
traj_filename, back into a batch array.Such a file is time-major with one frame per molecule per record; this undoes that.
- Parameters:
path (str) – Path to the file.
num (int) – Number of molecules the writing process owned (its
molecule_ids).
- Returns:
elements (list of str) – Element symbols of one molecule.
positions (numpy.ndarray of float, shape (n_records, num, n_atom, 3)) – Coordinates in Angstrom.