Variable Calculation

Dear all,
can i evaluate the value of a variable in a run at each step without
setting up the run at each step.

Thanks
Michele

Dear all,
can i evaluate the value of a variable in a run at each step without
setting up the run at each step.

this is too difficult to answer in this generality.
the variable documentation is very detailed and
exhaustive. please help yourself or tell us what
you want to achieve and hopefully somebody
can give you a suggestion how to get it done.

axel.

Ok!
I have two cases which are interesting for me:
1) compute the number of atoms of a give type at each step
2) compute distances between some atoms at each step

Many thanks
Ciao
M

Ok!
I have two cases which are interesting for me:
1) compute the number of atoms of a give type at each step
2) compute distances between some atoms at each step

both would be *much* easier to do in post processing,
particularly the latter, since atom date is distributed
across processors and thus you would need to do a
reduction operation with some elaborate atom-style
variables at a high performance penalty.

the former case, could be implemented with an atom
style variable expression "type == 4" (or whatever type
you want to count) and then running a 'compute reduce
sum' on it. the value of the compute can then be printed
using "fix print" or in thermo output.

a similar strategy could be implemented for retrieving
the coordinates of two arbitrary atoms and then using
an equal style variable to compute the distance, but
that would require multiple reduction operations, which
are very costly. it would be better to do this in post-processing,
or if you *really* need it at run time and at every step
(why?) by writing a custom compute, that can limit
the communication to one data assembly step across
the system.

axel.

One thing to realize about equal-style variables
in LAMMPS (which can do things like you describe),
is that they are only evaluated when some other
commands needs the result. Thus if you want
them to be evaluated every step, then you need
to also define a fix or compute that uses them,
such as fix ave/time and have it request the value
every step.

Steve