-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor entropy calculations: switch to per-timestep computation with molecule-type grouping #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
harryswift01
merged 26 commits into
main
from
30-averaging-over-molecules-of-the-same-type
Aug 4, 2025
Merged
Refactor entropy calculations: switch to per-timestep computation with molecule-type grouping #126
harryswift01
merged 26 commits into
main
from
30-averaging-over-molecules-of-the-same-type
Aug 4, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…calculating the covariance matrices and separating the entropy calculation from the loop that makes the matrices. Part 1.
…ding: - Modified force and torque matrix initializations to use None instead of empty lists, enabling clearer checks for uninitialized matrices. - Updated the logic that accumulates force and torque covariance matrices to handle cases where matrices have different shapes. - Introduced a new helper method `_pad_and_add` that pads two 2D numpy arrays with zeros to the maximum dimensions of both arrays, then returns their element-wise sum. - This method ensures that when covariance matrices from different frames have incompatible shapes, they can still be safely combined without losing data. - Updated `LevelManager.create_force_and_torque_matrix` to use `_pad_and_add` when accumulating matrices with mismatched shapes. - Cleaned up some list initializations and matrix sub-block assembly for clarity and consistency. - Fixed handling of dihedrals in entropy calculations by cycling through each dihedral individually rather than processing them as a batch. This change ensures correct assignment of conformations per dihedral.
…30-averaging-over-molecules-of-the-same-type
… storage - Removed the `_pad_and_add` function from `get_beads` so it returns only the actual bead selections without added padding. - Changed force and torque matrix storage from large pre-allocated lists with None placeholders to dictionaries keyed by `(molecule_id, residue_id)`. - These changes eliminate unnecessary data padding and improve direct access to relevant matrices. - Result is cleaner data structures and simpler, more reliable indexing.
…torques matrices
…ect timestep is being used
- Ensured correct indentation to prevent excessive looping - Passed appropriate `force_matrix`, `torque_matrix`, and `states` within the loop of `_process_united_atom_entropy` - Used correct keys for accessing matrices to maintain consistency and accuracy
…within expected range
…//github.com/CCPBioSim/CodeEntropy into 30-averaging-over-molecules-of-the-same-type
…//github.com/CCPBioSim/CodeEntropy into 30-averaging-over-molecules-of-the-same-type
…able components: - Extracted dihedral conformation logic into a new helper method. - Modularized the `_compute_entropies` method to delegate level-specific logic cleanly, including: - United atom level: per-residue dihedral state assignment and entropy processing. - Residue level: molecule-wide dihedral state assignment and entropy processing. - Polymer level: vibrational entropy only. - Introduced `_initialize_molecules`, `_build_covariance_matrices`, and `_update_force_torque_matrices` to encapsulate setup logic and matrix construction. - Implemented `_handle_water_entropy` to isolate water-specific entropy logic and update selection strings accordingly. - Ensured all new methods follow consistent naming and parameter conventions.
…s to `LevelManager` - Relocating the following functions as they deal more intrinsically with the levels rather than the entropy calculations - Relocated `compute_dihedral_conformations` to `LevelManager` - Relocated `build_covariance_matrices` to `LevelManager` - Relocated `update_force_torque_matrices` to `LevelManager`
…matrices and entropy calculations.
jimboid
approved these changes
Aug 4, 2025
Member
jimboid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks good to merge. I think there are some things we can look at in future:
- I can look at parallelism
- The new matrix math looks ripe for optimisation
But I don't think these are blockers for v1.0.0, we can work on them in a branch and if they are ready then they are ready, if not then they are not. But the priority is polishing for release.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR signifies a large and significant restructure in how
CodeEntropyperforms entropy calculations. The core change involves transitioning from a per-molecule computation model to a per-timestep approach. Additionally, entropy values are now grouped across molecule types, improving the interpretability and consistency of the results. These changes lay the groundwork for more scalable and scientifically robust analyses.Changes
Refactor entropy computation granularity:
Introduce molecule-type Grouping:
build_conformational_statesand related functions to support type-based aggregation.Testing and validation:
Impact