# How to do the averaging over the whole box?

Hi, all,

I am running a npt simulation with water. I want to output the
density, while I got some problems.

The command to output the density is as the following.

fix fxdnt all ave/spatial 100 10 1000 x lower 0.2 y
lower 0.2 z lower 0.2 density/mass ave running

I want to output the density of the whole domain, while I did not find
how to specify the averaging domain. Since I have to specify the
origin and delta.

I guess using lower for origin is OK, while how to specify the delta?

Thank you very much.

Best Regards,
Kai

Hi, all,

I am running a npt simulation with water. I want to output the
density, while I got some problems.

The command to output the density is as the following.

fix fxdnt all ave/spatial 100 10 1000 x lower 0.2 y
lower 0.2 z lower 0.2 density/mass ave running

I want to output the density of the whole domain, while I did not find
how to specify the averaging domain. Since I have to specify the
origin and delta.

I guess using lower for origin is OK, while how to specify the delta?

please re-think what you need to do.
the solution is much simpler. since
you want the total density of the system,
the only variable that you have to worry
about is the total volume of the simulation
box. the number of water molecules does
not change and their mass either. so all
you need to do is to define an equal style
variable that takes the total mass of the
waters, divides by the total volume and
then adjust to the desired units.
no big deal, right?

axel.

Hi, Axel,

I can use thermo_style to output the temperature and pressure and volume.

How can I save the volume to a variable so that I can compute the density with it?

BTW: the manual of lammps is really hard to follow. Of course partial reason is that I am new.

Best Regards,
Kai

Hi, Axel,

I can use thermo_style to output the temperature and pressure and volume.

in postprocessing this part of the file with a python/perl/tcl/awk/bash script.

How can I save the volume to a variable so that I can compute the density
with it?

see the variable command.

BTW: the manual of lammps is really hard to follow. Of course partial reason
is that I am new.

manuals don't provide direct solutions for specific problems.
for a tool as flexible as LAMMPS that would be impossible
to do. however, the manual provides pieces, and it is *your*
task, to assemble the pieces to something that matches your
needs. this is why there are examples in the manual and
the examples folder. this *does* require that you are able
to recognize a pattern and adapt it for your needs. this has
little to do with lammps, but is a generic skill required in
research. it is thus not really lammps' fault. in my experience
the lammps documentation is one of the better ones. there
are codes with *much* worse and much less detailed docs.

axel.