Numerical differentiation to calculate force

GROMACS version: 2021.3
GROMACS modification: No
Here post your question

I am trying to calculate the force of an atom through numerical differentiation to compare with the analytical force printed from Gromacs. Is there any way to do it?

The way I am doing it now is to slightly change the coordinate of an atom in gro file, and calculate the potential energy for the new structure. However, I found the potential energies from log file are same between the two structures that only have tiny differences of coordinates. This is because the output energies in log file has limited significant numbers, but the tiny differences of coordinates only result in the tiny differences of potential energies, which should be different to very small decimals. If there is no direct way to do compare the force between numerical approach and analytical approach, could you tell me how I can print out energies and forces with more significant numbers to reach more decimals?

Thank you!

You can run in double precision and use gmx energy -dp to get more decimals.

But all force kernels in GROMACS implement forces derived through analytical differentiation, so you will find that they match.