Updated README files

This commit is contained in:
Aidan Thompson
2020-12-23 10:17:55 -07:00
parent 6dc18d4ff2
commit 9122b18c6f
2 changed files with 41 additions and 35 deletions

View File

@ -1,7 +1,7 @@
This directory contains multipler examples of This directory contains multiple examples of
machine-learning potentials defined using the machine-learning potentials defined using the
MLIAP package in LAMMPS. The input files MLIAP package in LAMMPS. The input files
are descirbed below. are described below.
in.mliap.snap.Ta06A in.mliap.snap.Ta06A
------------------- -------------------
@ -21,58 +21,62 @@ Run EME-SNAP, equivalent to examples/snap/in.snap.InP.JCPA2020
in.mliap.snap.compute in.mliap.snap.compute
--------------------- ---------------------
Generate gradients w.r.t. coefficients for linear SNAP, Generate the A matrix, the gradients (w.r.t. coefficients)
equivalent to in.snap.compute of total potential energy, forces, and stress tensor for
linear SNAP, equivalent to in.snap.compute
in.mliap.quadratic.compute in.mliap.quadratic.compute
-------------------------- --------------------------
Generate gradients w.r.t. coefficients for quadratic SNAP, Generate the A matrix, the gradients (w.r.t. coefficients)
equivalent to in.snap.compute.quadratic of total potential energy, forces, and stress tensor for
for quadratic SNAP, equivalent to in.snap.compute.quadratic
in.mliap.pytorch.Ta06A in.mliap.pytorch.Ta06A
----------------------- -----------------------
This reproduces the output of in.mliap.snap.Ta06A above, This reproduces the output of in.mliap.snap.Ta06A above,
but using the Python coupling to PyTorch. but using the Python coupling to PyTorch.
It can be run in two different ways:
This example can be run in two different ways:
1: Running a LAMMPS executable: in.mliap.pytorch.Ta06A 1: Running a LAMMPS executable: in.mliap.pytorch.Ta06A
First run convert_mliap_Ta06A.py, which will convert the Ta06A potential First run ``python convert_mliap_Ta06A.py``. It creates
into a pytorch model. It will be saved as "Ta06A.mliap.pytorch.model.pkl". a PyTorch energy model that replicates the
SNAP Ta06A potential and saves it in the file
"Ta06A.mliap.pytorch.model.pt".
It will also copy "../../src/MLIAP/mliappy_pytorch.py" You can then run the example as follows
file into the current working directory. mliappy_pytorch.py contains
class definitions suitable for wrapping an arbitrary PyTorch
energy model. It must be available to python when
creating or unpickling a PyTorch energy model.
From that point you can run the example as follows
`lmp -in in.mliap.pytorch.Ta06A -echo both` `lmp -in in.mliap.pytorch.Ta06A -echo both`
The resultant log.lammps output should be identical to that generated The resultant log.lammps output should be identical to that generated
by in.mliap.snap.Ta06A. by in.mliap.snap.Ta06A.
If this fails, see the instructions for building the MLIAP package
with Python support enabled. Also, confirm that the
LAMMPS Python embedded Python interpreter is
working by running ../examples/in.python.
2: Running a Python script: mliap_pytorch_Ta06A.py 2: Running a Python script: mliap_pytorch_Ta06A.py
Before testing this, ensure that the first example Before testing this, ensure that the previous method
(using LAMMPS executable) works. (running a LAMMPS executable) works.
Also, not all python installations support this mode of operation.
It requires that the Python interpreter be initialized. You can run the example in serial:
To check this for your Python library,
try running the Py_IsInitialized() method.
If the return value is True, you should be able to run the example,
as follows:
`python mliap_pytorch_Ta06A.py` `python mliap_pytorch_Ta06A.py`
or or in parallel:
`mpirun -np 4 python mliap_pytorch_Ta06A.py` `mpirun -np 4 python mliap_pytorch_Ta06A.py`
The resultant log.lammps output should be identical to that generated The resultant log.lammps output should be identical to that generated
by in.mliap.snap.Ta06A and in.mliap.pytorch.Ta06A. by in.mliap.snap.Ta06A and in.mliap.pytorch.Ta06A.
Not all Python installations support this mode of operation.
It requires that the Python interpreter be initialized. If not,
the script will exit with an error message.
in.mliap.pytorch.relu1hidden in.mliap.pytorch.relu1hidden
---------------------------- ----------------------------
This example demonstrates a simple neural network potential This example demonstrates a simple neural network potential

View File

@ -8,12 +8,15 @@ definitions of the interatomic potential functional form (*model*)
and the geometric quantities that characterize the atomic positions and the geometric quantities that characterize the atomic positions
(*descriptor*). By defining *model* and *descriptor* separately, (*descriptor*). By defining *model* and *descriptor* separately,
it is possible to use many different models with a given descriptor, it is possible to use many different models with a given descriptor,
or many different descriptors with a given model. Currently, the pair_style or many different descriptors with a given model. The pair_style
supports just two models, *linear* and *quadratic*, supports the following models: *linear*, *quadratic*, and
and one descriptor, *sna*, the SNAP descriptor, including the *mliappy* (general Python interface to things like PyTorch, see below
linear, quadratic, and chem variants. Work is currently underway to extend for build instructions).
the interface to handle neural network energy models, It currently supports only one class of descriptors,
and it is also straightforward to add new descriptor styles. *sna*, the SNAP descriptors, including the
linear, quadratic, and chem variants.
It is straightforward to add new descriptor and model
styles.
The mliap compute style provides gradients of the energy, force, The mliap compute style provides gradients of the energy, force,
and stress tensor w.r.t. model parameters. and stress tensor w.r.t. model parameters.
@ -27,13 +30,13 @@ reference potential.
To see how this command To see how this command
can be used within a Python workflow to train machine-learning interatomic can be used within a Python workflow to train machine-learning interatomic
potentials, see the examples in FitSNAP https://github.com/FitSNAP/FitSNAP>. potentials, see the examples in FitSNAP https://github.com/FitSNAP/FitSNAP.
*Additional instructions for building MLIAP with Python support enabled* *Additional instructions for building MLIAP with Python support enabled*
The *mliappy* energy model requires that the MLIAP package The *mliappy* energy model requires that the MLIAP package
be compiled with Python support enabled. be compiled with Python support enabled.
This extension written by Nick Lubbers (LANL) This extension, written by Nick Lubbers (LANL),
provides a coupling to PyTorch and other Python modules. provides a coupling to PyTorch and other Python modules.
This should be automatically This should be automatically
enabled by default if the prerequisite software is installed. It can be enabled by default if the prerequisite software is installed. It can be
@ -51,5 +54,4 @@ file(s) in the src/MLIAP folder or there may be problems during compilation.
More information on building LAMMPS with this package is here: More information on building LAMMPS with this package is here:
https://lammps.sandia.gov/doc/html/Build_extras.html#mliap https://lammps.sandia.gov/doc/Build_extras.html#mliap