# [lammps-users] [Help] "variable" disaster!

Hi, respective Prof. Plimpton and everyone! I am trying to model simulating annealing algorithm to anneal metals by LAMMPS script, but it seemed that their are some problems with the last annealing lines.

The script is just like:

units metal
dimension 3
newton on
boundary p p p
atom_style atomic

variable tq equal 20.0
variable pi equal 3.141592653589793238463
variable kb equal 0.00008617385
variable tmax equal 600.0
variable tmin equal 1.0
variable tdamp equal 10.0
variable itmax1 equal 1000
variable itmax2 equal 1000
variable itmax equal “{itmax1}+{itmax2}”
variable scale equal “({tmin}/{tmax})^(1.0/\${itmax2})”
variable f index Nickel-110
variable freq equal 10

pair_style eam
pair_coeff * * Cu_u3.eam

neighbor 0.4 bin
neigh_modify delay 10

velocity all create 600.0 2349852 mom yes rot yes sum yes dist gaussian
fix 1 all nvt {tmax} {tmax} \${tdamp}

thermo {freq} dump 1 all xyz {freq} \$f.xyz
log \$f.log
timestep 0.002

run {itmax1} post no start 0 stop 2000 **#if the line changed as "run {itmax1} post no start 0 stop \${itmax}",**
#it is wrong, but why???

variable T equal tmax
variable i loop 1000
label loop

variable Told equal T

variable T delete
variable T equal “{Told}*{scale}”

unfix 1
fix 1 all nvt \${Told} T {tdamp} #where is the problem?
print “i {Told} \$T” #where is the problem?

run 1 post no start 0 stop 2000
variable Told delete

next i
jump annealing.in loop

Can anyone tell me why? Thanks a lot.

Hi, respective Prof. Plimpton and everyone! I am trying to model
simulating annealing algorithm to anneal metals by LAMMPS script,
but it seemed that their are some problems with the last annealing

the best way to achieve what you want would be to program
a proper "fix anneal" command. in principle you can get the
very same effect by using a temp/berendsen with a proper
choice of temperature ramp and damping parameters. if Tstop
is chosen to be 0K and Tdamp is set to a sufficiently large
parameter that would be equivalent to a simulated annealing.

but unless you are a specific reason to use the annealing algorithm
there also is "fix viscous" which will do a similar thing. but unlike
annealing it affects it puts a velocity depended scaling factor on
forces and thus specifically slows down fast moving atoms, rather than
rescaling the velocities uniformly. in my personal observation this
is almost always the more effective solution.

some comment on your script commands. using fix nvt is not a good
idea, since nvt employs a nose-hoover thermostat which manipulates
the acceleration and not velocities and moreover only achieves
thermalization over a longer time period. resetting its parameters
in every step will upset the underlying algorithm (it has to propagate
additional degrees of freedom that are coupled to the system for
thermalization). you'd rather want to use fix nve and fix temp/rescale.

cheers,
axel.

Your question is too vague for me to understand.