All,
I am currently working on a lammps simulation that uses the python interface
(running 2015-10-05 version from the Fedora 22 repo).
The various options to extract variables and computes
(LAMMPS Molecular Dynamics Simulator)
are clear enough, but they only pull data from the current state of my
system / lammps simulation, i.e. if I run my simulation, then attempt to
extract a compute, I get the last value.
Ideally, I would like to write or extract an array of values at each
time-step, essentially the output of a custom thermo_style command as an
array.
Is there a better way to do this other than to read the log file back in
with python as an array after the simulation has run? Can
lmp.extract_compute be run at specified intervals during the simulation and
the output appended (maybe a for loop that runs the simulation, then writes,
then iterates)?
i think you need to get a better understanding of how LAMMPS works
internally and how things are generally meant to be. here are some
general pieces that i can provide from my perspective on how i have
implemented features in the past.
- outside of the classes for computing forces from the force field,
there are two mechanisms to interact with a simulation. fixes and
computes. a fix is something that is called regularly during the time
integration and can execute specific functions are specific steps
during each iteration. if you want something to happen regularly
during a time step (e.g. output), you need to define some fix that
will be called when you need it and collect/provide/output the
information for you. a compute, however, it an on-demand action, that
can use internal data to derive some information from it. a compute
has to be defined *and* referenced to trigger some action.
- thus the typical way to collect and access/output data during a
simulation is a fix that references one or more computes. e.g. fix
ave/time and compute rdf. some more complex operations and processing
is possible using variables, which can access data provided from
various sources (computes, fixes, thermo keywords, other variables).
- also, you have to understand that the python interface (and the
library interface it is based on) is meant to be a rather high-level
tool, i.e. more like a "remote control" and less so that you can
insert particular python code at specific steps in the overall
simulation process.
that being said, there may be a way to achieve this nevertheless, if
you don't mind to a somewhat hackish route: what i am referring to is
the rather recent feature of python style variables. if you define a
fix that regularly accesses a python style variable, e.g. fix ave/time
with some suitable settings, then you can set up this python style
variable to access all kinds of *other* variables and execute
*arbitrary* python code whenever the python variable is referenced.
that python function would then become somewhat of a callback, that
could store and process all kinds of data for every step during the
evolution of your trajectory in any which way you like. the return
value of that function could be ignored, but you need the fix to
trigger it being referenced and executed. there was thread on using
python style variables in a similar fashion on this mailing list
recently. it may even be possible to import and access the python
wrapper functionality from within such python style variables, but you
have to be careful to not create any circular dependencies.
HTH,
axel.
Other than the outputs written to a log or dump file, are results of past
computes stored anywhere internally (I see that the actual compute command
does not: LAMMPS Molecular Dynamics Simulator)
no.