reduce sum

Dear All,

I wonder whether the group always has to be “all” when the command “compute ID, group-ID all reduce sum ……” is used.

I am simulating a two component mixture and therefore I would like to sum up properties of either species separately. In order to calculate the mean square displacement I have tried to define the molecules of either species as two separate groups, then I have used “msd/molecule” and finally “compute ID, group-ID reduce sum ……” to sum the individual mean square displacements, but this does not work.

Best Regards,

Sten Sarman

Dear All,

I wonder whether the group always has to be "all" when the command "compute
ID, group-ID all reduce sum ....." is used.

yes.

I am simulating a two component mixture and therefore I would like to sum
up properties of either species separately. In order to calculate the mean

that is easy to do by creating an atom style variable for each species
and multiplying the property of interest with a mask function.

square displacement I have tried to define the molecules of either species
as two separate groups, then I have used "msd/molecule" and finally "compute
ID, group-ID reduce sum ....." to sum the individual mean square
displacements, but this does not work.

as has been explained many times, "does not work" is a pretty much
useless description of a problem. without more details, the only
possible answer is "then you must be doing something wrong", which is
equally useless, since it doesn't provide any solution to the problem.
good answers require good questions.

axel

From the compute reduce doc page:

Each listed input is operated on independently. For per-atom inputs, the group specified with this command means only atoms within the group contribute to the result. For per-atom inputs, if the compute reduce/region command is used, the atoms must also currently be within the region. Note that an input that produces per-atom quantities may define its own group which affects the quantities it returns. For example, if a compute is used as an input which generates a per-atom vector, it will generate values of 0.0 for atoms that are not in the group specified for that compute.

So for per-atom arguments to compute reduce, the group you
specify is used.

For “local” args, the group setting is ignored, since it isn’t applicable.

You cannot use compute reduce on “global” args, which includes the
output of compute msd/molecule. Again from the compute doc page:

Define a calculation that “reduces” one or more vector inputs into scalar values, one per listed input. The inputs can be per-atom or local quantities; they cannot be global quantities. Atom attributes are per-atom quantities, computes and fixes may generate any of the three kinds of quantities, and atom-style variables generate per-atom quantities. See the variable command and its special functions which can perform the same operations as the compute reduce command on global vectors.

So the variable command can do a reduce, and they can use the mask functions that Axel mentioned.

Steve