Hi

I have imposed velocity on some groups of atoms in LAMMPS. Now I want to calculate the average velocity of the particles of that group. How to do the same

I tried this but it is showing an error:

variable vx1 equal GRP1 ave(vx)

Thanks

Hi

I have imposed velocity on some groups of atoms in LAMMPS. Now I want to calculate the average velocity of the particles of that group. How to do the same

I tried this but it is showing an error:

variable vx1 equal GRP1 ave(vx)

Thanks

This shows an error because this is a completely invented syntax. Thus it cannot work.

Computer programs are stubbornly unimaginative things: if they have not been explicitly programmed to do something, they cannot do it.

Since LAMMPS has distributed data, any operation that needs to get a sum or average or min or max across per-atom properties will need to do a so-called parallel reduction operation.

One way to do this is to use the compute reduce command, but there are also functions that do this implicitly.

Also, there is an inconsistency in what you say you want to compute and what you appear to try to compute.

There is a difference between computing the average velocity of the atoms and the velocity of the group. to get the former, you first need to compute the velocity of all individual atoms and then take the average of that. this can be realized with an atom style variable followed by a compute reduce operation. to get the latter, you first need to compute the sum over all velocity components multiplied with the mass of the individual atoms and then divide by the total mass which will result in getting the center of mass velocity components from which you can compute the center of mass velocity. this can be done with the vcm() variable function for each dimension followed by some computation that computes the scalar velocity from that. if you only want the one velocity component, e.g. x, then just using vcm() once with the x direction will suffice.

so please spend some more time reading the documentation and do not try to invent a syntax again. it will *never* work.