NBLIB usage

GROMACS version: 2021.3
GROMACS modification: No

Hi,

I am curious about the usage of NB-LIB, and I have some questions about it.

  1. I saw some examples of NB-LIB, which include calculation of bonded interaction, calculation of non-bonded interaction, topology builder, leap-frog integrator, and so on. However, I do not see any methods related to thermostat, pressure coupling, and long-range PME calculations, which are commonly used in MD. Are these methods contained in NB-LIB, or will these methods be included if I read tpr file with trpReader?
  2. If all above methods are implemented in NB-LIB, can I run real protein simulation with my own program by calling NB-LIB? If yes, how is the efficiency of running simulation with NB-LIB compared to directly running simulation with Gromacs?

Thanks,
Pan

Hi Pan,

Thanks for your questions and your interest in NB-LIB!

Currently, only NVE is implemented in NB-LIB, which means no thermostats or barostats. Also, no constraints are implemented, which means that a protein in water system would not have as good performance as the Gromacs binaries. For other systems, without constraints, NB-LIB should be about as fast as Gromacs, as long as you are only running on a single node, since we have not yet provided a domain decomposition interface. We do hope in the future that more aspects of update can be exposed in NB-LIB, though this will not be part of the upcoming Gromacs release.

I am curious if you could share more about your use case in terms of what systems you want to run and why you are interested to use NB-LIB, as this can help us to prioritize among the various development goals we have.

Joe Jordan

Hi Joe,

Thanks for providing so much information about NB-LIB. Your answers are very helpful.

I am interested in NB-LIB because I think it could be easier to apply user-defined energy and force calculations with NB-LIB in own code than adding them directly into Gromacs program. I am excited to know that NB-LIB is about as fast as Gromacs when running on a single node. I think it will be beneficial if NB-LIB can achieve most functionalities in Gromacs. In this case, we can assign all MD options in mdp file to generate tpr file, and read the tpr file with NB-LIB to run real protein simulations with some additional user-defined functions in our own codes.

Best,
Pan

Hi Pan,

I would like to press you for a bit more info, if possible. Can you be more specific about the types of energy and force calculations you would be interested in?

With regard to the use case you describe of reading in a tpr and using this as a starting point for calculations that extend existing gromacs functionality, this is a use case we have not yet considered. It should be possible, but likely would need to be a bit more complicated than what you describe. Basically we would need to implement an interface that exposes the non-bonded and listed forces read in from a tpr for editing. This is a very interesting prospect and I really want to thank you for helping crystallize this idea.

One further thing I can add is that some of the features you are thinking about may already exist or be on the cusp of existing in the python gmxapi. Already there is an interface that lets a user add custom forces along a collective variable defined by the user. Additionally, in gromacs 2022, we will have a generic interface that allows defining arbitrary CVs using pull coordinates in an mdp file. Finally, there is some discussion about adding the ability to modify parts of a tpr file using the python gmxapi. If I have missed (or missrepresented) things @ericirrgang can say perhaps say more on this topic.

Hi Joe,

I would like to add machine learning models for energy and force calculations, and the framework such as Tensorflow will be used. I am not sure how it is difficult to write machine learning codes into Gromacs directly, so I think the NBLIB might be easier to achieve this goal with own program. I saw that the compute method will be called for NBForceCalculator and ListedForceCalculator to calculate forces, and the forces can be manipulated inside the MD loop such as using zeroCartesianArray function, so I think it is possible to add functions calculating energy and forces before integration step.

I considered gmxapi before, but some examples I found (e.g. sample restraints) are using gmxapi 0.07 version, in which some functions or modules related to external forces are not supported in gmxapi 0.1 version or higher. The Gromacs installation comes with gmxapi 0.1 version or higher, but the documentation of gmxapi on Gromacs website seems too concise and I cannot find how external forces can be added. I really appreciate if anyone could help me with the detailed usage of gmxapi.

Best,
Pan

Hi Pan,

The area of machine learning potentials for force fields is indeed an area where there are very many interested parties. Indeed one primary goal of NBLIB is to allow rapid prototyping of user forces and energies without having to do too much work to understand much about gromacs internals. It may actually be possible to use the NBLIB topology specification to get your forces and energies computed directly in the underlying gromacs engine already. Can you specify the functional form of your potentials? Are they like LJ where there is a c6 and c12 parameter, or perhaps more like bonds or angles, where the interacting atoms are fixed for the length of a simulation? In that case, you would not even need to write any of your own code beyond some setup code. If you have a need for more generic non-bonded potentials, it would be great if you could outline a bit what they look like, so that I could try to assess how feasible it might be to implement that.

Thanks,
Joe

Hi Joe,

The functional form of machine learning potential I used is neural network, which is loaded by Tensorflow library. It is not similar to classical potential such as LJ, bonds or angles. The parameters of neural network are saved in a file that Tensorflow can read.

Best,
Pan

I am sorry, but I don’t understand this. Are you saying that the potentials are a table? If so, this is something that we have been meaning to re-implement in Gromacs for a few years now. You would need to ask @lindahl about the status of this. Once this is re-implemented, it would be quite easy I believe to expose this in NB-LIB.

I think the potential energy function form of neural network is not implemened in Gromacs, so we cannot only feed the parameters into Gromacs. Instead, we need to write additional codes to read the neural network graph and its corresponding parameters, and that is why I think using NB-LIB could be easier.

For example, here are parts of codes for MD loop using NB-LIB from the tutorial.

for (int step = 0; step < 100; step++)
{
    forceCalculator.compute(box, coordinates, forces);
    listedForceCalculator.compute(box, coordinates, forces);
    integrator.integrate(timestep, coordinates, velocities, forces);
    zeroCartesianArray(forces);
}

I think I could add my own function which performs neural network predictions to update forces before integrator.integrate, as the following codes show.


for (int step = 0; step < 100; step++)
{
    forceCalculator.compute(box, coordinates, forces);
    listedForceCalculator.compute(box, coordinates, forces);
    myNeuralNetworkPredictions(myInputs, forces); // Here the forces will be updated by neural network
    integrator.integrate(timestep, coordinates, velocities, forces);
    zeroCartesianArray(forces);
}

I am not sure if my understanding about the usage of NB-LIB is correct, and the prerequisite for me to use NB-LIB is that it supports the necessary functionalities of protein simulations.