Skip to content

Change residue level MOI calculation to all atom - #445

Merged
ioanaapapa merged 12 commits into
mainfrom
441-all-atom-MOI-refactored
Oct 19, 2026
Merged

ioanaapapa merged 12 commits into
mainfrom
441-all-atom-MOI-refactored

Conversation

@ioanaapapa

Copy link
Copy Markdown
Collaborator

Summary

This PR closes #441 and changes the MOI calculation at the residue level to use all atoms masses and positions, rather than heavy atom positions and UA (heavy atom + hydrogens) masses. This corresponds to what we discussed in the CodeEntropy catch up meeting on 8 October 2026.

Changes

  • When the residue level is the highest level of hierarchy, rotation axes correspond to vanilla principal axes and moment of inertia corresponds to vanilla all-atom moment of inertia from diagonals of MOI tensor.
  • When the residue level is below the polymer level, the get_custom_residue_moment_of_inertia function uses all atom positions and masses.
  • Regression tests have been updated to match the changes.

Impact

  • Moment of inertia calculation is consistent between levels and is consistent with torque calculation at all levels of hierarchy.
  • Entropy values are slightly higher, as below for one benzene molecule and 1 protein.
    benzene_MOIs.txt
    thioredoxin.txt

@harryswift01 harryswift01 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.

Hi @ioanaapapa , thanks for this, this is looking like a great PR. Moving the residue-level MOI calculation to an all-atom approach makes CodeEntropy more consistent, and I really appreciate you updating the regression baselines alongside it. I've spotted a few minor things and left comments for each: removing get_UA_masses and its related tests as it's no longer used, removing the unused box argument from get_residue_axes_from_topology, and adding a unit test for the bonded residue path to check the all-atom positions and masses are being used. If you're able to have a look and let me know what you think, that would be great, and if there's anything you'd like me to help with or clarify, please just ask. Overall this is looking very good and is close to being merged!

Comment thread CodeEntropy/levels/axes.py
Comment thread tests/unit/CodeEntropy/levels/test_axes.py Outdated
Comment thread tests/unit/CodeEntropy/levels/test_axes.py
@harryswift01 harryswift01 added this to the 2.6.0 milestone Oct 13, 2026
@harryswift01 harryswift01 added the feature request New feature or request label Oct 13, 2026
@ioanaapapa

Copy link
Copy Markdown
Collaborator Author

@harryswift01 Thanks, Harry! I'll make the changes.

@harryswift01 harryswift01 modified the milestones: 2.6.0, 2.7.0 Oct 14, 2026
@ioanaapapa

Copy link
Copy Markdown
Collaborator Author

Hi @harryswift01. I've made the changes, hopefully it's all ok now.

@harryswift01 harryswift01 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.

Thank you for applying all of my suggested changes to this PR @ioanaapapa! This is all looking good to me so I'm happy to see this merged in!

@ioanaapapa
ioanaapapa merged commit ea35b4e into main Oct 19, 2026
23 checks passed
@ioanaapapa
ioanaapapa deleted the 441-all-atom-MOI-refactored branch October 19, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Consistent all atom moments of inertia (MOI) and torques

2 participants