Completed first version of fix python/integrate

This includes an example of how to implement fix NVE in Python.

The library interface was extended to provide direct access to atom data using
numpy arrays. No data copies are made and numpy operations directly manipulate
memory of the native code.

To keep this numpy dependency optional, all functions are wrapped into the
lammps.numpy sub-object which is only loaded when accessed.
This commit is contained in:
Richard Berger
2017-07-09 02:10:26 -05:00
parent bbfe16782b
commit b9fd1156b2
5 changed files with 184 additions and 21 deletions

View File

@ -0,0 +1,15 @@
This folder contains several LAMMPS input scripts and a python module
file py_integrate.py to demonstrate the use of the fix style python/integrate.
in.fix_python_integrate_melt:
This is a version of the melt example which replaces the default NVE integrator
with a Python implementation. Fix python/integrate is used to create an
instance of the py_integrate.NVE class which implements the required interface.
It demonstrates how to access LAMMPS data as numpy arrays. This gives direct
access to memory owned by the C++ code, allows easy manipulation through numpy
operations and avoids unnecessary copies.
in.fix_python_integrate_melt_opt:
This version of melt example uses NVE_Opt instead of NVE. While this Python
implementation is still much slower than the native version, it shows that
simple code transformations can lead to speedups.