maximum height of a group of atoms

Dear lammps users,
I want to find out the maximum height of a group of atoms. I am sure it should be easy, but I couldn’t get it working.
I used:

compute c1 group_ID property/atom z
variable v1 equal max(c_c1)

it doesn’t give error when defining this, but when I want to print out this number by “thermo_style custom v_v1” I get the message that “Group ID in variable formula does not exist”. It seems that I am not correctly using the vector c1
I would be appreciated for any help on this.


It's hard to answer without the beginning of the script, but unless
you called the group of atoms from which you want to determine the
maximum height "group_ID", this will not work. You should replace
"group_ID" by the actual name of the group of atoms you're looking at.

In fact, you could do the same thing in one line using the variable
function "bound":

variable v1 equal bound(group_ID,zmax)


2011/5/11 Fatemesadat Emami <[email protected]...>:

When I add these lines to bench/in.lj

compute c1 all property/atom z
variable v1 equal max(c_c1)
thermo_style custom step temp v_v1

I get the error
ERROR: Mismatched compute in variable formula

which is correct b/c the max() function in a variable
operates on global vectors, not per-atom vectors.
See the variable doc page for details.

What I think you want is the compute reduce command
with its max option to tally the max value of a per-atom vector.


Dear Steve,
Thank you very much Steve for your answer. The compute/reduce works fine.
Dear Laurent,
it seems that the bound(group_ID, zmax) returns the wrapped coordinated (after counting the periodicity) because I get numbers equal to the height of the box, which I think they should relate to the atoms for the bottom of the surface.

I am trying to group a surface and its counterions (some of the ions move to solution and I don’t want to consider them). Having the max height of the atoms in the surface -surface is not fixed- (which I achieved in my previous question) I exactly know that ca. 5 Ang up will related to the superficial ions.
I used
region 1 block NULL NULL NULL NULL 10 30 move NULL NULL v_dz (I calculated dz by tracing the possible movement of the surface)
group 2 region 1
group 3 type xx (this is the atom type of the ions)
group 4 intersect 2 3

but when I print the number of ions in group 4 by

variable no_ions equal count(4)
thermo_style custom step v_no_ions

it gives me more that what is expected (I mean visualization shows only 4 and the lammps prints 12 (total of 20 ions are in the surface which half is for the top and half is for the bottom))

So can I use “region” at all for a periodic box?

Best regards