Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set KIM pointer appropriately for Energy #1727

Merged
merged 1 commit into from Oct 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 22 additions & 7 deletions src/KIM/pair_kim.cpp
Expand Up @@ -740,19 +740,14 @@ void PairKIM::kim_init()
kimerror = KIM_ComputeArguments_SetArgumentPointerInteger(pargs,
KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles,
&lmps_local_tot_num_atoms);
if (KIM_SupportStatus_NotEqual(kim_model_support_for_energy,
KIM_SUPPORT_STATUS_notSupported))
kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble(pargs,
KIM_COMPUTE_ARGUMENT_NAME_partialEnergy,
&(eng_vdwl));
if (kimerror) error->all(FLERR,"Unable to set KIM argument pointer");

kimerror = KIM_ComputeArguments_SetCallbackPointer(pargs,
KIM_COMPUTE_CALLBACK_NAME_GetNeighborList,
KIM_LANGUAGE_NAME_cpp,
reinterpret_cast<KIM_Function *>(get_neigh),
reinterpret_cast<void *>(this));

if (kimerror) error->all(FLERR,"Unable to register KIM pointers");
if (kimerror) error->all(FLERR,"Unable to set KIM call back pointer");
}

/* ---------------------------------------------------------------------- */
Expand All @@ -763,6 +758,26 @@ void PairKIM::set_argument_pointers()
kimerror = KIM_ComputeArguments_SetArgumentPointerDouble(
pargs, KIM_COMPUTE_ARGUMENT_NAME_coordinates, &(atom->x[0][0]));

// Set KIM pointer appropriately for Energy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yafshar I think you need to handle the case where the KIM Model has the partialEnergy argument as required (i.e., a non-null pointer must be set). Currently, it seems to assume the model has partialEnergy as optional.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ellio167 Fixed it.

if (KIM_SupportStatus_NotEqual(kim_model_support_for_energy,
KIM_SUPPORT_STATUS_notSupported))
{
if (KIM_SupportStatus_Equal(kim_model_support_for_energy,
KIM_SUPPORT_STATUS_required)
|| (eflag_global == 1))
{
kimerror = kimerror ||
KIM_ComputeArguments_SetArgumentPointerDouble(
pargs,KIM_COMPUTE_ARGUMENT_NAME_partialEnergy,&(eng_vdwl));
}
else
{
kimerror = kimerror ||
KIM_ComputeArguments_SetArgumentPointerDouble(
pargs,KIM_COMPUTE_ARGUMENT_NAME_partialEnergy,
reinterpret_cast<double * const>(NULL));
}
}
// Set KIM pointer appropriately for particalEnergy
if (KIM_SupportStatus_Equal(kim_model_support_for_particleEnergy,
KIM_SUPPORT_STATUS_required)
Expand Down