Resolve merge conflicts
This commit is contained in:
103
examples/mliap/README
Normal file
103
examples/mliap/README
Normal file
@ -0,0 +1,103 @@
|
||||
This directory contains multiple examples of
|
||||
machine-learning potentials defined using the
|
||||
MLIAP package in LAMMPS. The input files
|
||||
are described below.
|
||||
|
||||
in.mliap.snap.Ta06A
|
||||
-------------------
|
||||
Run linear SNAP, equivalent to examples/snap/in.snap.Ta06A
|
||||
|
||||
in.mliap.snap.WBe.PRB2019
|
||||
-------------------------
|
||||
Run linear SNAP, equivalent to examples/snap/in.snap.WBe.PRB2019
|
||||
|
||||
in.mliap.snap.quadratic
|
||||
-----------------------
|
||||
Run quadratic SNAP
|
||||
|
||||
in.mliap.snap.chem
|
||||
------------------
|
||||
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
|
||||
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
|
||||
for quadratic SNAP, equivalent to in.snap.compute.quadratic
|
||||
|
||||
in.mliap.pytorch.Ta06A
|
||||
-----------------------
|
||||
This reproduces the output of in.mliap.snap.Ta06A above,
|
||||
but using the Python coupling to PyTorch.
|
||||
|
||||
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
|
||||
"Ta06A.mliap.pytorch.model.pt".
|
||||
|
||||
You can then run the example as follows
|
||||
|
||||
`lmp -in in.mliap.pytorch.Ta06A -echo both`
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
Before testing this, ensure that the previous method
|
||||
(running a LAMMPS executable) works.
|
||||
|
||||
You can run the example in serial:
|
||||
|
||||
`python mliap_pytorch_Ta06A.py`
|
||||
|
||||
or in parallel:
|
||||
|
||||
`mpirun -np 4 python mliap_pytorch_Ta06A.py`
|
||||
|
||||
The resultant log.lammps output should be identical to that generated
|
||||
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
|
||||
----------------------------
|
||||
This example demonstrates a simple neural network potential
|
||||
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,
|
||||
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.
|
||||
|
||||
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
|
||||
could have been tampered with. Only load data you trust.
|
||||
|
||||
18
examples/mliap/Ta06A.mliap.pytorch
Normal file
18
examples/mliap/Ta06A.mliap.pytorch
Normal file
@ -0,0 +1,18 @@
|
||||
# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014)
|
||||
|
||||
# Definition of SNAP potential Ta_Cand06A
|
||||
# Assumes 1 LAMMPS atom type
|
||||
|
||||
variable zblcutinner equal 4
|
||||
variable zblcutouter equal 4.8
|
||||
variable zblz equal 73
|
||||
|
||||
# Specify hybrid with SNAP, ZBL
|
||||
|
||||
pair_style hybrid/overlay &
|
||||
zbl ${zblcutinner} ${zblcutouter} &
|
||||
mliap model mliappy Ta06A.mliap.pytorch.model.pt &
|
||||
descriptor sna Ta06A.mliap.descriptor
|
||||
pair_coeff 1 1 zbl ${zblz} ${zblz}
|
||||
pair_coeff * * mliap Ta
|
||||
|
||||
26
examples/mliap/convert_mliap_Ta06A.py
Normal file
26
examples/mliap/convert_mliap_Ta06A.py
Normal file
@ -0,0 +1,26 @@
|
||||
import sys
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
# torch.nn.modules useful for defining a MLIAPPY model.
|
||||
from lammps.mliap.pytorch import TorchWrapper, IgnoreElems
|
||||
|
||||
# Read coefficients
|
||||
coeffs = np.genfromtxt("Ta06A.mliap.model",skip_header=6)
|
||||
|
||||
# Write coefficients to a pytorch linear model
|
||||
bias = coeffs[0]
|
||||
weights = coeffs[1:]
|
||||
lin = torch.nn.Linear(weights.shape[0],1)
|
||||
lin.to(torch.float64)
|
||||
with torch.autograd.no_grad():
|
||||
lin.weight.set_(torch.from_numpy(weights).unsqueeze(0))
|
||||
lin.bias.set_(torch.as_tensor(bias,dtype=torch.float64).unsqueeze(0))
|
||||
|
||||
# Wrap the pytorch model for usage with mliappy coupling.
|
||||
model = IgnoreElems(lin) # The linear module does not use the types.
|
||||
n_descriptors = lin.weight.shape[1]
|
||||
n_elements = 1
|
||||
linked_model = TorchWrapper(model,n_descriptors=n_descriptors,n_elements=n_elements)
|
||||
|
||||
torch.save(linked_model,"Ta06A.mliap.pytorch.model.pt")
|
||||
53
examples/mliap/in.mliap.pytorch.Ta06A
Normal file
53
examples/mliap/in.mliap.pytorch.Ta06A
Normal file
@ -0,0 +1,53 @@
|
||||
# Demonstrate MLIAP/PyTorch interface to linear SNAP potential
|
||||
|
||||
# Initialize simulation
|
||||
|
||||
variable nsteps index 100
|
||||
variable nrep equal 4
|
||||
variable a equal 3.316
|
||||
units metal
|
||||
|
||||
# generate the box and atom positions using a BCC lattice
|
||||
|
||||
variable nx equal ${nrep}
|
||||
variable ny equal ${nrep}
|
||||
variable nz equal ${nrep}
|
||||
|
||||
boundary p p p
|
||||
|
||||
lattice bcc $a
|
||||
region box block 0 ${nx} 0 ${ny} 0 ${nz}
|
||||
create_box 1 box
|
||||
create_atoms 1 box
|
||||
|
||||
mass 1 180.88
|
||||
|
||||
# choose potential
|
||||
|
||||
include Ta06A.mliap.pytorch
|
||||
|
||||
# Setup output
|
||||
|
||||
compute eatom all pe/atom
|
||||
compute energy all reduce sum c_eatom
|
||||
|
||||
compute satom all stress/atom NULL
|
||||
compute str all reduce sum c_satom[1] c_satom[2] c_satom[3]
|
||||
variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol)
|
||||
|
||||
thermo_style custom step temp epair c_energy etotal press v_press
|
||||
thermo 10
|
||||
thermo_modify norm yes
|
||||
|
||||
# Set up NVE run
|
||||
|
||||
timestep 0.5e-3
|
||||
neighbor 1.0 bin
|
||||
neigh_modify once no every 1 delay 0 check yes
|
||||
|
||||
# Run MD
|
||||
|
||||
velocity all create 300.0 4928459 loop geom
|
||||
fix 1 all nve
|
||||
run ${nsteps}
|
||||
|
||||
53
examples/mliap/in.mliap.pytorch.relu1hidden
Normal file
53
examples/mliap/in.mliap.pytorch.relu1hidden
Normal file
@ -0,0 +1,53 @@
|
||||
# Demonstrate MLIAP interface to linear SNAP potential
|
||||
|
||||
# Initialize simulation
|
||||
|
||||
variable nsteps index 100
|
||||
variable nrep equal 4
|
||||
variable a equal 3.316
|
||||
units metal
|
||||
|
||||
# generate the box and atom positions using a BCC lattice
|
||||
|
||||
variable nx equal ${nrep}
|
||||
variable ny equal ${nrep}
|
||||
variable nz equal ${nrep}
|
||||
|
||||
boundary p p p
|
||||
|
||||
lattice bcc $a
|
||||
region box block 0 ${nx} 0 ${ny} 0 ${nz}
|
||||
create_box 1 box
|
||||
create_atoms 1 box
|
||||
|
||||
mass 1 180.88
|
||||
|
||||
# choose potential
|
||||
|
||||
include relu1hidden.mliap.pytorch
|
||||
|
||||
# Setup output
|
||||
|
||||
compute eatom all pe/atom
|
||||
compute energy all reduce sum c_eatom
|
||||
|
||||
compute satom all stress/atom NULL
|
||||
compute str all reduce sum c_satom[1] c_satom[2] c_satom[3]
|
||||
variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol)
|
||||
|
||||
thermo_style custom step temp epair c_energy etotal press v_press
|
||||
thermo 10
|
||||
thermo_modify norm yes
|
||||
|
||||
# Set up NVE run
|
||||
|
||||
timestep 0.5e-3
|
||||
neighbor 1.0 bin
|
||||
neigh_modify once no every 1 delay 0 check yes
|
||||
|
||||
# Run MD
|
||||
|
||||
velocity all create 300.0 4928459 loop geom
|
||||
fix 1 all nve
|
||||
run ${nsteps}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# Demonstrate MLIAP interface to kinear SNAP potential
|
||||
# Demonstrate MLIAP interface to linear SNAP potential
|
||||
|
||||
# Initialize simulation
|
||||
|
||||
|
||||
157
examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.1
Normal file
157
examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.1
Normal file
@ -0,0 +1,157 @@
|
||||
LAMMPS (30 Nov 2020)
|
||||
using 48 OpenMP thread(s) per MPI task
|
||||
# Demonstrate MLIAP/PyTorch interface to linear SNAP potential
|
||||
|
||||
# Initialize simulation
|
||||
|
||||
variable nsteps index 100
|
||||
variable nrep equal 4
|
||||
variable a equal 3.316
|
||||
units metal
|
||||
|
||||
# generate the box and atom positions using a BCC lattice
|
||||
|
||||
variable nx equal ${nrep}
|
||||
variable nx equal 4
|
||||
variable ny equal ${nrep}
|
||||
variable ny equal 4
|
||||
variable nz equal ${nrep}
|
||||
variable nz equal 4
|
||||
|
||||
boundary p p p
|
||||
|
||||
lattice bcc $a
|
||||
lattice bcc 3.316
|
||||
Lattice spacing in x,y,z = 3.3160000 3.3160000 3.3160000
|
||||
region box block 0 ${nx} 0 ${ny} 0 ${nz}
|
||||
region box block 0 4 0 ${ny} 0 ${nz}
|
||||
region box block 0 4 0 4 0 ${nz}
|
||||
region box block 0 4 0 4 0 4
|
||||
create_box 1 box
|
||||
Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (13.264000 13.264000 13.264000)
|
||||
1 by 1 by 1 MPI processor grid
|
||||
create_atoms 1 box
|
||||
Created 128 atoms
|
||||
create_atoms CPU = 0.002 seconds
|
||||
|
||||
mass 1 180.88
|
||||
|
||||
# choose potential
|
||||
|
||||
include Ta06A.mliap.pytorch
|
||||
# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014)
|
||||
|
||||
# Definition of SNAP potential Ta_Cand06A
|
||||
# Assumes 1 LAMMPS atom type
|
||||
|
||||
variable zblcutinner equal 4
|
||||
variable zblcutouter equal 4.8
|
||||
variable zblz equal 73
|
||||
|
||||
# Specify hybrid with SNAP, ZBL
|
||||
|
||||
pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor
|
||||
pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor
|
||||
pair_style hybrid/overlay zbl 4 4.8 mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor
|
||||
Loading python model complete.
|
||||
Reading potential file Ta06A.mliap.descriptor with DATE: 2014-09-05
|
||||
SNAP keyword rcutfac 4.67637
|
||||
SNAP keyword twojmax 6
|
||||
SNAP keyword nelems 1
|
||||
SNAP keyword elems Ta
|
||||
SNAP keyword radelems 0.5
|
||||
SNAP keyword welems 1
|
||||
SNAP keyword rfac0 0.99363
|
||||
SNAP keyword rmin0 0
|
||||
SNAP keyword bzeroflag 0
|
||||
pair_coeff 1 1 zbl ${zblz} ${zblz}
|
||||
pair_coeff 1 1 zbl 73 ${zblz}
|
||||
pair_coeff 1 1 zbl 73 73
|
||||
pair_coeff * * mliap Ta
|
||||
|
||||
|
||||
# Setup output
|
||||
|
||||
compute eatom all pe/atom
|
||||
compute energy all reduce sum c_eatom
|
||||
|
||||
compute satom all stress/atom NULL
|
||||
compute str all reduce sum c_satom[1] c_satom[2] c_satom[3]
|
||||
variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol)
|
||||
|
||||
thermo_style custom step temp epair c_energy etotal press v_press
|
||||
thermo 10
|
||||
thermo_modify norm yes
|
||||
|
||||
# Set up NVE run
|
||||
|
||||
timestep 0.5e-3
|
||||
neighbor 1.0 bin
|
||||
neigh_modify once no every 1 delay 0 check yes
|
||||
|
||||
# Run MD
|
||||
|
||||
velocity all create 300.0 4928459 loop geom
|
||||
fix 1 all nve
|
||||
run ${nsteps}
|
||||
run 100
|
||||
Neighbor list info ...
|
||||
update every 1 steps, delay 0 steps, check yes
|
||||
max neighbors/atom: 2000, page size: 100000
|
||||
master list distance cutoff = 5.8
|
||||
ghost atom cutoff = 5.8
|
||||
binsize = 2.9, bins = 5 5 5
|
||||
2 neighbor lists, perpetual/occasional/extra = 2 0 0
|
||||
(1) pair zbl, perpetual, half/full from (2)
|
||||
attributes: half, newton on
|
||||
pair build: halffull/newton
|
||||
stencil: none
|
||||
bin: none
|
||||
(2) pair mliap, perpetual
|
||||
attributes: full, newton on
|
||||
pair build: full/bin/atomonly
|
||||
stencil: full/bin/3d
|
||||
bin: standard
|
||||
Per MPI rank memory allocation (min/avg/max) = 159.8 | 159.8 | 159.8 Mbytes
|
||||
Step Temp E_pair c_energy TotEng Press v_press
|
||||
0 300 -11.85157 -11.85157 -11.813095 2717.1661 -2717.1661
|
||||
10 296.01467 -11.851059 -11.851059 -11.813095 2697.4796 -2697.4796
|
||||
20 284.53666 -11.849587 -11.849587 -11.813095 2289.1527 -2289.1527
|
||||
30 266.51577 -11.847275 -11.847275 -11.813095 1851.7131 -1851.7131
|
||||
40 243.05007 -11.844266 -11.844266 -11.813095 1570.684 -1570.684
|
||||
50 215.51032 -11.840734 -11.840734 -11.813094 1468.1899 -1468.1899
|
||||
60 185.48331 -11.836883 -11.836883 -11.813094 1524.8757 -1524.8757
|
||||
70 154.6736 -11.832931 -11.832931 -11.813094 1698.3351 -1698.3351
|
||||
80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715
|
||||
90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563
|
||||
100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526
|
||||
Loop time of 2.00236 on 48 procs for 100 steps with 128 atoms
|
||||
|
||||
Performance: 2.157 ns/day, 11.124 hours/ns, 49.941 timesteps/s
|
||||
288.8% CPU use with 1 MPI tasks x 48 OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 1.9998 | 1.9998 | 1.9998 | 0.0 | 99.87
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0.0011814 | 0.0011814 | 0.0011814 | 0.0 | 0.06
|
||||
Output | 0.00059724 | 0.00059724 | 0.00059724 | 0.0 | 0.03
|
||||
Modify | 0.00047352 | 0.00047352 | 0.00047352 | 0.0 | 0.02
|
||||
Other | | 0.0003468 | | | 0.02
|
||||
|
||||
Nlocal: 128.000 ave 128 max 128 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 727.000 ave 727 max 727 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 3712.00 ave 3712 max 3712 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
FullNghs: 7424.00 ave 7424 max 7424 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 7424
|
||||
Ave neighs/atom = 58.000000
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds = 0
|
||||
|
||||
Total wall time: 0:00:03
|
||||
157
examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.4
Normal file
157
examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.4
Normal file
@ -0,0 +1,157 @@
|
||||
LAMMPS (30 Nov 2020)
|
||||
using 48 OpenMP thread(s) per MPI task
|
||||
# Demonstrate MLIAP/PyTorch interface to linear SNAP potential
|
||||
|
||||
# Initialize simulation
|
||||
|
||||
variable nsteps index 100
|
||||
variable nrep equal 4
|
||||
variable a equal 3.316
|
||||
units metal
|
||||
|
||||
# generate the box and atom positions using a BCC lattice
|
||||
|
||||
variable nx equal ${nrep}
|
||||
variable nx equal 4
|
||||
variable ny equal ${nrep}
|
||||
variable ny equal 4
|
||||
variable nz equal ${nrep}
|
||||
variable nz equal 4
|
||||
|
||||
boundary p p p
|
||||
|
||||
lattice bcc $a
|
||||
lattice bcc 3.316
|
||||
Lattice spacing in x,y,z = 3.3160000 3.3160000 3.3160000
|
||||
region box block 0 ${nx} 0 ${ny} 0 ${nz}
|
||||
region box block 0 4 0 ${ny} 0 ${nz}
|
||||
region box block 0 4 0 4 0 ${nz}
|
||||
region box block 0 4 0 4 0 4
|
||||
create_box 1 box
|
||||
Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (13.264000 13.264000 13.264000)
|
||||
1 by 2 by 2 MPI processor grid
|
||||
create_atoms 1 box
|
||||
Created 128 atoms
|
||||
create_atoms CPU = 0.002 seconds
|
||||
|
||||
mass 1 180.88
|
||||
|
||||
# choose potential
|
||||
|
||||
include Ta06A.mliap.pytorch
|
||||
# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014)
|
||||
|
||||
# Definition of SNAP potential Ta_Cand06A
|
||||
# Assumes 1 LAMMPS atom type
|
||||
|
||||
variable zblcutinner equal 4
|
||||
variable zblcutouter equal 4.8
|
||||
variable zblz equal 73
|
||||
|
||||
# Specify hybrid with SNAP, ZBL
|
||||
|
||||
pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor
|
||||
pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor
|
||||
pair_style hybrid/overlay zbl 4 4.8 mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor
|
||||
Loading python model complete.
|
||||
Reading potential file Ta06A.mliap.descriptor with DATE: 2014-09-05
|
||||
SNAP keyword rcutfac 4.67637
|
||||
SNAP keyword twojmax 6
|
||||
SNAP keyword nelems 1
|
||||
SNAP keyword elems Ta
|
||||
SNAP keyword radelems 0.5
|
||||
SNAP keyword welems 1
|
||||
SNAP keyword rfac0 0.99363
|
||||
SNAP keyword rmin0 0
|
||||
SNAP keyword bzeroflag 0
|
||||
pair_coeff 1 1 zbl ${zblz} ${zblz}
|
||||
pair_coeff 1 1 zbl 73 ${zblz}
|
||||
pair_coeff 1 1 zbl 73 73
|
||||
pair_coeff * * mliap Ta
|
||||
|
||||
|
||||
# Setup output
|
||||
|
||||
compute eatom all pe/atom
|
||||
compute energy all reduce sum c_eatom
|
||||
|
||||
compute satom all stress/atom NULL
|
||||
compute str all reduce sum c_satom[1] c_satom[2] c_satom[3]
|
||||
variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol)
|
||||
|
||||
thermo_style custom step temp epair c_energy etotal press v_press
|
||||
thermo 10
|
||||
thermo_modify norm yes
|
||||
|
||||
# Set up NVE run
|
||||
|
||||
timestep 0.5e-3
|
||||
neighbor 1.0 bin
|
||||
neigh_modify once no every 1 delay 0 check yes
|
||||
|
||||
# Run MD
|
||||
|
||||
velocity all create 300.0 4928459 loop geom
|
||||
fix 1 all nve
|
||||
run ${nsteps}
|
||||
run 100
|
||||
Neighbor list info ...
|
||||
update every 1 steps, delay 0 steps, check yes
|
||||
max neighbors/atom: 2000, page size: 100000
|
||||
master list distance cutoff = 5.8
|
||||
ghost atom cutoff = 5.8
|
||||
binsize = 2.9, bins = 5 5 5
|
||||
2 neighbor lists, perpetual/occasional/extra = 2 0 0
|
||||
(1) pair zbl, perpetual, half/full from (2)
|
||||
attributes: half, newton on
|
||||
pair build: halffull/newton
|
||||
stencil: none
|
||||
bin: none
|
||||
(2) pair mliap, perpetual
|
||||
attributes: full, newton on
|
||||
pair build: full/bin/atomonly
|
||||
stencil: full/bin/3d
|
||||
bin: standard
|
||||
Per MPI rank memory allocation (min/avg/max) = 159.7 | 159.7 | 159.7 Mbytes
|
||||
Step Temp E_pair c_energy TotEng Press v_press
|
||||
0 300 -11.85157 -11.85157 -11.813095 2717.1661 -2717.1661
|
||||
10 296.01467 -11.851059 -11.851059 -11.813095 2697.4796 -2697.4796
|
||||
20 284.53666 -11.849587 -11.849587 -11.813095 2289.1527 -2289.1527
|
||||
30 266.51577 -11.847275 -11.847275 -11.813095 1851.7131 -1851.7131
|
||||
40 243.05007 -11.844266 -11.844266 -11.813095 1570.684 -1570.684
|
||||
50 215.51032 -11.840734 -11.840734 -11.813094 1468.1899 -1468.1899
|
||||
60 185.48331 -11.836883 -11.836883 -11.813094 1524.8757 -1524.8757
|
||||
70 154.6736 -11.832931 -11.832931 -11.813094 1698.3351 -1698.3351
|
||||
80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715
|
||||
90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563
|
||||
100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526
|
||||
Loop time of 0.562802 on 192 procs for 100 steps with 128 atoms
|
||||
|
||||
Performance: 7.676 ns/day, 3.127 hours/ns, 177.682 timesteps/s
|
||||
99.7% CPU use with 4 MPI tasks x 48 OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0.53583 | 0.54622 | 0.55401 | 0.9 | 97.05
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0.0071442 | 0.01491 | 0.025289 | 5.4 | 2.65
|
||||
Output | 0.00092525 | 0.00095771 | 0.0010166 | 0.0 | 0.17
|
||||
Modify | 0.00014479 | 0.00015043 | 0.00015893 | 0.0 | 0.03
|
||||
Other | | 0.0005624 | | | 0.10
|
||||
|
||||
Nlocal: 32.0000 ave 32 max 32 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 431.000 ave 431 max 431 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 928.000 ave 928 max 928 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
FullNghs: 1856.00 ave 1856 max 1856 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 7424
|
||||
Ave neighs/atom = 58.000000
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds = 0
|
||||
|
||||
Total wall time: 0:00:02
|
||||
104
examples/mliap/mliap_pytorch_Ta06A.py
Normal file
104
examples/mliap/mliap_pytorch_Ta06A.py
Normal file
@ -0,0 +1,104 @@
|
||||
# Demonstrate how to load a model from the python side.
|
||||
# This is essentially the same as in.mliap.pytorch.Ta06A
|
||||
# except that python is the driving program, and lammps
|
||||
# is in library mode.
|
||||
|
||||
before_loading =\
|
||||
"""# Demonstrate MLIAP/PyTorch interface to linear SNAP potential
|
||||
|
||||
# Initialize simulation
|
||||
|
||||
variable nsteps index 100
|
||||
variable nrep equal 4
|
||||
variable a equal 3.316
|
||||
units metal
|
||||
|
||||
# generate the box and atom positions using a BCC lattice
|
||||
|
||||
variable nx equal ${nrep}
|
||||
variable ny equal ${nrep}
|
||||
variable nz equal ${nrep}
|
||||
|
||||
boundary p p p
|
||||
|
||||
lattice bcc $a
|
||||
region box block 0 ${nx} 0 ${ny} 0 ${nz}
|
||||
create_box 1 box
|
||||
create_atoms 1 box
|
||||
|
||||
mass 1 180.88
|
||||
|
||||
# choose potential
|
||||
|
||||
# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014)
|
||||
|
||||
# Definition of SNAP potential Ta_Cand06A
|
||||
# Assumes 1 LAMMPS atom type
|
||||
|
||||
variable zblcutinner equal 4
|
||||
variable zblcutouter equal 4.8
|
||||
variable zblz equal 73
|
||||
|
||||
# Specify hybrid with SNAP, ZBL
|
||||
|
||||
pair_style hybrid/overlay &
|
||||
zbl ${zblcutinner} ${zblcutouter} &
|
||||
mliap model mliappy LATER &
|
||||
descriptor sna Ta06A.mliap.descriptor
|
||||
pair_coeff 1 1 zbl ${zblz} ${zblz}
|
||||
pair_coeff * * mliap Ta
|
||||
"""
|
||||
after_loading =\
|
||||
"""
|
||||
|
||||
# Setup output
|
||||
|
||||
compute eatom all pe/atom
|
||||
compute energy all reduce sum c_eatom
|
||||
|
||||
compute satom all stress/atom NULL
|
||||
compute str all reduce sum c_satom[1] c_satom[2] c_satom[3]
|
||||
variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol)
|
||||
|
||||
thermo_style custom step temp epair c_energy etotal press v_press
|
||||
thermo 10
|
||||
thermo_modify norm yes
|
||||
|
||||
# Set up NVE run
|
||||
|
||||
timestep 0.5e-3
|
||||
neighbor 1.0 bin
|
||||
neigh_modify once no every 1 delay 0 check yes
|
||||
|
||||
# Run MD
|
||||
|
||||
velocity all create 300.0 4928459 loop geom
|
||||
fix 1 all nve
|
||||
run ${nsteps}
|
||||
"""
|
||||
|
||||
import lammps
|
||||
|
||||
lmp = lammps.lammps(cmdargs=['-echo','both'])
|
||||
|
||||
# Before defining the pair style, one must do the following:
|
||||
import lammps.mliap
|
||||
lammps.mliap.activate_mliappy(lmp)
|
||||
# Otherwise, when running lammps in library mode,
|
||||
# you will get an error:
|
||||
# "ERROR: Loading MLIAPPY coupling module failure."
|
||||
|
||||
# Setup the simulation and declare an empty model
|
||||
# by specifying model filename as "LATER"
|
||||
lmp.commands_string(before_loading)
|
||||
|
||||
# Define the model however you like. In this example
|
||||
# we load it from disk:
|
||||
import torch
|
||||
model = torch.load('Ta06A.mliap.pytorch.model.pt')
|
||||
|
||||
# Connect the PyTorch model to the mliap pair style.
|
||||
lammps.mliap.load_model(model)
|
||||
|
||||
# run the simulation with the mliap pair style
|
||||
lmp.commands_string(after_loading)
|
||||
18
examples/mliap/relu1hidden.mliap.pytorch
Normal file
18
examples/mliap/relu1hidden.mliap.pytorch
Normal file
@ -0,0 +1,18 @@
|
||||
# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014)
|
||||
|
||||
# Definition of SNAP potential Ta_Cand06A
|
||||
# Assumes 1 LAMMPS atom type
|
||||
|
||||
variable zblcutinner equal 4
|
||||
variable zblcutouter equal 4.8
|
||||
variable zblz equal 73
|
||||
|
||||
# Specify hybrid with SNAP, ZBL
|
||||
|
||||
pair_style hybrid/overlay &
|
||||
zbl ${zblcutinner} ${zblcutouter} &
|
||||
mliap model mliappy relu1hidden.mliap.pytorch.model.pt &
|
||||
descriptor sna Ta06A.mliap.descriptor
|
||||
pair_coeff 1 1 zbl ${zblz} ${zblz}
|
||||
pair_coeff * * mliap Ta
|
||||
|
||||
BIN
examples/mliap/relu1hidden.mliap.pytorch.model.pt
Normal file
BIN
examples/mliap/relu1hidden.mliap.pytorch.model.pt
Normal file
Binary file not shown.
Reference in New Issue
Block a user