Adding user-defined mdp option

GROMACS version: 2021.3
GROMACS modification: Yes

I am trying to add user defined variables to the source code that are booleans and tensors.

I have added these new variables to src/gromacs/mdtypes/inputrec.cpp, src/gromacs/gmxpreprocess/readir.cpp, gromacs/fileio/readinp.cpp, and src/gromacs/filio/tpxio.cpp. I am able to recompile the code without errors and I see my new variables show up in the mdout.mdp file, but in the log file of the run the variable is set to the default value (false for the boolean variable even when the mdp file says “yes” and a 3x3 matrix of zeros rather than filling in what I have defined in the mdp file).

How do I make sure that gromacs is reading the actual values in the mdp file rather than filling in defaults for the user-defined mdp options?
If anyone has any insight on adding new variables to the mdp options and how to find all the relevant source files that need to be edited for this, it would be greatly appreciated!

Hi!

We don’t have a definitive list, but your list of relevant files looks complete, so perhaps something else is going wrong. Do you have your code available anywhere?

P.S. I moved your post to “Developers discussions”.

Thank you for moving my post. I couldn’t find the developer option when I created this discussion. I have added the src/gromacs/ folders with the edited files onto github (https://github.com/kong1-731/mygromacs_2021.3.git).

My added user inputs have the prefix sinp and are listed near the “userint” options in src/gromacs/mdtypes/inputrec.cpp, src/gromacs/gmxpreprocess/readir.cpp, gromacs/fileio/readinp.cpp, and src/gromacs/fileio/tpxio.cpp.

Hi! In your repo, you’re missing api/legacy/include/gromacs/mdtypes/inputrec.h, so it does not compile.

If you want, you can join the dev call this Wednesday.

Thank you for that kind offer. Unfortunately I was away and missed this call.

I have not been able to replicate the compilation error. I am able to compile without issues, but I am not sure if my dynamic pressure code is truly running. In my repo I was unable to fully copy the entirety of my gromacs-2021 folder due to space constraints and I wasn’t sure how to fork a new gromacs-2021 repo.

I noticed that for the simulated annealing module temperature is stored in inputrec.opts. My dynamic pressure updates ref_p stored in ir (ir → ref_p). Do I have to add ref_p to opts in order for the barostat code to actually look at the dynamic reference pressure values rather than the static value?

Thank you for any advice!

Hi!,

Note that the inputrec is intended to store the original input from the user. It should contain the original value of the reference pressure. Updated reference pressure values is not something the existing infrastructure has contemplated (since you seem to be formally changing the ensemble, how is the microstate even defined?) but my advice to you is to follow the approach of the other coupling modules and store the current state values in fields of t_state. In your case, that probably means both the computed pressure for this step (like other pressure coupling code does) and the updated value of the reference pressure (for which you will need to add fields to t_state).

Doing it this way gives you a much better chance of later getting parallelism and checkpointing working.

Thank you for your response! I will try storing the reference pressure in t_state. I am just wondering why I would need to save the computed pressure for the step as well. I intend for the code to function as the simulated annealing module does where the reference is updated after a set number of timesteps but the actual pressure control is still carried out by the Berendsen or Parrinello-Rahman barostats defined in coupling.cpp.