Skip to content

Support non-periodic trajectories without box dimensions - #447

Merged
harryswift01 merged 3 commits into
mainfrom
446-general-gas-phase-pbc
Oct 9, 2026
Merged

harryswift01 merged 3 commits into
mainfrom
446-general-gas-phase-pbc

Conversation

@harryswift01

Copy link
Copy Markdown
Member

Summary

This PR allows CodeEntropy to run on non-periodic trajectories, such as gas-phase simulations of isolated molecules. These trajectories have no box dimensions, so merge_forces failed with AttributeError: 'NoneType' object has no attribute 'copy' when loading them. The axes and covariance code also assumes a box when applying the minimum image convention and unwrapping molecules, so skipping the dimensions alone would not have been enough.

Changes

Handle trajectories without box dimensions:

  • merge_forces now checks whether the trajectory has box dimensions before extracting them.
  • When there are none, a cubic box is built for every frame, with 90° angles. Its side is max(10 × largest coordinate span, 100 Å), which is far more than twice any interatomic distance, so the minimum image and unwrap steps have no effect.
  • A warning is logged when this box is used, giving the box size.
  • Trajectories that have a box follow the same path as before.

Add unit tests:

  • Check that the generated box has the right shape, is larger than twice the largest extent, and has 90° angles.
  • Check that merge_forces passes a per-frame box to load_new when the trajectory has no dimensions.

Impact

  • Non-periodic trajectories can now be processed instead of failing at trajectory loading.
  • No change for trajectories that have a box, so existing results are unaffected.

@harryswift01 harryswift01 added this to the 2.5.0 milestone Oct 9, 2026
@harryswift01 harryswift01 self-assigned this Oct 9, 2026
@harryswift01 harryswift01 added bug Something isn't working feature request New feature or request labels Oct 9, 2026
@harryswift01
harryswift01 marked this pull request as ready for review October 9, 2026 15:16

@jimboid jimboid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fast turn around on this user reported bug. Happy with eyeballing of the numbers by Jas in the chat. Happy for this to merge and new minor release to be made on this basis.

@harryswift01
harryswift01 merged commit acc81d1 into main Oct 9, 2026
23 checks passed
@harryswift01
harryswift01 deleted the 446-general-gas-phase-pbc branch October 9, 2026 15:39
@HafizSaqibAli

Copy link
Copy Markdown

Hi @harryswift01,

Thank you so much for sorting this out so quickly. I’ve updated to v2.5.0 and can confirm that it’s now working perfectly on my gas-phase simulations, with no more AttributeError.

I really appreciate the fast turnaround.

Thanks,
Hafiz

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

Labels

bug Something isn't working feature request New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[General]: CodeEntropy fails for gas-phase MD simulations without periodic boundary conditions (PBC)

3 participants