-
Notifications
You must be signed in to change notification settings - Fork 188
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
Separate quaternion algebra from particle rotation #3164
Conversation
Use Vector4d arithmetic and std::tuple, remove unused error codes, simplify the Cython interface by enabling Vector4d indexing.
Codecov Report
@@ Coverage Diff @@
## python #3164 +/- ##
======================================
- Coverage 85% 85% -1%
======================================
Files 528 530 +2
Lines 25790 25777 -13
======================================
- Hits 22148 22136 -12
+ Misses 3642 3641 -1
Continue to review full report at Codecov.
|
I'd suggest deferring this until after 4.1. The freeze is already a few days overdue and I'd like to focus on release-relevant issues, right now. |
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.
Please move quaternion.hpp
to utils and add unit tests for the three functions in there.
@fweik I personally wouldn't move that file to utils because it's not re-usable. The corner case with +/-pi/2 shows this quaternion implementation only works because the calling sites were tailored for it. Writing a C++ unit test would not really make sense here, because only the final result of the rotation is of interest (already covered by Python tests), and it would make maintenance harder (we once had a C++ tabulated bond with the wrong sign, and a test that made sure the result had the wrong sign, because the python logic was tailored for it). Coming up with a unit test is also annoying because the quaternion formalism is not standard, and the fact that a unit test was hard-coded inside a calling site to check the rotation inversion implementation is correct every time the function is called is odd. |
Please add the tests. |
Testing the multiplication is easy, just check the multiplication table. For the conversion functions you should check that they are inverse to each other. It's sufficient that they encode the direction, not how. If anything, when there is client code that depends on a specific behavior of the function, especially it is non-standard, that gives more reason to add a test, so that behavior is kept. So you should also add a test for the sign convention. |
The C++ standard specifically excludes std::sqrt from the list of functions in cmath that are eligible for constexpr. Although some compilers made std::sqrt a constexpr function anyway, it's not the case of AppleClang 9.0.
bors r=fweik |
3164: Separate quaternion algebra from particle rotation r=fweik a=jngrad Description of changes: - extract quaternion algebra from the `particle_data.hpp` and `rotation.hpp` files - removes code duplication caused by a (now resolved) circular dependency (see #3157) - makes it possible to replace the quaternion code by a dedicated library, e.g. [boost:qvm::quat](https://www.boost.org/doc/libs/1_68_0/libs/qvm/doc/index.html) or [boost::math::quaternion](https://www.boost.org/doc/libs/1_62_0/libs/math/doc/html/quaternions.html) in the core (see #2289), [rowan](https://rowan.readthedocs.io/en/latest/) in the interface (see #2964) - simplify code around call sites using Vector4d arithmetic, `std::tuple`, Particle references - documentation cleanup 3245: Fix thermostat and integrator checkpointing r=KaiSzuttor a=jngrad The checkpointing mechanism silently broke in 4.1 for the SD and NPT integrators and LB and NPT thermostats. This was fixed, and now all integrators and thermostats checkpoints are tested in CI. Co-authored-by: Jean-Noël Grad <[email protected]> Co-authored-by: Kai Szuttor <[email protected]>
Build succeeded |
Description of changes:
particle_data.hpp
androtation.hpp
filesstd::tuple
, Particle references