GROMACS version: 2024.4
GROMACS modification: No
We have an ongoing discussion in the vermouth discussion forum about defining the strength of position restraints flexibly away from a default.
I can see that this can be done by having a section in a molecule itp along the lines of:
[ position_restraints ]
#ifdef POSRES
1 1 POSRES_FC POSRES_FC POSRES_FC
5 1 POSRES_FC POSRES_FC POSRES_FC
...
then in the mdp including -define = -DPOSRES_FC=1000
to specify the strength of the restraint, as described here.
If the value is not passed from the mdp, then there needs to be a default, otherwise grompp raises an error. Trivially, this can be done as:
[ position_restraints ]
#ifdef POSRES
#ifndef POSRES_FC
1 1 1000 1000 1000
5 1 1000 1000 1000
...
#else
1 1 POSRES_FC POSRES_FC POSRES_FC
5 1 POSRES_FC POSRES_FC POSRES_FC
...
This is an issue for vermouth development, because Vermouth does not (currently) handle nested #ifdef statements. What I’d really want to be able to do is instead have something at the top of the molecule itp file that redoes the #define there, along the lines of:
#ifndef POSRES_FC
#define = -DPOSRES_FC=1000
#endif
so that if the defines is missing from the mdp, the default is specified at the top of the itp. However, this seems to cause the same warning, so I don’t think grompp is processing this in the itp, so I think I’m messing up the syntax somehow. Is it possible to use the #define syntax like this, and if so, how is it possible to implement it?