Skip to content

Add extended XYZ auxiliary reader - #27

Open
PicoCentauri wants to merge 7 commits into
mainfrom
extxyz-auxreader
Open

PicoCentauri wants to merge 7 commits into
mainfrom
extxyz-auxreader

Conversation

@PicoCentauri

@PicoCentauri PicoCentauri commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Adds XYZReader, an MDAnalysis compatible auxiliary reader for ASE/i-PI style extended XYZ files. It attaches all data in the XYZ that can't read by the default XYZ reader from MDAnalysis. The reader handles per-atom data (e.g. Born effective charges, forces) and per-frame data (e.g. polarization, polarizability, energy) to an existing Universe.

The workflow follows the MDA style:

import MDAnalysis as mda
import spectrumkit  # registers the EXTXYZ/XYZ aux formats

u = mda.Universe("ipi.positions_0.extxyz", format="XYZ", dt=0.002)
u.trajectory.add_auxiliary({"becx": "becx"}, "ipi.becx_0.extxyz", dt=0.0005)
u.trajectory.ts.aux.becx  # (n_atoms, 3)

In summary the PR does:

  • Loads every property except species/pos into data_dict, like EDRReader.
  • Own small parser following the conventions of ase.io.extxyz.key_val_str_to_dict; ASE is only a test dependency.
  • Readers of the same unchanged file share one parse, because attach_auxiliary creates a new reader for every attached term. The shared arrays are read-only.
  • Tests reuse MDAnalysis' BaseAuxReaderTest; values are checked against ASE.
  • New test dependencies: MDAnalysisTests, ase.

I checked on an i-PI water trimer run: the BEC current J = Σ Z·v from the attached data matches the previous ASE-based route bitwise.

The idea is that this may goes upstream to MDAnalysis later (MDAnalysis/auxiliary/XYZ.py), after we tested it and are happy.


📚 Documentation preview 📚: https://spectrumkit--27.org.readthedocs.build/en/27/

Philip Loche and others added 7 commits November 24, 2026 12:59
The extxyz parser is reimplemented instead of depending on ASE; the tests
check it against ASE, which is only a test dependency.

Readers of the same unchanged file share one parse, because
attach_auxiliary creates a new reader for every attached term and
parsing a large i-PI file takes seconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Importing spectrumkit registers the EXTXYZ and XYZ auxiliary formats,
so add_auxiliary accepts these files by name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Universe already holds the atom names and count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeps the reader as close as possible to the upstream auxiliary readers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shape of each data_dict array already tells per-atom from per-frame
terms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"aux" is a reserved device name on Windows, so the checkout failed there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PicoCentauri
PicoCentauri requested a review from hejamu December 1, 2026 08:17

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant