Commit 25d2f4b1 authored by Ryan S. Elliott's avatar Ryan S. Elliott
Browse files

Update pair_kim for v1.9.4 and versatile linking

Use dlopen instead of directly linking to kim-api
library.  This will allow for easier distribution
of LAMMPS with support for KIM Models.
parent 0bfb6f0c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ Syntax from lib dir: python Install.py -b -v version -a kim-name
specify one or more options, order does not matter

  -v = version of KIM API library to use
       default = kim-api-v1.9.2 (current as of Oct 2017)
       default = kim-api-v1.9.4 (current as of Mar 2018)
  -b = download and build base KIM API library with example Models
       this will delete any previous installation in the current folder
  -n = do NOT download and build base KIM API library.
@@ -109,7 +109,7 @@ nargs = len(args)
if nargs == 0: error()

thisdir = os.environ['PWD']
version = "kim-api-v1.9.2"
version = "kim-api-v1.9.4"

buildflag = False
everythingflag = False
+3 −12
Original line number Diff line number Diff line
@@ -18,15 +18,6 @@

include ../../lib/kim/Makefile.KIM_DIR

ifeq ($(wildcard $(KIM_INSTALL_DIR)/bin/kim-api-v1-build-config),)
  KIM_CONFIG_HELPER = kim-api-v1-build-config
else
  KIM_CONFIG_HELPER = $(KIM_INSTALL_DIR)/bin/kim-api-v1-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

kim_SYSINC  = $(shell $(KIM_CONFIG_HELPER) --includes)
kim_SYSLIB  = $(shell $(KIM_CONFIG_HELPER) --ldlibs)
kim_SYSPATH = $(shell $(KIM_CONFIG_HELPER) --ldflags)
kim_SYSINC  = -DKIM_INSTALL_DIR=\"${KIM_INSTALL_DIR}\"
kim_SYSLIB  =
kim_SYSPATH =
+8 −21
Original line number Diff line number Diff line
@@ -21,46 +21,33 @@ Instructions:
1. Configure lammps for use with the kim-api library installed in this directory

$ printf "KIM_INSTALL_DIR=${PWD}\n" > ./Makefile.KIM_DIR
$ printf "include ${PWD}/lib/kim-api/Makefile.KIM_Config\n" > ./Makefile.KIM_Config

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
$ wget http://s3.openkim.org/kim-api/kim-api-vX.Y.Z.txz
$ tar zxvf kim-api-vX.Y.Z.txz

# configure the kim-api
$ cd kim-api-vX.Y.Z
$ ./configure --prefix=${PWD}/../

# setup the desired kim item
$ make add-Pair_Johnson_Fe__MO_857282754307_002
$ ./configure --prefix=${PWD}/../installed-kim-api-vX.Y.Z

3. Build and install the kim-api and model

$ make
$ make install

# replace X with the KIM API major version number
$ make install-set-default-to-vX
$ cd ../

4. Remove source and build files

$ rm -rf kim-api-vX.Y.Z
$ rm -rf kim-api-vX.Y.Z.tgz
$ rm -rf kim-api-vX.Y.Z.txz

5. To add additional items do the following (replace the kim item name with your
5. To add 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
$ source ${PWD}/../kim-api-vX.Y.Z/bin/kim-api-v1-activate
$ kim-api-v1-collections-management install system Pair_Johnson_Fe__MO_857282754307_002


-----------------

+299 −115

File changed.

Preview size limit exceeded, changes collapsed.

+37 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ PairStyle(kim,PairKIM)
#define LMP_PAIR_KIM_H

// includes from KIM & LAMMPS
class KIM_API_model;
//class KIM_API_model;
#include "pair.h"


@@ -87,7 +87,7 @@ namespace LAMMPS_NS {
      unit_sys lmps_units;

      // values set in set_kim_model_has_flags(), called by kim_init()
      KIM_API_model* pkim;
      void * pkim;
      bool kim_model_has_energy;
      bool kim_model_has_forces;
      bool kim_model_has_particleEnergy;
@@ -148,6 +148,37 @@ namespace LAMMPS_NS {
      static int get_neigh(void** kimmdl, int* mode, int* request,
                           int* atom, int* numnei, int** nei1atom,
                           double** pRij);

     bool setup_kim_api_library();
     static bool kim_api_is_strictly_between_1_5_and_2_0;
     // KIM symbols
     static void* kim_api_library;
     static int (*report_error)(int line, const char *, const char *, int);
     static void (*kim_api_setm_compute_by_index)(void *, int *, ...);
     static int (*kim_api_model_compute)(void *);
     static int (*kim_api_model_init)(void *);
     static int (*kim_api_model_reinit)(void *);
     static void * (*kim_api_get_sim_buffer)(void *, int *);
     static void * (*kim_api_get_data_by_index)(void *, int, int *);
     static int (*kim_api_model_destroy)(void *);
     static void (*kim_api_free)(void *, int *);
     static int (*kim_api_string_init)(void *, const char *, const char *);
     static int (*kim_api_is_half_neighbors)(void *, int *);
     static int (*kim_api_get_NBC_method)(void *, const char **);
     static int (*kim_api_get_index)(void *, const char *, int *);
     static int (*kim_api_getm_index)(void *, int *, int, ...);
     static int (*kim_api_get_species_code)(void *, const char *, int *);
     static void (*kim_api_setm_data_by_index)(void *, int *, int, ...);
     static int (*kim_api_set_method_by_index)(void *, int, intptr_t, void (*)());
     static void (*kim_api_set_sim_buffer)(void *, void *, int *);
     static int (*kim_api_set_data_by_index)(void *, int, intptr_t, void *);
     static void (*kim_api_set_compute_by_index)(void *, int, int, int*);
     static int (*kim_api_get_num_params)(void *, int *, int *);
     static int (*kim_api_get_free_parameter)(void *, const int, const char **);
     static void * (*kim_api_get_data)(void *, const char *, int *);
     static intptr_t (*kim_api_get_rank)(void *, const char *, int *);
     static intptr_t (*kim_api_get_shape)(void *, const char *, int *, int *);
     static int (*kim_api_model_info)(void *, const char *);
   };
}

@@ -162,6 +193,10 @@ Self-explanatory. Check the input script syntax and compare to the
documentation for the command.  You can use -echo screen as a
command-line option when running LAMMPS to see the offending line.

E: KIM API library cannot be found

Self-explanatory.

E: Unrecognized virial argument in pair_style command

Only two options are supported: LAMMPSvirial and KIMvirial
Loading