LAMMPS (Aug 2024) Problem to compute pairwise distance between atoms

I have been working on writing a simple Li-H system to determine the atom ID atom that is maximally stretched from a neighbor.

compute C1 all property/atom id

compute C2 all pair/local dist

compute C3 all reduce max c_C1 c_C2 replace 1 2

variable MY_ATOM_ID equal c_C3[1]

Then I made a couple of changes, and this is how my last script looks like:

Li-H system for finding max nonbonded stretch

units metal
atom_style full
dimension 3
boundary p p p

region box block 0 10 0 10 0 10
create_box 2 box

Create 5 Li and 5 H atoms

create_atoms 1 random 5 12345 box
create_atoms 2 random 5 54321 box

mass 1 6.941
mass 2 1.008

pair_style lj/cut 5.0
pair_coeff * * 1.0 1.0
pair_coeff 1 1 0.5 1.5
pair_coeff 2 2 0.3 1.2
pair_coeff 1 2 0.7 1.3

Get atom IDs for all interacting pairs

compute C1 all property/local patom1 patom2
compute C2 all pair/local dist

Find pair with max distance

compute C3 all reduce max c_C1[1] c_C1[2] c_C2 replace 1 3 replace 2 3

Variables to store the result

variable A equal c_C3[1]
variable B equal c_C3[2]
variable D equal c_C3[3]

thermo 1
thermo_style custom step v_A v_B v_D
run 0

print “Nonbonded pair with maximal stretch: {A} and {B}, distance = ${D}”

It appears that the August 2023 version runs the script without any issues, but in my version (August 2024), I keep encountering the following error: “Compute reduce compute C1 does not calculate per-atom values.”

Which means, that you haven’t carefully studied the documentation.
There has been a change in compute reduce between those two versions:

Added in version 21Nov2023.

The inputs keyword allows selection of whether all the inputs are per-atom or local quantities. As noted above, all the inputs must be the same kind (per-atom or local). Per-atom is the default setting. If a compute or fix is specified as an input, it must produce per-atom or local data to match this setting. If it produces both, like for example the compute voronoi/atom command, then this keyword selects between them. If a compute only produces local data, like for example the compute bond/local command, the setting “inputs local” is required.

There is no guarantee that LAMMPS will be fully backward compatible, since we are constantly adding new features and also refactor the implementation of existing features to be more consistent and efficient. That cannot always be done without breaking backwards compatibility.
We do make an effort to document such changes, though.

TL;DR: This is not a bug but documented behavior.

I changed into the following line and it worked on my personal computer:
compute C3 all reduce max c_C1[1] c_C1[2] c_C2 inputs local replace 1 3 replace 2 3

But when I tried to compute the same script into the cluster computer I have been working on, it is giving me the following error:
ERROR: Unknown compute reduce keyword: 1

This looks like you do not have the latest updated version of the 29 Aug 2024 version.
There has been an indexing bugfix for compute reduce in update 3: Release Update 3 for Stable release 29 August 2024 · lammps/lammps · GitHub

You may be able to work around this bug by moving the inputs keyword to the end of the command.

1 Like