[gmx-developers] Interfacing with gromacs to get potential energies/ forces

David van der Spoel spoel at xray.bmc.uu.se
Fri Nov 18 16:11:24 CET 2016

On 18/11/16 11:43, Augustin Chevallier wrote:
> Hello,
> first, I apologize if this is not the right mailing list, however it
> seemed more appropriate than user mailing list.
> I would like to get the potential energy computed by gromacs without
> having to use the command line and the overhead of writing/reading the
> result in files. I had a look at the code and indeed it seems possible
> using mdlib, however I'm a bit overwhelmed by the complexity of the code.
> From what I understood, I should call the function do_forces(), however
> it has many parameters, and after looking at do_md() ,mdrunner()  and
> main() it seems there is quite a lot of things to set up before calling
> that function.
> So here are some more precise questions:
> *which initialization are required? should I just copy past some parts
> of mdrunner for that?
> *how do I load a gromacs topology file?
> *I guess I also need a forcerec, how do I create on too?
> *If I want to modify the atoms positions, can I do it in mdAtoms directly?
> I know these questions are rather vague, so if you could just point to
> which part of md_runner() and do_md() I should look at, it would greatly
> help!
If you check out the branch qmmm you will find there is an interface to 
gromacs in src/gromacs/mmslave.h. You can call a few functions to change 
coordinates and charges and then calculate energy and forces. If you 
link your code to gromacs and call these routines it should work.

The problem with this code is that it will most likely disappear or 
change a lot before being taken up in regular gromacs.

> Thanks!
> Augustin Chevallier

David van der Spoel, Ph.D., Professor of Biology
Dept. of Cell & Molec. Biol., Uppsala University.
Box 596, 75124 Uppsala, Sweden. Phone:	+46184714205.
spoel at xray.bmc.uu.se    http://folding.bmc.uu.se

More information about the gromacs.org_gmx-developers mailing list