before defining lattice constant, define a variable like rn to read its value from a file like this:
variable rn file constant.txt
Then define your lattice:
lattice fcc ${rn}
For changing value of rn in the file you can write a simple bash script which every time it changes the lattice constant, runs your code saves your results then changes the constant again.
I attached the code below. Please change the code below, this is just a sample code:
#!/usr/bin/env bash
constant=5
counter=1
while [ $counter -le 4 ]
do
echo $constant > constant.txt #It writes constant value to a file and in in.lattice you forced lammps to read it
echo $(lammps -in in.lattice)
mkdir $counter/
mv log.lammps energy.dat $counter/ #Write your results here for moving to a folder after each run
A while back, I loaded a number of simple LAMMPS scripts online. The first ones I did were to calculate energy as a function of lattice parameter. You might want to read through tutorials 1 and 2.