Error "Variable maxXvalue: Compute used in variable between runs is not current"

Hello everybody.

I am trying to perform some modification with the simulation box and atoms corrdinates and I get error

ERROR: Variable maxXvalue: Compute used in variable between runs is not current (src/src/variable.cpp:1375)
Last command: 	displace_atoms		atoms	move	v_shiftX  ${shiftY}  ${shiftZ}		units box

In the beginning when I was using $ instead of v_ (for example ${maxXvalue} instead of v_maxXvalue) it also was creating the same issue.
What is the reason? The script is below.




    region		atoms		block		${xl}  ${xh}  ${yl}  ${yh}  ${zl}  ${zh}
	group		atoms		region		atoms

	compute		myXcoord	atoms		property/atom	x
	compute		minX		atoms		reduce		min		c_myXcoord
	compute		maxX		atoms		reduce		max		c_myXcoord

	variable	minXvalue		equal		c_minX
	variable	maxXvalue		equal		c_maxX

	variable	lengthX			equal		v_maxXvalue-v_minXvalue
	variable	boxXhi			equal		v_lengthX*2

	variable	shiftX			equal		v_boxXhi*0.4-v_minXvalue
	variable	shiftY			equal		0
	variable	shiftZ			equal		0

	displace_atoms		atoms	move	v_shiftX  ${shiftY}  ${shiftZ}		units box
	
	change_box	all		x	final		0	${boxXhi}		remap no
	change_box	all		y	final		0	${yh}			remap no
	change_box	all		z	final		0	${zh}			remap no

When reporting errors, please always report the LAMMPS version you are using.

The output of compute commands must be “consumed” during a run. This works recursively when used in variables. In many cases the results can be accessed in between run, like you are trying to do, but not always. Then the result needs to be cached with fix ave/time 1 1 1 or similar.

With the latest (17 April 2024) version of LAMMPS you can avoid the error by adding:

thermo_style custom step v_shiftX
run 0 post no

before the displace_atoms command.

Thank You very much!