LAMMPS ERROR: Compute used in variable between runs is not current

Hi all,
I am trying to simulate oil-water-surfactant system using DPD in LAMMPS.
I need to divide the box in 100 equal bins along the z axis so that I can
evaluate a property individually for each bin and use them later for
numerical integration.
As you know, there is a restriction of 32 groups in LAMMPS. After
discovering the inability to define this number of groups, I used a
dynamic group. Since the dynamic group changes its values, I computed the
values of stress/atom, used a formula using the computed values (using c_)
then assigned them to a variable using $ sign for immediate evaluation.
The error occurred is "Compute used in variable between runs is not current."

As given in the LAMMPS Manual, this problem is solved for temp by giving
the command run 0 so that it would evaluate the value of compute for later
use. This worked because LAMMPS automatically evaluates temp in its run.
How do I make the same thing work for me.

Here is that section of my input script
label loop

variable i loop 100

variable a equal (lz/100)*($i-1)
variable b equal (lz/100)*$i
region r_$i block 0. 11. 0. 11. $a $b
group g dynamic all region r_$i
compute $i g stress/atom thermo_temp
compute c_$i g reduce sum c_$i[1] c_$i[2] c_$i[3]
variable s equal (c_c_$i[3]-(c_c_$i[1]+c_c_$i[2])/2)
variable d_$i equal $s

next i
jump SELF loop
In the end, I need the values of all d_$i.

I would really appreciate any help on this problem I've been stuck.
Thank you.

Kalpit Jain

I’m not clear what you are trying to do or what groups have

to do with 100 spatial bins. You can use fix ave/chunk

for the latter, with no groups needed.

Using a loop 100 to define 100 different computes

with a variable name, then using those 100 computes
in a variables seems like a bad idea. Not

sure how you are invoking all 100 computes on

the timestep the variable accesses them.


Dear Steve,

Thank you for the reply. I have tried using ave/chunk as follows:

compute g1 all chunk/atom bin/1d z lower 0.1 units reduced
compute pr all stress/atom thermo_temp

The above lines compute stress/atom on all atoms. Then I bin them and
write to output files as below.

fix px1 all ave/chunk 2000 100 200000 g1 c_pr[1] file pxx1.dat
fix py2 all ave/chunk 2000 100 200000 g1 c_pr[2] file pyy2.dat
fix pz3 all ave/chunk 2000 100 200000 g1 c_pr[3] file pzz3.dat

Will this give me average pressure components along the z axis in the
different bins?

Also, says that the
stress per atom should be divided by volume to get a pressure component.
While we use units reduced, is it still required to divide it with volume?

Thanks in advance,

Kalpit Jain

It will give you per-atom stress for each atoms, averaged over the atoms

in a spatial bin. Yes, you still need to divide by the volume (of one atom),

regardless of what units you are using.