Skip to content

Spherical#285

Merged
joaander merged 16 commits into
trunkfrom
spherical
May 12, 2026
Merged

Spherical#285
joaander merged 16 commits into
trunkfrom
spherical

Conversation

@mthran
Copy link
Copy Markdown
Contributor

@mthran mthran commented May 4, 2026

Description

This PR introduces several small changes for Spherical<3> and Spherical<4>, namely:

  • The distance function from Metric for Spherical<3>' and Spherical<4>' is modified to clip the argument to the range of [-1.0,1.0].
  • Implementation of a new function from_versor for Spherical<4>
  • More efficient LocalTrial for Spherical<4> based on the exponential mapping of the manifold.

Motivation and context

These changes are largely motivated by my own use of hoomd-rs to simulate points on 2- and 3-spheres.

  • The distance function for Spherical<N> needed to be clipped because floating point errors sometimes made antipodal points return a distance of Nan instead of pi.
  • The from_versor function lends itself to a natural and efficient representation of 3-sphere points. In practice this is helpful for initializing points randomly on the 3-sphere.

How has this been tested?

This PR includes unit test functions for all the new functions. I have also been using this branch to run production simulations and have verified that the functions work as expected. For example, thermodynamic quantities calculated from the Spherical<4> methods reproduce values given by older published simulation results

Checklist:

  • [ X ] I have reviewed the Contributor Guidelines.
  • [ X ] I agree with the terms of the hoomd-rs Contributor Agreement.
  • [ X ] My name is on the list of contributors (doc/src/credits.md) in the pull request source branch.
  • I have summarized these changes in release-notes.md following the established format.

Copy link
Copy Markdown
Member

@joaander joaander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Please address the few suggestions I made and then we can merge this branch.

Comment thread hoomd-manifold/src/sphere.rs
Comment thread hoomd-vector/src/quaternion.rs
Comment thread hoomd-manifold/src/sphere.rs Outdated
Copy link
Copy Markdown
Member

@joaander joaander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@joaander joaander enabled auto-merge May 12, 2026 20:38
@joaander joaander merged commit 6f9ff64 into trunk May 12, 2026
18 checks passed
@joaander joaander deleted the spherical branch May 12, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants