[lammps-users] [ase-developers] classical MD code (LAMMPS) as a calculator for ASE?

would it make sense to add classical MD calculators (e.g. LAMMPS) to ASE?
Or are there good reasons not to do it?

I know I have heard people talking about possible uses for a LAMMPS
interface in ASE, so I believe that there are existing ASE users who
would find such a feature a good idea.

Is anyone on the LAMMPS forum aware of the LAMMPS calculator in ASE?

ASE forum would likely be a good place to discuss that.

I imagine ASE could work with LAMMPS the same way it works with Siesta:

1) ASE would set the configuration and parameters of an MD model in Python,
2) write input files for LAMMPS,
3) execute LAMMPS, and
4) read energy from the LAMMPS output file.

I guess something that might affect how a LAMMPS interface would be
implemented is that "normal" LAMMPS input is a series of commands that
are executed in order (a little bit like a specific language for MD;
e.g. create world, set this temperature and that potential, propagate N
MD-steps, calculate some statistic, propagate further, change
environment, ...).
Compared to calculators such as e.g. Siesta, where one usually in a
unambiguous way can define the calculation with a set of keywords when
creating the calculator object, maybe a LAMMPS interface needs to work
differently?

The trend of classical MD codes having input command files written in
a scripting language is attractive. LAMMPS has it's own input command
file programming language. Though using ASE as a common interface to
several classical MD codes would extend that. Well designed LAMMPS
calculator in ASE would be useful as a starting template for other
classical MD codes as well.

Also, (and I'm possibly just stating the obvious here) I think there are
a lot of available LAMMPS utilities and tools written in python (e.g.
the pizza toolkit, http://www.sandia.gov/~sjplimp/pizza.html), maybe
some of it could be (re)usable or provide inspiration of some kind.

Good point,
Pizza.py Toolkit has a lot of useful Python code related to LAMMPS.

-Bohumir

The trend of classical MD codes having input command files written in
a scripting language is attractive. LAMMPS has it's own input command
file programming language.

Correction:
LAMMPS comes with a nice Python interface!
      http://lammps.sandia.gov/doc/Section_python.html

-Bohumir

I imagine ASE could work with LAMMPS the same way it works with Siesta:

  1) ASE would set the configuration and parameters of an MD model in Python,
  2) write input files for LAMMPS,
  3) execute LAMMPS, and
  4) read energy from the LAMMPS output file.

Additional point: LAMMPS has a library interface,
which can be called from C++, C, Fortran, Python
etc. That's how the Python interface works.

It should be fairly straightforward to wrap LAMMPS with
other packages as well, e.g. the ASE you mention.

That's what the interface is designed for.

Steve

Python interface to LAMMPS seems to work well.

Though I could not build the Python interface with optional MEAM
library (Fortran 90) included in LAMMPS. Has anyone experimented with
that?

Thanks,
-Bohumir

Python interface to LAMMPS seems to work well.

Though I could not build the Python interface with optional MEAM
library (Fortran 90) included in LAMMPS. Has anyone experimented with
that?

no. but there are a few "ground rules"
- you will have to adapt the setup file for that so that
  it finds and links the meam library. then you also need
  to make sure that you link with the fortran compiler runtime
  library (same as for normal lammps build).
- you will probably have to manually compile
  the meam library and have to use the proper
  flags for compiling shared objects (i.e. position
  independent code). this is _very_ operating system
  dependent. the python setup build procedure does
  that automatically for c/c++ files. never tried fortran.
  on linux this requires the flag -fPIC

there may be more issues. i think your best chances
would be to ask in a python forum or search the (extensive)
python documentation on this. you are for certain not the
first person trying build a python module with some fortran
code in it.

cheers,
     axel.

- you will have to adapt the setup file for that so that
it finds and links the meam library.

By this, Axel means the python/setup.py or setup_serial.py
file needs to be edited to pull in additional libs to build
the self-contained Python package you are adding to your Python.
Similar things would have to be done to build LAMMPS
for Python with any of the LAMMPS libs (CUDA, atc, etc).
It will be more tricky for ReaxFF or MEAM b/c they
are Fortran as Axel notes. Also note, that shared-lib
versions of all the dependencies induced by these
add-on libs (e.g. system libs) will need to be available for Python
to be able to load it.

If you are successful in doing it, please send/post the amended
setup.py file(s) and library Makefiles (for the shared-lib versions)
and we will add them to the distribution.

Steve

It worked - thanks for your guide!

Attached are:

1) "Makefile.gfortran" for the MEAM library with added -fPIC flag

2) "setup_serial.py" with added options:

  libraries = ['meam', 'gfortran'],
  library_dirs = ['../lib/meam']

-Bohumir

Makefile.gfortran (1.5 KB)

setup_serial.py (1.2 KB)