fix: build the inertia tensor from centred coordinates - #184
Open
galjos wants to merge 1 commit into
Open
Conversation
rotational_modes centred the coordinates into atom_coords_cm but passed the original, un-centred coordinates to inertia_tensor. Away from the origin that tensor picks up the parallel-axis contribution of the centre of mass, so its eigenvectors are no longer the principal axes of the molecule. For a linear molecule the molecular axis is then not an eigenvector and none of the three rotational displacement vectors comes out with zero norm, so the linear-molecule filter keeps three rotations instead of two. The consequence is that a diatomic away from the origin has six external modes for six degrees of freedom, the internal subspace is empty, and hessian_sign_factor short-circuits to +1.0 instead of detecting the negative Hessian convention. A CO molecule with a negative-convention Hessian at a generic position was reported at -1436.17 cm-1, an imaginary mode, while the same molecule centred on the origin gave the correct +1436.17 cm-1. Building the tensor from the centred coordinates restores the principal axes. For non-linear molecules the three rotational vectors still span the same subspace, so the water reference spectrum is unchanged.
Contributor
|
PYLINT REPORT Your code has been rated at 9.78/10 Full reportRaw metrics
Duplication
Messages by category
% errors / warnings by module
Messages
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #184 +/- ##
==========================================
+ Coverage 93.86% 93.94% +0.07%
==========================================
Files 177 177
Lines 9215 9227 +12
==========================================
+ Hits 8650 8668 +18
+ Misses 565 559 -6
🚀 New features to boost your workflow:
|
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.
The rotational trial vectors are built from coordinates relative to the centre of mass, but the inertia tensor whose eigenvectors they are projected onto was built from the raw coordinates. For a linear molecule far from the origin the resulting basis is wrong enough that
hessian_sign = autoselects the opposite convention and the reported wavenumbers change sign.The tensor is now built from the same centred coordinates. The spectrum of a well centred molecule is unchanged, since any complete orthogonal basis leaves the eigenvalues alone.
Present in v1.5.0. 949 tests pass in both type checking modes.