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.
This commit is contained in:
@ -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
|
specify one or more options, order does not matter
|
||||||
|
|
||||||
-v = version of KIM API library to use
|
-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
|
-b = download and build base KIM API library with example Models
|
||||||
this will delete any previous installation in the current folder
|
this will delete any previous installation in the current folder
|
||||||
-n = do NOT download and build base KIM API library.
|
-n = do NOT download and build base KIM API library.
|
||||||
@ -109,7 +109,7 @@ nargs = len(args)
|
|||||||
if nargs == 0: error()
|
if nargs == 0: error()
|
||||||
|
|
||||||
thisdir = os.environ['PWD']
|
thisdir = os.environ['PWD']
|
||||||
version = "kim-api-v1.9.2"
|
version = "kim-api-v1.9.4"
|
||||||
|
|
||||||
buildflag = False
|
buildflag = False
|
||||||
everythingflag = False
|
everythingflag = False
|
||||||
|
|||||||
@ -18,15 +18,6 @@
|
|||||||
|
|
||||||
include ../../lib/kim/Makefile.KIM_DIR
|
include ../../lib/kim/Makefile.KIM_DIR
|
||||||
|
|
||||||
ifeq ($(wildcard $(KIM_INSTALL_DIR)/bin/kim-api-v1-build-config),)
|
kim_SYSINC = -DKIM_INSTALL_DIR=\"${KIM_INSTALL_DIR}\"
|
||||||
KIM_CONFIG_HELPER = kim-api-v1-build-config
|
kim_SYSLIB =
|
||||||
else
|
kim_SYSPATH =
|
||||||
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)
|
|
||||||
|
|||||||
@ -21,46 +21,33 @@ Instructions:
|
|||||||
1. Configure lammps for use with the kim-api library installed in this directory
|
1. Configure lammps for use with the kim-api library installed in this directory
|
||||||
|
|
||||||
$ printf "KIM_INSTALL_DIR=${PWD}\n" > ./Makefile.KIM_DIR
|
$ 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
|
2. Download and unpack the kim-api
|
||||||
|
|
||||||
# replace X.Y.Z as appropriate here and below
|
# replace X.Y.Z as appropriate here and below
|
||||||
$ wget http://s3.openkim.org/kim-api/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.tgz
|
$ tar zxvf kim-api-vX.Y.Z.txz
|
||||||
|
|
||||||
# configure the kim-api
|
# configure the kim-api
|
||||||
$ cd kim-api-vX.Y.Z
|
$ cd kim-api-vX.Y.Z
|
||||||
$ ./configure --prefix=${PWD}/../
|
$ ./configure --prefix=${PWD}/../installed-kim-api-vX.Y.Z
|
||||||
|
|
||||||
# setup the desired kim item
|
|
||||||
$ make add-Pair_Johnson_Fe__MO_857282754307_002
|
|
||||||
|
|
||||||
3. Build and install the kim-api and model
|
3. Build and install the kim-api and model
|
||||||
|
|
||||||
$ make
|
$ make
|
||||||
$ make install
|
$ make install
|
||||||
|
|
||||||
# replace X with the KIM API major version number
|
|
||||||
$ make install-set-default-to-vX
|
|
||||||
$ cd ../
|
|
||||||
|
|
||||||
4. Remove source and build files
|
4. Remove source and build files
|
||||||
|
|
||||||
$ rm -rf kim-api-vX.Y.Z
|
$ 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)
|
desired value)
|
||||||
|
|
||||||
$ wget https://openkim.org/download/EAM_Johnson_NearestNeighbor_Cu__MO_887933271505_001.tgz
|
$ source ${PWD}/../kim-api-vX.Y.Z/bin/kim-api-v1-activate
|
||||||
$ tar zxvf EAM_Johnson_NearestNeighbor_Cu__MO_887933271505_001.tgz
|
$ kim-api-v1-collections-management install system Pair_Johnson_Fe__MO_857282754307_002
|
||||||
$ 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
|
|
||||||
|
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
|||||||
@ -40,20 +40,201 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
// includes from KIM
|
// includes from KIM
|
||||||
#include "KIM_API.h"
|
#include "dlfcn.h"
|
||||||
#include "KIM_API_status.h"
|
|
||||||
|
|
||||||
#ifndef KIM_API_VERSION_MAJOR
|
#define KIM_STATUS_OK 1
|
||||||
// support v1.5.0
|
#define KIM_STATUS_NEIGH_ITER_PAST_END 2
|
||||||
#define KIM_API_VERSION_MAJOR 1
|
#define KIM_STATUS_NEIGH_ITER_INIT_OK 3
|
||||||
#define KIM_API_VERSION_MINOR 5
|
#define KIM_STATUS_NEIGH_INVALID_REQUEST -11
|
||||||
#define KIM_API_VERSION_PATCH 0
|
#define KIM_STATUS_NEIGH_INVALID_MODE -6
|
||||||
#endif
|
#define KIM_COMPUTE_FALSE 0
|
||||||
|
#define KIM_COMPUTE_TRUE 1
|
||||||
|
#define KIM_STATUS_FAIL 0
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void * PairKIM::kim_api_library = NULL;
|
||||||
|
bool PairKIM::kim_api_is_strictly_between_1_5_and_2_0;
|
||||||
|
int (*PairKIM::report_error)(int line, const char *, const char *, int) = NULL;
|
||||||
|
void (*PairKIM::kim_api_setm_compute_by_index)(void *, int *, ...) = NULL;
|
||||||
|
int (*PairKIM::kim_api_model_compute)(void *);
|
||||||
|
int (*PairKIM::kim_api_model_init)(void *);
|
||||||
|
int (*PairKIM::kim_api_model_reinit)(void *);
|
||||||
|
void * (*PairKIM::kim_api_get_sim_buffer)(void *, int *);
|
||||||
|
void * (*PairKIM::kim_api_get_data_by_index)(void *, int, int *);
|
||||||
|
int (*PairKIM::kim_api_model_destroy)(void *);
|
||||||
|
void (*PairKIM::kim_api_free)(void *, int *);
|
||||||
|
int (*PairKIM::kim_api_string_init)(void *, const char *, const char *);
|
||||||
|
int (*PairKIM::kim_api_is_half_neighbors)(void *, int *);
|
||||||
|
int (*PairKIM::kim_api_get_NBC_method)(void *, const char **);
|
||||||
|
int (*PairKIM::kim_api_get_index)(void *, const char *, int *);
|
||||||
|
int (*PairKIM::kim_api_getm_index)(void *, int *, int, ...);
|
||||||
|
int (*PairKIM::kim_api_get_species_code)(void *, const char *, int *);
|
||||||
|
void (*PairKIM::kim_api_setm_data_by_index)(void *, int *, int, ...);
|
||||||
|
int (*PairKIM::kim_api_set_method_by_index)(void *, int, intptr_t, void (*)());
|
||||||
|
void (*PairKIM::kim_api_set_sim_buffer)(void *, void *, int *);
|
||||||
|
int (*PairKIM::kim_api_set_data_by_index)(void *, int, intptr_t, void *);
|
||||||
|
void (*PairKIM::kim_api_set_compute_by_index)(void *, int, int, int*);
|
||||||
|
int (*PairKIM::kim_api_get_num_params)(void *, int *, int *);
|
||||||
|
int (*PairKIM::kim_api_get_free_parameter)(void *, const int, const char **);
|
||||||
|
void * (*PairKIM::kim_api_get_data)(void *, const char *, int *);
|
||||||
|
intptr_t (*PairKIM::kim_api_get_rank)(void *, const char *, int *);
|
||||||
|
intptr_t (*PairKIM::kim_api_get_shape)(void *, const char *, int *, int *);
|
||||||
|
int (*PairKIM::kim_api_model_info)(void *, const char *);
|
||||||
|
|
||||||
|
bool PairKIM::setup_kim_api_library()
|
||||||
|
{
|
||||||
|
if (kim_api_library == NULL)
|
||||||
|
{
|
||||||
|
#ifdef KIM_INSTALL_DIR
|
||||||
|
kim_api_library = dlopen(KIM_INSTALL_DIR "/lib/libkim-api-v1.so", RTLD_NOW);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (kim_api_library == NULL)
|
||||||
|
kim_api_library = dlopen("kim-api-v1.so", RTLD_NOW);
|
||||||
|
|
||||||
|
if (kim_api_library == NULL)
|
||||||
|
{
|
||||||
|
error->all(FLERR,"KIM API library cannot be found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check for version and set kim_api_is_strictly_between_1_5_and_2_0
|
||||||
|
void * ver = dlsym(kim_api_library, "KIM_API_get_version");
|
||||||
|
if (ver == NULL)
|
||||||
|
kim_api_is_strictly_between_1_5_and_2_0 = false;
|
||||||
|
else
|
||||||
|
kim_api_is_strictly_between_1_5_and_2_0 = true;
|
||||||
|
|
||||||
|
std::string error_prefix("KIM API library error: ");
|
||||||
|
// get symbols
|
||||||
|
if (NULL == (report_error =
|
||||||
|
(int (*)(int, const char *, const char *, int))
|
||||||
|
dlsym(kim_api_library, "KIM_API_report_error")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_setm_compute_by_index =
|
||||||
|
(void (*)(void *, int *, ...))
|
||||||
|
dlsym(kim_api_library, "KIM_API_setm_compute_by_index")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_model_compute = (int (*)(void *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_model_compute")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_model_init = (int (*)(void *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_model_init")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_model_reinit = (int (*)(void *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_model_reinit")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_get_sim_buffer = (void * (*)(void *, int *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_get_sim_buffer")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_get_data_by_index = (void * (*)(void *, int, int *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_get_data_by_index")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_model_destroy = (int (*)(void *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_model_destroy")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_free = (void (*)(void *, int *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_free")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_string_init =
|
||||||
|
(int (*)(void *, const char *, const char *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_string_init")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_is_half_neighbors = (int (*)(void *, int *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_is_half_neighbors")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_get_NBC_method = (int (*)(void *, const char **))
|
||||||
|
dlsym(kim_api_library, "KIM_API_get_NBC_method")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_get_index = (int (*)(void *, const char *, int *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_get_index")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_getm_index = (int (*)(void *, int *, int, ...))
|
||||||
|
dlsym(kim_api_library, "KIM_API_getm_index")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_get_species_code =
|
||||||
|
(int (*)(void *, const char *, int *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_get_species_code")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_setm_data_by_index =
|
||||||
|
(void (*)(void *, int *, int, ...))
|
||||||
|
dlsym(kim_api_library, "KIM_API_setm_data_by_index")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_set_method_by_index =
|
||||||
|
(int (*)(void *, int, intptr_t, void (*)()))
|
||||||
|
dlsym(kim_api_library, "KIM_API_set_method_by_index")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_set_sim_buffer = (void (*)(void *, void *, int *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_set_sim_buffer")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_set_data_by_index =
|
||||||
|
(int (*)(void *, int, intptr_t, void *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_set_data_by_index")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_set_compute_by_index =
|
||||||
|
(void (*)(void *, int, int, int*))
|
||||||
|
dlsym(kim_api_library, "KIM_API_set_compute_by_index")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_get_num_params = (int (*)(void *, int *, int *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_get_num_params")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_get_free_parameter =
|
||||||
|
(int (*)(void *, const int, const char **))
|
||||||
|
dlsym(kim_api_library, "KIM_API_get_free_parameter")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_get_data = (void * (*)(void *, const char *, int *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_get_data")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_get_rank =
|
||||||
|
(intptr_t (*)(void *, const char *, int *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_get_rank")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_get_shape =
|
||||||
|
(intptr_t (*)(void *, const char *, int *, int *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_get_shape")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
if (NULL == (kim_api_model_info = (int (*)(void *, const char *))
|
||||||
|
dlsym(kim_api_library, "KIM_API_model_info")))
|
||||||
|
error->all(FLERR,(error_prefix + std::string(dlerror())).c_str());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PairKIM::PairKIM(LAMMPS *lmp) :
|
PairKIM::PairKIM(LAMMPS *lmp) :
|
||||||
Pair(lmp),
|
Pair(lmp),
|
||||||
settings_call_count(0),
|
settings_call_count(0),
|
||||||
@ -105,35 +286,40 @@ PairKIM::PairKIM(LAMMPS *lmp) :
|
|||||||
|
|
||||||
PairKIM::~PairKIM()
|
PairKIM::~PairKIM()
|
||||||
{
|
{
|
||||||
// clean up kim_modelname
|
if (kim_api_library != NULL)
|
||||||
if (kim_modelname != 0) delete [] kim_modelname;
|
{
|
||||||
|
// clean up kim_modelname
|
||||||
|
if (kim_modelname != 0) delete [] kim_modelname;
|
||||||
|
|
||||||
// clean up lammps atom species number to unique particle names mapping
|
// clean up lammps atom species number to unique particle names mapping
|
||||||
if (lmps_unique_elements)
|
if (lmps_unique_elements)
|
||||||
for (int i = 0; i < lmps_num_unique_elements; i++)
|
for (int i = 0; i < lmps_num_unique_elements; i++)
|
||||||
delete [] lmps_unique_elements[i];
|
delete [] lmps_unique_elements[i];
|
||||||
delete [] lmps_unique_elements;
|
delete [] lmps_unique_elements;
|
||||||
|
|
||||||
// clean up local memory used to support KIM interface
|
// clean up local memory used to support KIM interface
|
||||||
memory->destroy(kim_particleSpecies);
|
memory->destroy(kim_particleSpecies);
|
||||||
memory->destroy(lmps_force_tmp);
|
memory->destroy(lmps_force_tmp);
|
||||||
memory->destroy(lmps_stripped_neigh_list);
|
memory->destroy(lmps_stripped_neigh_list);
|
||||||
|
|
||||||
// clean up allocated memory for standard Pair class usage
|
// clean up allocated memory for standard Pair class usage
|
||||||
// also, we allocate lmps_map_species_to_uniuqe in the allocate() function
|
// also, we allocate lmps_map_species_to_uniuqe in the allocate() function
|
||||||
if (allocated) {
|
if (allocated) {
|
||||||
memory->destroy(setflag);
|
memory->destroy(setflag);
|
||||||
memory->destroy(cutsq);
|
memory->destroy(cutsq);
|
||||||
delete [] lmps_map_species_to_unique;
|
delete [] lmps_map_species_to_unique;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up Rij array
|
// clean up Rij array
|
||||||
memory->destroy(Rij);
|
memory->destroy(Rij);
|
||||||
|
|
||||||
// clean up KIM interface (if necessary)
|
// clean up KIM interface (if necessary)
|
||||||
kim_free();
|
kim_free();
|
||||||
|
|
||||||
return;
|
dlclose(kim_api_library);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -179,7 +365,7 @@ void PairKIM::compute(int eflag , int vflag)
|
|||||||
// pass current atom pointers to KIM
|
// pass current atom pointers to KIM
|
||||||
set_volatiles();
|
set_volatiles();
|
||||||
|
|
||||||
pkim->setm_compute_by_index(&kimerror,3*3,
|
kim_api_setm_compute_by_index(pkim, &kimerror,3*3,
|
||||||
kim_ind_particleEnergy, eflag_atom,
|
kim_ind_particleEnergy, eflag_atom,
|
||||||
(int) kim_model_has_particleEnergy,
|
(int) kim_model_has_particleEnergy,
|
||||||
kim_ind_particleVirial, vflag_atom,
|
kim_ind_particleVirial, vflag_atom,
|
||||||
@ -189,7 +375,7 @@ void PairKIM::compute(int eflag , int vflag)
|
|||||||
kim_error(__LINE__,"setm_compute_by_index",kimerror);
|
kim_error(__LINE__,"setm_compute_by_index",kimerror);
|
||||||
|
|
||||||
// compute via KIM model
|
// compute via KIM model
|
||||||
kimerror = pkim->model_compute();
|
kimerror = kim_api_model_compute(pkim);
|
||||||
kim_error(__LINE__,"PairKIM::pkim->model_compute() error",kimerror);
|
kim_error(__LINE__,"PairKIM::pkim->model_compute() error",kimerror);
|
||||||
// assemble force and particleVirial if needed
|
// assemble force and particleVirial if needed
|
||||||
if (!lmps_using_newton) comm->reverse_comm_pair(this);
|
if (!lmps_using_newton) comm->reverse_comm_pair(this);
|
||||||
@ -265,6 +451,9 @@ void PairKIM::settings(int narg, char **arg)
|
|||||||
{
|
{
|
||||||
// This is called when "pair_style kim ..." is read from input
|
// This is called when "pair_style kim ..." is read from input
|
||||||
// may be called multiple times
|
// may be called multiple times
|
||||||
|
|
||||||
|
setup_kim_api_library(); // exits on failure
|
||||||
|
|
||||||
++settings_call_count;
|
++settings_call_count;
|
||||||
init_style_call_count = 0;
|
init_style_call_count = 0;
|
||||||
|
|
||||||
@ -414,7 +603,7 @@ void PairKIM::init_style()
|
|||||||
if (!kim_init_ok)
|
if (!kim_init_ok)
|
||||||
{
|
{
|
||||||
kim_init();
|
kim_init();
|
||||||
kimerror = pkim->model_init();
|
kimerror = kim_api_model_init(pkim);
|
||||||
if (kimerror != KIM_STATUS_OK)
|
if (kimerror != KIM_STATUS_OK)
|
||||||
kim_error(__LINE__, "KIM API:model_init() failed", kimerror);
|
kim_error(__LINE__, "KIM API:model_init() failed", kimerror);
|
||||||
else
|
else
|
||||||
@ -486,7 +675,7 @@ void PairKIM::reinit()
|
|||||||
|
|
||||||
// Then reinit KIM model
|
// Then reinit KIM model
|
||||||
int kimerror;
|
int kimerror;
|
||||||
kimerror = pkim->model_reinit();
|
kimerror = kim_api_model_reinit(pkim);
|
||||||
kim_error(__LINE__,"model_reinit unsuccessful", kimerror);
|
kim_error(__LINE__,"model_reinit unsuccessful", kimerror);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,7 +817,7 @@ double PairKIM::memory_usage()
|
|||||||
void PairKIM::kim_error(int ln, const char* msg, int errcode)
|
void PairKIM::kim_error(int ln, const char* msg, int errcode)
|
||||||
{
|
{
|
||||||
if (errcode == KIM_STATUS_OK) return;
|
if (errcode == KIM_STATUS_OK) return;
|
||||||
KIM_API_model::report_error(ln,(char *) __FILE__, (char *) msg,errcode);
|
report_error(ln,(char *) __FILE__, (char *) msg,errcode);
|
||||||
error->all(__FILE__,ln,"Internal KIM error");
|
error->all(__FILE__,ln,"Internal KIM error");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -639,10 +828,10 @@ void PairKIM::kim_error(int ln, const char* msg, int errcode)
|
|||||||
int PairKIM::get_neigh(void **kimmdl,int *mode,int *request,
|
int PairKIM::get_neigh(void **kimmdl,int *mode,int *request,
|
||||||
int *atom, int *numnei, int **nei1atom, double **pRij)
|
int *atom, int *numnei, int **nei1atom, double **pRij)
|
||||||
{
|
{
|
||||||
KIM_API_model *pkim = (KIM_API_model *) *kimmdl;
|
void * pkim = *kimmdl;
|
||||||
|
|
||||||
int kimerror;
|
int kimerror;
|
||||||
PairKIM *self = (PairKIM *) pkim->get_sim_buffer(&kimerror);
|
PairKIM *self = (PairKIM *) kim_api_get_sim_buffer(pkim, &kimerror);
|
||||||
|
|
||||||
if (self->kim_model_using_Rij) {
|
if (self->kim_model_using_Rij) {
|
||||||
*pRij = &(self->Rij[0]);
|
*pRij = &(self->Rij[0]);
|
||||||
@ -693,8 +882,8 @@ int PairKIM::get_neigh(void **kimmdl,int *mode,int *request,
|
|||||||
// set Rij if needed
|
// set Rij if needed
|
||||||
if (self->kim_model_using_Rij) {
|
if (self->kim_model_using_Rij) {
|
||||||
double* x = (double *)
|
double* x = (double *)
|
||||||
(*pkim).get_data_by_index(self->kim_ind_coordinates,
|
kim_api_get_data_by_index(pkim, self->kim_ind_coordinates,
|
||||||
&kimerror);
|
&kimerror);
|
||||||
for (jj=0; jj < *numnei; jj++) {
|
for (jj=0; jj < *numnei; jj++) {
|
||||||
int i = *atom;
|
int i = *atom;
|
||||||
j = (*nei1atom)[jj];
|
j = (*nei1atom)[jj];
|
||||||
@ -741,7 +930,8 @@ int PairKIM::get_neigh(void **kimmdl,int *mode,int *request,
|
|||||||
// set Rij if needed
|
// set Rij if needed
|
||||||
if (self->kim_model_using_Rij){
|
if (self->kim_model_using_Rij){
|
||||||
double* x = (double *)
|
double* x = (double *)
|
||||||
(*pkim).get_data_by_index(self->kim_ind_coordinates, &kimerror);
|
kim_api_get_data_by_index(pkim, self->kim_ind_coordinates,
|
||||||
|
&kimerror);
|
||||||
for(int jj=0; jj < *numnei; jj++){
|
for(int jj=0; jj < *numnei; jj++){
|
||||||
int i = *atom;
|
int i = *atom;
|
||||||
int j = (*nei1atom)[jj];
|
int j = (*nei1atom)[jj];
|
||||||
@ -772,17 +962,16 @@ void PairKIM::kim_free()
|
|||||||
|
|
||||||
if (kim_model_init_ok)
|
if (kim_model_init_ok)
|
||||||
{
|
{
|
||||||
kimerror = pkim->model_destroy();
|
kimerror = kim_api_model_destroy(pkim);
|
||||||
kim_model_init_ok = false;
|
kim_model_init_ok = false;
|
||||||
}
|
}
|
||||||
if (kim_init_ok)
|
if (kim_init_ok)
|
||||||
{
|
{
|
||||||
pkim->free(&kimerror);
|
kim_api_free(&pkim, &kimerror);
|
||||||
kim_init_ok = false;
|
kim_init_ok = false;
|
||||||
}
|
}
|
||||||
if (pkim != 0)
|
if (pkim != 0)
|
||||||
{
|
{
|
||||||
delete pkim;
|
|
||||||
pkim = 0;
|
pkim = 0;
|
||||||
}
|
}
|
||||||
if (kim_particle_codes_ok)
|
if (kim_particle_codes_ok)
|
||||||
@ -817,8 +1006,7 @@ void PairKIM::kim_init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initialize KIM model
|
// initialize KIM model
|
||||||
pkim = new KIM_API_model();
|
kimerror = kim_api_string_init(&pkim, test_descriptor_string, kim_modelname);
|
||||||
kimerror = pkim->string_init(test_descriptor_string, kim_modelname);
|
|
||||||
if (kimerror != KIM_STATUS_OK)
|
if (kimerror != KIM_STATUS_OK)
|
||||||
kim_error(__LINE__,"KIM initialization failed", kimerror);
|
kim_error(__LINE__,"KIM initialization failed", kimerror);
|
||||||
else
|
else
|
||||||
@ -831,10 +1019,10 @@ void PairKIM::kim_init()
|
|||||||
// determine kim_model_using_* true/false values
|
// determine kim_model_using_* true/false values
|
||||||
//
|
//
|
||||||
// check for half or full list
|
// check for half or full list
|
||||||
kim_model_using_half = (pkim->is_half_neighbors(&kimerror));
|
kim_model_using_half = kim_api_is_half_neighbors(pkim, &kimerror);
|
||||||
//
|
//
|
||||||
const char* NBC_method;
|
const char* NBC_method;
|
||||||
kimerror = pkim->get_NBC_method(&NBC_method);
|
kimerror = kim_api_get_NBC_method(pkim, &NBC_method);
|
||||||
kim_error(__LINE__,"NBC method not set",kimerror);
|
kim_error(__LINE__,"NBC method not set",kimerror);
|
||||||
// check for CLUSTER mode
|
// check for CLUSTER mode
|
||||||
kim_model_using_cluster = (strcmp(NBC_method,"CLUSTER")==0);
|
kim_model_using_cluster = (strcmp(NBC_method,"CLUSTER")==0);
|
||||||
@ -843,17 +1031,18 @@ void PairKIM::kim_init()
|
|||||||
(strcmp(NBC_method,"NEIGH_RVEC_F")==0));
|
(strcmp(NBC_method,"NEIGH_RVEC_F")==0));
|
||||||
|
|
||||||
// get correct index of each variable in kim_api object
|
// get correct index of each variable in kim_api object
|
||||||
pkim->getm_index(&kimerror, 3*13,
|
kim_api_getm_index(pkim, &kimerror, 3*15,
|
||||||
"coordinates", &kim_ind_coordinates, 1,
|
"coordinates", &kim_ind_coordinates, 1,
|
||||||
"cutoff", &kim_ind_cutoff, 1,
|
"cutoff", &kim_ind_cutoff, 1,
|
||||||
"numberOfParticles", &kim_ind_numberOfParticles, 1,
|
"numberOfParticles", &kim_ind_numberOfParticles, 1,
|
||||||
#if KIM_API_VERSION_MAJOR == 1 && KIM_API_VERSON_MINOR == 5
|
"numberParticleTypes", &kim_ind_numberOfSpecies,
|
||||||
"numberParticleTypes", &kim_ind_numberOfSpecies, 1,
|
! kim_api_is_strictly_between_1_5_and_2_0,
|
||||||
"particleTypes", &kim_ind_particleSpecies, 1,
|
"particleTypes", &kim_ind_particleSpecies,
|
||||||
#else
|
! kim_api_is_strictly_between_1_5_and_2_0,
|
||||||
"numberOfSpecies", &kim_ind_numberOfSpecies, 1,
|
"numberOfSpecies", &kim_ind_numberOfSpecies,
|
||||||
"particleSpecies", &kim_ind_particleSpecies, 1,
|
kim_api_is_strictly_between_1_5_and_2_0,
|
||||||
#endif
|
"particleSpecies", &kim_ind_particleSpecies,
|
||||||
|
kim_api_is_strictly_between_1_5_and_2_0,
|
||||||
"numberContributingParticles", &kim_ind_numberContributingParticles,
|
"numberContributingParticles", &kim_ind_numberContributingParticles,
|
||||||
kim_model_using_half,
|
kim_model_using_half,
|
||||||
"particleEnergy", &kim_ind_particleEnergy,
|
"particleEnergy", &kim_ind_particleEnergy,
|
||||||
@ -873,7 +1062,7 @@ void PairKIM::kim_init()
|
|||||||
for(int i = 0; i < lmps_num_unique_elements; i++){
|
for(int i = 0; i < lmps_num_unique_elements; i++){
|
||||||
int kimerror;
|
int kimerror;
|
||||||
kim_particle_codes[i]
|
kim_particle_codes[i]
|
||||||
= pkim->get_species_code(lmps_unique_elements[i], &kimerror);
|
= kim_api_get_species_code(pkim, lmps_unique_elements[i], &kimerror);
|
||||||
kim_error(__LINE__, "create_kim_particle_codes: symbol not found ",
|
kim_error(__LINE__, "create_kim_particle_codes: symbol not found ",
|
||||||
kimerror);
|
kimerror);
|
||||||
}
|
}
|
||||||
@ -892,7 +1081,7 @@ void PairKIM::set_statics()
|
|||||||
lmps_local_tot_num_atoms = (int) (atom->nghost + atom->nlocal);
|
lmps_local_tot_num_atoms = (int) (atom->nghost + atom->nlocal);
|
||||||
|
|
||||||
int kimerror;
|
int kimerror;
|
||||||
pkim->setm_data_by_index(&kimerror, 4*6,
|
kim_api_setm_data_by_index(pkim, &kimerror, 4*6,
|
||||||
kim_ind_numberOfSpecies, 1, (void *) &(atom->ntypes), 1,
|
kim_ind_numberOfSpecies, 1, (void *) &(atom->ntypes), 1,
|
||||||
kim_ind_cutoff, 1, (void *) &(kim_global_cutoff), 1,
|
kim_ind_cutoff, 1, (void *) &(kim_global_cutoff), 1,
|
||||||
kim_ind_numberOfParticles, 1, (void *) &lmps_local_tot_num_atoms, 1,
|
kim_ind_numberOfParticles, 1, (void *) &lmps_local_tot_num_atoms, 1,
|
||||||
@ -903,12 +1092,13 @@ void PairKIM::set_statics()
|
|||||||
kim_error(__LINE__, "setm_data_by_index", kimerror);
|
kim_error(__LINE__, "setm_data_by_index", kimerror);
|
||||||
if (!kim_model_using_cluster)
|
if (!kim_model_using_cluster)
|
||||||
{
|
{
|
||||||
kimerror = pkim->set_method_by_index(kim_ind_get_neigh, 1,
|
kimerror = kim_api_set_method_by_index(pkim, kim_ind_get_neigh, 1,
|
||||||
(func_ptr) &get_neigh);
|
(void (*)()) &get_neigh);
|
||||||
kim_error(__LINE__, "set_method_by_index", kimerror);
|
kim_error(__LINE__, "set_method_by_index", kimerror);
|
||||||
}
|
}
|
||||||
|
|
||||||
pkim->set_sim_buffer((void *)this, &kimerror);
|
|
||||||
|
kim_api_set_sim_buffer(pkim, (void *)this, &kimerror);
|
||||||
kim_error(__LINE__, "set_sim_buffer", kimerror);
|
kim_error(__LINE__, "set_sim_buffer", kimerror);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -922,33 +1112,33 @@ void PairKIM::set_volatiles()
|
|||||||
lmps_local_tot_num_atoms = (int) (atom->nghost + atom->nlocal);
|
lmps_local_tot_num_atoms = (int) (atom->nghost + atom->nlocal);
|
||||||
intptr_t nall = (intptr_t) lmps_local_tot_num_atoms;
|
intptr_t nall = (intptr_t) lmps_local_tot_num_atoms;
|
||||||
|
|
||||||
pkim->setm_data_by_index(&kimerror, 4*2,
|
kim_api_setm_data_by_index(pkim, &kimerror, 4*2,
|
||||||
kim_ind_coordinates, 3*nall, (void*) &(atom->x[0][0]), 1,
|
kim_ind_coordinates, 3*nall, (void*) &(atom->x[0][0]), 1,
|
||||||
kim_ind_particleSpecies, nall, (void*) kim_particleSpecies, 1);
|
kim_ind_particleSpecies, nall, (void*) kim_particleSpecies, 1);
|
||||||
kim_error(__LINE__, "setm_data_by_index", kimerror);
|
kim_error(__LINE__, "setm_data_by_index", kimerror);
|
||||||
|
|
||||||
if (kim_model_has_particleEnergy && (eflag_atom == 1))
|
if (kim_model_has_particleEnergy && (eflag_atom == 1))
|
||||||
{
|
{
|
||||||
kimerror = pkim->set_data_by_index(kim_ind_particleEnergy, nall,
|
kimerror = kim_api_set_data_by_index(pkim, kim_ind_particleEnergy, nall,
|
||||||
(void*) eatom);
|
(void*) eatom);
|
||||||
kim_error(__LINE__, "set_data_by_index", kimerror);
|
kim_error(__LINE__, "set_data_by_index", kimerror);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kim_model_has_particleVirial && (vflag_atom == 1))
|
if (kim_model_has_particleVirial && (vflag_atom == 1))
|
||||||
{
|
{
|
||||||
kimerror = pkim->set_data_by_index(kim_ind_particleVirial, 6*nall,
|
kimerror = kim_api_set_data_by_index(pkim, kim_ind_particleVirial, 6*nall,
|
||||||
(void*) &(vatom[0][0]));
|
(void*) &(vatom[0][0]));
|
||||||
kim_error(__LINE__, "set_data_by_index", kimerror);
|
kim_error(__LINE__, "set_data_by_index", kimerror);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kim_model_has_forces)
|
if (kim_model_has_forces)
|
||||||
{
|
{
|
||||||
if (lmps_hybrid)
|
if (lmps_hybrid)
|
||||||
kimerror = pkim->set_data_by_index(kim_ind_forces, nall*3,
|
kimerror = kim_api_set_data_by_index(pkim, kim_ind_forces, nall*3,
|
||||||
(void*) &(lmps_force_tmp[0][0]));
|
(void*) &(lmps_force_tmp[0][0]));
|
||||||
else
|
else
|
||||||
kimerror = pkim->set_data_by_index(kim_ind_forces, nall*3,
|
kimerror = kim_api_set_data_by_index(pkim, kim_ind_forces, nall*3,
|
||||||
(void*) &(atom->f[0][0]));
|
(void*) &(atom->f[0][0]));
|
||||||
kim_error(__LINE__, "setm_data_by_index", kimerror);
|
kim_error(__LINE__, "setm_data_by_index", kimerror);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -961,17 +1151,17 @@ void PairKIM::set_volatiles()
|
|||||||
if (kim_model_has_particleVirial)
|
if (kim_model_has_particleVirial)
|
||||||
{
|
{
|
||||||
if(vflag_atom != 1) {
|
if(vflag_atom != 1) {
|
||||||
pkim->set_compute_by_index(kim_ind_particleVirial, KIM_COMPUTE_FALSE,
|
kim_api_set_compute_by_index(pkim, kim_ind_particleVirial,
|
||||||
&kimerror);
|
KIM_COMPUTE_FALSE, &kimerror);
|
||||||
} else {
|
} else {
|
||||||
pkim->set_compute_by_index(kim_ind_particleVirial, KIM_COMPUTE_TRUE,
|
kim_api_set_compute_by_index(pkim, kim_ind_particleVirial,
|
||||||
&kimerror);
|
KIM_COMPUTE_TRUE, &kimerror);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (no_virial_fdotr_compute == 1)
|
if (no_virial_fdotr_compute == 1)
|
||||||
{
|
{
|
||||||
pkim->set_compute_by_index(kim_ind_virial,
|
kim_api_set_compute_by_index(pkim, kim_ind_virial,
|
||||||
((vflag_global != 1) ? KIM_COMPUTE_FALSE : KIM_COMPUTE_TRUE),
|
((vflag_global != 1) ? KIM_COMPUTE_FALSE : KIM_COMPUTE_TRUE),
|
||||||
&kimerror);
|
&kimerror);
|
||||||
}
|
}
|
||||||
@ -1029,39 +1219,37 @@ void PairKIM::set_lmps_flags()
|
|||||||
|
|
||||||
void PairKIM::set_kim_model_has_flags()
|
void PairKIM::set_kim_model_has_flags()
|
||||||
{
|
{
|
||||||
KIM_API_model mdl;
|
|
||||||
|
|
||||||
int kimerror;
|
int kimerror;
|
||||||
|
|
||||||
// get KIM API object representing the KIM Model only
|
// get KIM API object representing the KIM Model only
|
||||||
kimerror = mdl.model_info(kim_modelname);
|
kimerror = kim_api_model_info(&pkim, kim_modelname);
|
||||||
kim_error(__LINE__,"KIM initialization failed", kimerror);
|
kim_error(__LINE__,"KIM initialization failed", kimerror);
|
||||||
|
|
||||||
// determine if the KIM Model can compute the total energy
|
// determine if the KIM Model can compute the total energy
|
||||||
mdl.get_index((char*) "energy", &kimerror);
|
kim_api_get_index(pkim, (char*) "energy", &kimerror);
|
||||||
kim_model_has_energy = (kimerror == KIM_STATUS_OK);
|
kim_model_has_energy = (kimerror == KIM_STATUS_OK);
|
||||||
if (!kim_model_has_energy)
|
if (!kim_model_has_energy)
|
||||||
error->warning(FLERR,"KIM Model does not provide `energy'; "
|
error->warning(FLERR,"KIM Model does not provide `energy'; "
|
||||||
"Potential energy will be zero");
|
"Potential energy will be zero");
|
||||||
|
|
||||||
// determine if the KIM Model can compute the forces
|
// determine if the KIM Model can compute the forces
|
||||||
mdl.get_index((char*) "forces", &kimerror);
|
kim_api_get_index(pkim, (char*) "forces", &kimerror);
|
||||||
kim_model_has_forces = (kimerror == KIM_STATUS_OK);
|
kim_model_has_forces = (kimerror == KIM_STATUS_OK);
|
||||||
if (!kim_model_has_forces)
|
if (!kim_model_has_forces)
|
||||||
error->warning(FLERR,"KIM Model does not provide `forces'; "
|
error->warning(FLERR,"KIM Model does not provide `forces'; "
|
||||||
"Forces will be zero");
|
"Forces will be zero");
|
||||||
|
|
||||||
// determine if the KIM Model can compute the particleEnergy
|
// determine if the KIM Model can compute the particleEnergy
|
||||||
mdl.get_index((char*) "particleEnergy", &kimerror);
|
kim_api_get_index(pkim, (char*) "particleEnergy", &kimerror);
|
||||||
kim_model_has_particleEnergy = (kimerror == KIM_STATUS_OK);
|
kim_model_has_particleEnergy = (kimerror == KIM_STATUS_OK);
|
||||||
if (!kim_model_has_particleEnergy)
|
if (!kim_model_has_particleEnergy)
|
||||||
error->warning(FLERR,"KIM Model does not provide `particleEnergy'; "
|
error->warning(FLERR,"KIM Model does not provide `particleEnergy'; "
|
||||||
"energy per atom will be zero");
|
"energy per atom will be zero");
|
||||||
|
|
||||||
// determine if the KIM Model can compute the particleVerial
|
// determine if the KIM Model can compute the particleVerial
|
||||||
mdl.get_index((char*) "particleVirial", &kimerror);
|
kim_api_get_index(pkim, (char*) "particleVirial", &kimerror);
|
||||||
kim_model_has_particleVirial = (kimerror == KIM_STATUS_OK);
|
kim_model_has_particleVirial = (kimerror == KIM_STATUS_OK);
|
||||||
mdl.get_index((char*) "process_dEdr", &kimerror);
|
kim_api_get_index(pkim, (char*) "process_dEdr", &kimerror);
|
||||||
kim_model_has_particleVirial = kim_model_has_particleVirial ||
|
kim_model_has_particleVirial = kim_model_has_particleVirial ||
|
||||||
(kimerror == KIM_STATUS_OK);
|
(kimerror == KIM_STATUS_OK);
|
||||||
if (!kim_model_has_particleVirial)
|
if (!kim_model_has_particleVirial)
|
||||||
@ -1069,7 +1257,7 @@ void PairKIM::set_kim_model_has_flags()
|
|||||||
"virial per atom will be zero");
|
"virial per atom will be zero");
|
||||||
|
|
||||||
// tear down KIM API object
|
// tear down KIM API object
|
||||||
mdl.free(&kimerror);
|
kim_api_free(&pkim, &kimerror);
|
||||||
// now destructor will do the remaining tear down for mdl
|
// now destructor will do the remaining tear down for mdl
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -1095,17 +1283,6 @@ void PairKIM::write_descriptor(char** test_descriptor_string)
|
|||||||
"# This file is automatically generated from LAMMPS pair_style "
|
"# This file is automatically generated from LAMMPS pair_style "
|
||||||
"kim command\n");
|
"kim command\n");
|
||||||
char tmp_version[100];
|
char tmp_version[100];
|
||||||
sprintf(tmp_version,"# This is pair-kim-v%i.%i.%i",
|
|
||||||
PAIR_KIM_VERSION_MAJOR, PAIR_KIM_VERSION_MINOR,
|
|
||||||
PAIR_KIM_VERSION_PATCH);
|
|
||||||
strcat(*test_descriptor_string, tmp_version);
|
|
||||||
#ifdef PAIR_KIM_VERSION_PRERELEASE
|
|
||||||
sprintf(tmp_version,"-%s", PAIR_KIM_VERSION_PRERELEASE);
|
|
||||||
strcat(*test_descriptor_string, tmp_version);
|
|
||||||
#endif
|
|
||||||
#ifdef PAIR_KIM_VERSION_BUILD_METADATA
|
|
||||||
sprintf(tmp_version,"+%s", PAIR_KIM_VERSION_BUILD_METADATA);
|
|
||||||
#endif
|
|
||||||
strcat(*test_descriptor_string,
|
strcat(*test_descriptor_string,
|
||||||
"\n"
|
"\n"
|
||||||
"# The call number is (pair_style).(init_style): ");
|
"# The call number is (pair_style).(init_style): ");
|
||||||
@ -1114,11 +1291,13 @@ void PairKIM::write_descriptor(char** test_descriptor_string)
|
|||||||
strcat(*test_descriptor_string, tmp_num);
|
strcat(*test_descriptor_string, tmp_num);
|
||||||
strcat(*test_descriptor_string,
|
strcat(*test_descriptor_string,
|
||||||
"#\n"
|
"#\n"
|
||||||
"\n"
|
"\n");
|
||||||
#if KIM_API_VERSION_MAJOR == 1 && KIM_API_VERSION_MINOR == 5
|
|
||||||
#else
|
if (kim_api_is_strictly_between_1_5_and_2_0)
|
||||||
"KIM_API_Version := 1.6.0\n\n"
|
strcat(*test_descriptor_string,
|
||||||
#endif
|
"KIM_API_Version := 1.6.0\n\n");
|
||||||
|
|
||||||
|
strcat(*test_descriptor_string,
|
||||||
"# Base units\n");
|
"# Base units\n");
|
||||||
switch (lmps_units)
|
switch (lmps_units)
|
||||||
{
|
{
|
||||||
@ -1165,13 +1344,15 @@ void PairKIM::write_descriptor(char** test_descriptor_string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write Supported species section
|
// Write Supported species section
|
||||||
strcat(*test_descriptor_string,
|
if (kim_api_is_strictly_between_1_5_and_2_0)
|
||||||
|
strcat(*test_descriptor_string,
|
||||||
"\n"
|
"\n"
|
||||||
#if KIM_API_VERSION_MAJOR == 1 && KIM_API_VERSON_MINOR == 5
|
"PARTICLE_SPECIES:\n");
|
||||||
"SUPPORTED_ATOM/PARTICLES_TYPES:\n"
|
else
|
||||||
#else
|
strcat(*test_descriptor_string,
|
||||||
"PARTICLE_SPECIES:\n"
|
"\n"
|
||||||
#endif
|
"SUPPORTED_ATOM/PARTICLES_TYPES:\n");
|
||||||
|
strcat(*test_descriptor_string,
|
||||||
"# Symbol/name Type code\n");
|
"# Symbol/name Type code\n");
|
||||||
int code=1;
|
int code=1;
|
||||||
char* tmp_line = 0;
|
char* tmp_line = 0;
|
||||||
@ -1204,7 +1385,7 @@ void PairKIM::write_descriptor(char** test_descriptor_string)
|
|||||||
"NEIGH_PURE_F flag\n"
|
"NEIGH_PURE_F flag\n"
|
||||||
"NEIGH_RVEC_H flag\n"
|
"NEIGH_RVEC_H flag\n"
|
||||||
"NEIGH_RVEC_F flag\n");
|
"NEIGH_RVEC_F flag\n");
|
||||||
// @@ add code for MI_OPBC_? support ????
|
|
||||||
if (lmps_support_cluster)
|
if (lmps_support_cluster)
|
||||||
{
|
{
|
||||||
strcat(*test_descriptor_string,
|
strcat(*test_descriptor_string,
|
||||||
@ -1221,14 +1402,16 @@ void PairKIM::write_descriptor(char** test_descriptor_string)
|
|||||||
"MODEL_INPUT:\n"
|
"MODEL_INPUT:\n"
|
||||||
"# Name Type Unit Shape\n"
|
"# Name Type Unit Shape\n"
|
||||||
"numberOfParticles integer none []\n"
|
"numberOfParticles integer none []\n"
|
||||||
"numberContributingParticles integer none []\n"
|
"numberContributingParticles integer none []\n");
|
||||||
#if KIM_API_VERSION_MAJOR == 1 && KIM_API_VERSON_MINOR == 5
|
if (kim_api_is_strictly_between_1_5_and_2_0)
|
||||||
"numberParticleTypes integer none []\n"
|
strcat(*test_descriptor_string,
|
||||||
"particleTypes integer none "
|
|
||||||
#else
|
|
||||||
"numberOfSpecies integer none []\n"
|
"numberOfSpecies integer none []\n"
|
||||||
"particleSpecies integer none "
|
"particleSpecies integer none ");
|
||||||
#endif
|
else
|
||||||
|
strcat(*test_descriptor_string,
|
||||||
|
"numberParticleTypes integer none []\n"
|
||||||
|
"particleTypes integer none ");
|
||||||
|
strcat(*test_descriptor_string,
|
||||||
"[numberOfParticles]\n"
|
"[numberOfParticles]\n"
|
||||||
"coordinates double length "
|
"coordinates double length "
|
||||||
"[numberOfParticles,3]\n"
|
"[numberOfParticles,3]\n"
|
||||||
@ -1327,12 +1510,13 @@ void *PairKIM::extract(const char *str, int &dim)
|
|||||||
|
|
||||||
// check to make sure that the requested parameter is a valid free parameter
|
// check to make sure that the requested parameter is a valid free parameter
|
||||||
|
|
||||||
kimerror = pkim->get_num_params(&numParams, &dummyint);
|
kimerror = kim_api_get_num_params(pkim, &numParams, &dummyint);
|
||||||
kim_error(__LINE__, "get_num_free_params", kimerror);
|
kim_error(__LINE__, "get_num_free_params", kimerror);
|
||||||
char **freeParamNames = new char*[numParams];
|
char **freeParamNames = new char*[numParams];
|
||||||
for (int k = 0; k < numParams; k++)
|
for (int k = 0; k < numParams; k++)
|
||||||
{
|
{
|
||||||
kimerror = pkim->get_free_parameter(k, (const char**) &freeParamNames[k]);
|
kimerror = kim_api_get_free_parameter(pkim, k,
|
||||||
|
(const char**) &freeParamNames[k]);
|
||||||
kim_error(__LINE__, "get_free_parameter", kimerror);
|
kim_error(__LINE__, "get_free_parameter", kimerror);
|
||||||
if (0 == strcmp(paramName, freeParamNames[k]))
|
if (0 == strcmp(paramName, freeParamNames[k]))
|
||||||
{
|
{
|
||||||
@ -1350,7 +1534,7 @@ void *PairKIM::extract(const char *str, int &dim)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the parameter arry from pkim object
|
// get the parameter arry from pkim object
|
||||||
paramData = pkim->get_data(paramName, &kimerror);
|
paramData = kim_api_get_data(pkim, paramName, &kimerror);
|
||||||
if (kimerror == KIM_STATUS_FAIL)
|
if (kimerror == KIM_STATUS_FAIL)
|
||||||
{
|
{
|
||||||
delete [] speciesIndex, speciesIndex = 0;
|
delete [] speciesIndex, speciesIndex = 0;
|
||||||
@ -1359,7 +1543,7 @@ void *PairKIM::extract(const char *str, int &dim)
|
|||||||
kim_error(__LINE__,"get_data",kimerror);
|
kim_error(__LINE__,"get_data",kimerror);
|
||||||
|
|
||||||
// get rank and shape of parameter
|
// get rank and shape of parameter
|
||||||
rank = (*pkim).get_rank(paramName, &kimerror);
|
rank = kim_api_get_rank(pkim, paramName, &kimerror);
|
||||||
if (kimerror == KIM_STATUS_FAIL)
|
if (kimerror == KIM_STATUS_FAIL)
|
||||||
{
|
{
|
||||||
delete [] speciesIndex, speciesIndex = 0;
|
delete [] speciesIndex, speciesIndex = 0;
|
||||||
@ -1368,7 +1552,7 @@ void *PairKIM::extract(const char *str, int &dim)
|
|||||||
kim_error(__LINE__,"get_rank",kimerror);
|
kim_error(__LINE__,"get_rank",kimerror);
|
||||||
|
|
||||||
int *shape = new int[maxLine];
|
int *shape = new int[maxLine];
|
||||||
dummyint = (*pkim).get_shape(paramName, shape, &kimerror);
|
dummyint = kim_api_get_shape(pkim, paramName, shape, &kimerror);
|
||||||
if (kimerror == KIM_STATUS_FAIL)
|
if (kimerror == KIM_STATUS_FAIL)
|
||||||
{
|
{
|
||||||
delete [] speciesIndex, speciesIndex = 0;
|
delete [] speciesIndex, speciesIndex = 0;
|
||||||
|
|||||||
@ -32,7 +32,7 @@ PairStyle(kim,PairKIM)
|
|||||||
#define LMP_PAIR_KIM_H
|
#define LMP_PAIR_KIM_H
|
||||||
|
|
||||||
// includes from KIM & LAMMPS
|
// includes from KIM & LAMMPS
|
||||||
class KIM_API_model;
|
//class KIM_API_model;
|
||||||
#include "pair.h"
|
#include "pair.h"
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ namespace LAMMPS_NS {
|
|||||||
unit_sys lmps_units;
|
unit_sys lmps_units;
|
||||||
|
|
||||||
// values set in set_kim_model_has_flags(), called by kim_init()
|
// 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_energy;
|
||||||
bool kim_model_has_forces;
|
bool kim_model_has_forces;
|
||||||
bool kim_model_has_particleEnergy;
|
bool kim_model_has_particleEnergy;
|
||||||
@ -148,6 +148,37 @@ namespace LAMMPS_NS {
|
|||||||
static int get_neigh(void** kimmdl, int* mode, int* request,
|
static int get_neigh(void** kimmdl, int* mode, int* request,
|
||||||
int* atom, int* numnei, int** nei1atom,
|
int* atom, int* numnei, int** nei1atom,
|
||||||
double** pRij);
|
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
|
documentation for the command. You can use -echo screen as a
|
||||||
command-line option when running LAMMPS to see the offending line.
|
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
|
E: Unrecognized virial argument in pair_style command
|
||||||
|
|
||||||
Only two options are supported: LAMMPSvirial and KIMvirial
|
Only two options are supported: LAMMPSvirial and KIMvirial
|
||||||
|
|||||||
@ -1,64 +0,0 @@
|
|||||||
/* -*- c++ -*- ----------------------------------------------------------
|
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
|
||||||
http://lammps.sandia.gov, Sandia National Laboratories
|
|
||||||
Steve Plimpton, sjplimp@sandia.gov
|
|
||||||
|
|
||||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
|
||||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
|
||||||
certain rights in this software. This software is distributed under
|
|
||||||
the GNU General Public License.
|
|
||||||
|
|
||||||
See the README file in the top-level LAMMPS directory.
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
Contributing authors: Ryan S. Elliott,
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#ifndef LMP_PAIR_KIM_VERSION_H
|
|
||||||
#define LMP_PAIR_KIM_VERSION_H
|
|
||||||
|
|
||||||
//
|
|
||||||
// Release: This file is part of the pair-kim-v1.7.2+1 package.
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// This file defines the version information for the pair-kim package.
|
|
||||||
// The values specified here must conform to the Semantic Versioning
|
|
||||||
// 2.0.0 specification.
|
|
||||||
//
|
|
||||||
// Generally the version numbering for the pair-kim package will
|
|
||||||
// parallel the numbering for the kim-api package. However, if
|
|
||||||
// additional versioning increments are required for the pair-kim
|
|
||||||
// package, the build-metatdata field will be used to provide a
|
|
||||||
// "sub-patch" version number.
|
|
||||||
//
|
|
||||||
// The PATCH value should be incremented IMMEDIATELY after an official
|
|
||||||
// release.
|
|
||||||
//
|
|
||||||
// The MINOR value should be incremented AND the PATCH value reset to
|
|
||||||
// zero as soon as it becomes clear that the next official release
|
|
||||||
// MUST increment the MINOR version value.
|
|
||||||
//
|
|
||||||
// The MAJOR value should be incremented AND the MINOR and PATCH
|
|
||||||
// vaules reset to zero as soon as it becomes clear that the next
|
|
||||||
// official release MUST increment the MAJOR version value.
|
|
||||||
//
|
|
||||||
// The PRERELEASE value can be set to any value allowed by the
|
|
||||||
// Semantic Versioning specification. However, it will generally be
|
|
||||||
// empty. This value should be quoted as a string constant.
|
|
||||||
//
|
|
||||||
// The BUILD_METADATA value can be set to any value allowed by the
|
|
||||||
// Semantic Versioning specification. However, it will generally be
|
|
||||||
// emtpy; Except for when "sub-patch" versioning of the pair-kim
|
|
||||||
// package is necessary. This value should be quoted as a string
|
|
||||||
// constant.
|
|
||||||
//
|
|
||||||
|
|
||||||
#define PAIR_KIM_VERSION_MAJOR 1
|
|
||||||
#define PAIR_KIM_VERSION_MINOR 7
|
|
||||||
#define PAIR_KIM_VERSION_PATCH 2
|
|
||||||
//#define PAIR_KIM_VERSION_PRERELEASE
|
|
||||||
#define PAIR_KIM_VERSION_BUILD_METADATA "1"
|
|
||||||
|
|
||||||
#endif /* PAIR_KIM_VERSION_H */
|
|
||||||
Reference in New Issue
Block a user