[lammps-users] strange behavior to run a loop

I had a script which needed to run a loop in lammps but I found out a strange behavior. Here I paste out a simplified script:
----------------------------------- in.test ------------------------------------------
units metal
atom_style atomic
boundary p p p
dimension 3
variable max_strain equal 0.001
variable n equal 11
variable i loop $n
label loopa
variable strain_scale equal (2*($i-1)/(n-1)-1)*{max_strain}

variable a1_1 equal (1+{strain_scale})*1.414213562 variable a2_2 equal (1-{strain_scale})*1.414213562
lattice custom 3.615 a1 {a1_1} 0 0 a2 0 {a2_2} 0 a3 0 0 1 basis 0 0 0 basis 0.5 0 0 basis 0 0.5 0 basis 0.5 0.5 0 basis 0.25 0.25 0.5 basis 0.75 0.25 0.5 basis 0.25 0.75 0.5 basis 0.75 0.75 0.5
variable a equal 1
variable b equal 1
region mybox block 0 $a 0 $a 0 $b #units lattice
create_box 1 mybox
create_atoms 1 region mybox
pair_style eam
pair_coeff * * …/…/potentials/Cu_u3.eam
run 0
clear
next i
jump in.test loopa

The meaning of lattice spacings are described on the lattice
doc page. The reason your values are changing so much
is the difference between metal and LJ units. When
you do a clear and re-start your script, you are jumping
to loopa, which skips the units metal command, so subsequent
iterations are in lj units (the default).

Steve

Thanks for your help. I add the units setting again after the command “clear”, and everything is right now.

Wei