Constraints = h-bonds skips hydrogens whose names don't start with H (issue #5745)

GROMACS version: 2026.3
GROMACS modification: No

Hi all,

With constraints = h-bonds, I found that C-H bonds remain flexible when the hydrogen names start with a digit, such as 1H21. These names occur in some CHARMM-style lipid and detergent topologies.

In a minimal ethane reproduction, ordinary H-prefixed names give 6 constraints, while digit-prefixed names give 0 constraints. Both cases pass grompp with -maxwarn 0 at a 2 fs timestep. The hydrogen atom type has atomic number 1 in both cases.

I opened an issue with the reproduction files and details:

The hydrogen detection in count_hydrogens() checks the first character of the atom name. Would using the atomic number when available, with a fallback to the existing name-based check, be an acceptable change? OpenMM constrains the same topology as expected using the atomic number.

I have a warning-only patch ready with tests, and would also be happy to prepare an MR for atomic-number-based detection if that is preferred.

Thanks!

Thanks for reporting this.

The question is what exact condition we should use. Name starting with H OR atomic number is 1? I think we should anyhow check for the first letter in the name, not the first character. That would also solve this case.

I see now that the constraint conversion code checks the first character instead of calling the is_hydrogen() function that checks the second character when the first is a digit. I’ll upload a fix.

Could you test this fix?

Thanks for the quick fix! I built the branch and tested it, and it works: hydrogens named like `1H21` are now constrained. I put the details on the MR.