analysis: reject calc_rh for chains shorter than 2 beads (bug-sweep #46)#5371
Draft
RudolfWeeber wants to merge 1 commit into
Draft
analysis: reject calc_rh for chains shorter than 2 beads (bug-sweep #46)#5371RudolfWeeber wants to merge 1 commit into
RudolfWeeber wants to merge 1 commit into
Conversation
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>
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.
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