Update pair_kim to check for ModelRoutine requirements

Also fixup cmake settings for PKG_KIM
This commit is contained in:
Ryan S. Elliott
2018-11-14 13:11:47 -05:00
parent 81e79ec884
commit 03b1129abd
3 changed files with 53 additions and 1 deletions

View File

@ -609,7 +609,7 @@ if(PKG_KIM)
message(FATAL_ERROR "KIM not found, help CMake to find it by setting PKG_CONFIG_PATH, or set DOWNLOAD_KIM=ON to download it")
endif()
endif()
list(APPEND LAMMPS_LINK_LIBS ${KIM-API-V2_LIBRARIES})
list(APPEND LAMMPS_LINK_LIBS "${KIM-API-V2_LDFLAGS}")
include_directories(${KIM-API-V2_INCLUDE_DIRS})
endif()

View File

@ -789,6 +789,14 @@ void PairKIM::kim_init()
error->all(FLERR,"KIM Model did not accept the requested unit system");
}
// check that the model does not require unknown capabilities
kimerror = check_for_routine_compatibility();
if (kimerror)
{
error->all(FLERR,
"KIM Model requires unknown Routines. Unable to proceed.");
}
kimerror = KIM_Model_ComputeArgumentsCreate(pkim, &pargs);
if (kimerror)
{
@ -987,6 +995,49 @@ void PairKIM::set_lmps_flags()
/* ---------------------------------------------------------------------- */
int PairKIM::check_for_routine_compatibility()
{
/* Check that we know about all required routines */
int numberOfModelRoutineNames;
KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames(
&numberOfModelRoutineNames);
for (int i = 0; i < numberOfModelRoutineNames; ++i)
{
KIM_ModelRoutineName modelRoutineName;
KIM_MODEL_ROUTINE_NAME_GetModelRoutineName(i, &modelRoutineName);
int present;
int required;
int error = KIM_Model_IsRoutinePresent(
pkim, modelRoutineName, &present, &required);
if (error) { return true; }
if ((present == true) && (required == true))
{
if (!(KIM_ModelRoutineName_Equal(modelRoutineName,
KIM_MODEL_ROUTINE_NAME_Create)
|| KIM_ModelRoutineName_Equal(
modelRoutineName,
KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate)
|| KIM_ModelRoutineName_Equal(modelRoutineName,
KIM_MODEL_ROUTINE_NAME_Compute)
|| KIM_ModelRoutineName_Equal(modelRoutineName,
KIM_MODEL_ROUTINE_NAME_Refresh)
|| KIM_ModelRoutineName_Equal(
modelRoutineName,
KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy)
|| KIM_ModelRoutineName_Equal(modelRoutineName,
KIM_MODEL_ROUTINE_NAME_Destroy)))
{ return true; }
}
}
/* everything is good */
return false;
}
/* ---------------------------------------------------------------------- */
void PairKIM::set_kim_model_has_flags()
{
int numberOfComputeArgumentNames;

View File

@ -158,6 +158,7 @@ namespace LAMMPS_NS {
virtual void set_argument_pointers();
virtual void set_lmps_flags();
virtual void set_kim_model_has_flags();
virtual int check_for_routine_compatibility();
// static methods used as callbacks from KIM
static int get_neigh(
void const * const dataObject,