Skip to content

Change residue level MOI calculation to all atom - #442

Closed
ioanaapapa wants to merge 7 commits into
mainfrom
441-all-atom-MOI
Closed

ioanaapapa wants to merge 7 commits into
mainfrom
441-all-atom-MOI

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 (from MDAnalysis .principal_axes()) and moment of inertia corresponds to vanilla all-atom moment of inertia from diagonals of MOI tensor. (from MDAnalysis .moment_of_inertia()). The get_custom_principal_axes and get_moment_of_inertia_tensor are left in the code as we might need to coarse grain in the future for more complex systems.
  • 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, this looks like great work moving the MOI calculation to use all atoms. I've been working on making the calculations in CodeEntropy reproducible, to remove the flakiness in the PR and regression runs. It turned out to be in the axes calculations, so #440 overlaps with this branch. I did a trial merge locally and the code conflicts are small: the function renames in axes.py (get_vanilla_axes → get_molecule_axes, get_custom_axes → get_bonded_vector_axes, get_custom_principal_axes → get_principal_axes_from_tensor and get_principal_axes → get_principal_axes_from_group), the two places in get_residue_axes and get_residue_axes_from_topology where you call get_vanilla_axes keep your change, only the name differs, and the mocks in three tests. The regression baselines also conflict, since both branches regenerate them. Would it be ok for you to merge main into this branch, resolve those, and regenerate all of the baselines, including the slow ones. Once that's done I think we'll be in a good position to review it properly, and I'm happy to help if you get stuck on the merge.

@ioanaapapa

Copy link
Copy Markdown
Collaborator Author

@harryswift01 Thanks, Harry! I'll try to merge main and resolve the conflicts. Will let you know if I have any questions

@ioanaapapa ioanaapapa closed this Oct 9, 2026
@ioanaapapa
ioanaapapa deleted the 441-all-atom-MOI branch October 9, 2026 09:25
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.

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

2 participants