How does GROMACS know which bonds it should use?

GROMACS version: 2021.3
GROMACS modification: No

Dear GROMACS users,

I have a conceptual question about the structure of the gromos 54a7 force field together with GROMACS.

Say one would start a simulation from a .gro-file and a .top-file. The .gro-file contains the positions of atoms (assume the atoms are among the ones present in atomtypes.atp) on a lattice. In the topology file one would include the forcefield parameters in forcefield.itp, include some water topology, include the ion topology and then the number of atoms of the each type under [ molecules ].

In the forcefield.itp, both ffnonbonded.itp and ffbonded.itp are in turn included.
In ffbonded.itp different types of bonds and angles with names such as gb_x and ga_x (where x are integers) are specified.

My confusion is now the following: when starting a simulation from this point, how would GROMACS be able to know the different bonds and angles between the atoms in the lattice. Only the positions are given in the .gro-file and only bondtypes/angletypes are specified in ffbonded.itp, without there stating which atoms that use these bonds or angles (this is only done in examples in commented lines).

So how does GROMACS know what the bond lengths and angles are of the atoms on some lattice. Or to put it in terms of an example: if we had specified positions of a couple of S atoms in the .gro-file, how would it be clear to GROMACS that gb_36 is the bond that should be used between them?

Bonds and angles must be explicitly listed in the [moleculetype] definition using [bonds] and [angles] directives. Without these, there are no bonds in the system. From the defined bonds and angles, grompp uses the atom types for the participating atoms and looks up the relevant parameters from ffbonded.itp.

Thank you for your quick and clear response @jalemkul.

A follow-up question that came to mind:
For a periodic lattice one could define a unit cell under [moleculetypes] with the bonds and angles within it (in, say, an itp-file). One could then use several of these as building blocks to make up the entire lattice. But, am I correct in thinking that this would not include bonds and angles between the unit cells? Does that mean that when using some lattice (e.g. when modeling a solid surface or particle), one has to explicitly define the bonds and angles between every single atom in that lattice, even if there is a periodic structure? And that this would be done under [moleculetype] - in other words, one would have to implement the entire lattice as if it were a molecule?
Is there no way to take into account the periodicity and define in some way that there should be bonds of say type gb_x between atoms of type A and B in the lattice, and bonds of type gb_y between atoms of type B and C, and so on (and in a similar way for the angles)?

You can specify bonds and angles between atoms in periodic images by specifying them in the topology and using periodic_molecules = yes in the .mdp file. By doing so, mdrun will look for the shortest periodic distance when calculating the bonded forces.

Thank you, that’s very helpful.