compute reduce - compute not current


I am trying to get the y and z min/max atom coordinates using compute reduce so I can reset the simulation box bounds as shown in the snippet below. When I run this I get the error:

ERROR: Variable new_yhi_temp: Compute used in variable between runs is not current (…/variable.cpp:1331)
Last command: change_box all y final 0.0 {new_yhi} z final 0.0 {new_zhi} units box

Any ideas on how to fix this? Also, is there a better way to get min/max atom coordinates?


computes must be updated during time stepping and they will be only updated, if there is a “consumer” of the compute.
in your case, using fix ave/time with the options 1 1 1 is a good choice, and it has the benefit to also be a cache of the data, so when doing any system manipulations, the data will not become expired (unlike with computes) and cause errors.
also your input code can be simplified significantly. so please try the following:

compute min all reduce min y z
compute max all reduce max y z
fix minmax all ave/time 1 1 1 c_min[1] c_min[2] c_max[1] c_max[2]
run 0

variable new_yhi equal f_minmax[3]-f_minmax[1]+12.0
variable new_zhi equal f_minmax[4]-f_minmax[2]+12.0


Hi Axel,

This worked great! Thanks!

  • Stacey