GROMACS version: 2020.7
GROMACS modification: No
Hello,
I’m working with a coarse-grained model that uses fractional charges (1/3 to 16 sig. figs.) distributed across polymer chains, with the terminal bead carrying the remainder to ensure integer total charge. My supervisor raised a concern about whether GROMACS reads the full precision of these values or truncates them during topology parsing.
In my .itp files (manually created, not from pdb2gmx), I specify charges with 16 significant figures. The fractional charges are intentional as they represent charge distribution across virtual sites. By design, when summed across a complete molecule, they total to an integer value.
To test GROMACS’ charge validation behaviour, I deliberately created a test system where the charges had 16 significant figures (0.3333333333333333) but the terminal charge was NOT corrected, so the molecular charge should NOT sum to exactly an integer. I ran grompp with GROMACS 2020.7, and surprisingly, grompp gave no warnings or notes about non-integer charge. I expected at minimum a note like “System has non-zero total charge: 0.000xxx”.
This prompted me to investigate the source code. Looking at src/gromacs/gmxpreprocess/topio.cpp, I found a function that appears to explain this behaviour:
double tolAbs = 1e-6;
double tol = std::max(tolAbs, 0.5 * GMX_REAL_EPS * sumAbsQ);
if (std::abs(qTot - std::round(qTot)) < tol)
{
return std::round(qTot);
}
else
{
return qTot;
}
This appears to use a 10^-6 tolerance when checking molecular charges, which would explain why I got no warning.
What I’m trying to understand is: when I specify charges with many decimal places in my topology file, does GROMACS actually keep that precision internally, or does it get truncated at some point? And when this rounding check happens, is it just deciding whether to show a warning, or is it actually changing the charge values used in the simulation?
Thanks for any help,
Luke