core/immersed_boundary: fix Tribend concave reference angle (bug-sweep #5)#5385
Draft
RudolfWeeber wants to merge 1 commit into
Draft
core/immersed_boundary: fix Tribend concave reference angle (bug-sweep #5)#5385RudolfWeeber wants to merge 1 commit into
RudolfWeeber wants to merge 1 commit into
Conversation
…#5) IBMTribend::calc_forces() builds the dynamic dihedral angle as theta = acos(n1*n2) * copysign(1, desc), confined to [-pi, pi], while initialize() maps a concave reference dihedral (desc = dx1 . (n1 x n2) < 0) onto theta0 = 2*pi - acos(...) in [pi, 2*pi]. The two angles thus live on different branches and the raw difference DTh = theta - theta0 was never reduced modulo 2*pi. At a concave reference equilibrium DTh = -2*pi instead of 0, applying a spurious ~2*pi*kb bending force at the relaxed shape -- exactly the canonical biconcave-RBC / vesicle membrane use case. Fix: reduce DTh to (-pi, pi] via std::remainder(theta - theta0, 2*pi), keeping the signed theta and the copysign(1, theta) orientation factor unchanged. This zeroes the force at both convex and concave reference shapes and yields correctly restoring forces on both sides of equilibrium. (Note: the alternative of remapping the dynamic theta to [0, 2*pi] would collapse copysign(1, theta) to +1 and make concave references unstable.) Adds two regression tests to testsuite/python/ibm.py: a convex control (passes even on buggy code) and the concave equilibrium case (force ~6 on buggy HEAD, < 1e-6 after the fix). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
not obvious to me. Needs more detailed analysis. |
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.
IBMTribend::calc_forces() builds the dynamic dihedral angle as
theta = acos(n1n2) * copysign(1, desc), confined to [-pi, pi], while
initialize() maps a concave reference dihedral (desc = dx1 . (n1 x n2) < 0)
onto theta0 = 2pi - acos(...) in [pi, 2pi]. The two angles thus live on
different branches and the raw difference DTh = theta - theta0 was never
reduced modulo 2pi. At a concave reference equilibrium DTh = -2pi instead
of 0, applying a spurious ~2pi*kb bending force at the relaxed shape --
exactly the canonical biconcave-RBC / vesicle membrane use case.
Fix: reduce DTh to (-pi, pi] via std::remainder(theta - theta0, 2pi),
keeping the signed theta and the copysign(1, theta) orientation factor
unchanged. This zeroes the force at both convex and concave reference
shapes and yields correctly restoring forces on both sides of equilibrium.
(Note: the alternative of remapping the dynamic theta to [0, 2pi] would
collapse copysign(1, theta) to +1 and make concave references unstable.)
Adds two regression tests to testsuite/python/ibm.py: a convex control
(passes even on buggy code) and the concave equilibrium case (force ~6 on
buggy HEAD, < 1e-6 after the fix).
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
🤖 Generated with Claude Code