compatibility with new lammps-user-pace library and cleanup

This commit is contained in:
James Michael Goff
2023-09-19 17:24:15 -06:00
parent f9cc60cfd5
commit db4f55b76f
11 changed files with 46 additions and 117 deletions

View File

@ -0,0 +1,9 @@
# This folder contains examples for pace in LAMMPS
## Compute pace usage
compute/latte_cell_0.data # lammps data file with C-H-O structure
compute/latte_cell_0.xyz # xyz file with C-H-O structure
compute/coupling_coefficients.yace # .yace file containing coupling coefficients (or ACE potential parameters)
compute/in.lammps # input file for calling `compute pace`

View File

View File

@ -0,0 +1,22 @@
#info all out log
units metal
atom_style atomic
boundary p p p
atom_modify map hash
boundary p p p
read_data latte_cell_0.data
mass 1 1.00
mass 2 14.00
mass 3 15.999
# potential settings
pair_style zero 5.7
pair_coeff * *
compute pace all pace coupling_coefficients.yace 1 0
thermo 1
thermo_style custom step temp c_pace[1][183]
run 0

View File

@ -1,5 +0,0 @@
Check that seg fault doesn't occur by doing:
./loop.sh
which will loop through many runs of `python test_en.py`.

View File

@ -1,8 +0,0 @@
for (( ; ; ))
do
python test_en.py
# terminate loop if seg fault
if [[ $? -eq 139 ]]; then
break
fi
done

View File

@ -1,86 +0,0 @@
from __future__ import print_function
import sys, os
import ctypes
import numpy as np
from ase.io import read,write
from lammps import lammps, LMP_TYPE_ARRAY, LMP_STYLE_GLOBAL
# get MPI settings from LAMMPS
def run_struct(f):
file_prefix = f.split('.')[0]
atoms = read(f)
lmp = lammps()
me = lmp.extract_setting("world_rank")
nprocs = lmp.extract_setting("world_size")
write('%s.data' % file_prefix,atoms,format='lammps-data')
cmds = ["-screen", "none", "-log", "none"]
lmp = lammps(cmdargs = cmds)
print("Made LAMMPS instance")
def run_lammps(dgradflag):
# simulation settings
fname = file_prefix
lmp.command("clear")
lmp.command("info all out log")
lmp.command('units metal')
lmp.command('atom_style atomic')
lmp.command("boundary p p p")
lmp.command("atom_modify map hash")
lmp.command('neighbor 2.3 bin')
# boundary
lmp.command('boundary p p p')
# read atoms
lmp.command('read_data %s.data' % fname )
lmp.command('mass 1 1.00')
lmp.command('mass 2 14.00')
lmp.command('mass 3 15.999')
# potential settings
lmp.command(f"pair_style zero 5.7")
lmp.command(f"pair_coeff * *")
if dgradflag:
lmp.command(f"compute pace all pace coupling_coefficients.yace 1 1")
else:
lmp.command(f"compute pace all pace coupling_coefficients.yace 1 0 ")
# run
lmp.command(f"thermo 100")
lmp.command(f"run {nsteps}")
# declare simulation/structure variables
nsteps = 0
ntypes = 3
# declare compute pace variables
bikflag = 1
# NUMBER of descriptors
nd = 91
dgradflag = 0
run_lammps(dgradflag)
lmp_pace = lmp.numpy.extract_compute("pace", LMP_STYLE_GLOBAL, LMP_TYPE_ARRAY)
print ('global shape',np.shape(lmp_pace))
np.save('%s_chi_i.npy' % file_prefix,lmp_pace)
lmp.close()
del lmp
return None
import glob
for f in sorted(glob.glob('*.xyz')):
print ('running %s' % f)
run_struct(f)