# Difference between density obtained from gmx energy & gmx densityusing

**URL:** <https://gromacs.bioexcel.eu/t/difference-between-density-obtained-from-gmx-energy-gmx-densityusing/190>\
**Category:** User discussions\
**Created:** [May 25, 2020, 10:47pm UTC](https://gromacs.bioexcel.eu/t/difference-between-density-obtained-from-gmx-energy-gmx-densityusing/190 "2020-05-25T22:47:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_Abdelaal](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@M\_Abdelaal](https://gromacs.bioexcel.eu/u/M_Abdelaal)\
**Post date:** [May 25, 2020, 10:47pm UTC](https://gromacs.bioexcel.eu/t/difference-between-density-obtained-from-gmx-energy-gmx-densityusing/190/1 "2020-05-25T22:47:22Z")

</div>

GROMACS version: 2020.2  
GROMACS modification: No

Hello everyone,

I am simulating the deposition of C60 Molecules onto a graphene sheet. I am interested in the density analysis.

It seems that the density can be measured either by using the gmx energy or by using the gmx density and I would like to know what is the difference between the density values obtained by: gmx energy -f npt.edr -o density.xvg and by: gmx density -s md\_0\_1.tpr -f md\_noPBC.xtc -o density.xvg ?

I have noticed that the values of the density obtained by gmx energy is with respect to time while the values obtained by gmx density is with respect to distance. If this is the only difference, then why did I obtain different values in each curve (The values obtained using gmx energy is on the left side with average value 1300 and the values obtained from gmx density is on the right side with average value 1550)?

Thanks

 ![2](https://europe1.discourse-cdn.com/flex017/uploads/bioexcel1/original/1X/9bbfed570b00ae6593946ab1182d0d1bc40e2413.png)

---

<div class="post-metadata">

**Author:** ![Dr\_DBW](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/dr_dbw/32/42_2.png) [@Dr\_DBW](https://gromacs.bioexcel.eu/u/Dr_DBW)\
**Post date:** [May 25, 2020, 10:55pm UTC](https://gromacs.bioexcel.eu/t/difference-between-density-obtained-from-gmx-energy-gmx-densityusing/190/2 "2020-05-25T22:55:54Z")

</div>

[http://manual.gromacs.org/documentation/current/onlinehelp/gmx-density.html](http://manual.gromacs.org/documentation/current/onlinehelp/gmx-density.html)

> `gmx density` computes partial densities across the box, using an index file.

gmx energy computes things for the entire box.

If you look at your right hand graph, from gmx density, the average is not 1550. At the start and end it drops down to 500 from a peak of 1550 around the central 5nm.

---

<div class="post-metadata">

**Author:** ![M\_Abdelaal](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@M\_Abdelaal](https://gromacs.bioexcel.eu/u/M_Abdelaal)\
**Post date:** [May 26, 2020, 2:44pm UTC](https://gromacs.bioexcel.eu/t/difference-between-density-obtained-from-gmx-energy-gmx-densityusing/190/3 "2020-05-26T14:44:46Z")

</div>

Thanks for the clarification.

If I used gmx density and I selected the whole system, should I obtain similar value for that obtained using the gmx energy ?

I want to evaluate the density along the z axis and this is why I am using the gmx density, the problem is that, I found the value is not the same as the value obtained from gmx energy and therefore I don’t know , which one of them is more reliable ?

Is is possible to use gmx energy to obtain the values of density with respect to distance (along the z axis) ?

Many thanks

---

<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:** [May 26, 2020, 2:57pm UTC](https://gromacs.bioexcel.eu/t/difference-between-density-obtained-from-gmx-energy-gmx-densityusing/190/4 "2020-05-26T14:57:29Z")

</div>

> [@M\_Abdelaal](#):
>
> Thanks for the clarification.
> 
> If I used gmx density and I selected the whole system, should I obtain similar value for that obtained using the gmx energy ?

Possibly; try it and see.

> [@](#):
>
> I want to evaluate the density along the z axis and this is why I am using the gmx density, the problem is that, I found the value is not the same as the value obtained from gmx energy and therefore I don’t know , which one of them is more reliable ?

As Dallas said, the two programs do different things. The value in the `.edr` file is computed during the simulation and is simply the total density of the box. There is no ability to decompose this value into anything else via `gmx energy`.

> [@](#):
>
> Is is possible to use gmx energy to obtain the values of density with respect to distance (along the z axis) ?

No.

---

<div class="post-metadata">

**Author:** ![Dr\_DBW](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/dr_dbw/32/42_2.png) [@Dr\_DBW](https://gromacs.bioexcel.eu/u/Dr_DBW)\
**Post date:** [May 26, 2020, 10:57pm UTC](https://gromacs.bioexcel.eu/t/difference-between-density-obtained-from-gmx-energy-gmx-densityusing/190/5 "2020-05-26T22:57:09Z")

</div>

A simplification of what you have going on in your system. Should you expect the values obtained from “gmx energy” and “gmx density” to be the same? Are they measuring the same thing? If you made a slice the size of the entire box, then you will get the same value. So “gmx density” is actually providing exactly what you want.

![energy_vs_density](https://europe1.discourse-cdn.com/flex017/uploads/bioexcel1/original/1X/245a382610cb341140f36c32ab08481f53bade2e.png)

---

<div class="post-metadata">

**Author:** ![Silentium](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@Silentium](https://gromacs.bioexcel.eu/u/Silentium)\
**Post date:** [January 19, 2021, 7:03am UTC](https://gromacs.bioexcel.eu/t/difference-between-density-obtained-from-gmx-energy-gmx-densityusing/190/6 "2021-01-19T07:03:41Z")

</div>

Hallo, need help here

# [Why the density of water (in 534K 14bar) is fluctuating like this in the electric field （2.5 GHz 1\*10^9 V/m）？](https://gromacs.bioexcel.eu/t/why-the-density-of-water-is-fluctuating-like-this-in-the-electric-field/1446) ![potential energy](https://europe1.discourse-cdn.com/flex017/uploads/bioexcel1/original/1X/8e84d7f0405a80a507ed566eb68c7203cd507fb2.png)

PS there is no reply my topic, so i have to ask the relevant question here, sorry.

---

<div class="post-metadata">

**Author:** ![oveis](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/oveis/32/2537_2.png) [@oveis](https://gromacs.bioexcel.eu/u/oveis)\
**Post date:** [June 9, 2023, 3:30pm UTC](https://gromacs.bioexcel.eu/t/difference-between-density-obtained-from-gmx-energy-gmx-densityusing/190/7 "2023-06-09T15:30:10Z")

</div>

Hi,  
How did you get the fluctuations over time? Using gmx density I only get distance on the x-axis…!
