Dynamic POSRES_FC assignment in .mdp

GROMACS version: 2024.4
GROMACS modification: No

Hello everyone,

I came across this issue, which states that assigning values to preprocessor variables (e.g., -DPOSRES_FC= ) in the .mdp file was no longer supported in GROMACS 2018.

Previously, this method allowed easy modification of position restraint force constants (POSRES_FC) during different equilibration stages:

define = -DPOSRES -DPOSRES_FC= 

And in the .itp file:

#define POSRES_FC 1000.0
#endif

[ position_restraints ]
; atom  type      fx      fy      fz
1       1     POSRES_FC  POSRES_FC  POSRES_FC
4       1     POSRES_FC  POSRES_FC  POSRES_FC
7       1     POSRES_FC  POSRES_FC  POSRES_FC

I am using GROMACS 2024.4. Has this behavior changed in newer versions?
If not, what is the recommended approach for gradually reducing position restraints across equilibration stages?

I appreciate any insights!

I think this should still work.

But what is the #endif doing in your .itp file? What conditional do you have before that?

I can confirm that this works properly, I use it regularly with several GROMACS versions (v2022 or higher).

Thanks for your response! The #endif was just an example and not actually from my .itp file.

I appreciate your confirmation!

Yes but if grompp compiles it should mean that the formalism of the ifdef statement is correct and then you risk define parameters that you did not want to use. If you do not need constants and definition as they come from other systems/tutorials I’d rather remove those definitions!

Thank you for your clarification! In my .itp file, I have included position restraints as follows:

; Include Position restraint file
#ifdef POSRES
#include "posre.itp"
#endif

In posre.itp, I define the restraints like this:

[ position_restraints ]
; atom  type      fx      fy      fz
     1     1  POSRES_FC  POSRES_FC  POSRES_FC

And in my .mdp file, I specify:

; Position Restraints
define          = -DPOSRES -DPOSRES_FC=

I adjust the value of POSRES_FC by changing the -DPOSRES_FC parameter.

Does this setup look correct to you? I want to ensure that the position restraints are applied properly without unintended issues.

Looks good to me!

Thank you!