# GMX Trajectory not extracting force or velocities

**URL:** <https://gromacs.bioexcel.eu/t/gmx-trajectory-not-extracting-force-or-velocities/3087>\
**Category:** User discussions\
**Tags:** analysis-tools\
**Created:** [November 5, 2021, 5:44pm UTC](https://gromacs.bioexcel.eu/t/gmx-trajectory-not-extracting-force-or-velocities/3087 "2021-11-05T17:44:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![organicchemistry\_01](https://avatars.discourse-cdn.com/v4/letter/o/6bbea6/32.png) [@organicchemistry\_01](https://gromacs.bioexcel.eu/u/organicchemistry_01)\
**Post date:** [November 5, 2021, 5:44pm UTC](https://gromacs.bioexcel.eu/t/gmx-trajectory-not-extracting-force-or-velocities/3087/1 "2021-11-05T17:44:37Z")

</div>

GROMACS version: 2021.3  
GROMACS modification: Yes

I have these enabled in my `md file`:

```auto
nstxout = 500 
nstvout = 500
nstfout = 500 

```

but when I use:

```auto
gmx trajectory

```

I could only extract the position but not the velocities and forces. How to extract forces and velocities from my trajectory files?

---

<div class="post-metadata">

**Author:** ![jalemkul](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/jalemkul/32/18_2.png) [@jalemkul](https://gromacs.bioexcel.eu/u/jalemkul)\
**Post date:** [November 6, 2021, 4:51pm UTC](https://gromacs.bioexcel.eu/t/gmx-trajectory-not-extracting-force-or-velocities/3087/2 "2021-11-06T16:51:37Z")

</div>

What does `gmx check` tell you about the contents of the trajectory? What was your exact `gmx trajectory` command?

---

<div class="post-metadata">

**Author:** ![organicchemistry\_01](https://avatars.discourse-cdn.com/v4/letter/o/6bbea6/32.png) [@organicchemistry\_01](https://gromacs.bioexcel.eu/u/organicchemistry_01)\
**Post date:** [November 16, 2021, 12:40pm UTC](https://gromacs.bioexcel.eu/t/gmx-trajectory-not-extracting-force-or-velocities/3087/3 "2021-11-16T12:40:35Z")

</div>

This is what appears after: `gmx check -f md.trr -rmsd`

```auto
Item #frames Timestep (ps)
Step 50001 1
Time 50001 1
Lambda 50001 1
Coords 50001 1
Velocities 50001 1
Forces 50001 1
Box 50001 1

```

---

<div class="post-metadata">

**Author:** ![jalemkul](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/jalemkul/32/18_2.png) [@jalemkul](https://gromacs.bioexcel.eu/u/jalemkul)\
**Post date:** [November 16, 2021, 8:47pm UTC](https://gromacs.bioexcel.eu/t/gmx-trajectory-not-extracting-force-or-velocities/3087/4 "2021-11-16T20:47:07Z")

</div>

And what was your `gmx trajectory` command?

---

<div class="post-metadata">

**Author:** ![ABaer](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@ABaer](https://gromacs.bioexcel.eu/u/ABaer)\
**Post date:** [April 21, 2022, 12:51pm UTC](https://gromacs.bioexcel.eu/t/gmx-trajectory-not-extracting-force-or-velocities/3087/5 "2022-04-21T12:51:21Z")

</div>

Hi all,

I have in principle the same problem: I would like to extract the molecular COM velocity for a subgroup (“LIG”) of the system with the following command:  
`gmx trajectory -f trajectory.trr -s topol.tpr -e 100 -ov vel_tmp.xvg -seltype mol_com -select LIG`  
This will result in an empty velocity file (`vel_tmp.xvg`), which only contains the `.xvg` header.

If I also want to extract the position with the following command:  
`gmx trajectory -f trajectory.trr -s topol.tpr -e 100 -ox pos_tmp.xvg -ov vel_tmp.xvg -seltype mol_com -select LIG`  
I will obtain the following error message:

```nohighlight
-------------------------------------------------------
Program: gmx trajectory, version 2021.3
Source file: src/gromacs/analysisdata/datastorage.cpp (line 828)
Function: gmx::AnalysisDataStorageFrame& gmx::AnalysisDataStorage::startFrame(const gmx::AnalysisDataFrameHeader&)

API error (bug):
Out of bounds frame index

For more information and tips for troubleshooting, please check the GROMACS
website at http://www.gromacs.org/Documentation/Errors
-------------------------------------------------------

```

In the trajectory, there are positions and velocities (no forces), both saved every 0.2 ps (i.e. every 200 timesteps) as confirmed by `gmx check`:

```nohighlight
Item #frames Timestep (ps)
Step 250001 0.2
Time 250001 0.2
Lambda 250001 0.2
Coords 250001 0.2
Velocities 250001 0.2
Forces 0
Box 250001 0.2

```

I also tried different types of the selection (different groups, `-seltype atom`) with the same results.

Do you have an idea, whether it is a misusage/not implemented feature or a bug?

Best,  
Andreas

---

<div class="post-metadata">

**Author:** ![apoma](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/apoma/32/1819_2.png) [@apoma](https://gromacs.bioexcel.eu/u/apoma)\
**Post date:** [November 16, 2022, 9:58pm UTC](https://gromacs.bioexcel.eu/t/gmx-trajectory-not-extracting-force-or-velocities/3087/6 "2022-11-16T21:58:18Z")

</div>

Hi,  
Did you manage to get the Velocities? I am reporting also something similar with gmx trajectory. Take a look at [GMX trjconv does not print forces and velocities from trajectory trr file](https://gromacs.bioexcel.eu/t/gmx-trjconv-does-not-print-forces-and-velocities-from-trajectory-trr-file/5205)  
If you managed to fix this, I will appreciate any hint.  
best,  
Adolfo

---

<div class="post-metadata">

**Author:** ![apoma](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/apoma/32/1819_2.png) [@apoma](https://gromacs.bioexcel.eu/u/apoma)\
**Post date:** [November 17, 2022, 10:51am UTC](https://gromacs.bioexcel.eu/t/gmx-trajectory-not-extracting-force-or-velocities/3087/7 "2022-11-17T10:51:30Z")

</div>

it seem to be a problem with **gmx trajectory** with flag **-ov -of** and it requires someone to check It out.

Alternatively if you are not interested in -select, you can use the simple

> gmx g\_traj with flags -ov -of

with same flags and it works for me, as long as your trr file has save the velocities and forces (nstxout, nstvout, nstfout).

cheers,  
Adolfo
