forked from lijiext/lammps
commit
b64849d574
|
@ -0,0 +1,2 @@
|
|||
/Makefile.KIM_DIR
|
||||
/Makefile.KIM_Config
|
|
@ -0,0 +1,150 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# install.py tool to setup the kim-api library
|
||||
# used to automate the steps described in the README file in this dir
|
||||
|
||||
import sys,os,re,urllib,commands
|
||||
|
||||
help = """
|
||||
Syntax: install.py -v version -c kim-dir -b kim-model-name -a kim-name
|
||||
specify one or more options, order does not matter
|
||||
-v = version of kim-api to download and work with
|
||||
default = kim-api-v1.8.2 (current as of June 2017)
|
||||
-c = create Makefile.KIM_DIR within lammps lib/kim to configure lammps
|
||||
for use with the kim-api library installed at "kim-dir" (absolute
|
||||
path). default = this dir
|
||||
-b = build kim-api and kim model where kim-model-name can be a specific
|
||||
openkim.org model name (such as
|
||||
"EAM_Dynamo_Ackland_W__MO_141627196590_002") or the keyword
|
||||
"OpenKIM" to install all compatible models from the openkim.org
|
||||
site.
|
||||
-a = add kim-name openkim.org item (model driver or model) to existing
|
||||
kim-api instalation.
|
||||
"""
|
||||
|
||||
def error():
|
||||
print help
|
||||
sys.exit()
|
||||
|
||||
# parse args
|
||||
|
||||
args = sys.argv
|
||||
|
||||
thisdir = os.environ['PWD']
|
||||
dir = thisdir
|
||||
version = "kim-api-v1.8.2"
|
||||
|
||||
dirflag = 0
|
||||
buildflag = 0
|
||||
addflag = 0
|
||||
|
||||
iarg = 1
|
||||
while iarg < len(args):
|
||||
if args[iarg] == "-v":
|
||||
if iarg+2 > len(args): error()
|
||||
version = args[iarg+1]
|
||||
iarg += 2
|
||||
elif args[iarg] == "-c":
|
||||
dirflag = 1
|
||||
if iarg+2 > len(args): error()
|
||||
dir = args[iarg+1]
|
||||
iarg += 2
|
||||
elif args[iarg] == "-b":
|
||||
buildflag = 1
|
||||
if iarg+2 > len(args): error()
|
||||
modelname = args[iarg+1]
|
||||
iarg += 2
|
||||
elif args[iarg] == "-a":
|
||||
addflag = 1
|
||||
if iarg+2 > len(args): error()
|
||||
addmodelname = args[iarg+1]
|
||||
iarg += 2
|
||||
else: error()
|
||||
|
||||
thisdir = os.path.abspath(thisdir)
|
||||
dir = os.path.abspath(dir)
|
||||
url = "https://s3.openkim.org/kim-api/%s.tgz" % version
|
||||
|
||||
# download and unpack tarball
|
||||
|
||||
|
||||
if not os.path.isfile("%s/Makefile.KIM_DIR" % thisdir):
|
||||
open("%s/Makefile.KIM_DIR" % thisdir, 'w').write("KIM_INSTALL_DIR=%s" % dir)
|
||||
open("%s/Makefile.KIM_Config" % thisdir, 'w').write("include %s/lib/kim-api/Makefile.KIM_Config" % dir)
|
||||
print "Created %s/Makefile.KIM_DIR : using %s" % (thisdir,dir)
|
||||
else:
|
||||
if dirflag == 1:
|
||||
open("%s/Makefile.KIM_DIR" % thisdir, 'w').write("KIM_INSTALL_DIR=%s" % dir)
|
||||
open("%s/Makefile.KIM_Config" % thisdir, 'w').write("include %s/lib/kim-api/Makefile.KIM_Config" % dir)
|
||||
print "Updated %s/Makefile.KIM_DIR : using %s" % (thisdir,dir)
|
||||
|
||||
|
||||
if buildflag == 1:
|
||||
# download kim-api
|
||||
print "Downloading kim-api tarball ..."
|
||||
urllib.urlretrieve(url,"%s/%s.tgz" % (thisdir,version))
|
||||
print "Unpacking kim-api tarball ..."
|
||||
cmd = "cd %s; rm -rf %s; tar zxvf %s.tgz" % (thisdir,version,version)
|
||||
txt = commands.getstatusoutput(cmd)
|
||||
if txt[0] != 0: error()
|
||||
|
||||
# configure kim-api
|
||||
print "Configuring kim-api ..."
|
||||
cmd = "cd %s/%s; ./configure --prefix='%s'" % (thisdir,version,dir)
|
||||
txt = commands.getstatusoutput(cmd)
|
||||
print txt[1]
|
||||
if txt[0] != 0: error()
|
||||
|
||||
# build kim-api
|
||||
print "Configuring model : %s" % modelname
|
||||
cmd = "cd %s/%s; make add-%s" % (thisdir,version,modelname)
|
||||
txt = commands.getstatusoutput(cmd)
|
||||
print txt[1]
|
||||
if txt[0] != 0: error()
|
||||
#
|
||||
print "Building kim-api ..."
|
||||
cmd = "cd %s/%s; make" % (thisdir,version)
|
||||
txt = commands.getstatusoutput(cmd)
|
||||
print txt[1]
|
||||
if txt[0] != 0: error()
|
||||
|
||||
# install kim-api
|
||||
print "Installing kim-api ..."
|
||||
cmd = "cd %s/%s; make install" % (thisdir,version)
|
||||
txt = commands.getstatusoutput(cmd)
|
||||
print txt[1]
|
||||
if txt[0] != 0: error()
|
||||
#
|
||||
cmd = "cd %s/%s; make install-set-default-to-v1" %(thisdir,version)
|
||||
txt = commands.getstatusoutput(cmd)
|
||||
print txt[1]
|
||||
if txt[0] != 0: error()
|
||||
|
||||
# remove source files
|
||||
print "Removing kim-api source and build files ..."
|
||||
cmd = "cd %s; rm -rf %s; rm -rf %s.tgz" % (thisdir,version,version)
|
||||
txt = commands.getstatusoutput(cmd)
|
||||
print txt[1]
|
||||
if txt[0] != 0: error()
|
||||
|
||||
if addflag == 1:
|
||||
# download model
|
||||
url = "https://openkim.org/download/%s.tgz" % addmodelname
|
||||
print "Downloading item tarball ..."
|
||||
urllib.urlretrieve(url,"%s/%s.tgz" % (thisdir,addmodelname))
|
||||
print "Unpacking item tarball ..."
|
||||
cmd = "cd %s; tar zxvf %s.tgz" % (thisdir,addmodelname)
|
||||
txt = commands.getstatusoutput(cmd)
|
||||
if txt[0] != 0: error()
|
||||
#
|
||||
print "Building item ..."
|
||||
cmd = "cd %s/%s; make; make install" %(thisdir,addmodelname)
|
||||
txt = commands.getstatusoutput(cmd)
|
||||
print txt[1]
|
||||
if txt[0] != 0: error()
|
||||
#
|
||||
print "Removing kim item source and build files ..."
|
||||
cmd = "cd %s; rm -rf %s; rm -rf %s.tgz" %(thisdir,addmodelname,addmodelname)
|
||||
txt = commands.getstatusoutput(cmd)
|
||||
print txt[1]
|
||||
if txt[0] != 0: error()
|
|
@ -16,7 +16,13 @@
|
|||
# Settings that the LAMMPS build will import when this package is installed
|
||||
|
||||
|
||||
KIM_CONFIG_HELPER = kim-api-build-config
|
||||
include ../../lib/kim/Makefile.KIM_DIR
|
||||
|
||||
ifeq ($(wildcard $(KIM_INSTALL_DIR)/bin/kim-api-build-config),)
|
||||
KIM_CONFIG_HELPER = kim-api-build-config
|
||||
else
|
||||
KIM_CONFIG_HELPER = $(KIM_INSTALL_DIR)/bin/kim-api-build-config
|
||||
endif
|
||||
ifeq ($(shell $(KIM_CONFIG_HELPER) --version 2> /dev/null),)
|
||||
$(error $(KIM_CONFIG_HELPER) utility is not available. Something is wrong with your KIM API package setup)
|
||||
endif
|
||||
|
|
|
@ -9,71 +9,66 @@ KIM API and he also maintains the code that implements the pair_style
|
|||
kim command.
|
||||
|
||||
To download, build, and install the KIM API on your system, follow
|
||||
these steps. We are working on scripts that will automate this
|
||||
process.
|
||||
these steps. You can use the install.py script to automate these steps.
|
||||
|
||||
The KIM API is available for download from "this
|
||||
site"_https://openkim.org, namely https://openkim.org. The tarball
|
||||
you download is "kim-api-vX.Y.Z.tgz", which can be unpacked in this
|
||||
directory or whereever you wish:
|
||||
-----------------
|
||||
|
||||
tar xvfz kim*tgz
|
||||
Instructions:
|
||||
|
||||
Note that if you unpack and build KIM in this directory, when you
|
||||
download a new LAMMPS tarball, the files you have added here will be
|
||||
lost. So you likely want to build it somewhere else.
|
||||
|
||||
The kim-api-vX.Y.Z/docs/ directory has further documentation for the
|
||||
KIM API. In order to compile and install the KIM API follow the
|
||||
instructions found in the file kim-api-vX.Y.Z/INSTALL. (Don't forget
|
||||
to download and compile any Model Drivers and Models that you want to
|
||||
use.)
|
||||
1. Configure lammps for use with the kim-api library installed in this directory
|
||||
|
||||
Once you have successfully compiled and installed the KIM API, you
|
||||
need to make sure the utility kim-api-build-config is in your PATH so
|
||||
that the LAMMPS build system can properly work with the KIM API.
|
||||
$ printf "KIM_INSTALL_DIR=${PWD}\n" > ./Makefile.KIM_DIR
|
||||
$ printf "include ${PWD}/lib/kim-api/Makefile.KIM_Config\n" > ./Makefile.KIM_Config
|
||||
|
||||
The following are example commands that perform these steps:
|
||||
2. Download and unpack the kim-api
|
||||
|
||||
# replace X.Y.Z as appropriate here and below
|
||||
$ wget http://s3.openkim.org/kim-api/kim-api-vX.Y.Z.tgz
|
||||
$ tar zxvf kim-api-vX.Y.Z.tgz
|
||||
|
||||
# get OpenKIM models, setup and compile
|
||||
# configure the kim-api
|
||||
$ cd kim-api-vX.Y.Z
|
||||
$ cp Makefile.KIM_Config.example Makefile.KIM_Config
|
||||
$ ./configure --prefix=${PWD}/../
|
||||
|
||||
# edit this file as appropriate following the instructions given in
|
||||
# INSTALL. Here, we'll assume you set the 'prefix' variable as
|
||||
# follows in order to install the KIM API to your home directory:
|
||||
# prefix = $(HOME)/local
|
||||
$ vi Makefile.KIM_Config
|
||||
# setup the desired kim item
|
||||
$ make add-Pair_Johnson_Fe__MO_857282754307_002
|
||||
|
||||
3. Build and install the kim-api and model
|
||||
|
||||
$ make add-EAM_Dynamo_Angelo_Moody_NiAlH__MO_418978237058_001
|
||||
$ make
|
||||
$ make install
|
||||
|
||||
# replace X with the KIM API major version number
|
||||
$ make install-set-default-to-vX
|
||||
$ cd ../
|
||||
|
||||
# In order to permanently add the kim-api-build-config utility to your
|
||||
# PATH variable, perform the following:
|
||||
#
|
||||
# For the bash shell:
|
||||
$ printf "export PATH=${PATH}:${HOME}/local/bin\n" >> ${HOME}/.bashrc
|
||||
$ source ${HOME}/.bashrc
|
||||
#
|
||||
# For the csh shell:
|
||||
% printf "setenv PATH ${PATH}:${HOME}/local/bin\b" >> ${HOME}/.cshrc
|
||||
% source ${HOME}/.cshrc
|
||||
4. Remove source and build files
|
||||
|
||||
$ rm -rf kim-api-vX.Y.Z
|
||||
$ rm -rf kim-api-vX.Y.Z.tgz
|
||||
|
||||
5. To add additional items do the following (replace the kim item name with your
|
||||
desired value)
|
||||
|
||||
$ wget https://openkim.org/download/EAM_Johnson_NearestNeighbor_Cu__MO_887933271505_001.tgz
|
||||
$ tar zxvf EAM_Johnson_NearestNeighbor_Cu__MO_887933271505_001.tgz
|
||||
$ cd EAM_Johnson_NearestNeighbor_Cu__MO_887933271505_001
|
||||
$ make
|
||||
$ make install
|
||||
$ cd ..
|
||||
$ rm -rf EAM_Johnson_NearestNeighbor_Cu__MO_887933271505_001
|
||||
$ rm -rf EAM_Johnson_NearestNeighbor_Cu__MO_887933271505_001.tgz
|
||||
|
||||
-----------------
|
||||
|
||||
When these steps are complete you can build LAMMPS with the KIM
|
||||
package installed:
|
||||
|
||||
$ cd lammps/src
|
||||
$ cd ../../src
|
||||
$ make yes-kim
|
||||
$ make g++ (or whatever target you wish)
|
||||
|
||||
Note that the Makefile.lammps file in this directory is required
|
||||
to allow the LAMMPS build to find the necessary KIM files. You
|
||||
should not normally need to edit this file.
|
||||
Note that the Makefile.lammps and Makefile.KIM_DIR files in this directory
|
||||
are required to allow the LAMMPS build to find the necessary KIM files.
|
||||
You should not normally need to edit this file.
|
||||
|
|
Loading…
Reference in New Issue