Start devel of native support for KIM simulator models

* CMake change to use KIM-API SimulatorModels branch
* Minimal changes to pair_kim to illustrate use of KIM API
  interface. Only c++ interface is implemented for development.
* Added example input: in.kim.simulator-model
This commit is contained in:
Ryan S. Elliott 2019-04-30 21:45:21 -05:00
parent 4f3c87f8c4
commit 99430767df
4 changed files with 67 additions and 3 deletions

View File

@ -738,8 +738,10 @@ if(PKG_KIM)
enable_language(Fortran)
include(ExternalProject)
ExternalProject_Add(kim_build
URL https://s3.openkim.org/kim-api/kim-api-2.0.2.txz
URL_MD5 537d9c0abd30f85b875ebb584f9143fa
GIT_REPOSITORY https://github.com/openkim/kim-api.git
GIT_TAG SimulatorModels
#URL https://s3.openkim.org/kim-api/kim-api-2.0.2.txz
#URL_MD5 537d9c0abd30f85b875ebb584f9143fa
BINARY_DIR build
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}

View File

@ -0,0 +1,41 @@
# 3d Lennard-Jones melt
#
# This example requires that the example models provided with
# the kim-api package are installed. see the ./lib/kim/README or
# ./lib/kim/Install.py files for details on how to install these
# example models.
#
variable x index 1
variable y index 1
variable z index 1
variable xx equal 20*$x
variable yy equal 20*$y
variable zz equal 20*$z
units metal
atom_style atomic
newton off
lattice fcc 4.4300
region box block 0 ${xx} 0 ${yy} 0 ${zz}
create_box 1 box
create_atoms 1 box
#pair_style lj/cut 8.1500
#pair_coeff 1 1 0.0104 3.4000
pair_style kim ex_sim_model_Si_mod_tersoff
pair_coeff * * Ar
mass 1 39.95
velocity all create 200.0 232345 loop geom
neighbor 0.3 bin
neigh_modify delay 0 every 1 check yes
fix 1 all nve
#fix 1 all npt temp 1.0 1.0 1.0 iso 1.0 1.0 3.0
run 100

View File

@ -87,6 +87,7 @@ PairKIM::PairKIM(LAMMPS *lmp) :
chargeUnit(KIM_CHARGE_UNIT_unused),
temperatureUnit(KIM_TEMPERATURE_UNIT_unused),
timeUnit(KIM_TIME_UNIT_unused),
simulatorModel(NULL),
pkim(NULL),
pargs(NULL),
kim_model_support_for_energy(KIM_SUPPORT_STATUS_notSupported),
@ -396,8 +397,10 @@ void PairKIM::coeff(int narg, char **arg)
// Assume all species arguments are valid
// errors will be detected by below
std::string atom_type_sym_list;
lmps_num_unique_elements = 0;
for (i = 2; i < narg; i++) {
atom_type_sym_list += std::string(" ") + arg[i];
for (j = 0; j < lmps_num_unique_elements; j++)
if (strcmp(arg[i],lmps_unique_elements[j]) == 0) break;
lmps_map_species_to_unique[i-1] = j;
@ -422,6 +425,15 @@ void PairKIM::coeff(int narg, char **arg)
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
if (simulatorModel)
{
simulatorModel->AddTemplateMap("atom-type-sym-list", atom_type_sym_list);
simulatorModel->CloseTemplateMap();
error->all(FLERR,(simulatorModel->ToString()).c_str());
}
else
{
// setup mapping between LAMMPS unique elements and KIM species codes
if (kim_particle_codes_ok)
{
@ -449,6 +461,7 @@ void PairKIM::coeff(int narg, char **arg)
error->all(FLERR, msg.str().c_str());
}
}
}
return;
}
@ -770,7 +783,13 @@ void PairKIM::kim_init()
&requestedUnitsAccepted,
&pkim);
if (kimerror)
error->all(FLERR,"KIM ModelCreate failed");
{
kimerror = KIM::SimulatorModel::Create(kim_modelname,&simulatorModel);
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");

View File

@ -68,6 +68,7 @@ class KIM_API_model;
extern "C" {
#include "KIM_SimulatorHeaders.h"
}
#include "KIM_SimulatorModel.hpp"
#include <sstream>
@ -121,6 +122,7 @@ namespace LAMMPS_NS {
KIM_TemperatureUnit temperatureUnit;
KIM_TimeUnit timeUnit;
KIM::SimulatorModel * simulatorModel;
KIM_Model * pkim;
KIM_ComputeArguments * pargs;