[lammps-users] Variable questions?

LAMMPS Users,

I have some questions about the variable command. I am trying to build
a crystal structure of alternating layers of two atom types and having
trouble implementing the current value of a variable (v_) in my input
script with a filename of "in.superlattice". Below is the section of
script causing the problems. I keep getting "ERROR: Using variable
equal keyword before initial run" when LAMMPS tries to evaluate "$s".
It seems that the code does not like to evaluate my variables unless
runs are embedded within the loop. Is there a work around or another
way of evaluating a variable without doing an initial run? The last
part of the documentation on variable seems to imply it is possible.

Also when using "v_" does the variable name have to be a single
character? Or can one use something like "v_{variablename}"? I just
haven't had much luck with it, but the errors described above might be
the real problem. In other words, can I use something like "layer" and
"v_layer" instead of "x" and "v_x" in the script below?

Thank you,

Rob

variable x loop $p

#These will not be redefined each loop.

variable s equal add(4.0,mult(sub(v_x,1),add($m,$n))) #start of first
atom type layer

variable t equal add(3.99,add(mult(sub(v_x,1),add($m,$n)),$m))#end of
1st atom type layer

variable u equal add(4.0,add(mult(sub(v_x,1),add($m,$n)),$m)) #start of
2nd atom type layer

variable v equal add(3.99, mult(v_x,add($m,$n))) #end of 1st atom type
layer

label periodloop

region S$x block 0.0 $w 0.0 $w $s $t

region G$x block 0.0 $w 0.0 $w $u $v

create_atoms 1 region S$x

create_atoms 1 region G$x

next x #iterate to next x

jump in.superlattice periodloop

Are you using the most current LAMMPS version? I don't see the
error: Using variable equal keyword ... in my source.

LAMMPS doesn't care if you evaluate variables before a run,
but it won't protect you against using something like Temperature
in the variable def, that won't be defined if atoms haven't been
read in.

After v_, you can use either a single- or multi-letter variable.

If you're still having problems, post a simple script with variables
that doesn't work.

Steve

Steve,

Thanks. The new version helped but now I get several more errors with
my input script.

I use temp/rescale fix and have been tracking the energy using
fix_modify fixID thermo yes energy yes

In the manual it still mentions fix_modify energy option under the
temp_rescale section
(http://lammps.sandia.gov/doc/fix_temp_rescale.html) but under the
fix_modify section there is no mention of the energy option. Is it no
longer supported?

I also get an error with the thermo option. Here is the section of
script causing the problem:

fix heat gaheat temp/rescale 1 $h $h 0.01 1
fix cool gbcool temp/rescale 1 $c $c 0.01 1
timestep 0.001
fix 1 gactivebox nve
fix_modify heat thermo yes

When the program hits the last line I get the error "Illegal fix_modify
command"

It looks like the alternative to the energy option above is to use
thermo_style with f_ID for a temp/rescale fix, but what quantity is
actually logged? It is not clear to me from the explanation in the
temp/rescale section of the manual. Is it just temp/rescale fix
contribution to the potential energy added since the last data dump or
cumulative or some other value(s)?

Thanks,
Rob

The fix modify doc page was out-of-date. There is only
a fix_modify energy option now, no fix_modify thermo. The
latter can be printed directly for any fix that supports it via
the f_ID[N] syntax in thermo_style custom, as you indicate.

For fix temp/rescale, the printed quantity is seen in
fix_temp_rescale.cpp

      efactor = (0.5 * force->boltz * temperature->dof);
      energy += (t_current-t_target) * efactor;

It's supposed to be the delta in energy added to the
velocities, but it isn't accumulated timestep to timestep.

Steve