update unified LJ Ar example to include creating the pickle in the input

This commit is contained in:
Axel Kohlmeyer
2022-09-24 03:33:19 -04:00
parent c7b24cb1e3
commit f1756eeeee
2 changed files with 69 additions and 60 deletions

View File

@ -1,6 +1,6 @@
This directory contains multiple examples of
machine-learning potentials defined using the
MLIAP package in LAMMPS. The input files
This directory contains multiple examples of
machine-learning potentials defined using the
ML-IAP package in LAMMPS. The input files
are described below.
in.mliap.snap.Ta06A
@ -21,14 +21,14 @@ Run EME-SNAP, equivalent to examples/snap/in.snap.InP.JCPA2020
in.mliap.snap.compute
---------------------
Generate the A matrix, the gradients (w.r.t. coefficients)
of total potential energy, forces, and stress tensor for
Generate the A matrix, the gradients (w.r.t. coefficients)
of total potential energy, forces, and stress tensor for
linear SNAP, equivalent to in.snap.compute
in.mliap.quadratic.compute
--------------------------
Generate the A matrix, the gradients (w.r.t. coefficients)
of total potential energy, forces, and stress tensor for
Generate the A matrix, the gradients (w.r.t. coefficients)
of total potential energy, forces, and stress tensor for
for quadratic SNAP, equivalent to in.snap.compute.quadratic
in.mliap.pytorch.Ta06A
@ -41,8 +41,8 @@ This example can be run in two different ways:
1: Running a LAMMPS executable: in.mliap.pytorch.Ta06A
First run ``python convert_mliap_Ta06A.py``. It creates
a PyTorch energy model that replicates the
SNAP Ta06A potential and saves it in the file
a PyTorch energy model that replicates the
SNAP Ta06A potential and saves it in the file
"Ta06A.mliap.pytorch.model.pt".
You can then run the example as follows
@ -52,7 +52,7 @@ You can then run the example as follows
The resultant log.lammps output should be identical to that generated
by in.mliap.snap.Ta06A.
If this fails, see the instructions for building the MLIAP package
If this fails, see the instructions for building the ML-IAP package
with Python support enabled. Also, confirm that the
LAMMPS Python embedded Python interpreter is
working by running ../examples/in.python.
@ -62,7 +62,7 @@ working by running ../examples/in.python.
Before testing this, ensure that the previous method
(running a LAMMPS executable) works.
You can run the example in serial:
You can run the example in serial:
`python mliap_pytorch_Ta06A.py`
@ -80,25 +80,25 @@ the script will exit with an error message.
in.mliap.pytorch.relu1hidden
----------------------------
This example demonstrates a simple neural network potential
using PyTorch and SNAP descriptors.
using PyTorch and SNAP descriptors.
`lmp -in in.mliap.pytorch.relu1hidden -echo both`
It was trained on just the energy component (no forces) of
the data used in the original SNAP Ta06A potential for
tantalum (Thompson, Swiler, Trott, Foiles, Tucker,
It was trained on just the energy component (no forces) of
the data used in the original SNAP Ta06A potential for
tantalum (Thompson, Swiler, Trott, Foiles, Tucker,
J Comp Phys, 285, 316 (2015).). Because of the very small amount
of energy training data, it uses just 1 hidden layer with
a ReLU activation function. It is not expected to be
very accurate for forces.
of energy training data, it uses just 1 hidden layer with
a ReLU activation function. It is not expected to be
very accurate for forces.
NOTE: Unlike the previous example, this example uses
a pre-built PyTorch file `Ta06A.mliap.pytorch.model.pt`.
NOTE: Unlike the previous example, this example uses
a pre-built PyTorch file `Ta06A.mliap.pytorch.model.pt`.
It is read using `torch.load`,
which implicitly uses the Python `pickle` module.
This is known to be insecure. It is possible to construct malicious
pickle data that will execute arbitrary code during unpickling. Never
load data that could have come from an untrusted source, or that
This is known to be insecure. It is possible to construct malicious
pickle data that will execute arbitrary code during unpickling. Never
load data that could have come from an untrusted source, or that
could have been tampered with. Only load data you trust.
in.mliap.nn.Ta06A
@ -112,36 +112,36 @@ Run a neural network potential for Cu, a combination of SNAP descriptors and the
in.mliap.unified.lj.Ar
-----------------------
This reproduces the output of examples/melt/in.melt,
but using the ``unified`` keyword and
but using the ``unified`` keyword and
the Python coupling to PyTorch.
This example can be run in two different ways:
1: Running a LAMMPS executable: in.mliap.unified.lj.Ar
First run ``python ./pickle_mliap_unified_lj_Ar.py``. It creates
an MLIAP unified model that replicates the ``lj/cut`` pair
style defined in examples/melt/in/melt
and saves it in the file "mliap_unified_lj_Ar.pkl".
You can then run the example as follows
You can run the example as follows
`lmp -in in.mliap.unified.lj.Ar -echo both`
The resultant log.lammps output should be identical to that generated
by in.melt.
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.
The input first runs ``python pickle_mliap_unified_lj_Ar.py`` and
thus creates an ML-IAP unified model that replicates the ``lj/cut``
pair style defined in examples/melt/in/melt and saves it in the
file "mliap_unified_lj_Ar.pkl".
If this fails, see the instructions for building the ML-IAP package
with Python support enabled. Also, confirm that the LAMMPS Python
embedded Python interpreter is working by running ../examples/in.python
and that the LAMMPS python module is installed and working.
2: Running a Python script: mliap_unified_lj_Ar.py
Before testing this, ensure that the previous method
(running a LAMMPS executable) works.
You can run the example in serial:
You can run the example in serial:
`python mliap_unified_lj_Ar.py`
@ -155,17 +155,17 @@ by in.melt and in.mliap.unified.lj.Ar.
in.mliap.unified.hippynn.Al
---------------------------
Demonstrate MLIAP interface to HIPNN Al potential. Requires the HIPNN code.
Demonstrate ML-IAP interface to HIPNN Al potential. Requires the HIPNN code.
in.mliap.unified.hippynn.Al.ghostneigh
--------------------------------------
Demonstrate MLIAP interface to HIPNN Al potential with ghost neighbors. Requires the HIPNN code.
Demonstrate ML-IAP interface to HIPNN Al potential with ghost neighbors. Requires the HIPNN code.
in.mliap.unified.hippynn.InP
----------------------------
Demonstrate MLIAP interface to HIPNN InP potential. Requires the HIPNN code.
Demonstrate ML-IAP interface to HIPNN InP potential. Requires the HIPNN code.
in.mliap.so3.Ni_Mo
------------------

View File

@ -1,35 +1,44 @@
# create pickle of unified model
shell rm mliap_unified_lj_Ar.pkl
shell python pickle_mliap_unified_lj_Ar.py
# 3d Lennard-Jones melt
units lj
atom_style atomic
units lj
atom_style atomic
lattice fcc 0.8442
region box block 0 10 0 10 0 10
create_box 1 box
create_atoms 1 box
mass 1 1.0
lattice fcc 0.8442
region box block 0 10 0 10 0 10
create_box 1 box
create_atoms 1 box
mass 1 1.0
velocity all create 3.0 87287 loop geom
velocity all create 3.0 87287 loop geom
pair_style mliap unified mliap_unified_lj_Ar.pkl
pair_coeff * * Ar
pair_style mliap unified mliap_unified_lj_Ar.pkl
pair_coeff * * Ar
neighbor 0.3 bin
neigh_modify every 20 delay 0 check no
neighbor 0.3 bin
neigh_modify every 20 delay 0 check no
fix 1 all nve
fix 1 all nve
#dump id all atom 50 dump.melt
#dump id all atom 50 dump.melt
#dump 2 all image 25 image.*.jpg type type &
# axes yes 0.8 0.02 view 60 -30
#dump_modify 2 pad 3
#dump 2 all image 25 image.*.jpg type type &
# axes yes 0.8 0.02 view 60 -30
#dump_modify 2 pad 3
#dump 3 all movie 1 movie.mpg type type &
# axes yes 0.8 0.02 view 60 -30
#dump_modify 3 pad 3
#dump 3 all movie 1 movie.mpg type type &
# axes yes 0.8 0.02 view 60 -30
#dump_modify 3 pad 3
#dump 4 all custom 1 forces.xyz fx fy fz
thermo 50
run 250
thermo 50
run 250
# clean up
shell rm mliap_unified_lj_Ar.pkl