From 4de5b1b61240ab531b459249b0c4ca6844b03714 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Fri, 13 Nov 2020 16:30:05 -0700 Subject: [PATCH 1/4] Added README explaining how to run cythonize --- src/MLIAPPY/README | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/MLIAPPY/README diff --git a/src/MLIAPPY/README b/src/MLIAPPY/README new file mode 100644 index 00000000000..12f162da5a1 --- /dev/null +++ b/src/MLIAPPY/README @@ -0,0 +1,9 @@ +This package provides a coupling to PyTorch energy models +via the MLIAP package. + +Before compiling LAMMPS with either make or cmake, you have +to run cythoniz to create the coupling source files +in the src/MLIAPPY directory e.g. + +cd MLIAPPY +~/anaconda3/bin/cythonize mliap_model_python_couple.pyx From 0623817afea8a695772b85d3e3dd8c9540c87d28 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Fri, 20 Nov 2020 11:47:31 -0700 Subject: [PATCH 2/4] Updated README --- src/MLIAPPY/README | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/MLIAPPY/README b/src/MLIAPPY/README index 12f162da5a1..ba15d6eb51d 100644 --- a/src/MLIAPPY/README +++ b/src/MLIAPPY/README @@ -2,8 +2,23 @@ This package provides a coupling to PyTorch energy models via the MLIAP package. Before compiling LAMMPS with either make or cmake, you have -to run cythoniz to create the coupling source files +to run cythonize to create the coupling source files in the src/MLIAPPY directory e.g. cd MLIAPPY -~/anaconda3/bin/cythonize mliap_model_python_couple.pyx +cythonize mliap_model_python_couple.pyx + +When building with make, you will have to add this +compiler option, suitably modified for your NumPy: + +-I/home/athomps/anaconda3/lib/python3.7/site-packages/numpy/core/include + +When bulding with cmake, it should just work, but if you have +cmake version older than 3.14, you will have to edit +this file accordingly: +more ../../cmake/Modules/Packages/MLIAPPY.cmake +if(CMAKE_VERSION VERSION_LESS 3.14) +: + target_include_directories(lammps PRIVATE /home/athomps/anaconda3/lib/python3.7/site-packages/numpy/core/include) +: + From 97b77e0f138413162b3d51a6e784ad28517f91eb Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Mon, 30 Nov 2020 19:29:28 -0700 Subject: [PATCH 3/4] Added preprocessor flag --- src/MLIAPPY/Install.sh | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 src/MLIAPPY/Install.sh diff --git a/src/MLIAPPY/Install.sh b/src/MLIAPPY/Install.sh new file mode 100755 index 00000000000..8fccbc2a9c4 --- /dev/null +++ b/src/MLIAPPY/Install.sh @@ -0,0 +1,53 @@ +# Install/unInstall package files in LAMMPS +# mode = 0/1/2 for uninstall/install/update + +mode=$1 + +# arg1 = file, arg2 = file it depends on + +# enforce using portable C locale +LC_ALL=C +export LC_ALL + +action () { + if (test $mode = 0) then + rm -f ../$1 + elif (! cmp -s $1 ../$1) then + if (test -z "$2" || test -e ../$2) then + cp $1 .. + if (test $mode = 2) then + echo " updating src/$1" + fi + fi + elif (test -n "$2") then + if (test ! -e ../$2) then + rm -f ../$1 + fi + fi +} + +# force rebuild of files using python header + +touch ../lmppython.h + +# all package files with no dependencies + +for file in *.cpp *.h; do + test -f ${file} && action $file +done + +# edit 2 Makefile.package files to include/exclude package info + +if (test $1 = 1) then + + if (test -e ../Makefile.package) then + sed -i -e 's|^PKG_INC =[ \t]*|&-DLMP_MLIAPPY |' ../Makefile.package + fi + +elif (test $1 = 0) then + + if (test -e ../Makefile.package) then + sed -i -e 's/[^ \t]*MLIAPPY[^ \t]* //g' ../Makefile.package + fi + +fi From 973382295b1439897e5869ff37cf5ff9915a9c54 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Thu, 3 Dec 2020 16:47:27 -0700 Subject: [PATCH 4/4] Clean up file --- examples/mliappy/in.mliap.pytorch.Ta06A | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/examples/mliappy/in.mliap.pytorch.Ta06A b/examples/mliappy/in.mliap.pytorch.Ta06A index e44b4352e7b..1d93d6a4249 100644 --- a/examples/mliappy/in.mliap.pytorch.Ta06A +++ b/examples/mliappy/in.mliap.pytorch.Ta06A @@ -22,20 +22,6 @@ create_atoms 1 box mass 1 180.88 -python simple here """ -from __future__ import print_function - -def simple(): - foo = 0 - print("Inside simple function") - try: - foo += 1 - except Exception as e: - print("FOO error:", e) -""" - -python simple invoke - # choose potential include Ta06A.mliap.pytorch