# Compute the kinetic energy of a specific group in Gromacs

**URL:** <https://gromacs.bioexcel.eu/t/compute-the-kinetic-energy-of-a-specific-group-in-gromacs/7129>\
**Category:** User discussions\
**Created:** [September 4, 2023, 4:25pm UTC](https://gromacs.bioexcel.eu/t/compute-the-kinetic-energy-of-a-specific-group-in-gromacs/7129 "2023-09-04T16:25:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lida](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@Lida](https://gromacs.bioexcel.eu/u/Lida)\
**Post date:** [September 4, 2023, 4:25pm UTC](https://gromacs.bioexcel.eu/t/compute-the-kinetic-energy-of-a-specific-group-in-gromacs/7129/1 "2023-09-04T16:25:18Z")

</div>

GROMACS version:  
GROMACS modification: Yes/No

I am using the NEMD method to calculate the thermal conductivity of water in Gromacs. I have three groups in the simulation: hot water, cold water, and free water. I want to calculate the kinetic energy of each group.

Here is the method I used:

1. Using **gmx select** to isolate the group, producing an index file.

2. With the **convert-tpr** command, I can create a modified **.tpr** file centered on the selected group.

3. The **gmx trjconv** command extracts the group’s coordinates from the entire trajectory to obtain a group-specific trajectory.

4. With the modified **.tpr** file and the group-specific trajectory, the **gmx mdrun** command with the **-rerun** option recalculates the energies for the specific group, generating a new energy file. This energy data can then be extracted and analyzed using **gmx energy.**

However, there is no option for the kinetic energy. What I got is attached. Any suggestions would be very appreciated!

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/bioexcel1/original/2X/c/c2bbcc641e24b3a7ed27e6d61aaaa7a0d91518fd.png)

---

<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:** [September 4, 2023, 4:40pm UTC](https://gromacs.bioexcel.eu/t/compute-the-kinetic-energy-of-a-specific-group-in-gromacs/7129/2 "2023-09-04T16:40:29Z")

</div>

If the trajectory passed to `-rerun` does not have velocities (like an `.xtc` file), then you will not be able to get kinetic energy values.

---

<div class="post-metadata">

**Author:** ![Lida](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@Lida](https://gromacs.bioexcel.eu/u/Lida)\
**Post date:** [September 4, 2023, 5:27pm UTC](https://gromacs.bioexcel.eu/t/compute-the-kinetic-energy-of-a-specific-group-in-gromacs/7129/3 "2023-09-04T17:27:55Z")

</div>

Hi Dr. Lemkul,

Thank you for your prompt response. I used a .trr file for the -rerun option and checked its contents using the gmx check command. The file contains velocities but lacks force data. Could the absence of forces be the reason I’m not obtaining kinetic energy values?

![image](https://europe1.discourse-cdn.com/flex017/uploads/bioexcel1/original/2X/c/c0e16322c730ca10873b1dce40570ff898e06573.png)

---

<div class="post-metadata">

**Author:** ![Lida](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@Lida](https://gromacs.bioexcel.eu/u/Lida)\
**Post date:** [September 4, 2023, 5:49pm UTC](https://gromacs.bioexcel.eu/t/compute-the-kinetic-energy-of-a-specific-group-in-gromacs/7129/4 "2023-09-04T17:49:58Z")

</div>

I’ve updated the .trr file to include force data, but I’m still not seeing an option for kinetic energy.

---

<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:** [September 5, 2023, 3:27pm UTC](https://gromacs.bioexcel.eu/t/compute-the-kinetic-energy-of-a-specific-group-in-gromacs/7129/5 "2023-09-05T15:27:04Z")

</div>

With rerun you can not get kinetic information.

You can use gmx traj to compute the temperature of groups using a trr file with velocities. For water you need to multiply the temperature by a factor 1.5 to take the constraints into account that gmx traj ignores.

---

<div class="post-metadata">

**Author:** ![Lida](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@Lida](https://gromacs.bioexcel.eu/u/Lida)\
**Post date:** [September 5, 2023, 3:46pm UTC](https://gromacs.bioexcel.eu/t/compute-the-kinetic-energy-of-a-specific-group-in-gromacs/7129/6 "2023-09-05T15:46:02Z")

</div>

Hello Hess,

Thank you for your reply. Based on your reply, I have a couple of questions:

1. I utilized water as the basis for developing a protocol to predict thermal conductivity. How can I adapt this factor to other molecules?

2. I attempted to calculate translational and rotational kinetic energy using the gmx traj command. Is this factor also applicable to kinetic energy calculations?

Thank you in advance for your help.

---

<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:** [September 6, 2023, 6:34am UTC](https://gromacs.bioexcel.eu/t/compute-the-kinetic-energy-of-a-specific-group-in-gromacs/7129/7 "2023-09-06T06:34:21Z")

</div>

gmx traj does not know about constraints. Thus you need to correct the temperature of a group by the factor #atoms_3/(#atoms_3 - #constraints).

The translational and rotational kinetic energy are only for the COM of a group, so not useful for you, I would think.
