Repository navigation
Use X-H bond axes for united atoms with one hydrogen - #501
Open
michalkrompiec wants to merge 3 commits into
Open
michalkrompiec wants to merge 3 commits into
michalkrompiec wants to merge 3 commits into
Conversation
For a united atom of a heavy atom and one hydrogen, the bonded axes were built from the heavy-atom neighbours and the smallest moment was zeroed. Which axis had the smallest moment depended on where the hydrogen pointed, so it could change between frames and one torque covariance index mixed two rotations. Build these axes from the X-H bond instead: axis1 along X-H, axis2 from the lowest-index bonded heavy atom, axis3 their cross product. The zeroed moment is then always axis1. The cached-topology path uses the same axes. United atoms with no or more than one hydrogen are unchanged.
Check that the moment about the X-H bond is zeroed on axis1 in frames where the old smallest-moment axis differs, that both axes paths agree, and that united atoms without exactly one hydrogen keep their axes.
The fast regression baselines of benzaldehyde, benzene and DNA change in united_atom:Rovibrational only. Baselines whose only changes were at floating-point rounding level are left as they were.
michalkrompiec
marked this pull request as ready for review
November 27, 2026 17:19
This branch has not been deployed
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
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
For a united atom made of a heavy atom X and one hydrogen,
get_custom_moment_of_inertiazeroed the smallest of the three moments about the bonded axes. Those axes are built from the heavy-atom neighbours, so which one has the smallest moment depends on where the hydrogen points, and it can change between frames. One index of the torque covariance then mixes two different rotations. This PR builds the axes of these united atoms from the X-H bond, so the zeroed moment is always the rotation about the bond.Fixes #498
Changes
get_bonded_axesandget_bonded_axes_from_topology: a new case6 for a heavy atom bonded to exactly one hydrogen and at least one heavy atom. Axis1 is along X-H, axis2 is perpendicular to the plane of H, X and the lowest-index bonded heavy atom R1, and axis3 is their cross product (in that plane, towards R1). Both axes paths (localandtopology) build the same axes.get_custom_moment_of_inertia: for a two-atom united atom, zero the moment about axis1 (the X-H bond) instead of the smallest moment.ValueErrorfromget_bonded_vector_axes, as it did before in case3.Testing
tests/unit/CodeEntropy/levels/test_axes.py: methanol at C-O-H 108 and 150 degrees, where the smallest moment about the old axes is on different axes, gets axis1 along O-H with a zero moment in both; the N-H of dimethylamine takes axis2 from the lowest-index carbon; thelocalandtopologypaths give identical axes and moments for every heavy atom of propanoic acid; united atoms with zero, two or three hydrogens give the same axes and moments as before; HX keeps its principal axes; collinear H-X-R raises.Impact
axes: principal, are unchanged.pytest tests/regression -m "not slow" --update-baselines; onlyunited_atom:Rovibrational(and the total) changes: benzaldehydeselection_subsetandcombined_forcetorque_false+2.20 J/mol/K,frame_window+0.41; benzeneselection_subsetandcombined_forcetorque_off+1.40,frame_window+0.58; DNAframe_window-0.010 and +0.027 for its two groups;grouping_each(benzaldehyde, benzene, DNA) and DNAselection_subsetandcombined_forcetorque_offchange by less than 0.003 per group. Methanol, octanol and the other systems are unchanged (rounding-level differences were not committed).default,rad) were not regenerated locally; they will need the Update Regression Baselines workflow on this branch.Checklist
pyproject.tomlchanged, the lower bounds were reviewed deliberately