[lammps-users] possible bug: variable with special function & array_flag Jones, Reese

i again,
  Perhaps I should have lead with the problem not my ill-informed solution :wink:

this input script :

echo both
units real
dimension 3
boundary p p p
lattice fcc 5.376
region box block 0 3 0 3 0 3
create_box 1 box
create_atoms 1 box
mass 1 39.948
pair_style lj/cut 13.0
pair_coeff * * 0.2381 3.405

compute PE all pe/atom
variable maxPE equal max(c_PE)

thermo_style custom step pe v_maxPE

timestep 4.0
thermo 1
fix NVE all nve
run 2

results in:

Setting up run ...
Memory usage per processor = 1.82285 Mbytes
Step PotEng maxPE
ERROR: Mismatched compute in variable formula

which I can attribute to the use of a "special" function such as max on (any) per-atom compute, e.g. pe/atom, displace/atom.

Perhaps I am using this wrong but I suspect a bug. I would like to offer a solution but I don't have enough knowledge of what flags indicate what. I do know this operation works fine for a "fix"


The array_flag is set for computes that calculate a global
array, not per-atom arrays. Pe/atom, displace/atom, etc
calculate per-atom vectors and arrays.


From the variable doc page:

The sum(x), min(x), max(x), ave(x), and trap(x) functions each take 1
argument which is of the form "c_ID" or "c_ID[N]" or "f_ID" or
"f_ID[N]". The first two are computes and the second two are fixes;
the ID in the reference should be replaced by the ID of a compute or
fix defined elsewhere in the input script. The compute or fix must
produce either a global vector or array.

I.e. you cannot use these special functions on a per-atom vector.
But you can use compute reduce on a per-atom vector, as
it says further down on the doc page:

These functions operate on the global vector of inputs and reduce it
to a single scalar value. This is analagous to the operation of the
compute reduce command, which invokes the same functions on per-atom
and local vectors.