gmx density computes partial densities across the box, using an index file.
For the total density of NPT simulations, use gmx energy instead.
Densities are in kg/m^3, and number densities or electron densities can also be calculated. For electron densities, a file describing the number of electrons for each type of atom should be provided using -ei. It should look like: 2 atomname = nrelectrons atomname = nrelectrons The first line contains the number of lines to read from the file. There should be one line for each unique atom name in your system. The number of electrons for each atom is modified by its atomic partial charge.