Skip to content

analysis: reject calc_rh for chains shorter than 2 beads (bug-sweep #46)#5371

Draft
RudolfWeeber wants to merge 1 commit into
espressomd:pythonfrom
RudolfWeeber:fix/bug-46-calc-rh-chainlen1
Draft

analysis: reject calc_rh for chains shorter than 2 beads (bug-sweep #46)#5371
RudolfWeeber wants to merge 1 commit into
espressomd:pythonfrom
RudolfWeeber:fix/bug-46-calc-rh-chainlen1

Conversation

@RudolfWeeber

Copy link
Copy Markdown
Contributor

The hydrodynamic radius is computed as a sum over distinct bead pairs
with a 0.5N(N-1) prefactor. For a single-bead chain (chain_length==1)
there are no pairs: the prefactor is 0 and the accumulated inverse
distance ri stays 0, so calc_rh evaluated prefac/ri = 0.0/0.0 = NaN and
returned a silent NaN array instead of reporting the ill-posed request.

check_topology only rejects chain_length<=0 and is shared with calc_re
and calc_rg, where single-bead chains are valid (R_e==0, R_g==0), so the
guard cannot live there. Add a calc_rh-specific precondition in the
script-interface dispatch that throws std::domain_error (surfaced as a
Python ValueError, consistent with the other chain-analysis domain
checks) when chain_length < 2.

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

🤖 Generated with Claude Code

The hydrodynamic radius is computed as a sum over distinct bead pairs
with a 0.5*N*(N-1) prefactor. For a single-bead chain (chain_length==1)
there are no pairs: the prefactor is 0 and the accumulated inverse
distance ri stays 0, so calc_rh evaluated prefac/ri = 0.0/0.0 = NaN and
returned a silent NaN array instead of reporting the ill-posed request.

check_topology only rejects chain_length<=0 and is shared with calc_re
and calc_rg, where single-bead chains are valid (R_e==0, R_g==0), so the
guard cannot live there. Add a calc_rh-specific precondition in the
script-interface dispatch that throws std::domain_error (surfaced as a
Python ValueError, consistent with the other chain-analysis domain
checks) when chain_length < 2.

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