Error: Compute used in variable between runs is not current

Hi everybody.

I am trying to adjust the simulation box to the atoms positions and I get this error:

ERROR: Variable xlo_temp: Compute used in variable between runs is not current (../variable.cpp:1341)
Last command: variable xlo equal ${xlo_temp} - ${buffer}

I found lots of topics regarding this error but still couldn’t solve the problem. Can anyone help?
The LAMMPS version I’m using is 3 Mar 2020.

units			metal
dimension		3
boundary		p p p
atom_style		atomic

read_data		cut2.lmp

timestep		0.001
pair_style		vashishta
pair_coeff		* *		SiO.1990.vashishta	Si O

neighbor	    	1.0	bin
neigh_modify	    delay	1

thermo			1000
thermo_style	custom	step  temp  press  pe  vol  fnorm  density
										

	
		dump	d	all		custom		10000	everything.dump		id  type  x y z

variable	buffer	equal	1

compute xmin all reduce min x
compute xmax all reduce max x
compute ymin all reduce min y
compute ymax all reduce max y
compute zmin all reduce min z
compute zmax all reduce max z

run 0

variable xlo_temp equal c_xmin
variable xhi_temp equal c_xmax
variable ylo_temp equal c_ymin
variable yhi_temp equal c_ymax
variable zlo_temp equal c_zmin
variable zhi_temp equal c_zmax

variable xlo equal ${xlo_temp} - ${buffer}
variable xhi equal ${xhi_temp} + ${buffer}
variable ylo equal ${ylo_temp} - ${buffer}
variable yhi equal ${yhi_temp} + ${buffer}
variable zlo equal ${zlo_temp} - ${buffer}
variable zhi equal ${zhi_temp} + ${buffer}

change_box all x final ${xlo} ${xhi} y final ${ylo} ${yhi} z final ${zlo} ${zhi} units box

write_data	cut22.lmp

		undump  d

The problem comes from the fact that LAMMPS is an efficient program - it doesn’t calculate a value unless it’s used somewhere. The easiest way to get around this is adding the variable (or the compute it uses) to your thermo_style command. The values will be computed during the run and they should be available afterwards.

As a side note - you should update your LAMMPS version to the newest stable one - there were several bugs fixed in the last four years.

1 Like