-
Notifications
You must be signed in to change notification settings - Fork 57
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
Fix gradients and metric functions of distanceDir #724
Conversation
Types indicating differences or derivatives of unit vectors and unit quaternions are needed to handle values with the same dimensionality as the original types, but no constraints. The two enum also need to be handled explicitly in a switch statement to compile without warnings. However, it is better if the corresponding code raises an error, instead of computing something that has no consistent definition.
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.
Looks good to me!
{ | ||
return (x1.rvector_value - x2.rvector_value).norm2(); | ||
return x1.dist2(x2); |
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.
So now the square of distance of two distanceDir
is calculated as the angle between them. Should we clarify that in the documentation?
After merging this PR and #713 , I may still need to verify if polarPhi
and distanceDir
with a custom function could yield the same trajectories.
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.
So now the square of distance of two
distanceDir
is calculated as the angle between them. Should we clarify that in the documentation?
Yes. I meant to do that, but forgot. I would say, though, that defining the distance as such is the same as taking the standard Euclidean distance (L^2 norm) but making it comply with the unit-vector constraint.
After merging this PR and #713 , I may still need to verify if
polarPhi
anddistanceDir
with a custom function could yield the same trajectories.
Yeah, that makes sense. (EDIT: the choice of metrics in colvarvalue
should not matter there, only that the gradients of colvar::distance_dir
are correct.)
Fixes #714