# Best way to output forces of atoms

**URL:** <https://gromacs.bioexcel.eu/t/best-way-to-output-forces-of-atoms/1902>\
**Category:** User discussions\
**Created:** [April 6, 2021, 5:51am UTC](https://gromacs.bioexcel.eu/t/best-way-to-output-forces-of-atoms/1902 "2021-04-06T05:51:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rnd90](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@rnd90](https://gromacs.bioexcel.eu/u/rnd90)\
**Post date:** [April 6, 2021, 5:51am UTC](https://gromacs.bioexcel.eu/t/best-way-to-output-forces-of-atoms/1902/1 "2021-04-06T05:51:12Z")

</div>

GROMACS version: 2021  
GROMACS modification: Yes/No

Hi guys,

I’m looking for a simple way to extract forces from a trr file with a certain time step for further matching it with the positions for further processing (not just plotting). First, I tried to use this command:  
`gmx trjconv -f NVT.trr -s NVT.tpr -n index.ndx -o force.gro -force -dt 100`  
It gave me a gro file with output like  
`1670CL CL 8800 3.294 3.554 1.270 0.2940 0.1316 0.2854`  
where the last three values seem to be velocities and changing `-force` to `-vel` did not make any difference.

The best output utility I have found so far is to dump the trr file, then parse and match up with the previous output.  
`gmx dump -f NVT.trr | grep f > force.txt`  
Yes, it is possible to do, but it does not look like a simple way to do it.

Am I using the trjconv utility correctly? Is it possible to output forces instead of velocities? Is there a simple way to output positions and forces of individual atoms in a tab/space-separted format?

---

<div class="post-metadata">

**Author:** ![hess](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/hess/32/416_2.png) [@hess](https://gromacs.bioexcel.eu/u/hess)\
**Post date:** [April 6, 2021, 11:32am UTC](https://gromacs.bioexcel.eu/t/best-way-to-output-forces-of-atoms/1902/2 "2021-04-06T11:32:55Z")

</div>

You want: gmx traj -of  
You can supply an index file if you want to select certain atoms.

---

<div class="post-metadata">

**Author:** ![rnd90](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@rnd90](https://gromacs.bioexcel.eu/u/rnd90)\
**Post date:** [April 6, 2021, 6:11pm UTC](https://gromacs.bioexcel.eu/t/best-way-to-output-forces-of-atoms/1902/3 "2021-04-06T18:11:03Z")

</div>

> [@hess](#):
>
> gmx traj -of

@hess, thanks but it gives me a timeseries for specific atoms, which is convenient for plotting time series, but not processing and more complex plotting, let us say, making a running-averaged histogram of force by the z-coordinate. For this purpose, it is more convenient to read the dump file than the .xvg file. Given n atoms and m timeslices I want is a format like this:

```
(data at t = t_1)
atom_id_1 x_1 y_1 z_1 fx_1 fy_1 fz_1
atom_id_2 x_2 y_2 z_2 fx_2 fy_2 fz_2
....
atom_id_n x_n y_n z_n fx_n fy_n fz_n
(data at t = t_2)
atom_id_1 x_1 y_1 z_1 fx_1 fy_1 fz_1
atom_id_2 x_2 y_2 z_2 fx_2 fy_2 fz_2
....
atom_id_n x_n y_n z_n fx_n fy_n fz_n
...
(data at t = t_m)
atom_id_1 x_1 y_1 z_1 fx_1 fy_1 fz_1
atom_id_2 x_2 y_2 z_2 fx_2 fy_2 fz_2
....
atom_id_n x_n y_n z_n fx_n fy_n fz_n

```

---

<div class="post-metadata">

**Author:** ![hess](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/hess/32/416_2.png) [@hess](https://gromacs.bioexcel.eu/u/hess)\
**Post date:** [April 7, 2021, 8:19am UTC](https://gromacs.bioexcel.eu/t/best-way-to-output-forces-of-atoms/1902/4 "2021-04-07T08:19:39Z")

</div>

We don’t have such functionality. You could write a gmx tool for this yourself.
