reformat pair style kim to LAMMPS style and add some existing simiulator model code (non-functional)

This commit is contained in:
Axel Kohlmeyer
2019-05-07 18:21:58 -04:00
parent 99430767df
commit 11407a165b
2 changed files with 714 additions and 796 deletions

View File

@ -55,6 +55,7 @@
#include <cstring>
#include <cstdlib>
#include <string>
// includes from LAMMPS
#include "pair_kim.h"
@ -105,7 +106,9 @@ PairKIM::PairKIM(LAMMPS *lmp) :
kim_particleSpecies(NULL),
kim_particleContributing(NULL),
lmps_stripped_neigh_list(NULL),
lmps_stripped_neigh_ptr(NULL)
lmps_stripped_neigh_ptr(NULL),
simulator_class(NULL),
simulator_style(NULL)
{
// Initialize Pair data members to appropriate values
single_enable = 0; // We do not provide the Single() function
@ -120,8 +123,6 @@ PairKIM::PairKIM(LAMMPS *lmp) :
kim_init_ok = false;
kim_particle_codes_ok = false;
// END
return;
}
/* ---------------------------------------------------------------------- */
@ -137,8 +138,7 @@ PairKIM::~PairKIM()
delete [] lmps_unique_elements[i];
delete [] lmps_unique_elements;
if (kim_particle_codes_ok)
{
if (kim_particle_codes_ok) {
delete [] kim_particle_codes;
kim_particle_codes = NULL;
kim_particle_codes_ok = false;
@ -149,8 +149,7 @@ PairKIM::~PairKIM()
memory->destroy(kim_particleContributing);
memory->destroy(lmps_stripped_neigh_list);
// clean up lmps_stripped_neigh_ptr
if (lmps_stripped_neigh_ptr)
{
if (lmps_stripped_neigh_ptr) {
delete [] lmps_stripped_neigh_ptr;
lmps_stripped_neigh_ptr = 0;
}
@ -164,27 +163,23 @@ PairKIM::~PairKIM()
}
// clean up neighborlist pointers
if (neighborLists)
{
if (neighborLists) {
delete [] neighborLists;
neighborLists = 0;
}
// clean up KIM interface (if necessary)
kim_free();
return;
}
/* ---------------------------------------------------------------------- */
void PairKIM::set_contributing()
{
int const nall = atom->nlocal + atom->nghost;
for (int i = 0; i < nall; ++i)
{
kim_particleContributing[i] = ( (i < atom->nlocal) ? 1 : 0 );
}
}
/* ---------------------------------------------------------------------- */
@ -211,8 +206,7 @@ void PairKIM::compute(int eflag , int vflag)
KIM_COMPUTE_ARGUMENT_NAME_particleContributing,
kim_particleContributing);
if (kimerror)
error->all(
FLERR,
error->all(FLERR,
"Unable to set KIM particle species codes and/or contributing");
}
@ -242,24 +236,19 @@ void PairKIM::compute(int eflag , int vflag)
// compute virial before reverse comm!
if (vflag_global)
{
virial_fdotr_compute();
}
// if newton is off, perform reverse comm
if (!lmps_using_newton)
{
if (!lmps_using_newton) {
comm->reverse_comm_pair(this);
}
if ((vflag_atom) &&
KIM_SupportStatus_NotEqual(kim_model_support_for_particleVirial,
KIM_SUPPORT_STATUS_notSupported)
)
{ // flip sign and order of virial if KIM is computing it
KIM_SUPPORT_STATUS_notSupported)) {
// flip sign and order of virial if KIM is computing it
double tmp;
for (int i = 0; i < nall; ++i)
{
for (int i = 0; i < nall; ++i) {
for (int j = 0; j < 3; ++j) vatom[i][j] = -1.0*vatom[i][j];
tmp = vatom[i][3];
vatom[i][3] = -vatom[i][5];
@ -267,8 +256,6 @@ void PairKIM::compute(int eflag , int vflag)
vatom[i][5] = -tmp;
}
}
return;
}
/* ----------------------------------------------------------------------
@ -291,8 +278,6 @@ void PairKIM::allocate()
lmps_map_species_to_unique = new int[n+1];
allocated = 1;
return;
}
/* ----------------------------------------------------------------------
@ -306,16 +291,12 @@ void PairKIM::settings(int narg, char **arg)
++settings_call_count;
init_style_call_count = 0;
if (narg != 1)
{
if (narg != 1) {
if ((narg > 0) && ((0 == strcmp("KIMvirial", arg[0])) ||
(0 == strcmp("LAMMPSvirial", arg[0]))))
{
(0 == strcmp("LAMMPSvirial", arg[0])))) {
error->all(FLERR,"'KIMvirial' or 'LAMMPSvirial' not supported with "
"kim-api.");
}
else
error->all(FLERR,"Illegal pair_style command");
} else error->all(FLERR,"Illegal pair_style command");
}
// arg[0] is the KIM Model name
@ -339,8 +320,7 @@ void PairKIM::settings(int narg, char **arg)
// set KIM Model name
int nmlen = strlen(arg[0]);
if (kim_modelname != 0)
{
if (kim_modelname != 0) {
delete [] kim_modelname;
kim_modelname = 0;
}
@ -350,7 +330,10 @@ void PairKIM::settings(int narg, char **arg)
// initialize KIM Model
kim_init();
return;
// initialize LAMMPS Simulator model
if (simulatorModel) {
printf("LAMMPS simulator model: %s\n",kim_modelname);
}
}
/* ----------------------------------------------------------------------
@ -374,7 +357,6 @@ void PairKIM::coeff(int narg, char **arg)
if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0)
error->all(FLERR,"Incorrect args for pair coefficients");
int ilo,ihi,jlo,jhi;
force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi);
force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi);
@ -394,7 +376,6 @@ void PairKIM::coeff(int narg, char **arg)
lmps_unique_elements = new char*[atom->ntypes];
for (i = 0; i < atom->ntypes; i++) lmps_unique_elements[i] = 0;
// Assume all species arguments are valid
// errors will be detected by below
std::string atom_type_sym_list;
@ -425,18 +406,14 @@ void PairKIM::coeff(int narg, char **arg)
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
if (simulatorModel)
{
if (simulatorModel) {
simulatorModel->AddTemplateMap("atom-type-sym-list", atom_type_sym_list);
simulatorModel->CloseTemplateMap();
error->all(FLERR,(simulatorModel->ToString()).c_str());
}
else
{
} else {
// setup mapping between LAMMPS unique elements and KIM species codes
if (kim_particle_codes_ok)
{
if (kim_particle_codes_ok) {
delete [] kim_particle_codes;
kim_particle_codes = NULL;
kim_particle_codes_ok = false;
@ -451,19 +428,15 @@ void PairKIM::coeff(int narg, char **arg)
KIM_SpeciesName_FromString(lmps_unique_elements[i]),
&supported,
&code);
if (supported)
if (supported) {
kim_particle_codes[i] = code;
else
{
std::stringstream msg;
msg << "create_kim_particle_codes: symbol not found: "
<< lmps_unique_elements[i];
error->all(FLERR, msg.str().c_str());
} else {
std::string msg("create_kim_particle_codes: symbol not found: ");
msg += lmps_unique_elements[i];
error->all(FLERR, msg.c_str());
}
}
}
return;
}
/* ----------------------------------------------------------------------
@ -487,42 +460,33 @@ void PairKIM::init_style()
delete [] lmps_stripped_neigh_ptr;
lmps_stripped_neigh_ptr = new int*[kim_number_of_neighbor_lists];
for (int i = 0; i < kim_number_of_neighbor_lists; ++i)
{
lmps_stripped_neigh_ptr[i]
= &(lmps_stripped_neigh_list[i*(neighbor->oneatom)]);
}
}
// make sure comm_reverse expects (at most) 9 values when newton is off
if (!lmps_using_newton) comm_reverse_off = 9;
// request full neighbor
for (int i = 0; i < kim_number_of_neighbor_lists; ++i)
{
for (int i = 0; i < kim_number_of_neighbor_lists; ++i) {
int irequest = neighbor->request(this,instance_me);
neighbor->requests[irequest]->id = i;
neighbor->requests[irequest]->half = 0;
neighbor->requests[irequest]->full = 1;
if (modelWillNotRequestNeighborsOfNoncontributingParticles[i])
{
neighbor->requests[irequest]->ghost = 0;
}
else
{
neighbor->requests[irequest]->ghost = 1;
}
// always want all owned/ghost pairs
neighbor->requests[irequest]->newton = 2;
// set cutoff
neighbor->requests[irequest]->cut = 1;
neighbor->requests[irequest]->cutoff
= kim_cutoff_values[i] + neighbor->skin;
}
return;
}
/* ----------------------------------------------------------------------
@ -564,25 +528,20 @@ int PairKIM::pack_reverse_comm(int n, int first, double *buf)
&&
((vflag_atom == 0) ||
KIM_SupportStatus_Equal(kim_model_support_for_particleVirial,
KIM_SUPPORT_STATUS_notSupported)))
{
for (i = first; i < last; i++)
{
KIM_SUPPORT_STATUS_notSupported))) {
for (i = first; i < last; i++) {
buf[m++] = fp[3*i+0];
buf[m++] = fp[3*i+1];
buf[m++] = fp[3*i+2];
}
return m;
}
else if (KIM_SupportStatus_NotEqual(kim_model_support_for_forces,
} else if (KIM_SupportStatus_NotEqual(kim_model_support_for_forces,
KIM_SUPPORT_STATUS_notSupported) &&
(vflag_atom == 1) &&
KIM_SupportStatus_NotEqual(kim_model_support_for_particleVirial,
KIM_SUPPORT_STATUS_notSupported))
{
KIM_SUPPORT_STATUS_notSupported)) {
double *va=&(vatom[0][0]);
for (i = first; i < last; i++)
{
for (i = first; i < last; i++) {
buf[m++] = fp[3*i+0];
buf[m++] = fp[3*i+1];
buf[m++] = fp[3*i+2];
@ -595,17 +554,14 @@ int PairKIM::pack_reverse_comm(int n, int first, double *buf)
buf[m++] = va[6*i+5];
}
return m;
}
else if (KIM_SupportStatus_Equal(kim_model_support_for_forces,
} else if (KIM_SupportStatus_Equal(kim_model_support_for_forces,
KIM_SUPPORT_STATUS_notSupported)
&&
(vflag_atom == 1) &&
KIM_SupportStatus_NotEqual(kim_model_support_for_particleVirial,
KIM_SUPPORT_STATUS_notSupported))
{
KIM_SUPPORT_STATUS_notSupported)) {
double *va=&(vatom[0][0]);
for (i = first; i < last; i++)
{
for (i = first; i < last; i++) {
buf[m++] = va[6*i+0];
buf[m++] = va[6*i+1];
buf[m++] = va[6*i+2];
@ -614,9 +570,7 @@ int PairKIM::pack_reverse_comm(int n, int first, double *buf)
buf[m++] = va[6*i+5];
}
return m;
}
else
return 0;
} else return 0;
}
/* ---------------------------------------------------------------------- */
@ -633,26 +587,21 @@ void PairKIM::unpack_reverse_comm(int n, int *list, double *buf)
&&
((vflag_atom == 0) ||
KIM_SupportStatus_Equal(kim_model_support_for_particleVirial,
KIM_SUPPORT_STATUS_notSupported)))
{
for (i = 0; i < n; i++)
{
KIM_SUPPORT_STATUS_notSupported))) {
for (i = 0; i < n; i++) {
j = list[i];
fp[3*j+0]+= buf[m++];
fp[3*j+1]+= buf[m++];
fp[3*j+2]+= buf[m++];
}
}
else if (KIM_SupportStatus_NotEqual(kim_model_support_for_forces,
} else if (KIM_SupportStatus_NotEqual(kim_model_support_for_forces,
KIM_SUPPORT_STATUS_notSupported)
&&
(vflag_atom == 1) &&
KIM_SupportStatus_NotEqual(kim_model_support_for_particleVirial,
KIM_SUPPORT_STATUS_notSupported))
{
KIM_SUPPORT_STATUS_notSupported)) {
double *va=&(vatom[0][0]);
for (i = 0; i < n; i++)
{
for (i = 0; i < n; i++) {
j = list[i];
fp[3*j+0]+= buf[m++];
fp[3*j+1]+= buf[m++];
@ -665,17 +614,14 @@ void PairKIM::unpack_reverse_comm(int n, int *list, double *buf)
va[j*6+4]+=buf[m++];
va[j*6+5]+=buf[m++];
}
}
else if (KIM_SupportStatus_Equal(kim_model_support_for_forces,
} else if (KIM_SupportStatus_Equal(kim_model_support_for_forces,
KIM_SUPPORT_STATUS_notSupported)
&&
(vflag_atom == 1) &&
KIM_SupportStatus_NotEqual(kim_model_support_for_particleVirial,
KIM_SUPPORT_STATUS_notSupported))
{
KIM_SUPPORT_STATUS_notSupported)) {
double *va=&(vatom[0][0]);
for (i = 0; i < n; i++)
{
for (i = 0; i < n; i++) {
j = list[i];
va[j*6+0]+=buf[m++];
va[j*6+1]+=buf[m++];
@ -687,8 +633,6 @@ void PairKIM::unpack_reverse_comm(int n, int *list, double *buf)
} else {
; // do nothing
}
return;
}
/* ----------------------------------------------------------------------
@ -701,6 +645,32 @@ double PairKIM::memory_usage()
return bytes;
}
/* ----------------------------------------------------------------------
simulator model support functions
------------------------------------------------------------------------- */
void PairKIM::simulator_init()
{
int dummy;
// do not try with suffixes for now.
simulator_class = force->new_pair("lj/cut",1,dummy);
force->store_style(simulator_style,"lj/cut",1);
printf("Simulator model init: %s -> %s\n", kim_modelname, simulator_style);
char **args = new char*[1];
args[0] = (char *)"8.1500";
simulator_class->settings(1,args);
delete[] args;
}
void PairKIM::simulator_free()
{
printf("Simulator model free: %s -> %s\n", kim_modelname, simulator_style);
delete[] simulator_style;
simulator_style = NULL;
delete simulator_class;
simulator_class = NULL;
}
/* ----------------------------------------------------------------------
KIM-specific interface
------------------------------------------------------------------------- */
@ -708,7 +678,8 @@ double PairKIM::memory_usage()
int PairKIM::get_neigh(void const * const dataObject,
int const numberOfNeighborLists,
double const * const cutoffs,
int const neighborListIndex, int const particleNumber,
int const neighborListIndex,
int const particleNumber,
int * const numberOfNeighbors,
int const ** const neighborsOfParticle)
{
@ -717,8 +688,7 @@ int PairKIM::get_neigh(void const * const dataObject,
if (numberOfNeighborLists != Model->kim_number_of_neighbor_lists)
return true;
for (int i = 0; i < numberOfNeighborLists; ++i)
{
for (int i = 0; i < numberOfNeighborLists; ++i) {
if (Model->kim_cutoff_values[i] < cutoffs[i]) return true;
}
@ -738,8 +708,7 @@ int PairKIM::get_neigh(void const * const dataObject,
// strip off neighbor mask for molecular systems
if (!Model->lmps_using_molecular)
*neighborsOfParticle = firstneigh[particleNumber];
else
{
else {
int n = *numberOfNeighbors;
int *ptr = firstneigh[particleNumber];
int *lmps_stripped_neigh_list
@ -755,8 +724,7 @@ int PairKIM::get_neigh(void const * const dataObject,
void PairKIM::kim_free()
{
if (kim_init_ok)
{
if (kim_init_ok) {
int kimerror = KIM_Model_ComputeArgumentsDestroy(pkim, &pargs);
if (kimerror)
error->all(FLERR,"Unable to destroy Compute Arguments Object");
@ -764,8 +732,6 @@ void PairKIM::kim_free()
KIM_Model_Destroy(&pkim);
}
kim_init_ok = false;
return;
}
/* ---------------------------------------------------------------------- */
@ -782,37 +748,25 @@ void PairKIM::kim_init()
kim_modelname,
&requestedUnitsAccepted,
&pkim);
if (kimerror)
{
if (kimerror) {
kimerror = KIM::SimulatorModel::Create(kim_modelname,&simulatorModel);
if (kimerror)
error->all(FLERR,"KIM ModelCreate failed");
else
return;
}
else {
if (!requestedUnitsAccepted) {
if (kimerror) error->all(FLERR,"KIM ModelCreate failed");
else return;
} else {
if (!requestedUnitsAccepted)
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)
{
if (kimerror) {
KIM_Model_Destroy(&pkim);
error->all(FLERR,"KIM ComputeArgumentsCreate failed");
}
else
{
kim_init_ok = true;
}
} else kim_init_ok = true;
}
// determine KIM Model capabilities (used in this function below)
@ -824,8 +778,7 @@ void PairKIM::kim_init()
&kim_number_of_neighbor_lists,
&kim_cutoff_values,
&modelWillNotRequestNeighborsOfNoncontributingParticles);
if (neighborLists)
{
if (neighborLists) {
delete [] neighborLists;
neighborLists = 0;
}
@ -846,10 +799,7 @@ void PairKIM::kim_init()
reinterpret_cast<KIM_Function *>(get_neigh),
reinterpret_cast<void *>(this));
if (kimerror)
error->all(FLERR,"Unable to register KIM pointers");
return;
if (kimerror) error->all(FLERR,"Unable to register KIM pointers");
}
/* ---------------------------------------------------------------------- */
@ -863,11 +813,9 @@ void PairKIM::set_argument_pointers()
// Set KIM pointer appropriately for particalEnergy
if (KIM_SupportStatus_Equal(kim_model_support_for_particleEnergy,
KIM_SUPPORT_STATUS_required)
&& (eflag_atom != 1))
{
&& (eflag_atom != 1)) {
// reallocate per-atom energy array if necessary
if (atom->nmax > maxeatom)
{
if (atom->nmax > maxeatom) {
maxeatom = atom->nmax;
memory->destroy(eatom);
memory->create(eatom,comm->nthreads*maxeatom,"pair:eatom");
@ -875,31 +823,25 @@ void PairKIM::set_argument_pointers()
}
if (KIM_SupportStatus_Equal(kim_model_support_for_particleEnergy,
KIM_SUPPORT_STATUS_optional)
&& (eflag_atom != 1))
{
&& (eflag_atom != 1)) {
kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble(
pargs,
KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy,
reinterpret_cast<double * const>(NULL));
}
else if (KIM_SupportStatus_NotEqual(kim_model_support_for_particleEnergy,
KIM_SUPPORT_STATUS_notSupported))
{
} else if (KIM_SupportStatus_NotEqual(kim_model_support_for_particleEnergy,
KIM_SUPPORT_STATUS_notSupported)) {
kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble(
pargs, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, eatom);
}
// Set KIM pointer appropriately for forces
if (KIM_SupportStatus_Equal(kim_model_support_for_forces,
KIM_SUPPORT_STATUS_notSupported))
{
KIM_SUPPORT_STATUS_notSupported)) {
kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble(
pargs,
KIM_COMPUTE_ARGUMENT_NAME_partialForces,
reinterpret_cast<double * const>(NULL));
}
else
{
} else {
kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble(
pargs, KIM_COMPUTE_ARGUMENT_NAME_partialForces, &(atom->f[0][0]));
}
@ -907,11 +849,9 @@ void PairKIM::set_argument_pointers()
// Set KIM pointer appropriately for particleVirial
if (KIM_SupportStatus_Equal(kim_model_support_for_particleVirial,
KIM_SUPPORT_STATUS_required)
&& (vflag_atom != 1))
{
&& (vflag_atom != 1)) {
// reallocate per-atom virial array if necessary
if (atom->nmax > maxeatom)
{
if (atom->nmax > maxeatom) {
maxvatom = atom->nmax;
memory->destroy(vatom);
memory->create(vatom,comm->nthreads*maxvatom,6,"pair:vatom");
@ -919,26 +859,18 @@ void PairKIM::set_argument_pointers()
}
if (KIM_SupportStatus_Equal(kim_model_support_for_particleVirial,
KIM_SUPPORT_STATUS_optional)
&& (vflag_atom != 1))
{
&& (vflag_atom != 1)) {
kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble(
pargs,
KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial,
reinterpret_cast<double * const>(NULL));
}
else if (KIM_SupportStatus_NotEqual(kim_model_support_for_particleVirial,
KIM_SUPPORT_STATUS_notSupported))
{
} else if (KIM_SupportStatus_NotEqual(kim_model_support_for_particleVirial,
KIM_SUPPORT_STATUS_notSupported)) {
kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble(
pargs, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, &(vatom[0][0]));
}
if (kimerror)
{
error->all(FLERR,"Unable to set KIM argument pointers");
}
return;
if (kimerror) error->all(FLERR,"Unable to set KIM argument pointers");
}
/* ---------------------------------------------------------------------- */
@ -950,9 +882,7 @@ void PairKIM::set_lmps_flags()
// determine if running with pair hybrid
if (force->pair_match("hybrid",0))
{
error->all(FLERR,"pair_kim does not support hybrid");
}
// determine unit system and set lmps_units flag
if ((strcmp(update->unit_style,"real")==0)) {
@ -995,8 +925,6 @@ void PairKIM::set_lmps_flags()
} else {
error->all(FLERR,"Unknown unit_style");
}
return;
}
/* ---------------------------------------------------------------------- */
@ -1007,8 +935,7 @@ int PairKIM::check_for_routine_compatibility()
int numberOfModelRoutineNames;
KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames(
&numberOfModelRoutineNames);
for (int i = 0; i < numberOfModelRoutineNames; ++i)
{
for (int i = 0; i < numberOfModelRoutineNames; ++i) {
KIM_ModelRoutineName modelRoutineName;
KIM_MODEL_ROUTINE_NAME_GetModelRoutineName(i, &modelRoutineName);
@ -1016,10 +943,9 @@ int PairKIM::check_for_routine_compatibility()
int required;
int error = KIM_Model_IsRoutinePresent(
pkim, modelRoutineName, &present, &required);
if (error) { return true; }
if (error) return true;
if ((present == true) && (required == true))
{
if ((present == true) && (required == true)) {
if (!(KIM_ModelRoutineName_Equal(modelRoutineName,
KIM_MODEL_ROUTINE_NAME_Create)
|| KIM_ModelRoutineName_Equal(
@ -1033,8 +959,9 @@ int PairKIM::check_for_routine_compatibility()
modelRoutineName,
KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy)
|| KIM_ModelRoutineName_Equal(modelRoutineName,
KIM_MODEL_ROUTINE_NAME_Destroy)))
{ return true; }
KIM_MODEL_ROUTINE_NAME_Destroy))) {
return true;
}
}
}
@ -1049,8 +976,7 @@ void PairKIM::set_kim_model_has_flags()
int numberOfComputeArgumentNames;
KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames(
&numberOfComputeArgumentNames);
for (int i = 0; i < numberOfComputeArgumentNames; ++i)
{
for (int i = 0; i < numberOfComputeArgumentNames; ++i) {
KIM_ComputeArgumentName computeArgumentName;
KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName(
i, &computeArgumentName);
@ -1059,32 +985,24 @@ void PairKIM::set_kim_model_has_flags()
pargs, computeArgumentName, &supportStatus);
if (KIM_ComputeArgumentName_Equal(computeArgumentName,
KIM_COMPUTE_ARGUMENT_NAME_partialEnergy)
)
KIM_COMPUTE_ARGUMENT_NAME_partialEnergy))
kim_model_support_for_energy = supportStatus;
else if (KIM_ComputeArgumentName_Equal(
computeArgumentName, KIM_COMPUTE_ARGUMENT_NAME_partialForces)
)
computeArgumentName, KIM_COMPUTE_ARGUMENT_NAME_partialForces))
kim_model_support_for_forces = supportStatus;
else if
(KIM_ComputeArgumentName_Equal(
else if (KIM_ComputeArgumentName_Equal(
computeArgumentName,
KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy)\
)
KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy))
kim_model_support_for_particleEnergy = supportStatus;
else if
(KIM_ComputeArgumentName_Equal(
else if (KIM_ComputeArgumentName_Equal(
computeArgumentName,
KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial)
)
KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial))
kim_model_support_for_particleVirial = supportStatus;
else if (KIM_SupportStatus_Equal(supportStatus, KIM_SUPPORT_STATUS_required)
)
{
std::stringstream msg;
msg << "KIM Model requires unsupported compute argument: "
<< KIM_ComputeArgumentName_ToString(computeArgumentName);
error->all(FLERR, msg.str().c_str());
else if (KIM_SupportStatus_Equal(supportStatus,
KIM_SUPPORT_STATUS_required)) {
std::string msg("KIM Model requires unsupported compute argument: ");
msg += KIM_ComputeArgumentName_ToString(computeArgumentName);
error->all(FLERR, msg.c_str());
}
}
@ -1111,20 +1029,15 @@ void PairKIM::set_kim_model_has_flags()
int numberOfComputeCallbackNames;
KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames(
&numberOfComputeCallbackNames);
for (int i = 0; i < numberOfComputeCallbackNames; ++i)
{
for (int i = 0; i < numberOfComputeCallbackNames; ++i) {
KIM_ComputeCallbackName computeCallbackName;
KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName(
i, &computeCallbackName);
KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName(i, &computeCallbackName);
KIM_SupportStatus supportStatus;
KIM_ComputeArguments_GetCallbackSupportStatus(
pargs, computeCallbackName, &supportStatus);
KIM_ComputeArguments_GetCallbackSupportStatus(pargs,
computeCallbackName,
&supportStatus);
if (KIM_SupportStatus_Equal(supportStatus, KIM_SUPPORT_STATUS_required))
{
error->all(FLERR,"KIM Model requires unsupported compute callback");
}
}
return;
}

View File

@ -12,7 +12,7 @@
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing authors: Ryan S. Elliott (UMinn)
Contributing authors: Ryan S. Elliott (UMinn), Axel Kohlmeyer (Temple U)
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
@ -65,12 +65,11 @@ PairStyle(kim,PairKIM)
// includes from KIM & LAMMPS
class KIM_API_model;
#include "pair.h"
extern "C" {
#include "KIM_SimulatorHeaders.h"
}
#include "KIM_SimulatorModel.hpp"
#include <sstream>
namespace LAMMPS_NS {
@ -153,6 +152,12 @@ namespace LAMMPS_NS {
// is in molecular mode
int** lmps_stripped_neigh_ptr; // pointer into lists
// LAMMPS Simulator model support
Pair *simulator_class;
char *simulator_style;
virtual void simulator_init();
virtual void simulator_free();
// KIM specific helper functions
virtual void set_contributing();
virtual void kim_init();