Skip to content

shapes: fix SimplePore side-sign at lower pore mouth (bug-sweep #13)#5387

Draft
RudolfWeeber wants to merge 1 commit into
espressomd:pythonfrom
RudolfWeeber:fix/bug-13-simplepore-side-sign
Draft

shapes: fix SimplePore side-sign at lower pore mouth (bug-sweep #13)#5387
RudolfWeeber wants to merge 1 commit into
espressomd:pythonfrom
RudolfWeeber:fix/bug-13-simplepore-side-sign

Conversation

@RudolfWeeber

Copy link
Copy Markdown
Contributor

SimplePore::calculate_dist determined the inside/outside side in the
smoothing (torus) corner using the signed z in
Utils::sqr(z - c_z), while dist_half_pore and every other use of z in
the side logic (the std::abs(z) > m_half_length and std::abs(z) >= c_z
guards) use |z|. The function documents mirror symmetry in z about the
center, so at the negative-z mouth this forced side=+1 (outside) even for a
point inside the solid wall material, flipping the sign of the returned
distance. The constraint force then points the wrong way and particles can
penetrate the lower mouth — asymmetric, silently wrong physics. The sibling
Cylinder::calculate_dist uses |z| in its analogous test.

Fix: use Utils::sqr(std::abs(z) - c_z) so the side determination is
mirror-symmetric, matching the rest of the function. This is a no-op for
z >= 0, so the previously-tested +z mouth is unchanged.

Add SimplePore_test.cpp asserting mirror symmetry of the signed distance
between the +z and -z mouths inside the smoothing fillet, and that a point
inside the solid reports a negative distance at both mouths.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

🤖 Generated with Claude Code

SimplePore::calculate_dist determined the inside/outside side in the
smoothing (torus) corner using the signed z in
`Utils::sqr(z - c_z)`, while dist_half_pore and every other use of z in
the side logic (the `std::abs(z) > m_half_length` and `std::abs(z) >= c_z`
guards) use |z|. The function documents mirror symmetry in z about the
center, so at the negative-z mouth this forced side=+1 (outside) even for a
point inside the solid wall material, flipping the sign of the returned
distance. The constraint force then points the wrong way and particles can
penetrate the lower mouth — asymmetric, silently wrong physics. The sibling
Cylinder::calculate_dist uses |z| in its analogous test.

Fix: use `Utils::sqr(std::abs(z) - c_z)` so the side determination is
mirror-symmetric, matching the rest of the function. This is a no-op for
z >= 0, so the previously-tested +z mouth is unchanged.

Add SimplePore_test.cpp asserting mirror symmetry of the signed distance
between the +z and -z mouths inside the smoothing fillet, and that a point
inside the solid reports a negative distance at both mouths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant