Run gmx energy on a large number of systems

GROMACS version: 2026.0 (conda, CUDA)
GROMACS modification: No
Hello, I need to run gmx energy on 100 systems and extract multiple observables (temperature, pressure, potential, total energies, etc). Typically, for each observable and each system, one would issue this command:

gmx energy -f md.edr -o [observable].xvg

And manually type the name of the observable. It will take a lot of time to manually type 100 times for each observable for my 100 systems. Is there a way to make gmx energy automatically extract all the observables I want from 100 different systems?

Best regards,

Hoa

There’s no way to do this natively in GROMACS, but you can achieve this pretty easily using a shell script. In particular, you’ll probably want something like

shopt -s nullglob 
edrfiles=(*.edr)
observable="<observable>"
obs_index=10 # the index of the observable you want gmx to extract
for file in $edrfiles; do
  echo ${obs_index} 0 | gmx energy -f $file -o "${observable}.xvg"
done

There are also bash commands that can parse output and extract specific information. Any LLM will probably do a pretty good job at this.

Thank you! It worked!