From 99430767dfa399dd1b8fd8a0ecf71fdef5544c5d Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Tue, 30 Apr 2019 21:45:21 -0500 Subject: [PATCH 001/107] 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 --- cmake/CMakeLists.txt | 6 +++-- examples/kim/in.kim.simulator-model | 41 +++++++++++++++++++++++++++++ src/KIM/pair_kim.cpp | 21 ++++++++++++++- src/KIM/pair_kim.h | 2 ++ 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 examples/kim/in.kim.simulator-model diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index dbbbc7f7ac..6acc61576a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -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} diff --git a/examples/kim/in.kim.simulator-model b/examples/kim/in.kim.simulator-model new file mode 100644 index 0000000000..32baf9d78e --- /dev/null +++ b/examples/kim/in.kim.simulator-model @@ -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 diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index a1c13ae81f..01b435194e 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -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"); diff --git a/src/KIM/pair_kim.h b/src/KIM/pair_kim.h index 27bab6c687..dcfb4a8af0 100644 --- a/src/KIM/pair_kim.h +++ b/src/KIM/pair_kim.h @@ -68,6 +68,7 @@ class KIM_API_model; extern "C" { #include "KIM_SimulatorHeaders.h" } +#include "KIM_SimulatorModel.hpp" #include @@ -121,6 +122,7 @@ namespace LAMMPS_NS { KIM_TemperatureUnit temperatureUnit; KIM_TimeUnit timeUnit; + KIM::SimulatorModel * simulatorModel; KIM_Model * pkim; KIM_ComputeArguments * pargs; From 11407a165b1b3d26e09e9f6f3a7c0ac96a6080af Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 7 May 2019 18:21:58 -0400 Subject: [PATCH 002/107] reformat pair style kim to LAMMPS style and add some existing simiulator model code (non-functional) --- src/KIM/pair_kim.cpp | 1335 ++++++++++++++++++++---------------------- src/KIM/pair_kim.h | 175 +++--- 2 files changed, 714 insertions(+), 796 deletions(-) diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index 01b435194e..d75d960355 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -55,6 +55,7 @@ #include #include +#include // includes from LAMMPS #include "pair_kim.h" @@ -74,201 +75,187 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ PairKIM::PairKIM(LAMMPS *lmp) : - Pair(lmp), - settings_call_count(0), - init_style_call_count(0), - kim_modelname(NULL), - lmps_map_species_to_unique(NULL), - lmps_unique_elements(NULL), - lmps_num_unique_elements(0), - lmps_units(METAL), - lengthUnit(KIM_LENGTH_UNIT_unused), - energyUnit(KIM_ENERGY_UNIT_unused), - 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), - kim_model_support_for_forces(KIM_SUPPORT_STATUS_notSupported), - kim_model_support_for_particleEnergy(KIM_SUPPORT_STATUS_notSupported), - kim_model_support_for_particleVirial(KIM_SUPPORT_STATUS_notSupported), - lmps_local_tot_num_atoms(0), - kim_global_influence_distance(0.0), - kim_number_of_neighbor_lists(0), - kim_cutoff_values(NULL), - modelWillNotRequestNeighborsOfNoncontributingParticles(NULL), - neighborLists(NULL), - kim_particle_codes(NULL), - lmps_maxalloc(0), - kim_particleSpecies(NULL), - kim_particleContributing(NULL), - lmps_stripped_neigh_list(NULL), - lmps_stripped_neigh_ptr(NULL) + Pair(lmp), + settings_call_count(0), + init_style_call_count(0), + kim_modelname(NULL), + lmps_map_species_to_unique(NULL), + lmps_unique_elements(NULL), + lmps_num_unique_elements(0), + lmps_units(METAL), + lengthUnit(KIM_LENGTH_UNIT_unused), + energyUnit(KIM_ENERGY_UNIT_unused), + 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), + kim_model_support_for_forces(KIM_SUPPORT_STATUS_notSupported), + kim_model_support_for_particleEnergy(KIM_SUPPORT_STATUS_notSupported), + kim_model_support_for_particleVirial(KIM_SUPPORT_STATUS_notSupported), + lmps_local_tot_num_atoms(0), + kim_global_influence_distance(0.0), + kim_number_of_neighbor_lists(0), + kim_cutoff_values(NULL), + modelWillNotRequestNeighborsOfNoncontributingParticles(NULL), + neighborLists(NULL), + kim_particle_codes(NULL), + lmps_maxalloc(0), + kim_particleSpecies(NULL), + kim_particleContributing(NULL), + lmps_stripped_neigh_list(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 - restartinfo = 0; // We do not write any restart info - one_coeff = 1; // We only allow one coeff * * call - // set to 1, regardless use of fdotr, to avoid ev_set()'s futzing with - // vflag_global - no_virial_fdotr_compute = 1; + // Initialize Pair data members to appropriate values + single_enable = 0; // We do not provide the Single() function + restartinfo = 0; // We do not write any restart info + one_coeff = 1; // We only allow one coeff * * call + // set to 1, regardless use of fdotr, to avoid ev_set()'s futzing with + // vflag_global + no_virial_fdotr_compute = 1; - // BEGIN: initial values that determine the KIM state - // (used by kim_free(), etc.) - kim_init_ok = false; - kim_particle_codes_ok = false; - // END - - return; + // BEGIN: initial values that determine the KIM state + // (used by kim_free(), etc.) + kim_init_ok = false; + kim_particle_codes_ok = false; + // END } /* ---------------------------------------------------------------------- */ PairKIM::~PairKIM() { - // clean up kim_modelname - 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 - if (lmps_unique_elements) - for (int i = 0; i < lmps_num_unique_elements; i++) - delete [] lmps_unique_elements[i]; - delete [] lmps_unique_elements; + // clean up lammps atom species number to unique particle names mapping + if (lmps_unique_elements) + for (int i = 0; i < lmps_num_unique_elements; i++) + delete [] lmps_unique_elements[i]; + delete [] lmps_unique_elements; - if (kim_particle_codes_ok) - { - delete [] kim_particle_codes; - kim_particle_codes = NULL; - kim_particle_codes_ok = false; - } + if (kim_particle_codes_ok) { + delete [] kim_particle_codes; + kim_particle_codes = NULL; + kim_particle_codes_ok = false; + } - // clean up local memory used to support KIM interface - memory->destroy(kim_particleSpecies); - memory->destroy(kim_particleContributing); - memory->destroy(lmps_stripped_neigh_list); - // clean up lmps_stripped_neigh_ptr - if (lmps_stripped_neigh_ptr) - { - delete [] lmps_stripped_neigh_ptr; - lmps_stripped_neigh_ptr = 0; - } + // clean up local memory used to support KIM interface + memory->destroy(kim_particleSpecies); + memory->destroy(kim_particleContributing); + memory->destroy(lmps_stripped_neigh_list); + // clean up lmps_stripped_neigh_ptr + if (lmps_stripped_neigh_ptr) { + delete [] lmps_stripped_neigh_ptr; + lmps_stripped_neigh_ptr = 0; + } - // clean up allocated memory for standard Pair class usage - // also, we allocate lmps_map_species_to_uniuqe in the allocate() function - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); - delete [] lmps_map_species_to_unique; - } + // clean up allocated memory for standard Pair class usage + // also, we allocate lmps_map_species_to_uniuqe in the allocate() function + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + delete [] lmps_map_species_to_unique; + } - // clean up neighborlist pointers - if (neighborLists) - { - delete [] neighborLists; - neighborLists = 0; - } + // clean up neighborlist pointers + if (neighborLists) { + delete [] neighborLists; + neighborLists = 0; + } - // clean up KIM interface (if necessary) - kim_free(); - - return; + // clean up KIM interface (if necessary) + kim_free(); } /* ---------------------------------------------------------------------- */ + 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 ); - } } /* ---------------------------------------------------------------------- */ -void PairKIM::compute(int eflag , int vflag) +void PairKIM::compute(int eflag, int vflag) { - ev_init(eflag,vflag); + ev_init(eflag,vflag); - // grow kim_particleSpecies and kim_particleContributing array if necessary - // needs to be atom->nmax in length - if (atom->nmax > lmps_maxalloc) { - memory->destroy(kim_particleSpecies); - memory->destroy(kim_particleContributing); + // grow kim_particleSpecies and kim_particleContributing array if necessary + // needs to be atom->nmax in length + if (atom->nmax > lmps_maxalloc) { + memory->destroy(kim_particleSpecies); + memory->destroy(kim_particleContributing); - lmps_maxalloc = atom->nmax; - memory->create(kim_particleSpecies,lmps_maxalloc, - "pair:kim_particleSpecies"); - int kimerror = KIM_ComputeArguments_SetArgumentPointerInteger(pargs, - KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes, - kim_particleSpecies); - memory->create(kim_particleContributing,lmps_maxalloc, - "pair:kim_particleContributing"); - kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerInteger( - pargs, - KIM_COMPUTE_ARGUMENT_NAME_particleContributing, - kim_particleContributing); - if (kimerror) - error->all( - FLERR, - "Unable to set KIM particle species codes and/or contributing"); - } + lmps_maxalloc = atom->nmax; + memory->create(kim_particleSpecies,lmps_maxalloc, + "pair:kim_particleSpecies"); + int kimerror = KIM_ComputeArguments_SetArgumentPointerInteger(pargs, + KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes, + kim_particleSpecies); + memory->create(kim_particleContributing,lmps_maxalloc, + "pair:kim_particleContributing"); + kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerInteger( + pargs, + KIM_COMPUTE_ARGUMENT_NAME_particleContributing, + kim_particleContributing); + if (kimerror) + error->all(FLERR, + "Unable to set KIM particle species codes and/or contributing"); + } - // kim_particleSpecies = KIM atom species for each LAMMPS atom + // kim_particleSpecies = KIM atom species for each LAMMPS atom - int *species = atom->type; - int nall = atom->nlocal + atom->nghost; - int ielement; + int *species = atom->type; + int nall = atom->nlocal + atom->nghost; + int ielement; - for (int i = 0; i < nall; i++) { - ielement = lmps_map_species_to_unique[species[i]]; - kim_particleSpecies[i] = kim_particle_codes[ielement]; - } + for (int i = 0; i < nall; i++) { + ielement = lmps_map_species_to_unique[species[i]]; + kim_particleSpecies[i] = kim_particle_codes[ielement]; + } - // Set kim contributing flags - set_contributing(); + // Set kim contributing flags + set_contributing(); - // pass current atom pointers to KIM - set_argument_pointers(); + // pass current atom pointers to KIM + set_argument_pointers(); - // set number of particles - lmps_local_tot_num_atoms = (int) nall; + // set number of particles + lmps_local_tot_num_atoms = (int) nall; - // compute via KIM model - int kimerror = KIM_Model_Compute(pkim, pargs); - if (kimerror) error->all(FLERR,"KIM Compute returned error"); + // compute via KIM model + int kimerror = KIM_Model_Compute(pkim, pargs); + if (kimerror) error->all(FLERR,"KIM Compute returned error"); - // compute virial before reverse comm! - if (vflag_global) - { - virial_fdotr_compute(); - } + // compute virial before reverse comm! + if (vflag_global) + virial_fdotr_compute(); - // if newton is off, perform reverse comm - if (!lmps_using_newton) - { - comm->reverse_comm_pair(this); - } + // if newton is off, perform reverse comm + 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 - double tmp; - 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]; - vatom[i][4] = -vatom[i][4]; - vatom[i][5] = -tmp; - } - } - - return; + 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 + double tmp; + 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]; + vatom[i][4] = -vatom[i][4]; + vatom[i][5] = -tmp; + } + } } /* ---------------------------------------------------------------------- @@ -277,22 +264,20 @@ void PairKIM::compute(int eflag , int vflag) void PairKIM::allocate() { - int n = atom->ntypes; + int n = atom->ntypes; - // allocate standard Pair class arrays - memory->create(setflag,n+1,n+1,"pair:setflag"); - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; + // allocate standard Pair class arrays + memory->create(setflag,n+1,n+1,"pair:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; - memory->create(cutsq,n+1,n+1,"pair:cutsq"); + memory->create(cutsq,n+1,n+1,"pair:cutsq"); - // allocate mapping array - lmps_map_species_to_unique = new int[n+1]; + // allocate mapping array + lmps_map_species_to_unique = new int[n+1]; - allocated = 1; - - return; + allocated = 1; } /* ---------------------------------------------------------------------- @@ -301,56 +286,54 @@ void PairKIM::allocate() void PairKIM::settings(int narg, char **arg) { - // This is called when "pair_style kim ..." is read from input - // may be called multiple times - ++settings_call_count; - init_style_call_count = 0; + // This is called when "pair_style kim ..." is read from input + // may be called multiple times + ++settings_call_count; + init_style_call_count = 0; - if (narg != 1) - { - if ((narg > 0) && ((0 == strcmp("KIMvirial", 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"); - } - // arg[0] is the KIM Model name + if (narg != 1) { + if ((narg > 0) && ((0 == strcmp("KIMvirial", 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"); + } + // arg[0] is the KIM Model name - lmps_using_molecular = (atom->molecular > 0); + lmps_using_molecular = (atom->molecular > 0); - // ensure we are in a clean state for KIM (needed on repeated call) - // first time called will do nothing... - kim_free(); + // ensure we are in a clean state for KIM (needed on repeated call) + // first time called will do nothing... + kim_free(); - // make sure things are allocated - if (allocated != 1) allocate(); + // make sure things are allocated + if (allocated != 1) allocate(); - // clear setflag to ensure coeff() is called after settings() - int n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; + // clear setflag to ensure coeff() is called after settings() + int n = atom->ntypes; + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; - // set lmps_* bool flags - set_lmps_flags(); + // set lmps_* bool flags + set_lmps_flags(); - // set KIM Model name - int nmlen = strlen(arg[0]); - if (kim_modelname != 0) - { - delete [] kim_modelname; - kim_modelname = 0; - } - kim_modelname = new char[nmlen+1]; - strcpy(kim_modelname, arg[0]); + // set KIM Model name + int nmlen = strlen(arg[0]); + if (kim_modelname != 0) { + delete [] kim_modelname; + kim_modelname = 0; + } + kim_modelname = new char[nmlen+1]; + strcpy(kim_modelname, arg[0]); - // initialize KIM Model - kim_init(); + // initialize KIM Model + kim_init(); - return; + // initialize LAMMPS Simulator model + if (simulatorModel) { + printf("LAMMPS simulator model: %s\n",kim_modelname); + } } /* ---------------------------------------------------------------------- @@ -359,91 +342,85 @@ void PairKIM::settings(int narg, char **arg) void PairKIM::coeff(int narg, char **arg) { - // This is called when "pair_coeff ..." is read from input - // may be called multiple times + // This is called when "pair_coeff ..." is read from input + // may be called multiple times - int i,j,n; + int i,j,n; - if (!allocated) allocate(); + if (!allocated) allocate(); - if (narg != 2 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); + if (narg != 2 + atom->ntypes) + error->all(FLERR,"Incorrect args for pair coefficients"); - // insure I,J args are * * + // insure I,J args are * * - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); + 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); - int ilo,ihi,jlo,jhi; - force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi); - force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi); + // read args that map atom species to KIM elements + // lmps_map_species_to_unique[i] = + // which element the Ith atom type is + // lmps_num_unique_elements = # of unique elements + // lmps_unique_elements = list of element names - // read args that map atom species to KIM elements - // lmps_map_species_to_unique[i] = - // which element the Ith atom type is - // lmps_num_unique_elements = # of unique elements - // lmps_unique_elements = list of element names + // if called multiple times: update lmps_unique_elements + if (lmps_unique_elements) { + for (i = 0; i < lmps_num_unique_elements; i++) + delete [] lmps_unique_elements[i]; + delete [] lmps_unique_elements; + } + lmps_unique_elements = new char*[atom->ntypes]; + for (i = 0; i < atom->ntypes; i++) lmps_unique_elements[i] = 0; - // if called multiple times: update lmps_unique_elements - if (lmps_unique_elements) { - for (i = 0; i < lmps_num_unique_elements; i++) - delete [] lmps_unique_elements[i]; - delete [] lmps_unique_elements; - } - 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; + 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; + if (j == lmps_num_unique_elements) { + n = strlen(arg[i]) + 1; + lmps_unique_elements[j] = new char[n]; + strcpy(lmps_unique_elements[j],arg[i]); + lmps_num_unique_elements++; + } + } + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo,i); j <= jhi; j++) { + if (lmps_map_species_to_unique[i] >= 0 && + lmps_map_species_to_unique[j] >= 0) { + setflag[i][j] = 1; + count++; + } + } + } - // 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; - if (j == lmps_num_unique_elements) { - n = strlen(arg[i]) + 1; - lmps_unique_elements[j] = new char[n]; - strcpy(lmps_unique_elements[j],arg[i]); - lmps_num_unique_elements++; - } - } + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); - int count = 0; - for (int i = ilo; i <= ihi; i++) { - for (int j = MAX(jlo,i); j <= jhi; j++) { - if (lmps_map_species_to_unique[i] >= 0 && - lmps_map_species_to_unique[j] >= 0) { - setflag[i][j] = 1; - count++; - } - } - } + if (simulatorModel) { + simulatorModel->AddTemplateMap("atom-type-sym-list", atom_type_sym_list); + simulatorModel->CloseTemplateMap(); - 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) - { - delete [] kim_particle_codes; - kim_particle_codes = NULL; - kim_particle_codes_ok = false; - } - kim_particle_codes = new int[lmps_num_unique_elements]; - kim_particle_codes_ok = true; - for(int i = 0; i < lmps_num_unique_elements; i++){ + error->all(FLERR,(simulatorModel->ToString()).c_str()); + } else { + // setup mapping between LAMMPS unique elements and KIM species codes + if (kim_particle_codes_ok) { + delete [] kim_particle_codes; + kim_particle_codes = NULL; + kim_particle_codes_ok = false; + } + kim_particle_codes = new int[lmps_num_unique_elements]; + kim_particle_codes_ok = true; + for(int i = 0; i < lmps_num_unique_elements; i++) { int supported; int code; KIM_Model_GetSpeciesSupportAndCode( @@ -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; + } + } } /* ---------------------------------------------------------------------- @@ -472,57 +445,48 @@ void PairKIM::coeff(int narg, char **arg) void PairKIM::init_style() { - // This is called for each "run ...", "minimize ...", etc. read from input - ++init_style_call_count; + // This is called for each "run ...", "minimize ...", etc. read from input + ++init_style_call_count; - if (domain->dimension != 3) - error->all(FLERR,"PairKIM only works with 3D problems"); + if (domain->dimension != 3) + error->all(FLERR,"PairKIM only works with 3D problems"); - // setup lmps_stripped_neigh_list for neighbors of one atom, if needed - if (lmps_using_molecular) { - memory->destroy(lmps_stripped_neigh_list); - memory->create(lmps_stripped_neigh_list, - kim_number_of_neighbor_lists*neighbor->oneatom, - "pair:lmps_stripped_neigh_list"); - 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)]); - } + // setup lmps_stripped_neigh_list for neighbors of one atom, if needed + if (lmps_using_molecular) { + memory->destroy(lmps_stripped_neigh_list); + memory->create(lmps_stripped_neigh_list, + kim_number_of_neighbor_lists*neighbor->oneatom, + "pair:lmps_stripped_neigh_list"); + 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; - // 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) { + int irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = i; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->full = 1; - // request full neighbor - 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; - 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; - } - // 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; + // set cutoff + neighbor->requests[irequest]->cut = 1; + neighbor->requests[irequest]->cutoff + = kim_cutoff_values[i] + neighbor->skin; + } } /* ---------------------------------------------------------------------- @@ -541,154 +505,134 @@ void PairKIM::init_list(int id, NeighList *ptr) double PairKIM::init_one(int i, int j) { - // This is called once of each (unordered) i,j pair for each - // "run ...", "minimize ...", etc. read from input + // This is called once of each (unordered) i,j pair for each + // "run ...", "minimize ...", etc. read from input - if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); + if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); - return kim_global_influence_distance; + return kim_global_influence_distance; } /* ---------------------------------------------------------------------- */ int PairKIM::pack_reverse_comm(int n, int first, double *buf) { - int i,m,last; - double *fp; - fp = &(atom->f[0][0]); + int i,m,last; + double *fp; + fp = &(atom->f[0][0]); - m = 0; - last = first + n; - if (KIM_SupportStatus_NotEqual(kim_model_support_for_forces, - KIM_SUPPORT_STATUS_notSupported) - && - ((vflag_atom == 0) || - KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, - 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, - KIM_SUPPORT_STATUS_notSupported) && - (vflag_atom == 1) && - KIM_SupportStatus_NotEqual(kim_model_support_for_particleVirial, - KIM_SUPPORT_STATUS_notSupported)) - { - double *va=&(vatom[0][0]); - for (i = first; i < last; i++) - { - buf[m++] = fp[3*i+0]; - buf[m++] = fp[3*i+1]; - buf[m++] = fp[3*i+2]; + m = 0; + last = first + n; + if (KIM_SupportStatus_NotEqual(kim_model_support_for_forces, + KIM_SUPPORT_STATUS_notSupported) + && + ((vflag_atom == 0) || + KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, + 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, + KIM_SUPPORT_STATUS_notSupported) && + (vflag_atom == 1) && + KIM_SupportStatus_NotEqual(kim_model_support_for_particleVirial, + KIM_SUPPORT_STATUS_notSupported)) { + double *va=&(vatom[0][0]); + for (i = first; i < last; i++) { + buf[m++] = fp[3*i+0]; + buf[m++] = fp[3*i+1]; + buf[m++] = fp[3*i+2]; - buf[m++] = va[6*i+0]; - buf[m++] = va[6*i+1]; - buf[m++] = va[6*i+2]; - buf[m++] = va[6*i+3]; - buf[m++] = va[6*i+4]; - buf[m++] = va[6*i+5]; - } - return m; - } - 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)) - { - double *va=&(vatom[0][0]); - for (i = first; i < last; i++) - { - buf[m++] = va[6*i+0]; - buf[m++] = va[6*i+1]; - buf[m++] = va[6*i+2]; - buf[m++] = va[6*i+3]; - buf[m++] = va[6*i+4]; - buf[m++] = va[6*i+5]; - } - return m; - } - else - return 0; + buf[m++] = va[6*i+0]; + buf[m++] = va[6*i+1]; + buf[m++] = va[6*i+2]; + buf[m++] = va[6*i+3]; + buf[m++] = va[6*i+4]; + buf[m++] = va[6*i+5]; + } + return m; + } 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)) { + double *va=&(vatom[0][0]); + for (i = first; i < last; i++) { + buf[m++] = va[6*i+0]; + buf[m++] = va[6*i+1]; + buf[m++] = va[6*i+2]; + buf[m++] = va[6*i+3]; + buf[m++] = va[6*i+4]; + buf[m++] = va[6*i+5]; + } + return m; + } else return 0; } /* ---------------------------------------------------------------------- */ void PairKIM::unpack_reverse_comm(int n, int *list, double *buf) { - int i,j,m; - double *fp; - fp = &(atom->f[0][0]); + int i,j,m; + double *fp; + fp = &(atom->f[0][0]); - m = 0; - if (KIM_SupportStatus_NotEqual(kim_model_support_for_forces, - KIM_SUPPORT_STATUS_notSupported) - && - ((vflag_atom == 0) || - KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, - 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, - KIM_SUPPORT_STATUS_notSupported) - && - (vflag_atom == 1) && - KIM_SupportStatus_NotEqual(kim_model_support_for_particleVirial, - KIM_SUPPORT_STATUS_notSupported)) - { - double *va=&(vatom[0][0]); - 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++]; + m = 0; + if (KIM_SupportStatus_NotEqual(kim_model_support_for_forces, + KIM_SUPPORT_STATUS_notSupported) + && + ((vflag_atom == 0) || + KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, + 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, + KIM_SUPPORT_STATUS_notSupported) + && + (vflag_atom == 1) && + KIM_SupportStatus_NotEqual(kim_model_support_for_particleVirial, + KIM_SUPPORT_STATUS_notSupported)) { + double *va=&(vatom[0][0]); + 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++]; - va[j*6+0]+=buf[m++]; - va[j*6+1]+=buf[m++]; - va[j*6+2]+=buf[m++]; - va[j*6+3]+=buf[m++]; - va[j*6+4]+=buf[m++]; - va[j*6+5]+=buf[m++]; - } - } - 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)) - { - double *va=&(vatom[0][0]); - for (i = 0; i < n; i++) - { - j = list[i]; - va[j*6+0]+=buf[m++]; - va[j*6+1]+=buf[m++]; - va[j*6+2]+=buf[m++]; - va[j*6+3]+=buf[m++]; - va[j*6+4]+=buf[m++]; - va[j*6+5]+=buf[m++]; - } - } else { - ; // do nothing - } - - return; + va[j*6+0]+=buf[m++]; + va[j*6+1]+=buf[m++]; + va[j*6+2]+=buf[m++]; + va[j*6+3]+=buf[m++]; + va[j*6+4]+=buf[m++]; + va[j*6+5]+=buf[m++]; + } + } 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)) { + double *va=&(vatom[0][0]); + for (i = 0; i < n; i++) { + j = list[i]; + va[j*6+0]+=buf[m++]; + va[j*6+1]+=buf[m++]; + va[j*6+2]+=buf[m++]; + va[j*6+3]+=buf[m++]; + va[j*6+4]+=buf[m++]; + va[j*6+5]+=buf[m++]; + } + } else { + ; // do nothing + } } /* ---------------------------------------------------------------------- @@ -697,8 +641,34 @@ void PairKIM::unpack_reverse_comm(int n, int *list, double *buf) double PairKIM::memory_usage() { - double bytes = 2 * lmps_maxalloc * sizeof(int); - return bytes; + double bytes = 2 * lmps_maxalloc * sizeof(int); + 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; } /* ---------------------------------------------------------------------- @@ -708,148 +678,128 @@ 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) { - PairKIM const * const Model - = reinterpret_cast(dataObject); + PairKIM const * const Model + = reinterpret_cast(dataObject); - if (numberOfNeighborLists != Model->kim_number_of_neighbor_lists) - return true; - for (int i = 0; i < numberOfNeighborLists; ++i) - { - if (Model->kim_cutoff_values[i] < cutoffs[i]) return true; - } + if (numberOfNeighborLists != Model->kim_number_of_neighbor_lists) + return true; + for (int i = 0; i < numberOfNeighborLists; ++i) { + if (Model->kim_cutoff_values[i] < cutoffs[i]) return true; + } - // neighborListIndex and particleNumber are validated by KIM API + // neighborListIndex and particleNumber are validated by KIM API - // initialize numNeigh - *numberOfNeighbors = 0; + // initialize numNeigh + *numberOfNeighbors = 0; - NeighList * neiobj = Model->neighborLists[neighborListIndex]; + NeighList * neiobj = Model->neighborLists[neighborListIndex]; - int *numneigh, **firstneigh; - numneigh = neiobj->numneigh; // # of J neighbors for each I atom - firstneigh = neiobj->firstneigh; // ptr to 1st J int value of each I atom + int *numneigh, **firstneigh; + numneigh = neiobj->numneigh; // # of J neighbors for each I atom + firstneigh = neiobj->firstneigh; // ptr to 1st J int value of each I atom - *numberOfNeighbors = numneigh[particleNumber]; + *numberOfNeighbors = numneigh[particleNumber]; - // strip off neighbor mask for molecular systems - if (!Model->lmps_using_molecular) - *neighborsOfParticle = firstneigh[particleNumber]; - else - { - int n = *numberOfNeighbors; - int *ptr = firstneigh[particleNumber]; - int *lmps_stripped_neigh_list - = Model->lmps_stripped_neigh_ptr[neighborListIndex]; - for (int i = 0; i < n; i++) - lmps_stripped_neigh_list[i] = *(ptr++) & NEIGHMASK; - *neighborsOfParticle = lmps_stripped_neigh_list; - } - return false; + // strip off neighbor mask for molecular systems + if (!Model->lmps_using_molecular) + *neighborsOfParticle = firstneigh[particleNumber]; + else { + int n = *numberOfNeighbors; + int *ptr = firstneigh[particleNumber]; + int *lmps_stripped_neigh_list + = Model->lmps_stripped_neigh_ptr[neighborListIndex]; + for (int i = 0; i < n; i++) + lmps_stripped_neigh_list[i] = *(ptr++) & NEIGHMASK; + *neighborsOfParticle = lmps_stripped_neigh_list; + } + return false; } /* ---------------------------------------------------------------------- */ void PairKIM::kim_free() { - if (kim_init_ok) - { - int kimerror = KIM_Model_ComputeArgumentsDestroy(pkim, &pargs); - if (kimerror) - error->all(FLERR,"Unable to destroy Compute Arguments Object"); + if (kim_init_ok) { + int kimerror = KIM_Model_ComputeArgumentsDestroy(pkim, &pargs); + if (kimerror) + error->all(FLERR,"Unable to destroy Compute Arguments Object"); - KIM_Model_Destroy(&pkim); - } - kim_init_ok = false; - - return; + KIM_Model_Destroy(&pkim); + } + kim_init_ok = false; } /* ---------------------------------------------------------------------- */ void PairKIM::kim_init() { - int kimerror; + int kimerror; - // initialize KIM model - int requestedUnitsAccepted; - kimerror = KIM_Model_Create( - KIM_NUMBERING_zeroBased, - lengthUnit, energyUnit, chargeUnit, temperatureUnit, timeUnit, - kim_modelname, - &requestedUnitsAccepted, - &pkim); - if (kimerror) - { - 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"); - } + // initialize KIM model + int requestedUnitsAccepted; + kimerror = KIM_Model_Create( + KIM_NUMBERING_zeroBased, + lengthUnit, energyUnit, chargeUnit, temperatureUnit, timeUnit, + kim_modelname, + &requestedUnitsAccepted, + &pkim); + if (kimerror) { + 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"); - // 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."); - } + // 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) - { - KIM_Model_Destroy(&pkim); - error->all(FLERR,"KIM ComputeArgumentsCreate failed"); - } - else - { - kim_init_ok = true; - } - } + kimerror = KIM_Model_ComputeArgumentsCreate(pkim, &pargs); + if (kimerror) { + KIM_Model_Destroy(&pkim); + error->all(FLERR,"KIM ComputeArgumentsCreate failed"); + } else kim_init_ok = true; + } - // determine KIM Model capabilities (used in this function below) - set_kim_model_has_flags(); + // determine KIM Model capabilities (used in this function below) + set_kim_model_has_flags(); - KIM_Model_GetInfluenceDistance(pkim, &kim_global_influence_distance); - KIM_Model_GetNeighborListPointers( - pkim, - &kim_number_of_neighbor_lists, - &kim_cutoff_values, - &modelWillNotRequestNeighborsOfNoncontributingParticles); - if (neighborLists) - { - delete [] neighborLists; - neighborLists = 0; - } - neighborLists = new NeighList*[kim_number_of_neighbor_lists]; + KIM_Model_GetInfluenceDistance(pkim, &kim_global_influence_distance); + KIM_Model_GetNeighborListPointers( + pkim, + &kim_number_of_neighbor_lists, + &kim_cutoff_values, + &modelWillNotRequestNeighborsOfNoncontributingParticles); + if (neighborLists) { + delete [] neighborLists; + neighborLists = 0; + } + neighborLists = new NeighList*[kim_number_of_neighbor_lists]; - 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)); + 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)); - kimerror = KIM_ComputeArguments_SetCallbackPointer(pargs, - KIM_COMPUTE_CALLBACK_NAME_GetNeighborList, - KIM_LANGUAGE_NAME_cpp, - reinterpret_cast(get_neigh), - reinterpret_cast(this)); + kimerror = KIM_ComputeArguments_SetCallbackPointer(pargs, + KIM_COMPUTE_CALLBACK_NAME_GetNeighborList, + KIM_LANGUAGE_NAME_cpp, + reinterpret_cast(get_neigh), + reinterpret_cast(this)); - if (kimerror) - error->all(FLERR,"Unable to register KIM pointers"); - - return; + if (kimerror) error->all(FLERR,"Unable to register KIM pointers"); } /* ---------------------------------------------------------------------- */ @@ -858,16 +808,14 @@ void PairKIM::set_argument_pointers() { int kimerror; kimerror = KIM_ComputeArguments_SetArgumentPointerDouble( - pargs, KIM_COMPUTE_ARGUMENT_NAME_coordinates, &(atom->x[0][0])); + pargs, KIM_COMPUTE_ARGUMENT_NAME_coordinates, &(atom->x[0][0])); // 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(NULL)); - } - else if (KIM_SupportStatus_NotEqual(kim_model_support_for_particleEnergy, - KIM_SUPPORT_STATUS_notSupported)) - { + pargs, + KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, + reinterpret_cast(NULL)); + } 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(NULL)); - } - else - { + pargs, + KIM_COMPUTE_ARGUMENT_NAME_partialForces, + reinterpret_cast(NULL)); + } 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,84 +859,72 @@ 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(NULL)); - } - else if (KIM_SupportStatus_NotEqual(kim_model_support_for_particleVirial, - KIM_SUPPORT_STATUS_notSupported)) - { + pargs, + KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial, + reinterpret_cast(NULL)); + } 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])); + 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"); } /* ---------------------------------------------------------------------- */ void PairKIM::set_lmps_flags() { - // determint if newton is on or off - lmps_using_newton = (force->newton_pair == 1); + // determint if newton is on or off + lmps_using_newton = (force->newton_pair == 1); - // determine if running with pair hybrid - if (force->pair_match("hybrid",0)) - { - error->all(FLERR,"pair_kim does not support hybrid"); - } + // 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)) { - lmps_units = REAL; - lengthUnit = KIM_LENGTH_UNIT_A; - energyUnit = KIM_ENERGY_UNIT_kcal_mol; - chargeUnit = KIM_CHARGE_UNIT_e; - temperatureUnit = KIM_TEMPERATURE_UNIT_K; - timeUnit = KIM_TIME_UNIT_fs; - } else if ((strcmp(update->unit_style,"metal")==0)) { - lmps_units = METAL; - lengthUnit = KIM_LENGTH_UNIT_A; - energyUnit = KIM_ENERGY_UNIT_eV; - chargeUnit = KIM_CHARGE_UNIT_e; - temperatureUnit = KIM_TEMPERATURE_UNIT_K; - timeUnit = KIM_TIME_UNIT_ps; - } else if ((strcmp(update->unit_style,"si")==0)) { - lmps_units = SI; - lengthUnit = KIM_LENGTH_UNIT_m; - energyUnit = KIM_ENERGY_UNIT_J; - chargeUnit = KIM_CHARGE_UNIT_C; - temperatureUnit = KIM_TEMPERATURE_UNIT_K; - timeUnit = KIM_TIME_UNIT_s; - } else if ((strcmp(update->unit_style,"cgs")==0)) { - lmps_units = CGS; - lengthUnit = KIM_LENGTH_UNIT_cm; - energyUnit = KIM_ENERGY_UNIT_erg; - chargeUnit = KIM_CHARGE_UNIT_statC; - temperatureUnit = KIM_TEMPERATURE_UNIT_K; - timeUnit = KIM_TIME_UNIT_s; - } else if ((strcmp(update->unit_style,"electron")==0)) { - lmps_units = ELECTRON; - lengthUnit = KIM_LENGTH_UNIT_Bohr; - energyUnit = KIM_ENERGY_UNIT_Hartree; - chargeUnit = KIM_CHARGE_UNIT_e; - temperatureUnit = KIM_TEMPERATURE_UNIT_K; - timeUnit = KIM_TIME_UNIT_fs; - } else if ((strcmp(update->unit_style,"lj")==0)) { - error->all(FLERR,"LAMMPS unit_style lj not supported by KIM models"); - } else { - error->all(FLERR,"Unknown unit_style"); - } - - return; + // determine unit system and set lmps_units flag + if ((strcmp(update->unit_style,"real")==0)) { + lmps_units = REAL; + lengthUnit = KIM_LENGTH_UNIT_A; + energyUnit = KIM_ENERGY_UNIT_kcal_mol; + chargeUnit = KIM_CHARGE_UNIT_e; + temperatureUnit = KIM_TEMPERATURE_UNIT_K; + timeUnit = KIM_TIME_UNIT_fs; + } else if ((strcmp(update->unit_style,"metal")==0)) { + lmps_units = METAL; + lengthUnit = KIM_LENGTH_UNIT_A; + energyUnit = KIM_ENERGY_UNIT_eV; + chargeUnit = KIM_CHARGE_UNIT_e; + temperatureUnit = KIM_TEMPERATURE_UNIT_K; + timeUnit = KIM_TIME_UNIT_ps; + } else if ((strcmp(update->unit_style,"si")==0)) { + lmps_units = SI; + lengthUnit = KIM_LENGTH_UNIT_m; + energyUnit = KIM_ENERGY_UNIT_J; + chargeUnit = KIM_CHARGE_UNIT_C; + temperatureUnit = KIM_TEMPERATURE_UNIT_K; + timeUnit = KIM_TIME_UNIT_s; + } else if ((strcmp(update->unit_style,"cgs")==0)) { + lmps_units = CGS; + lengthUnit = KIM_LENGTH_UNIT_cm; + energyUnit = KIM_ENERGY_UNIT_erg; + chargeUnit = KIM_CHARGE_UNIT_statC; + temperatureUnit = KIM_TEMPERATURE_UNIT_K; + timeUnit = KIM_TIME_UNIT_s; + } else if ((strcmp(update->unit_style,"electron")==0)) { + lmps_units = ELECTRON; + lengthUnit = KIM_LENGTH_UNIT_Bohr; + energyUnit = KIM_ENERGY_UNIT_Hartree; + chargeUnit = KIM_CHARGE_UNIT_e; + temperatureUnit = KIM_TEMPERATURE_UNIT_K; + timeUnit = KIM_TIME_UNIT_fs; + } else if ((strcmp(update->unit_style,"lj")==0)) { + error->all(FLERR,"LAMMPS unit_style lj not supported by KIM models"); + } else { + error->all(FLERR,"Unknown unit_style"); + } } /* ---------------------------------------------------------------------- */ @@ -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( - computeArgumentName, - KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy)\ - ) + else if (KIM_ComputeArgumentName_Equal( + computeArgumentName, + KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy)) kim_model_support_for_particleEnergy = supportStatus; - else if - (KIM_ComputeArgumentName_Equal( - computeArgumentName, - KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial) - ) + else if (KIM_ComputeArgumentName_Equal( + computeArgumentName, + 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; } diff --git a/src/KIM/pair_kim.h b/src/KIM/pair_kim.h index dcfb4a8af0..37a6be1e5b 100644 --- a/src/KIM/pair_kim.h +++ b/src/KIM/pair_kim.h @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing authors: Ryan S. Elliott (UMinn) + Contributing authors: Ryan S. Elliott (UMinn), Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- @@ -65,110 +65,115 @@ 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 - namespace LAMMPS_NS { - class PairKIM : public Pair { - public: - PairKIM(class LAMMPS*); - ~PairKIM(); +class PairKIM : public Pair { + public: + PairKIM(class LAMMPS*); + ~PairKIM(); - // LAMMPS Pair class virtual function prototypes - virtual void compute(int, int); - virtual void settings(int, char**); - virtual void coeff(int, char**); - virtual void init_style(); - virtual void init_list(int id, NeighList *ptr); - virtual double init_one(int, int); - virtual int pack_reverse_comm(int, int, double*); - virtual void unpack_reverse_comm(int, int*, double*); - virtual double memory_usage(); + // LAMMPS Pair class virtual function prototypes + virtual void compute(int, int); + virtual void settings(int, char**); + virtual void coeff(int, char**); + virtual void init_style(); + virtual void init_list(int id, NeighList *ptr); + virtual double init_one(int, int); + virtual int pack_reverse_comm(int, int, double*); + virtual void unpack_reverse_comm(int, int*, double*); + virtual double memory_usage(); - protected: - // (nearly) all bool flags are not initialized in constructor, but set - // explicitly in the indicated function. All other data members are - // initialized in constructor - int settings_call_count; - int init_style_call_count; + protected: + // (nearly) all bool flags are not initialized in constructor, but set + // explicitly in the indicated function. All other data members are + // initialized in constructor + int settings_call_count; + int init_style_call_count; - // values set in settings() - char* kim_modelname; + // values set in settings() + char* kim_modelname; - // values set in coeff() + // values set in coeff() - // values set in allocate(), called by coeff() - virtual void allocate(); - int* lmps_map_species_to_unique; + // values set in allocate(), called by coeff() + virtual void allocate(); + int* lmps_map_species_to_unique; - // values set in coeff(), after calling allocate() - char** lmps_unique_elements; // names of unique elements given - // in pair_coeff command - int lmps_num_unique_elements; + // values set in coeff(), after calling allocate() + char** lmps_unique_elements; // names of unique elements given + // in pair_coeff command + int lmps_num_unique_elements; - // values set in set_lmps_flags(), called from init_style() - bool lmps_using_newton; - bool lmps_using_molecular; - enum unit_sys {REAL, METAL, SI, CGS, ELECTRON}; - unit_sys lmps_units; - KIM_LengthUnit lengthUnit; - KIM_EnergyUnit energyUnit; - KIM_ChargeUnit chargeUnit; - KIM_TemperatureUnit temperatureUnit; - KIM_TimeUnit timeUnit; + // values set in set_lmps_flags(), called from init_style() + bool lmps_using_newton; + bool lmps_using_molecular; + enum unit_sys {REAL, METAL, SI, CGS, ELECTRON}; + unit_sys lmps_units; + KIM_LengthUnit lengthUnit; + KIM_EnergyUnit energyUnit; + KIM_ChargeUnit chargeUnit; + KIM_TemperatureUnit temperatureUnit; + KIM_TimeUnit timeUnit; - KIM::SimulatorModel * simulatorModel; - KIM_Model * pkim; - KIM_ComputeArguments * pargs; + KIM::SimulatorModel * simulatorModel; + KIM_Model * pkim; + KIM_ComputeArguments * pargs; - // values set in set_kim_model_has_flags(), called by kim_init() - KIM_SupportStatus kim_model_support_for_energy; - KIM_SupportStatus kim_model_support_for_forces; - KIM_SupportStatus kim_model_support_for_particleEnergy; - KIM_SupportStatus kim_model_support_for_particleVirial; + // values set in set_kim_model_has_flags(), called by kim_init() + KIM_SupportStatus kim_model_support_for_energy; + KIM_SupportStatus kim_model_support_for_forces; + KIM_SupportStatus kim_model_support_for_particleEnergy; + KIM_SupportStatus kim_model_support_for_particleVirial; - // values set in kim_init() - bool kim_init_ok; - int lmps_local_tot_num_atoms; - double kim_global_influence_distance; // KIM Model cutoff value - int kim_number_of_neighbor_lists; - double const * kim_cutoff_values; - int const * modelWillNotRequestNeighborsOfNoncontributingParticles; - class NeighList ** neighborLists; + // values set in kim_init() + bool kim_init_ok; + int lmps_local_tot_num_atoms; + double kim_global_influence_distance; // KIM Model cutoff value + int kim_number_of_neighbor_lists; + double const * kim_cutoff_values; + int const * modelWillNotRequestNeighborsOfNoncontributingParticles; + class NeighList ** neighborLists; - // values set in init_style() - bool kim_particle_codes_ok; - int *kim_particle_codes; + // values set in init_style() + bool kim_particle_codes_ok; + int *kim_particle_codes; - // values set in compute() - int lmps_maxalloc; // max allocated memory value - int* kim_particleSpecies; // array of KIM particle species - int* kim_particleContributing; // array of KIM particle contributing - int* lmps_stripped_neigh_list; // neighbors of one atom, used when LAMMPS - // is in molecular mode - int** lmps_stripped_neigh_ptr; // pointer into lists + // values set in compute() + int lmps_maxalloc; // max allocated memory value + int* kim_particleSpecies; // array of KIM particle species + int* kim_particleContributing; // array of KIM particle contributing + int* lmps_stripped_neigh_list; // neighbors of one atom, used when LAMMPS + // is in molecular mode + int** lmps_stripped_neigh_ptr; // pointer into lists - // KIM specific helper functions - virtual void set_contributing(); - virtual void kim_init(); - virtual void kim_free(); - 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, - int const numberOfCutoffs, double const * const cutoffs, - int const neighborListIndex, int const particleNumber, - int * const numberOfNeighbors, - int const ** const neighborsOfParticle); - }; + // 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(); + virtual void kim_free(); + 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, + int const numberOfCutoffs, double const * const cutoffs, + int const neighborListIndex, int const particleNumber, + int * const numberOfNeighbors, + int const ** const neighborsOfParticle); +}; } #endif From 32379d2d840a7b5421823ba1f01aed68028d5c6b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 18 May 2019 21:07:15 -0400 Subject: [PATCH 003/107] add JSON tokenizer to utils library --- src/utils.cpp | 376 +++++++++++++++++++++++++++++++++++++++++++++++++- src/utils.h | 2 + 2 files changed, 376 insertions(+), 2 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index c3c173a73f..77ff8ef749 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -12,6 +12,8 @@ ------------------------------------------------------------------------- */ #include +#include +#include #include "utils.h" #include "error.h" @@ -46,9 +48,68 @@ extern "C" { - /** Match text against a (simplified) regular expression - * (regexp will be compiled automatically). */ +/** Match text against a (simplified) regular expression + * (regexp will be compiled automatically). */ static int re_match(const char *text, const char *pattern); + +/** + * JSON type identifier. Basic types are: + * o Object + * o Array + * o String + * o Other primitive: number, boolean (true/false) or null + */ + typedef enum { + JSMN_UNDEFINED = 0, + JSMN_OBJECT = 1, + JSMN_ARRAY = 2, + JSMN_STRING = 3, + JSMN_PRIMITIVE = 4 + } jsmntype_t; + + enum jsmnerr { + /* Not enough tokens were provided */ + JSMN_ERROR_NOMEM = -1, + /* Invalid character inside JSON string */ + JSMN_ERROR_INVAL = -2, + /* The string is not a full JSON packet, more bytes expected */ + JSMN_ERROR_PART = -3 + }; + +/** + * JSON token description. + * type type (object, array, string etc.) + * start start position in JSON data string + * end end position in JSON data string + */ + typedef struct { + jsmntype_t type; + int start; + int end; + int size; + } jsmntok_t; + +/** + * JSON parser. Contains an array of token blocks available. Also stores + * the string being parsed now and current position in that string + */ + typedef struct { + unsigned int pos; /* offset in the JSON string */ + unsigned int toknext; /* next token to allocate */ + int toksuper; /* superior token node, e.g parent object or array */ + } jsmn_parser; + +/** + * Create JSON parser over an array of tokens + */ + static void jsmn_init(jsmn_parser *parser); + +/** + * Run JSON parser. It parses a JSON data string into and array of tokens, each describing + * a single JSON object. + */ + static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, + jsmntok_t *tokens, unsigned int num_tokens); } using namespace LAMMPS_NS; @@ -121,6 +182,72 @@ void utils::sfgets(const char *srcname, int srcline, char *s, int size, return; } + + +int utils::kim_simulator_json_parse(int argc, char **argv) +{ + FILE *fp; + jsmn_parser p; + jsmntok_t *tok; + char *buf; + size_t nbytes; + + if (argc != 2) { + printf("usage: %s \n",argv[0]); + return 1; + } + + // open JSON file + + fp = fopen(argv[1],"rb"); + if (!fp) { + perror("Error opening JSON file"); + return 2; + } + + // determine file size and allocate suitable buffer + + fseek(fp,0,SEEK_END); + long int flen = ftell(fp); + rewind(fp); + buf = new char[flen]; + nbytes = fread(buf,1,flen,fp); + fclose(fp); + + // parse once to count number of tokens + + jsmn_init(&p); + int ntok = jsmn_parse(&p,buf,nbytes,NULL,1); + if (ntok < 0) { + printf("failed to parse JSON: %d\n",ntok); + return 3; + } + + // allocate token storage and parse again + + jsmn_init(&p); + tok = new jsmntok_t[ntok]; + int retval = jsmn_parse(&p,buf,nbytes,tok,ntok); + if ((retval < 1) || (tok[0].type != JSMN_OBJECT)) { + printf("failed to parse JSON: no root object\n"); + return 4; + } + + for (int i=1; i < retval; ++i) { + printf("key: %.*s\n",tok[i].end-tok[i].start,buf+tok[i].start); + if (tok[i+1].type == JSMN_ARRAY) { + printf("value is array of size %d\n",tok[i+1].size); + i += tok[i+1].size + 1; + } else { + ++i; + } + } + + delete [] buf; + delete [] tok; + return 0; +} + /* ------------------------------------------------------------------ */ extern "C" { @@ -437,4 +564,249 @@ extern "C" { return 0; } + + +/** + * Allocates a fresh unused token from the token pool. + */ + static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, + jsmntok_t *tokens, size_t num_tokens) { + jsmntok_t *tok; + if (parser->toknext >= num_tokens) { + return NULL; + } + tok = &tokens[parser->toknext++]; + tok->start = tok->end = -1; + tok->size = 0; + return tok; + } + +/** + * Fills token type and boundaries. + */ + static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type, + int start, int end) { + token->type = type; + token->start = start; + token->end = end; + token->size = 0; + } + +/** + * Fills next available token with JSON primitive. + */ + static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, + size_t len, jsmntok_t *tokens, size_t num_tokens) { + jsmntok_t *token; + int start; + + start = parser->pos; + + for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { + switch (js[parser->pos]) { + case '\t' : case '\r' : case '\n' : case ' ' : + case ',' : case ']' : case '}' : + goto found; + } + if (js[parser->pos] < 32 || js[parser->pos] >= 127) { + parser->pos = start; + return JSMN_ERROR_INVAL; + } + } + + found: + if (tokens == NULL) { + parser->pos--; + return 0; + } + token = jsmn_alloc_token(parser, tokens, num_tokens); + if (token == NULL) { + parser->pos = start; + return JSMN_ERROR_NOMEM; + } + jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos); + parser->pos--; + return 0; + } + +/** + * Fills next token with JSON string. + */ + static int jsmn_parse_string(jsmn_parser *parser, const char *js, + size_t len, jsmntok_t *tokens, size_t num_tokens) { + jsmntok_t *token; + + int start = parser->pos; + + parser->pos++; + + /* Skip starting quote */ + for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { + char c = js[parser->pos]; + + /* Quote: end of string */ + if (c == '\"') { + if (tokens == NULL) { + return 0; + } + token = jsmn_alloc_token(parser, tokens, num_tokens); + if (token == NULL) { + parser->pos = start; + return JSMN_ERROR_NOMEM; + } + jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos); + return 0; + } + + /* Backslash: Quoted symbol expected */ + if (c == '\\' && parser->pos + 1 < len) { + int i; + parser->pos++; + switch (js[parser->pos]) { + /* Allowed escaped symbols */ + case '\"': case '/' : case '\\' : case 'b' : + case 'f' : case 'r' : case 'n' : case 't' : + break; + /* Allows escaped symbol \uXXXX */ + case 'u': + parser->pos++; + for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) { + /* If it isn't a hex character we have an error */ + if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ + (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ + (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ + parser->pos = start; + return JSMN_ERROR_INVAL; + } + parser->pos++; + } + parser->pos--; + break; + /* Unexpected symbol */ + default: + parser->pos = start; + return JSMN_ERROR_INVAL; + } + } + } + parser->pos = start; + return JSMN_ERROR_PART; + } + +/** + * Parse JSON string and fill tokens. + */ + int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, + jsmntok_t *tokens, unsigned int num_tokens) { + int r; + int i; + jsmntok_t *token; + int count = parser->toknext; + + for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { + char c; + jsmntype_t type; + + c = js[parser->pos]; + switch (c) { + case '{': case '[': + count++; + if (tokens == NULL) { + break; + } + token = jsmn_alloc_token(parser, tokens, num_tokens); + if (token == NULL) + return JSMN_ERROR_NOMEM; + if (parser->toksuper != -1) { + tokens[parser->toksuper].size++; + } + token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY); + token->start = parser->pos; + parser->toksuper = parser->toknext - 1; + break; + case '}': case ']': + if (tokens == NULL) + break; + type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY); + for (i = parser->toknext - 1; i >= 0; i--) { + token = &tokens[i]; + if (token->start != -1 && token->end == -1) { + if (token->type != type) { + return JSMN_ERROR_INVAL; + } + parser->toksuper = -1; + token->end = parser->pos + 1; + break; + } + } + /* Error if unmatched closing bracket */ + if (i == -1) return JSMN_ERROR_INVAL; + for (; i >= 0; i--) { + token = &tokens[i]; + if (token->start != -1 && token->end == -1) { + parser->toksuper = i; + break; + } + } + break; + case '\"': + r = jsmn_parse_string(parser, js, len, tokens, num_tokens); + if (r < 0) return r; + count++; + if (parser->toksuper != -1 && tokens != NULL) + tokens[parser->toksuper].size++; + break; + case '\t' : case '\r' : case '\n' : case ' ': + break; + case ':': + parser->toksuper = parser->toknext - 1; + break; + case ',': + if (tokens != NULL && parser->toksuper != -1 && + tokens[parser->toksuper].type != JSMN_ARRAY && + tokens[parser->toksuper].type != JSMN_OBJECT) { + for (i = parser->toknext - 1; i >= 0; i--) { + if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) { + if (tokens[i].start != -1 && tokens[i].end == -1) { + parser->toksuper = i; + break; + } + } + } + } + break; + /* In non-strict mode every unquoted value is a primitive */ + default: + r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens); + if (r < 0) return r; + count++; + if (parser->toksuper != -1 && tokens != NULL) + tokens[parser->toksuper].size++; + break; + + } + } + + if (tokens != NULL) { + for (i = parser->toknext - 1; i >= 0; i--) { + /* Unmatched opened object or array */ + if (tokens[i].start != -1 && tokens[i].end == -1) { + return JSMN_ERROR_PART; + } + } + } + + return count; + } + +/** + * Creates a new parser based over a given buffer with an array of tokens + * available. + */ + void jsmn_init(jsmn_parser *parser) { + parser->pos = 0; + parser->toknext = 0; + parser->toksuper = -1; + } } + diff --git a/src/utils.h b/src/utils.h index 2596fcd774..e908dcae81 100644 --- a/src/utils.h +++ b/src/utils.h @@ -66,6 +66,8 @@ namespace LAMMPS_NS { */ void sfgets(const char *srcname, int srcline, char *s, int size, FILE *fp, const char *filename, Error *error); + + int kim_simulator_json_parse(int argc, char **argv); } } From b779bf524afaf41e95ad4f9fb4fe7c622022825e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 19 May 2019 10:09:25 -0400 Subject: [PATCH 004/107] use KIM-API calls to query simulator model info --- src/KIM/pair_kim.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index d75d960355..fff84a1821 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -13,6 +13,7 @@ /* ---------------------------------------------------------------------- Contributing authors: Ryan S. Elliott (UMinn) + Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- @@ -61,6 +62,7 @@ #include "pair_kim.h" #include "atom.h" #include "comm.h" +#include "universe.h" #include "force.h" #include "neighbor.h" #include "neigh_list.h" @@ -132,6 +134,14 @@ PairKIM::~PairKIM() // clean up kim_modelname if (kim_modelname != 0) delete [] kim_modelname; + if (simulatorModel) { + KIM::SimulatorModel::Destroy(&simulatorModel); + + // clean up KIM interface (if necessary) + kim_free(); + return; + } + // clean up lammps atom species number to unique particle names mapping if (lmps_unique_elements) for (int i = 0; i < lmps_num_unique_elements; i++) @@ -330,9 +340,40 @@ void PairKIM::settings(int narg, char **arg) // initialize KIM Model kim_init(); - // initialize LAMMPS Simulator model + // Set up and initialize LAMMPS Simulator model + if (simulatorModel) { - printf("LAMMPS simulator model: %s\n",kim_modelname); + const std::string *sim_name, *sim_version; + simulatorModel->GetSimulatorName(&sim_name); + simulatorModel->GetSimulatorVersion(&sim_version); + + if (comm->me == 0) { + std::string mesg("Using KIM Simulator Model : "); + mesg += kim_modelname; + mesg += "\n"; + mesg += "For Simulator : "; + mesg += *sim_name + " " + *sim_version + "\n"; + mesg += "Running on : LAMMPS "; + mesg += universe->version; + mesg += "\n"; + + if (screen) fputs(mesg.c_str(),screen); + if (logfile) fputs(mesg.c_str(),logfile); + } + + if (*sim_name != "LAMMPS") + error->all(FLERR,"Incompatible KIM Simulator Model"); + + int sim_fields, sim_lines; + const std::string *sim_field, *sim_value; + simulatorModel->GetNumberOfSimulatorFields(&sim_fields); + printf("sim_fields=%d\n",sim_fields); + for (int i=0; i < sim_fields; ++i) { + simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + printf("i=%d: %s (%d)\n",i,sim_field->c_str(),sim_lines); +// for (int j=0; j < +// simulatorModel->GetSimulatorFieldLine(i, + } } } From 56cf97e4970508b42ef4842e6f0de9ecfc1a9618 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 May 2019 13:53:17 -0400 Subject: [PATCH 005/107] hard code creation of simulator model pair style for now --- src/KIM/pair_kim.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index fff84a1821..87a6d636d2 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -371,9 +371,25 @@ void PairKIM::settings(int narg, char **arg) for (int i=0; i < sim_fields; ++i) { simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); printf("i=%d: %s (%d)\n",i,sim_field->c_str(),sim_lines); -// for (int j=0; j < -// simulatorModel->GetSimulatorFieldLine(i, } + // hard code result for now: + + int dummy; + const char *simulator_style = (const char*)"tersoff/mod"; + simulator_class = force->new_pair(simulator_style,1,dummy); + if (simulator_class) { + if (comm->me == 0) { + std::string mesg("Created simulator pair style: "); + mesg += simulator_style; + mesg += "\n"; + + if (screen) fputs(mesg.c_str(),screen); + if (logfile) fputs(mesg.c_str(),logfile); + } + } else { + error->all(FLERR,"Failure to create simulator model pair style"); + } + simulator_class->settings(0,NULL); } } From 38a8c765f0974799a82cee1a185adff5f3eb06fc Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 May 2019 22:54:20 -0400 Subject: [PATCH 006/107] add support species checking --- examples/kim/in.kim.simulator-model | 6 +-- src/KIM/pair_kim.cpp | 79 +++++++++++++++++++---------- 2 files changed, 54 insertions(+), 31 deletions(-) diff --git a/examples/kim/in.kim.simulator-model b/examples/kim/in.kim.simulator-model index 32baf9d78e..109711fffc 100644 --- a/examples/kim/in.kim.simulator-model +++ b/examples/kim/in.kim.simulator-model @@ -20,16 +20,16 @@ newton off lattice fcc 4.4300 region box block 0 ${xx} 0 ${yy} 0 ${zz} -create_box 1 box +create_box 2 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 +pair_coeff * * Si Si -mass 1 39.95 +mass * 39.95 velocity all create 200.0 232345 loop geom neighbor 0.3 bin diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index 87a6d636d2..2ed9df0aed 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -344,6 +344,8 @@ void PairKIM::settings(int narg, char **arg) if (simulatorModel) { const std::string *sim_name, *sim_version; + std::string atom_type_sym_list; + simulatorModel->GetSimulatorName(&sim_name); simulatorModel->GetSimulatorVersion(&sim_version); @@ -363,33 +365,6 @@ void PairKIM::settings(int narg, char **arg) if (*sim_name != "LAMMPS") error->all(FLERR,"Incompatible KIM Simulator Model"); - - int sim_fields, sim_lines; - const std::string *sim_field, *sim_value; - simulatorModel->GetNumberOfSimulatorFields(&sim_fields); - printf("sim_fields=%d\n",sim_fields); - for (int i=0; i < sim_fields; ++i) { - simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); - printf("i=%d: %s (%d)\n",i,sim_field->c_str(),sim_lines); - } - // hard code result for now: - - int dummy; - const char *simulator_style = (const char*)"tersoff/mod"; - simulator_class = force->new_pair(simulator_style,1,dummy); - if (simulator_class) { - if (comm->me == 0) { - std::string mesg("Created simulator pair style: "); - mesg += simulator_style; - mesg += "\n"; - - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); - } - } else { - error->all(FLERR,"Failure to create simulator model pair style"); - } - simulator_class->settings(0,NULL); } } @@ -464,9 +439,57 @@ 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->AddTemplateMap("atom-type-sym-list",atom_type_sym_list); simulatorModel->CloseTemplateMap(); + int len = strlen(atom_type_sym_list.c_str())+1; + char *strbuf = new char[len]; + char *strword; + + int sim_num_species; + const std::string *sim_species; + simulatorModel->GetNumberOfSupportedSpecies(&sim_num_species); + for (int i=0; i < sim_num_species; ++i) { + simulatorModel->GetSupportedSpecies(i, &sim_species); + strcpy(strbuf,atom_type_sym_list.c_str()); + strword = strtok(strbuf," \t"); + while (strword) { + if (strcmp(sim_species->c_str(),strword) != 0) + error->all(FLERR,"Species not supported by KIM Simulator Model"); + strword = strtok(NULL," \t"); + } + } + + int sim_fields, sim_lines; + const std::string *sim_field, *sim_value; + simulatorModel->GetNumberOfSimulatorFields(&sim_fields); + if (comm->me==0) printf("sim_fields=%d\n",sim_fields); + for (int i=0; i < sim_fields; ++i) { + simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + if (comm->me==0) printf("field[%d]=%s\n",i,sim_field->c_str()); + for (int j=0; j < sim_lines; ++j) { + simulatorModel->GetSimulatorFieldLine(i,j,&sim_value); + if (comm->me==0) printf("line %d: %s\n",j,sim_value->c_str()); + } + } + // hard code result for now: + + int dummy; + const char *simulator_style = (const char*)"tersoff/mod"; + simulator_class = force->new_pair(simulator_style,1,dummy); + if (simulator_class) { + if (comm->me == 0) { + std::string mesg("Created simulator pair style: "); + mesg += simulator_style; + mesg += "\n"; + + if (screen) fputs(mesg.c_str(),screen); + if (logfile) fputs(mesg.c_str(),logfile); + } + } else { + error->all(FLERR,"Failure to create simulator model pair style"); + } + simulator_class->settings(0,NULL); error->all(FLERR,(simulatorModel->ToString()).c_str()); } else { // setup mapping between LAMMPS unique elements and KIM species codes From 92b042552e4de87631b5a6a848209a24945f2cac Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 May 2019 22:54:33 -0400 Subject: [PATCH 007/107] Revert "add JSON tokenizer to utils library" This reverts commit 32379d2d840a7b5421823ba1f01aed68028d5c6b. --- src/utils.cpp | 376 +------------------------------------------------- src/utils.h | 2 - 2 files changed, 2 insertions(+), 376 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index 77ff8ef749..c3c173a73f 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -12,8 +12,6 @@ ------------------------------------------------------------------------- */ #include -#include -#include #include "utils.h" #include "error.h" @@ -48,68 +46,9 @@ extern "C" { -/** Match text against a (simplified) regular expression - * (regexp will be compiled automatically). */ + /** Match text against a (simplified) regular expression + * (regexp will be compiled automatically). */ static int re_match(const char *text, const char *pattern); - -/** - * JSON type identifier. Basic types are: - * o Object - * o Array - * o String - * o Other primitive: number, boolean (true/false) or null - */ - typedef enum { - JSMN_UNDEFINED = 0, - JSMN_OBJECT = 1, - JSMN_ARRAY = 2, - JSMN_STRING = 3, - JSMN_PRIMITIVE = 4 - } jsmntype_t; - - enum jsmnerr { - /* Not enough tokens were provided */ - JSMN_ERROR_NOMEM = -1, - /* Invalid character inside JSON string */ - JSMN_ERROR_INVAL = -2, - /* The string is not a full JSON packet, more bytes expected */ - JSMN_ERROR_PART = -3 - }; - -/** - * JSON token description. - * type type (object, array, string etc.) - * start start position in JSON data string - * end end position in JSON data string - */ - typedef struct { - jsmntype_t type; - int start; - int end; - int size; - } jsmntok_t; - -/** - * JSON parser. Contains an array of token blocks available. Also stores - * the string being parsed now and current position in that string - */ - typedef struct { - unsigned int pos; /* offset in the JSON string */ - unsigned int toknext; /* next token to allocate */ - int toksuper; /* superior token node, e.g parent object or array */ - } jsmn_parser; - -/** - * Create JSON parser over an array of tokens - */ - static void jsmn_init(jsmn_parser *parser); - -/** - * Run JSON parser. It parses a JSON data string into and array of tokens, each describing - * a single JSON object. - */ - static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, - jsmntok_t *tokens, unsigned int num_tokens); } using namespace LAMMPS_NS; @@ -182,72 +121,6 @@ void utils::sfgets(const char *srcname, int srcline, char *s, int size, return; } - - -int utils::kim_simulator_json_parse(int argc, char **argv) -{ - FILE *fp; - jsmn_parser p; - jsmntok_t *tok; - char *buf; - size_t nbytes; - - if (argc != 2) { - printf("usage: %s \n",argv[0]); - return 1; - } - - // open JSON file - - fp = fopen(argv[1],"rb"); - if (!fp) { - perror("Error opening JSON file"); - return 2; - } - - // determine file size and allocate suitable buffer - - fseek(fp,0,SEEK_END); - long int flen = ftell(fp); - rewind(fp); - buf = new char[flen]; - nbytes = fread(buf,1,flen,fp); - fclose(fp); - - // parse once to count number of tokens - - jsmn_init(&p); - int ntok = jsmn_parse(&p,buf,nbytes,NULL,1); - if (ntok < 0) { - printf("failed to parse JSON: %d\n",ntok); - return 3; - } - - // allocate token storage and parse again - - jsmn_init(&p); - tok = new jsmntok_t[ntok]; - int retval = jsmn_parse(&p,buf,nbytes,tok,ntok); - if ((retval < 1) || (tok[0].type != JSMN_OBJECT)) { - printf("failed to parse JSON: no root object\n"); - return 4; - } - - for (int i=1; i < retval; ++i) { - printf("key: %.*s\n",tok[i].end-tok[i].start,buf+tok[i].start); - if (tok[i+1].type == JSMN_ARRAY) { - printf("value is array of size %d\n",tok[i+1].size); - i += tok[i+1].size + 1; - } else { - ++i; - } - } - - delete [] buf; - delete [] tok; - return 0; -} - /* ------------------------------------------------------------------ */ extern "C" { @@ -564,249 +437,4 @@ extern "C" { return 0; } - - -/** - * Allocates a fresh unused token from the token pool. - */ - static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, - jsmntok_t *tokens, size_t num_tokens) { - jsmntok_t *tok; - if (parser->toknext >= num_tokens) { - return NULL; - } - tok = &tokens[parser->toknext++]; - tok->start = tok->end = -1; - tok->size = 0; - return tok; - } - -/** - * Fills token type and boundaries. - */ - static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type, - int start, int end) { - token->type = type; - token->start = start; - token->end = end; - token->size = 0; - } - -/** - * Fills next available token with JSON primitive. - */ - static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, - size_t len, jsmntok_t *tokens, size_t num_tokens) { - jsmntok_t *token; - int start; - - start = parser->pos; - - for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { - switch (js[parser->pos]) { - case '\t' : case '\r' : case '\n' : case ' ' : - case ',' : case ']' : case '}' : - goto found; - } - if (js[parser->pos] < 32 || js[parser->pos] >= 127) { - parser->pos = start; - return JSMN_ERROR_INVAL; - } - } - - found: - if (tokens == NULL) { - parser->pos--; - return 0; - } - token = jsmn_alloc_token(parser, tokens, num_tokens); - if (token == NULL) { - parser->pos = start; - return JSMN_ERROR_NOMEM; - } - jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos); - parser->pos--; - return 0; - } - -/** - * Fills next token with JSON string. - */ - static int jsmn_parse_string(jsmn_parser *parser, const char *js, - size_t len, jsmntok_t *tokens, size_t num_tokens) { - jsmntok_t *token; - - int start = parser->pos; - - parser->pos++; - - /* Skip starting quote */ - for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { - char c = js[parser->pos]; - - /* Quote: end of string */ - if (c == '\"') { - if (tokens == NULL) { - return 0; - } - token = jsmn_alloc_token(parser, tokens, num_tokens); - if (token == NULL) { - parser->pos = start; - return JSMN_ERROR_NOMEM; - } - jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos); - return 0; - } - - /* Backslash: Quoted symbol expected */ - if (c == '\\' && parser->pos + 1 < len) { - int i; - parser->pos++; - switch (js[parser->pos]) { - /* Allowed escaped symbols */ - case '\"': case '/' : case '\\' : case 'b' : - case 'f' : case 'r' : case 'n' : case 't' : - break; - /* Allows escaped symbol \uXXXX */ - case 'u': - parser->pos++; - for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) { - /* If it isn't a hex character we have an error */ - if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ - (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ - (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ - parser->pos = start; - return JSMN_ERROR_INVAL; - } - parser->pos++; - } - parser->pos--; - break; - /* Unexpected symbol */ - default: - parser->pos = start; - return JSMN_ERROR_INVAL; - } - } - } - parser->pos = start; - return JSMN_ERROR_PART; - } - -/** - * Parse JSON string and fill tokens. - */ - int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, - jsmntok_t *tokens, unsigned int num_tokens) { - int r; - int i; - jsmntok_t *token; - int count = parser->toknext; - - for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { - char c; - jsmntype_t type; - - c = js[parser->pos]; - switch (c) { - case '{': case '[': - count++; - if (tokens == NULL) { - break; - } - token = jsmn_alloc_token(parser, tokens, num_tokens); - if (token == NULL) - return JSMN_ERROR_NOMEM; - if (parser->toksuper != -1) { - tokens[parser->toksuper].size++; - } - token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY); - token->start = parser->pos; - parser->toksuper = parser->toknext - 1; - break; - case '}': case ']': - if (tokens == NULL) - break; - type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY); - for (i = parser->toknext - 1; i >= 0; i--) { - token = &tokens[i]; - if (token->start != -1 && token->end == -1) { - if (token->type != type) { - return JSMN_ERROR_INVAL; - } - parser->toksuper = -1; - token->end = parser->pos + 1; - break; - } - } - /* Error if unmatched closing bracket */ - if (i == -1) return JSMN_ERROR_INVAL; - for (; i >= 0; i--) { - token = &tokens[i]; - if (token->start != -1 && token->end == -1) { - parser->toksuper = i; - break; - } - } - break; - case '\"': - r = jsmn_parse_string(parser, js, len, tokens, num_tokens); - if (r < 0) return r; - count++; - if (parser->toksuper != -1 && tokens != NULL) - tokens[parser->toksuper].size++; - break; - case '\t' : case '\r' : case '\n' : case ' ': - break; - case ':': - parser->toksuper = parser->toknext - 1; - break; - case ',': - if (tokens != NULL && parser->toksuper != -1 && - tokens[parser->toksuper].type != JSMN_ARRAY && - tokens[parser->toksuper].type != JSMN_OBJECT) { - for (i = parser->toknext - 1; i >= 0; i--) { - if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) { - if (tokens[i].start != -1 && tokens[i].end == -1) { - parser->toksuper = i; - break; - } - } - } - } - break; - /* In non-strict mode every unquoted value is a primitive */ - default: - r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens); - if (r < 0) return r; - count++; - if (parser->toksuper != -1 && tokens != NULL) - tokens[parser->toksuper].size++; - break; - - } - } - - if (tokens != NULL) { - for (i = parser->toknext - 1; i >= 0; i--) { - /* Unmatched opened object or array */ - if (tokens[i].start != -1 && tokens[i].end == -1) { - return JSMN_ERROR_PART; - } - } - } - - return count; - } - -/** - * Creates a new parser based over a given buffer with an array of tokens - * available. - */ - void jsmn_init(jsmn_parser *parser) { - parser->pos = 0; - parser->toknext = 0; - parser->toksuper = -1; - } } - diff --git a/src/utils.h b/src/utils.h index e908dcae81..2596fcd774 100644 --- a/src/utils.h +++ b/src/utils.h @@ -66,8 +66,6 @@ namespace LAMMPS_NS { */ void sfgets(const char *srcname, int srcline, char *s, int size, FILE *fp, const char *filename, Error *error); - - int kim_simulator_json_parse(int argc, char **argv); } } From 1e2ceb88daa631e50d68d79c581193a8bd52bdad Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 21 May 2019 15:57:14 -0400 Subject: [PATCH 008/107] complete basic simulator model proxy class creation and setup. --- src/KIM/pair_kim.cpp | 120 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 97 insertions(+), 23 deletions(-) diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index 2ed9df0aed..626b7ccb1c 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -64,6 +64,7 @@ #include "comm.h" #include "universe.h" #include "force.h" +#include "input.h" #include "neighbor.h" #include "neigh_list.h" #include "neigh_request.h" @@ -71,6 +72,7 @@ #include "memory.h" #include "domain.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -136,6 +138,7 @@ PairKIM::~PairKIM() if (simulatorModel) { KIM::SimulatorModel::Destroy(&simulatorModel); + delete simulator_class; // clean up KIM interface (if necessary) kim_free(); @@ -446,6 +449,8 @@ void PairKIM::coeff(int narg, char **arg) char *strbuf = new char[len]; char *strword; + // validate species selection + int sim_num_species; const std::string *sim_species; simulatorModel->GetNumberOfSupportedSpecies(&sim_num_species); @@ -454,7 +459,7 @@ void PairKIM::coeff(int narg, char **arg) strcpy(strbuf,atom_type_sym_list.c_str()); strword = strtok(strbuf," \t"); while (strword) { - if (strcmp(sim_species->c_str(),strword) != 0) + if ((strcmp(strword,"NULL") != 0) && (strcmp(sim_species->c_str(),strword) != 0)) error->all(FLERR,"Species not supported by KIM Simulator Model"); strword = strtok(NULL," \t"); } @@ -463,33 +468,102 @@ void PairKIM::coeff(int narg, char **arg) int sim_fields, sim_lines; const std::string *sim_field, *sim_value; simulatorModel->GetNumberOfSimulatorFields(&sim_fields); - if (comm->me==0) printf("sim_fields=%d\n",sim_fields); for (int i=0; i < sim_fields; ++i) { simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); - if (comm->me==0) printf("field[%d]=%s\n",i,sim_field->c_str()); + if (*sim_field == "units") { + simulatorModel->GetSimulatorFieldLine(i,0,&sim_value); + if (*sim_value != update->unit_style) + error->all(FLERR,"Incompatible units for KIM Simulator Model"); + break; + } + } + + for (int i=0; i < sim_fields; ++i) { + simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + if (*sim_field == "model-init") { + for (int j=0; j < sim_lines; ++j) { + simulatorModel->GetSimulatorFieldLine(i,j,&sim_value); + input->one(sim_value->c_str()); + } + break; + } + } + + int sim_model_idx=-1; + for (int i=0; i < sim_fields; ++i) { + simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + if (*sim_field == "model-defn") { + sim_model_idx = i; + break; + } + } + + if (sim_model_idx < 0) + error->all(FLERR,"KIM Simulator Model has no Model definition"); + else { for (int j=0; j < sim_lines; ++j) { - simulatorModel->GetSimulatorFieldLine(i,j,&sim_value); - if (comm->me==0) printf("line %d: %s\n",j,sim_value->c_str()); + simulatorModel->GetSimulatorFieldLine(sim_model_idx,j,&sim_value); + if (utils::strmatch(*sim_value,"^pair_style")) { + char *ptr,*sim_style; + char *style_args[64]; + int style_narg = 0; + int len = strlen(sim_value->c_str())+1; + char *stylecmd = new char[len]; + strcpy(stylecmd,sim_value->c_str()); + + // ignore first word (pair_style) + strtok(stylecmd," \t"); + ptr = sim_style = strtok(NULL," \t"); + while (ptr && (style_narg < 63)) { + ptr = strtok(NULL," \t"); + if (!ptr) break; + style_args[style_narg] = ptr; + ++style_narg; + } + + int dummy; + delete simulator_class; + simulator_class = force->new_pair(sim_style,1,dummy); + if (simulator_class) { + if (comm->me == 0) { + std::string mesg("Created KIM Simulator Model pair style: "); + mesg += sim_style; + mesg += "\n"; + + if (screen) fputs(mesg.c_str(),screen); + if (logfile) fputs(mesg.c_str(),logfile); + } + } else { + error->all(FLERR,"Failure to create simulator model pair style"); + } + simulator_class->settings(style_narg,style_args); + delete[] stylecmd; + } + } + for (int j=0; j < sim_lines; ++j) { + simulatorModel->GetSimulatorFieldLine(sim_model_idx,j,&sim_value); + if (utils::strmatch(*sim_value,"^pair_coeff")) { + char *ptr; + char *coeff_args[64]; + int coeff_narg = 0; + int len = strlen(sim_value->c_str())+1; + char *coeffcmd = new char[len]; + strcpy(coeffcmd,sim_value->c_str()); + + // ignore first word (pair_coeff) + strtok(coeffcmd," \t"); + ptr = strtok(NULL," \t"); + while (ptr && (coeff_narg < 63)) { + coeff_args[coeff_narg] = ptr; + ++coeff_narg; + ptr = strtok(NULL," \t"); + } + + simulator_class->coeff(coeff_narg,coeff_args); + delete[] coeffcmd; + } } } - // hard code result for now: - - int dummy; - const char *simulator_style = (const char*)"tersoff/mod"; - simulator_class = force->new_pair(simulator_style,1,dummy); - if (simulator_class) { - if (comm->me == 0) { - std::string mesg("Created simulator pair style: "); - mesg += simulator_style; - mesg += "\n"; - - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); - } - } else { - error->all(FLERR,"Failure to create simulator model pair style"); - } - simulator_class->settings(0,NULL); error->all(FLERR,(simulatorModel->ToString()).c_str()); } else { // setup mapping between LAMMPS unique elements and KIM species codes From ce46d52c8a9ab27383d797fc29c9108f4ed59ccd Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 May 2019 10:23:26 -0400 Subject: [PATCH 009/107] add new 'kim_style' command as front end for KIM simulator (and regular) models --- examples/kim/in.kim.simulator-model | 4 +- src/KIM/fix_store_kim.cpp | 127 ++++++++++++ src/KIM/fix_store_kim.h | 98 ++++++++++ src/KIM/kim_query.cpp | 1 - src/KIM/kim_style.cpp | 286 ++++++++++++++++++++++++++++ src/KIM/kim_style.h | 87 +++++++++ src/modify.cpp | 2 +- 7 files changed, 600 insertions(+), 5 deletions(-) create mode 100644 src/KIM/fix_store_kim.cpp create mode 100644 src/KIM/fix_store_kim.h create mode 100644 src/KIM/kim_style.cpp create mode 100644 src/KIM/kim_style.h diff --git a/examples/kim/in.kim.simulator-model b/examples/kim/in.kim.simulator-model index 109711fffc..1e6e9dec89 100644 --- a/examples/kim/in.kim.simulator-model +++ b/examples/kim/in.kim.simulator-model @@ -16,7 +16,6 @@ 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} @@ -26,8 +25,7 @@ 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 * * Si Si +kim_style define ex_sim_model_Si_mod_tersoff Si Si mass * 39.95 velocity all create 200.0 232345 loop geom diff --git a/src/KIM/fix_store_kim.cpp b/src/KIM/fix_store_kim.cpp new file mode 100644 index 0000000000..8e9946c20d --- /dev/null +++ b/src/KIM/fix_store_kim.cpp @@ -0,0 +1,127 @@ +/* ---------------------------------------------------------------------- + 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: Axel Kohlmeyer (Temple U), + Ryan S. Elliott (UMN) +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, see . + + Linking LAMMPS statically or dynamically with other modules is making a + combined work based on LAMMPS. Thus, the terms and conditions of the GNU + General Public License cover the whole combination. + + In addition, as a special exception, the copyright holders of LAMMPS give + you permission to combine LAMMPS with free software programs or libraries + that are released under the GNU LGPL and with code included in the standard + release of the "kim-api" under the CDDL (or modified versions of such code, + with unchanged license). You may copy and distribute such a system following + the terms of the GNU GPL for LAMMPS and the licenses of the other code + concerned, provided that you include the source code of that other code + when and as the GNU GPL requires distribution of source code. + + Note that people who make modified versions of LAMMPS are not obligated to + grant this special exception for their modified versions; it is their choice + whether to do so. The GNU General Public License gives permission to release + a modified version without this exception; this exception also makes it + possible to release a modified version which carries forward this exception. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Designed for use with the kim-api-2.0.2 (and newer) package +------------------------------------------------------------------------- */ + +#include +#include "fix_store_kim.h" +#include "KIM_SimulatorModel.hpp" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace FixConst; + +/* ---------------------------------------------------------------------- */ + +FixStoreKIM::FixStoreKIM(LAMMPS *lmp, int narg, char **arg) + : Fix(lmp, narg, arg), simulator_model(NULL), model_name(NULL) +{ + if (narg != 3) error->all(FLERR,"Illegal fix STORE/KIM command"); +} + +/* ---------------------------------------------------------------------- */ + +FixStoreKIM::~FixStoreKIM() +{ + // free associated storage + + if (simulator_model) { + KIM::SimulatorModel *sm = (KIM::SimulatorModel *)simulator_model; + KIM::SimulatorModel::Destroy(&sm); + simulator_model = NULL; + } + + if (model_name) { + char *mn = (char *)model_name; + delete[] mn; + model_name = NULL; + } +} + +/* ---------------------------------------------------------------------- */ + +int FixStoreKIM::setmask() +{ + int mask = 0; + return mask; +} + + +/* ---------------------------------------------------------------------- */ + +void FixStoreKIM::setptr(const char *name, void *ptr) +{ + if (strcmp(name,"simulator_model") == 0) { + if (simulator_model) { + KIM::SimulatorModel *sm = (KIM::SimulatorModel *)simulator_model; + KIM::SimulatorModel::Destroy(&sm); + } + simulator_model = ptr; + } else if (strcmp(name,"model_name") == 0) { + if (model_name) { + char *mn = (char *)model_name; + delete[] mn; + } + model_name = ptr; + } +} + +/* ---------------------------------------------------------------------- */ + +void *FixStoreKIM::getptr(const char *name) +{ + if (strcmp(name,"simulator_model") == 0) return simulator_model; + else if (strcmp(name,"model_name") == 0) return model_name; + else return NULL; +} diff --git a/src/KIM/fix_store_kim.h b/src/KIM/fix_store_kim.h new file mode 100644 index 0000000000..04081fd6dc --- /dev/null +++ b/src/KIM/fix_store_kim.h @@ -0,0 +1,98 @@ +/* -*- 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: Axel Kohlmeyer (Temple U), + Ryan S. Elliott (UMN) +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, see . + + Linking LAMMPS statically or dynamically with other modules is making a + combined work based on LAMMPS. Thus, the terms and conditions of the GNU + General Public License cover the whole combination. + + In addition, as a special exception, the copyright holders of LAMMPS give + you permission to combine LAMMPS with free software programs or libraries + that are released under the GNU LGPL and with code included in the standard + release of the "kim-api" under the CDDL (or modified versions of such code, + with unchanged license). You may copy and distribute such a system following + the terms of the GNU GPL for LAMMPS and the licenses of the other code + concerned, provided that you include the source code of that other code + when and as the GNU GPL requires distribution of source code. + + Note that people who make modified versions of LAMMPS are not obligated to + grant this special exception for their modified versions; it is their choice + whether to do so. The GNU General Public License gives permission to release + a modified version without this exception; this exception also makes it + possible to release a modified version which carries forward this exception. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Designed for use with the kim-api-2.0.2 (and newer) package +------------------------------------------------------------------------- */ + +#ifdef FIX_CLASS + +FixStyle(STORE/KIM,FixStoreKIM) + +#else + +#ifndef LMP_FIX_STORE_KIM_H +#define LMP_FIX_STORE_KIM_H + +#include +#include "fix.h" + +namespace LAMMPS_NS { + +class FixStoreKIM : public Fix { + public: + FixStoreKIM(class LAMMPS *, int, char **); + ~FixStoreKIM(); + int setmask(); + + void setptr(const char *, void *); + void *getptr(const char *); + + private: + void *simulator_model; // pointer to KIM simulator model class + void *model_name; // string of KIM model name +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +*/ diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index fedc976110..e4818abc94 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -11,7 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- Contributing authors: Axel Kohlmeyer (Temple U), Ryan S. Elliott (UMN) diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp new file mode 100644 index 0000000000..865f6827ab --- /dev/null +++ b/src/KIM/kim_style.cpp @@ -0,0 +1,286 @@ +/* ---------------------------------------------------------------------- + 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: Axel Kohlmeyer (Temple U), + Ryan S. Elliott (UMN) +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, see . + + Linking LAMMPS statically or dynamically with other modules is making a + combined work based on LAMMPS. Thus, the terms and conditions of the GNU + General Public License cover the whole combination. + + In addition, as a special exception, the copyright holders of LAMMPS give + you permission to combine LAMMPS with free software programs or libraries + that are released under the GNU LGPL and with code included in the standard + release of the "kim-api" under the CDDL (or modified versions of such code, + with unchanged license). You may copy and distribute such a system following + the terms of the GNU GPL for LAMMPS and the licenses of the other code + concerned, provided that you include the source code of that other code + when and as the GNU GPL requires distribution of source code. + + Note that people who make modified versions of LAMMPS are not obligated to + grant this special exception for their modified versions; it is their choice + whether to do so. The GNU General Public License gives permission to release + a modified version without this exception; this exception also makes it + possible to release a modified version which carries forward this exception. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Designed for use with the kim-api-2.0.2 (and newer) package +------------------------------------------------------------------------- */ + +#include +#include +#include "kim_style.h" +#include "error.h" +#include "atom.h" +#include "comm.h" +#include "domain.h" +#include "modify.h" +#include "update.h" +#include "universe.h" +#include "input.h" +#include "fix_store_kim.h" + +#include "KIM_SimulatorModel.hpp" + + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +void KimStyle::command(int narg, char **arg) +{ + if (narg < 2) error->all(FLERR,"Illegal kim_style command"); + + if (strcmp(arg[0],"init") == 0) { + if (narg > 2) error->all(FLERR,"Illegal kim_style init command"); + if (domain->box_exist) + error->all(FLERR,"Must use 'kim_style init' command before " + "simulation box is defined"); + int len = strlen(arg[1])+1; + char *model = new char[len]; + strcpy(model,arg[1]); + do_init(model); + } else if (strcmp(arg[0],"define") == 0) { + if (!domain->box_exist) + error->all(FLERR,"Must use 'kim_style define' command after " + "simulation box is defined"); + do_defn(narg-1,arg+1); + } else error->all(FLERR,"Illegal kim_style command"); +} + + +/* ---------------------------------------------------------------------- */ + +void KimStyle::do_init(char *model) +{ + // create storage proxy fix. delete existing fix, if needed. + + int ifix = modify->find_fix("KIM_MODEL_STORE"); + if (ifix >= 0) modify->delete_fix(ifix); + input->one("fix KIM_MODEL_STORE all STORE/KIM"); + ifix = modify->find_fix("KIM_MODEL_STORE"); + + FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; + fix_store->setptr("model_name", (void *) model); + + int kimerror; + KIM::SimulatorModel * simulatorModel; + kimerror = KIM::SimulatorModel::Create(model,&simulatorModel); + + // not a Kim Simulator Model; nothing else to do here. + if (kimerror) return; + + fix_store->setptr("simulator_model", (void *) simulatorModel); + + // need to call this to have access to (some) simulator model init data. + simulatorModel->CloseTemplateMap(); + + int sim_fields, sim_lines; + const std::string *sim_field, *sim_value; + simulatorModel->GetNumberOfSimulatorFields(&sim_fields); + + // set units + for (int i=0; i < sim_fields; ++i) { + simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + if (*sim_field == "units") { + simulatorModel->GetSimulatorFieldLine(i,0,&sim_value); + std::string cmd("units "); + cmd += *sim_value; + input->one(cmd.c_str()); + break; + } + } + + // init model + for (int i=0; i < sim_fields; ++i) { + simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + if (*sim_field == "model-init") { + for (int j=0; j < sim_lines; ++j) { + simulatorModel->GetSimulatorFieldLine(i,j,&sim_value); + input->one(sim_value->c_str()); + } + break; + } + } + + // reset template map. + simulatorModel->ClearTemplateMap(); +} + +/* ---------------------------------------------------------------------- */ + +void KimStyle::do_defn(int narg, char **arg) +{ + if (narg != atom->ntypes + 1) + error->all(FLERR,"Incorrect number of arguments for kim_style define command"); + + char *model = arg[0]; + KIM::SimulatorModel *simulatorModel(NULL); + int kimerror; + + // check if we had a kim_style init command by finding fix STORE/KIM + // retrieve model name and pointer to simulator model class instance. + // validate model name if not given as NULL. + // if kim_style init wasn't run try to initialize simulator model now. + + int ifix = modify->find_fix("KIM_MODEL_STORE"); + if (ifix >= 0) { + FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; + if (strcmp(model,"NULL") == 0) + model = (char *)fix_store->getptr("model_name"); + else if (strcmp(model,(const char*)fix_store->getptr("model_name")) != 0) + error->all(FLERR,"Inconsistent KIM model name"); + + simulatorModel = (KIM::SimulatorModel *)fix_store->getptr("simulator_model"); + } else { + + kimerror = KIM::SimulatorModel::Create(model,&simulatorModel); + if (kimerror) simulatorModel = NULL; + } + + if (simulatorModel) { + + const std::string *sim_name, *sim_version; + std::string atom_type_sym_list; + + simulatorModel->GetSimulatorName(&sim_name); + simulatorModel->GetSimulatorVersion(&sim_version); + + if (comm->me == 0) { + std::string mesg("Using KIM Simulator Model : "); + mesg += model; + mesg += "\n"; + mesg += "For Simulator : "; + mesg += *sim_name + " " + *sim_version + "\n"; + mesg += "Running on : LAMMPS "; + mesg += universe->version; + mesg += "\n"; + + if (screen) fputs(mesg.c_str(),screen); + if (logfile) fputs(mesg.c_str(),logfile); + } + + if (*sim_name != "LAMMPS") + error->all(FLERR,"Incompatible KIM Simulator Model"); + + for (int i = 1; i < narg; i++) + atom_type_sym_list += std::string(" ") + arg[i]; + + simulatorModel->AddTemplateMap("atom-type-sym-list",atom_type_sym_list); + simulatorModel->CloseTemplateMap(); + + int len = strlen(atom_type_sym_list.c_str())+1; + char *strbuf = new char[len]; + char *strword; + + // validate species selection + + int sim_num_species; + const std::string *sim_species; + simulatorModel->GetNumberOfSupportedSpecies(&sim_num_species); + for (int i=0; i < sim_num_species; ++i) { + simulatorModel->GetSupportedSpecies(i, &sim_species); + strcpy(strbuf,atom_type_sym_list.c_str()); + strword = strtok(strbuf," \t"); + while (strword) { + if ((strcmp(strword,"NULL") != 0) && (strcmp(sim_species->c_str(),strword) != 0)) + error->all(FLERR,"Species not supported by KIM Simulator Model"); + strword = strtok(NULL," \t"); + } + } + delete[] strbuf; + + int sim_fields, sim_lines; + const std::string *sim_field, *sim_value; + simulatorModel->GetNumberOfSimulatorFields(&sim_fields); + for (int i=0; i < sim_fields; ++i) { + simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + if (*sim_field == "units") { + simulatorModel->GetSimulatorFieldLine(i,0,&sim_value); + if (*sim_value != update->unit_style) + error->all(FLERR,"Incompatible units for KIM Simulator Model"); + break; + } + } + + int sim_model_idx=-1; + for (int i=0; i < sim_fields; ++i) { + simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + if (*sim_field == "model-defn") { + sim_model_idx = i; + for (int j=0; j < sim_lines; ++j) { + simulatorModel->GetSimulatorFieldLine(sim_model_idx,j,&sim_value); + input->one(sim_value->c_str()); + } + } + } + + if (sim_model_idx < 0) + error->all(FLERR,"KIM Simulator Model has no Model definition"); + + } else { + + // not a simulator model. issue pair_style and pair_coeff commands. + // NOTE: all references to arg must appear before calls to input->one() + // as that will reset the argument vector. + + std::string cmd1("pair_style kim "); + cmd1 += model; + + std::string cmd2("pair_coeff * * "); + for (int i=1; i < narg; ++i) { + cmd2 += arg[i]; + cmd2 += " "; + } + + input->one(cmd1.c_str()); + input->one(cmd2.c_str()); + } +} diff --git a/src/KIM/kim_style.h b/src/KIM/kim_style.h new file mode 100644 index 0000000000..588de6e620 --- /dev/null +++ b/src/KIM/kim_style.h @@ -0,0 +1,87 @@ +/* -*- 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: Axel Kohlmeyer (Temple U), + Ryan S. Elliott (UMN) +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, see . + + Linking LAMMPS statically or dynamically with other modules is making a + combined work based on LAMMPS. Thus, the terms and conditions of the GNU + General Public License cover the whole combination. + + In addition, as a special exception, the copyright holders of LAMMPS give + you permission to combine LAMMPS with free software programs or libraries + that are released under the GNU LGPL and with code included in the standard + release of the "kim-api" under the CDDL (or modified versions of such code, + with unchanged license). You may copy and distribute such a system following + the terms of the GNU GPL for LAMMPS and the licenses of the other code + concerned, provided that you include the source code of that other code + when and as the GNU GPL requires distribution of source code. + + Note that people who make modified versions of LAMMPS are not obligated to + grant this special exception for their modified versions; it is their choice + whether to do so. The GNU General Public License gives permission to release + a modified version without this exception; this exception also makes it + possible to release a modified version which carries forward this exception. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Designed for use with the kim-api-2.0.2 (and newer) package +------------------------------------------------------------------------- */ + +#ifdef COMMAND_CLASS + +CommandStyle(kim_style,KimStyle) + +#else + +#ifndef LMP_KIM_STYLE_H +#define LMP_KIM_STYLE_H + +#include "pointers.h" + +namespace LAMMPS_NS { + +class KimStyle : protected Pointers { + public: + KimStyle(class LAMMPS *lmp) : Pointers(lmp) {}; + void command(int, char **); + private: + void do_init(char *); + void do_defn(int, char **); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + + +*/ diff --git a/src/modify.cpp b/src/modify.cpp index 7f43f035d2..9f0457c9d0 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -793,7 +793,7 @@ void Modify::add_fix(int narg, char **arg, int trysuffix) const char *exceptions[] = {"GPU", "OMP", "INTEL", "property/atom", "cmap", "cmap3", "rx", - "deprecated", NULL}; + "deprecated", "STORE/KIM", NULL}; if (domain->box_exist == 0) { int m; From b91b3c18cffff347ca58f2d5cdef7052adf5875b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 May 2019 11:52:38 -0400 Subject: [PATCH 010/107] remove references to simulator models from pair style kim --- src/KIM/pair_kim.cpp | 269 ++++++------------------------------------- src/KIM/pair_kim.h | 13 +-- 2 files changed, 41 insertions(+), 241 deletions(-) diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index 626b7ccb1c..6251ebb6c7 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -92,7 +92,6 @@ 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), @@ -110,9 +109,7 @@ PairKIM::PairKIM(LAMMPS *lmp) : kim_particleSpecies(NULL), kim_particleContributing(NULL), lmps_stripped_neigh_list(NULL), - lmps_stripped_neigh_ptr(NULL), - simulator_class(NULL), - simulator_style(NULL) + lmps_stripped_neigh_ptr(NULL) { // Initialize Pair data members to appropriate values single_enable = 0; // We do not provide the Single() function @@ -136,15 +133,6 @@ PairKIM::~PairKIM() // clean up kim_modelname if (kim_modelname != 0) delete [] kim_modelname; - if (simulatorModel) { - KIM::SimulatorModel::Destroy(&simulatorModel); - delete simulator_class; - - // clean up KIM interface (if necessary) - kim_free(); - return; - } - // clean up lammps atom species number to unique particle names mapping if (lmps_unique_elements) for (int i = 0; i < lmps_num_unique_elements; i++) @@ -342,33 +330,6 @@ void PairKIM::settings(int narg, char **arg) // initialize KIM Model kim_init(); - - // Set up and initialize LAMMPS Simulator model - - if (simulatorModel) { - const std::string *sim_name, *sim_version; - std::string atom_type_sym_list; - - simulatorModel->GetSimulatorName(&sim_name); - simulatorModel->GetSimulatorVersion(&sim_version); - - if (comm->me == 0) { - std::string mesg("Using KIM Simulator Model : "); - mesg += kim_modelname; - mesg += "\n"; - mesg += "For Simulator : "; - mesg += *sim_name + " " + *sim_version + "\n"; - mesg += "Running on : LAMMPS "; - mesg += universe->version; - mesg += "\n"; - - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); - } - - if (*sim_name != "LAMMPS") - error->all(FLERR,"Incompatible KIM Simulator Model"); - } } /* ---------------------------------------------------------------------- @@ -441,154 +402,29 @@ 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(); + // setup mapping between LAMMPS unique elements and KIM species codes + if (kim_particle_codes_ok) { + delete [] kim_particle_codes; + kim_particle_codes = NULL; + kim_particle_codes_ok = false; + } + kim_particle_codes = new int[lmps_num_unique_elements]; + kim_particle_codes_ok = true; - int len = strlen(atom_type_sym_list.c_str())+1; - char *strbuf = new char[len]; - char *strword; - - // validate species selection - - int sim_num_species; - const std::string *sim_species; - simulatorModel->GetNumberOfSupportedSpecies(&sim_num_species); - for (int i=0; i < sim_num_species; ++i) { - simulatorModel->GetSupportedSpecies(i, &sim_species); - strcpy(strbuf,atom_type_sym_list.c_str()); - strword = strtok(strbuf," \t"); - while (strword) { - if ((strcmp(strword,"NULL") != 0) && (strcmp(sim_species->c_str(),strword) != 0)) - error->all(FLERR,"Species not supported by KIM Simulator Model"); - strword = strtok(NULL," \t"); - } - } - - int sim_fields, sim_lines; - const std::string *sim_field, *sim_value; - simulatorModel->GetNumberOfSimulatorFields(&sim_fields); - for (int i=0; i < sim_fields; ++i) { - simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); - if (*sim_field == "units") { - simulatorModel->GetSimulatorFieldLine(i,0,&sim_value); - if (*sim_value != update->unit_style) - error->all(FLERR,"Incompatible units for KIM Simulator Model"); - break; - } - } - - for (int i=0; i < sim_fields; ++i) { - simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); - if (*sim_field == "model-init") { - for (int j=0; j < sim_lines; ++j) { - simulatorModel->GetSimulatorFieldLine(i,j,&sim_value); - input->one(sim_value->c_str()); - } - break; - } - } - - int sim_model_idx=-1; - for (int i=0; i < sim_fields; ++i) { - simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); - if (*sim_field == "model-defn") { - sim_model_idx = i; - break; - } - } - - if (sim_model_idx < 0) - error->all(FLERR,"KIM Simulator Model has no Model definition"); - else { - for (int j=0; j < sim_lines; ++j) { - simulatorModel->GetSimulatorFieldLine(sim_model_idx,j,&sim_value); - if (utils::strmatch(*sim_value,"^pair_style")) { - char *ptr,*sim_style; - char *style_args[64]; - int style_narg = 0; - int len = strlen(sim_value->c_str())+1; - char *stylecmd = new char[len]; - strcpy(stylecmd,sim_value->c_str()); - - // ignore first word (pair_style) - strtok(stylecmd," \t"); - ptr = sim_style = strtok(NULL," \t"); - while (ptr && (style_narg < 63)) { - ptr = strtok(NULL," \t"); - if (!ptr) break; - style_args[style_narg] = ptr; - ++style_narg; - } - - int dummy; - delete simulator_class; - simulator_class = force->new_pair(sim_style,1,dummy); - if (simulator_class) { - if (comm->me == 0) { - std::string mesg("Created KIM Simulator Model pair style: "); - mesg += sim_style; - mesg += "\n"; - - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); - } - } else { - error->all(FLERR,"Failure to create simulator model pair style"); - } - simulator_class->settings(style_narg,style_args); - delete[] stylecmd; - } - } - for (int j=0; j < sim_lines; ++j) { - simulatorModel->GetSimulatorFieldLine(sim_model_idx,j,&sim_value); - if (utils::strmatch(*sim_value,"^pair_coeff")) { - char *ptr; - char *coeff_args[64]; - int coeff_narg = 0; - int len = strlen(sim_value->c_str())+1; - char *coeffcmd = new char[len]; - strcpy(coeffcmd,sim_value->c_str()); - - // ignore first word (pair_coeff) - strtok(coeffcmd," \t"); - ptr = strtok(NULL," \t"); - while (ptr && (coeff_narg < 63)) { - coeff_args[coeff_narg] = ptr; - ++coeff_narg; - ptr = strtok(NULL," \t"); - } - - simulator_class->coeff(coeff_narg,coeff_args); - delete[] coeffcmd; - } - } - } - error->all(FLERR,(simulatorModel->ToString()).c_str()); - } else { - // setup mapping between LAMMPS unique elements and KIM species codes - if (kim_particle_codes_ok) { - delete [] kim_particle_codes; - kim_particle_codes = NULL; - kim_particle_codes_ok = false; - } - kim_particle_codes = new int[lmps_num_unique_elements]; - kim_particle_codes_ok = true; - for(int i = 0; i < lmps_num_unique_elements; i++) { - int supported; - int code; - KIM_Model_GetSpeciesSupportAndCode( - pkim, - KIM_SpeciesName_FromString(lmps_unique_elements[i]), - &supported, - &code); - if (supported) { - kim_particle_codes[i] = code; - } else { - std::string msg("create_kim_particle_codes: symbol not found: "); - msg += lmps_unique_elements[i]; - error->all(FLERR, msg.c_str()); - } + for(int i = 0; i < lmps_num_unique_elements; i++) { + int supported; + int code; + KIM_Model_GetSpeciesSupportAndCode( + pkim, + KIM_SpeciesName_FromString(lmps_unique_elements[i]), + &supported, + &code); + if (supported) { + kim_particle_codes[i] = code; + } else { + std::string msg("create_kim_particle_codes: symbol not found: "); + msg += lmps_unique_elements[i]; + error->all(FLERR, msg.c_str()); } } } @@ -799,32 +635,6 @@ 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 ------------------------------------------------------------------------- */ @@ -902,26 +712,21 @@ void PairKIM::kim_init() kim_modelname, &requestedUnitsAccepted, &pkim); + if (kimerror) error->all(FLERR,"KIM ModelCreate failed"); + 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) { - 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"); - - // 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) { - KIM_Model_Destroy(&pkim); - error->all(FLERR,"KIM ComputeArgumentsCreate failed"); - } else kim_init_ok = true; - } + KIM_Model_Destroy(&pkim); + error->all(FLERR,"KIM ComputeArgumentsCreate failed"); + } else kim_init_ok = true; // determine KIM Model capabilities (used in this function below) set_kim_model_has_flags(); diff --git a/src/KIM/pair_kim.h b/src/KIM/pair_kim.h index 37a6be1e5b..aa33b9b271 100644 --- a/src/KIM/pair_kim.h +++ b/src/KIM/pair_kim.h @@ -69,7 +69,6 @@ class KIM_API_model; extern "C" { #include "KIM_SimulatorHeaders.h" } -#include "KIM_SimulatorModel.hpp" namespace LAMMPS_NS { @@ -121,7 +120,6 @@ class PairKIM : public Pair { KIM_TemperatureUnit temperatureUnit; KIM_TimeUnit timeUnit; - KIM::SimulatorModel * simulatorModel; KIM_Model * pkim; KIM_ComputeArguments * pargs; @@ -152,12 +150,6 @@ class PairKIM : public Pair { // 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(); @@ -191,7 +183,10 @@ The KIM model was unable, for some reason, to complete the computation. E: 'KIMvirial' or 'LAMMPSvirial' not supported with kim-api. -"KIMvirial or "LAMMPSvirial" found on the pair_style line. These keys are not supported kim-api. (The virial computation is always performed by LAMMPS.) Please remove these keys, make sure the KIM model you are using supports kim-api, and rerun. +"KIMvirial or "LAMMPSvirial" found on the pair_style line. These keys +are not supported kim-api. (The virial computation is always performed +by LAMMPS.) Please remove these keys, make sure the KIM model you are +using supports kim-api, and rerun. E: Illegal pair_style command From fc8a639d585c7325eb08e2044a274a3b514043d8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 May 2019 19:39:15 -0400 Subject: [PATCH 011/107] add documentation for kim_style command. update a few KIM related doc files --- doc/src/Commands_all.txt | 1 + doc/src/Packages_details.txt | 11 +++-- doc/src/commands_list.txt | 1 + doc/src/kim_query.txt | 3 +- doc/src/kim_style.txt | 81 ++++++++++++++++++++++++++++++++++++ doc/src/lammps.book | 1 + doc/src/pair_kim.txt | 3 +- src/KIM/README | 6 +-- 8 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 doc/src/kim_style.txt diff --git a/doc/src/Commands_all.txt b/doc/src/Commands_all.txt index 52c2e67e2e..d76ffac14c 100644 --- a/doc/src/Commands_all.txt +++ b/doc/src/Commands_all.txt @@ -69,6 +69,7 @@ An alphabetic list of all general LAMMPS commands. "include"_include.html, "jump"_jump.html, "kim_query"_kim_query.html, +"kim_style"_kim_style.html, "kspace_modify"_kspace_modify.html, "kspace_style"_kspace_style.html, "label"_label.html, diff --git a/doc/src/Packages_details.txt b/doc/src/Packages_details.txt index 352a38af84..19c7e96fe9 100644 --- a/doc/src/Packages_details.txt +++ b/doc/src/Packages_details.txt @@ -342,7 +342,10 @@ A "pair_style kim"_pair_kim.html command which is a wrapper on the Knowledge Base for Interatomic Models (KIM) repository of interatomic potentials, enabling any of them to be used in LAMMPS simulations. Also a "kim_query"_kim_query.html command, which allows to query -the OpenKIM database for stored properties. +the OpenKIM database for stored properties, and a +"kim_style"_kim_style.html command, which serves as a front end to +generating LAMMPS input on-the-fly for KIM simulator models and native +KIM models. To use this package you must have the KIM library available on your system. @@ -352,8 +355,10 @@ https://openkim.org. The KIM project is led by Ellad Tadmor and Ryan Elliott (U Minnesota). [Authors:] Ryan Elliott (U Minnesota) is the main developer for the KIM -API which the "pair_style kim"_pair_kim.html command uses. He -developed the pair style. +API which the "pair_style kim"_pair_kim.html command uses. He developed +the pair style. Axel Kohlmeyer (Temple U) contributed the +"kim_query"_kim_query.html and "kim_style"_kim_style.html commands in +close collaboration with Ryan. [Install:] diff --git a/doc/src/commands_list.txt b/doc/src/commands_list.txt index cf716df9ac..39d2f7c7d0 100644 --- a/doc/src/commands_list.txt +++ b/doc/src/commands_list.txt @@ -54,6 +54,7 @@ Commands :h1 info jump kim_query + kim_style kspace_modify kspace_style label diff --git a/doc/src/kim_query.txt b/doc/src/kim_query.txt index c581de0ebb..84eca6e676 100644 --- a/doc/src/kim_query.txt +++ b/doc/src/kim_query.txt @@ -43,4 +43,5 @@ See the "Build package"_Build_package.html doc page for more info. [Related commands:] -"pair_style kim"_pair_kim.html, "variable"_variable.html +"pair_style kim"_pair_kim.html, "kim_style"_kim_style.html, +"variable"_variable.html diff --git a/doc/src/kim_style.txt b/doc/src/kim_style.txt new file mode 100644 index 0000000000..ab605c017a --- /dev/null +++ b/doc/src/kim_style.txt @@ -0,0 +1,81 @@ +"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c + +:link(lws,http://lammps.sandia.gov) +:link(ld,Manual.html) +:link(lc,Commands_all.html) + +:line + +kim_style command :h3 + +[Syntax:] + +kim_style mode model args :pre + +mode = {init} or {define} +model = name of the KIM model (potential or simulator model) or NULL +args = atom type to species mapping ({define} option only, one entry per atom type) :ul + +[Examples:] + +kim_style init ex_sim_model_Si_mod_tersoff +kim_style define NULL Si Si +kim_style define LennardJones_Ar Ar :pre + +[Description:] + +The kim_style command is a high-level wrapper around the +"Knowledge Base for Interatomic Models (OpenKIM)"_https://openkim.org +repository of interatomic potentials, so that they can be used by +LAMMPS scripts. It does not implement any computations directly, but +rather will generate LAMMPS input commands based on the information +retrieved from the OpenKIM repository. It is primarily meant to realize +so-called "KIM Simulator Models", which are OpenKIM repository entries +of models using native features of the simulation engine, i.e. LAMMPS +in this case, but it also supports realizing conventional KIM models +via the "pair_style kim"_pair_kim.html command. + +The kim_style command has two modes, {init} and {define}, indicated by +the first argument to the kim_style command. An {init} mode command +must be issued [before] the simulation box is created, while the {define} +mode version may only be used [after] the simulation box exists. The +{init} mode version is only required, if the KIM model requires it. +The second argument to the kim_style command is the KIM model ID. It +can be set to NULL in the kim_style define command, if it was already +set in a kim_style init command. Otherwise, the two model IDs must match. + +Only the kim_style define command allows additional arguments. Those +are used to map the atom types in LAMMPS to the available species in +the KIM model. This is equivalent to the arguments following +"pair_coeff * *" in a "kim"_pair_kim.html pair style. Thus the command + +kim_style define LennardJones_Ar Ar :pre + +will generate the LAMMPS input commands: + +pair_style kim LennardJones_Ar +pair_coeff * * Ar :pre + +For simulator models, the generated input commands may be more complex +and require that LAMMPS is built with the required packages included. +The commands generated by the kim_style command, can be copied to the +screen or log file, through the "echo"_echo.html command. +The kim_style command will also validate, that the selected simulator +model was generated for the LAMMPS MD code and not some other software. +In addition, the version strings for LAMMPS version used for defining +the simulator model and the LAMMPS version being currently run are +printed, so that it can be tracked down, if there are any incompatible +changes to input script or command syntax between the two LAMMPS versions. + +[Restrictions:] + +This command is part of the KIM package. It is only enabled if +LAMMPS was built with that package. Furthermore, its correct +functioning depends on compiling LAMMPS with all required packages +installed that are required by the commands embedded in any KIM +simulator models used. +See the "Build package"_Build_package.html doc page for more info. + +[Related commands:] + +"pair_style kim"_pair_kim.html, "kim_query"_kim_query.html diff --git a/doc/src/lammps.book b/doc/src/lammps.book index 500690597d..cedb6ea709 100644 --- a/doc/src/lammps.book +++ b/doc/src/lammps.book @@ -168,6 +168,7 @@ include.html info.html jump.html kim_query.html +kim_style.html label.html lattice.html log.html diff --git a/doc/src/pair_kim.txt b/doc/src/pair_kim.txt index a415ac606b..523bd89d7c 100644 --- a/doc/src/pair_kim.txt +++ b/doc/src/pair_kim.txt @@ -112,6 +112,7 @@ kim-api package version 2.0.0 and higher. [Related commands:] -"pair_coeff"_pair_coeff.html +"pair_coeff"_pair_coeff.html, "kim_style"_kim_style.html, +"kim_query"_kim_query.html [Default:] none diff --git a/src/KIM/README b/src/KIM/README index a69206596f..4f52d69a67 100644 --- a/src/KIM/README +++ b/src/KIM/README @@ -13,8 +13,8 @@ Using this package requires the KIM library and its models system. The library can be downloaded and built in lib/kim or elsewhere on your system, which must be done before bulding LAMMPS with this package. Details of the download, build, and install -process for KIM are given in the lib/kim/README file, and scripts will -soon be provided to help automate the process. Also see the LAMMPS +process for KIM are given in the lib/kim/README file, and scripts +are provided to help automate the process. Also see the LAMMPS manual for general information on building LAMMPS with external libraries. The settings in the Makefile.lammps file in lib/kim must be correct for LAMMPS to build correctly with this package installed. @@ -24,6 +24,6 @@ Makefile.lammps file usually will not need to be changed. Once you have successfully built LAMMPS with this package and the KIM library you can test it using an input file from the examples dir: -./lmp_serial < lammps/examples/kim/in.kim.lj +./lmp_serial -in lammps/examples/kim/in.kim.lj This pair_style was written by Ryan S. Elliott (U Minn). From ee5fa04732588646047111488bd5f4fec2870772 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 May 2019 22:41:28 -0400 Subject: [PATCH 012/107] create internal fix via modify->add_fix() so it does not get logged --- src/KIM/kim_style.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp index 865f6827ab..53bf2958b3 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_style.cpp @@ -104,7 +104,11 @@ void KimStyle::do_init(char *model) int ifix = modify->find_fix("KIM_MODEL_STORE"); if (ifix >= 0) modify->delete_fix(ifix); - input->one("fix KIM_MODEL_STORE all STORE/KIM"); + char *fixarg[3]; + fixarg[0] = (char *)"KIM_MODEL_STORE"; + fixarg[1] = (char *)"all"; + fixarg[2] = (char *)"STORE/KIM"; + modify->add_fix(3,fixarg); ifix = modify->find_fix("KIM_MODEL_STORE"); FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; From 5a929aff6ed77043341a396ecf30b25d14add523 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 May 2019 22:42:40 -0400 Subject: [PATCH 013/107] error out if kim_style init is required but wasn't called --- src/KIM/kim_style.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp index 53bf2958b3..d906d56041 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_style.cpp @@ -240,17 +240,27 @@ void KimStyle::do_defn(int narg, char **arg) } } delete[] strbuf; - + + // check if units are unchanged, and if kim_style init was required + int sim_fields, sim_lines; const std::string *sim_field, *sim_value; simulatorModel->GetNumberOfSimulatorFields(&sim_fields); for (int i=0; i < sim_fields; ++i) { simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + if (*sim_field == "units") { simulatorModel->GetSimulatorFieldLine(i,0,&sim_value); if (*sim_value != update->unit_style) error->all(FLERR,"Incompatible units for KIM Simulator Model"); - break; + } + + if ((ifix < 0) && ( *sim_field == "model-init")) { + for (int j=0; j < sim_lines; ++j) { + simulatorModel->GetSimulatorFieldLine(i,j,&sim_value); + if (*sim_value != "") + error->all(FLERR,"Must use 'kim_style init' with this model"); + } } } From c3897212e2fe7531c6cd37d0165b2c7a419f54da Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 May 2019 22:44:03 -0400 Subject: [PATCH 014/107] must call ClearTemplateMap(), so kim_style define may be called multiple times --- src/KIM/kim_style.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp index d906d56041..323832fbad 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_style.cpp @@ -279,6 +279,7 @@ void KimStyle::do_defn(int narg, char **arg) if (sim_model_idx < 0) error->all(FLERR,"KIM Simulator Model has no Model definition"); + simulatorModel->ClearTemplateMap(); } else { // not a simulator model. issue pair_style and pair_coeff commands. From 264f6e1630e3d4730953c9ca4b169a5631de3d34 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 May 2019 22:44:41 -0400 Subject: [PATCH 015/107] whitespace cleanup --- src/KIM/kim_style.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp index 323832fbad..e8aee77b66 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_style.cpp @@ -113,17 +113,19 @@ void KimStyle::do_init(char *model) FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; fix_store->setptr("model_name", (void *) model); - + int kimerror; KIM::SimulatorModel * simulatorModel; kimerror = KIM::SimulatorModel::Create(model,&simulatorModel); // not a Kim Simulator Model; nothing else to do here. + if (kimerror) return; fix_store->setptr("simulator_model", (void *) simulatorModel); // need to call this to have access to (some) simulator model init data. + simulatorModel->CloseTemplateMap(); int sim_fields, sim_lines; @@ -131,6 +133,7 @@ void KimStyle::do_init(char *model) simulatorModel->GetNumberOfSimulatorFields(&sim_fields); // set units + for (int i=0; i < sim_fields; ++i) { simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); if (*sim_field == "units") { @@ -143,6 +146,7 @@ void KimStyle::do_init(char *model) } // init model + for (int i=0; i < sim_fields; ++i) { simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); if (*sim_field == "model-init") { @@ -155,6 +159,7 @@ void KimStyle::do_init(char *model) } // reset template map. + simulatorModel->ClearTemplateMap(); } @@ -281,7 +286,7 @@ void KimStyle::do_defn(int narg, char **arg) simulatorModel->ClearTemplateMap(); } else { - + // not a simulator model. issue pair_style and pair_coeff commands. // NOTE: all references to arg must appear before calls to input->one() // as that will reset the argument vector. From 4619018eadc0f9e23bc347d5df53b745a15b60d0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 27 May 2019 23:26:26 -0400 Subject: [PATCH 016/107] provide more simulator model variant input examples --- examples/kim/data.VOH | 118 ++++++++++++++++++ examples/kim/in.kim.VOH.simulator.model | 24 ++++ examples/kim/in.kim.ex_si_1.simulator_model | 69 ++++++++++ examples/kim/in.kim.ex_si_2.simulator_model | 69 ++++++++++ ...ulator-model => in.kim.lj.simulator-model} | 7 +- 5 files changed, 284 insertions(+), 3 deletions(-) create mode 100644 examples/kim/data.VOH create mode 100644 examples/kim/in.kim.VOH.simulator.model create mode 100644 examples/kim/in.kim.ex_si_1.simulator_model create mode 100644 examples/kim/in.kim.ex_si_2.simulator_model rename examples/kim/{in.kim.simulator-model => in.kim.lj.simulator-model} (88%) diff --git a/examples/kim/data.VOH b/examples/kim/data.VOH new file mode 100644 index 0000000000..c093705adc --- /dev/null +++ b/examples/kim/data.VOH @@ -0,0 +1,118 @@ +# VOH example + +100 atoms +4 atom types + +0 25.000 xlo xhi +0 25.000 ylo yhi +0 25.000 zlo zhi + +Masses + +1 1.0080 +2 12.0107 +3 15.9994 +4 50.9415 + +Atoms + + 1 2 0.0 12.35333 12.56112 11.08925 + 2 4 0.0 12.32916 12.62071 13.13099 + 3 3 0.0 14.09425 12.56218 13.76130 + 4 3 0.0 11.42814 11.10330 13.76732 + 5 3 0.0 11.63260 13.89286 13.64097 + 6 1 0.0 10.61647 11.29221 14.30535 + 7 1 0.0 14.38026 13.34626 14.29055 + 8 1 0.0 11.32479 12.58820 10.70253 + 9 1 0.0 12.90918 13.42567 10.69612 + 10 1 0.0 12.84043 11.63643 10.74688 + 11 2 0.0 0.93670 23.74637 24.45218 + 12 4 0.0 2.18151 24.36876 0.94725 + 13 3 0.0 3.93452 24.44779 0.28384 + 14 3 0.0 2.13668 23.10529 2.33362 + 15 3 0.0 1.76108 0.74666 1.48323 + 16 1 0.0 1.82070 23.45305 3.20745 + 17 1 0.0 4.35555 0.34186 0.31083 + 18 1 0.0 24.90472 23.68735 24.82586 + 19 1 0.0 0.97611 24.45631 23.61244 + 20 1 0.0 1.24583 22.75250 24.09589 + 21 2 0.0 2.25730 12.18969 18.74792 + 22 4 0.0 0.67140 13.31162 19.37385 + 23 3 0.0 0.71106 13.43250 21.24545 + 24 3 0.0 24.08603 12.44025 18.87949 + 25 3 0.0 0.70486 14.71920 18.75808 + 26 1 0.0 23.49516 12.95430 18.26686 + 27 1 0.0 0.79723 14.34808 21.60818 + 28 1 0.0 2.24383 12.10285 17.65239 + 29 1 0.0 3.19860 12.66607 19.06030 + 30 1 0.0 2.20214 11.18299 19.18774 + 31 2 0.0 9.32237 8.16220 23.74501 + 32 4 0.0 9.41775 7.26178 21.91463 + 33 3 0.0 8.54752 8.34565 20.65588 + 34 3 0.0 8.50942 5.62151 22.00137 + 35 3 0.0 10.87539 7.02683 21.48455 + 36 1 0.0 9.06507 4.82324 21.80615 + 37 1 0.0 9.11458 8.67119 19.91477 + 38 1 0.0 9.82196 7.53487 24.49616 + 39 1 0.0 9.81855 9.14254 23.70532 + 40 1 0.0 8.27176 8.30387 24.03831 + 41 2 0.0 9.10113 13.98748 23.44281 + 42 4 0.0 8.84954 12.89163 21.73780 + 43 3 0.0 10.01387 13.54293 20.42005 + 44 3 0.0 7.08992 13.11522 21.12954 + 45 3 0.0 9.12937 11.39982 21.99065 + 46 1 0.0 6.55309 12.28287 21.08224 + 47 1 0.0 10.67858 12.89258 20.08249 + 48 1 0.0 8.42108 13.62252 24.22498 + 49 1 0.0 10.13926 13.89766 23.79639 + 50 1 0.0 8.88118 15.04646 23.24289 + 51 2 0.0 17.73225 3.40708 8.28945 + 52 4 0.0 18.49877 5.29835 8.37599 + 53 3 0.0 19.48472 5.62627 6.81505 + 54 3 0.0 19.66498 5.40961 9.84118 + 55 3 0.0 17.38120 6.34466 8.51889 + 56 1 0.0 19.41208 6.07779 10.52927 + 57 1 0.0 19.15960 6.37609 6.25924 + 58 1 0.0 17.15579 3.19557 9.20103 + 59 1 0.0 17.07197 3.31049 7.41454 + 60 1 0.0 18.54903 2.67524 8.20436 + 61 2 0.0 5.18346 20.97409 24.28840 + 62 4 0.0 7.06396 20.17968 24.34847 + 63 3 0.0 7.63220 19.82889 22.59578 + 64 3 0.0 7.00272 18.55243 0.28036 + 65 3 0.0 8.05085 21.13715 0.03620 + 66 1 0.0 7.56109 18.51690 1.09952 + 67 1 0.0 8.44257 20.31624 22.30833 + 68 1 0.0 4.83239 21.17976 0.30904 + 69 1 0.0 5.19182 21.91237 23.71419 + 70 1 0.0 4.49282 20.26573 23.80772 + 71 2 0.0 21.82701 12.79861 20.63056 + 72 4 0.0 21.27646 11.09990 19.63611 + 73 3 0.0 19.52930 10.64327 20.13923 + 74 3 0.0 22.41924 9.70346 20.14638 + 75 3 0.0 21.34556 11.30206 18.11274 + 76 1 0.0 22.94464 9.30084 19.40876 + 77 1 0.0 18.86743 10.62817 19.40629 + 78 1 0.0 22.85378 13.07853 20.35349 + 79 1 0.0 21.14666 13.62206 20.37063 + 80 1 0.0 21.78702 12.62668 21.71522 + 81 2 0.0 4.84801 10.63893 5.85720 + 82 4 0.0 2.99668 11.06158 5.10490 + 83 3 0.0 3.09505 11.09458 3.23258 + 84 3 0.0 2.48053 12.76555 5.69567 + 85 3 0.0 1.96195 10.01780 5.55634 + 86 1 0.0 1.65323 12.78746 6.24245 + 87 1 0.0 2.52753 10.43264 2.76734 + 88 1 0.0 4.80984 10.62196 6.95551 + 89 1 0.0 5.18492 9.65688 5.49273 + 90 1 0.0 5.56737 11.40648 5.53568 + 91 2 0.0 13.58126 9.47098 19.40329 + 92 4 0.0 14.17691 10.17243 21.22692 + 93 3 0.0 14.44428 12.02521 21.10583 + 94 3 0.0 15.81206 9.37183 21.67632 + 95 3 0.0 13.12907 9.86545 22.30960 + 96 1 0.0 15.80034 8.83149 22.50703 + 97 1 0.0 13.87232 12.57457 21.69672 + 98 1 0.0 13.42563 8.38456 19.45392 + 99 1 0.0 12.63978 9.95672 19.10431 + 100 1 0.0 14.35123 9.68789 18.64825 diff --git a/examples/kim/in.kim.VOH.simulator.model b/examples/kim/in.kim.VOH.simulator.model new file mode 100644 index 0000000000..3803ceceba --- /dev/null +++ b/examples/kim/in.kim.VOH.simulator.model @@ -0,0 +1,24 @@ +# REAX potential for VOH system +# ..... + +units real +atom_style charge + +kim_style init Sim_LAMMPS_ReaxFF_ChenowethVanDuinPersson_2008_CHOV__SM_429148913211_000 + +read_data data.VOH + +kim_style define NULL H C O V + +neighbor 2 bin +neigh_modify every 10 delay 0 check no + +fix 1 all nve +fix 2 all qeq/reax 1 0.0 10.0 1e-6 param.qeq +fix 3 all temp/berendsen 500.0 500.0 100.0 + +timestep 0.25 + +#dump 1 all atom 30 dump.reax.voh + +run 300 diff --git a/examples/kim/in.kim.ex_si_1.simulator_model b/examples/kim/in.kim.ex_si_1.simulator_model new file mode 100644 index 0000000000..03f9c25a33 --- /dev/null +++ b/examples/kim/in.kim.ex_si_1.simulator_model @@ -0,0 +1,69 @@ + +units metal +kim_style init ex_sim_model_Si_mod_tersoff + +atom_style atomic +atom_modify map array +boundary p p p + +# temperatures +variable tlo equal 1800.0 +variable thi equal 2400.0 + +# coordination number cutoff + +variable r equal 2.835 + +# minimization parameters + +variable etol equal 1.0e-5 +variable ftol equal 1.0e-5 +variable maxiter equal 100 +variable maxeval equal 100 +variable dmax equal 1.0e-1 + +# diamond unit cell + +variable a equal 5.431 +lattice custom $a & + a1 1.0 0.0 0.0 & + a2 0.0 1.0 0.0 & + a3 0.0 0.0 1.0 & + basis 0.0 0.0 0.0 & + basis 0.0 0.5 0.5 & + basis 0.5 0.0 0.5 & + basis 0.5 0.5 0.0 & + basis 0.25 0.25 0.25 & + basis 0.25 0.75 0.75 & + basis 0.75 0.25 0.75 & + basis 0.75 0.75 0.25 + +region myreg block 0 4 & + 0 4 & + 0 4 +create_box 1 myreg +create_atoms 1 region myreg + +mass 1 28.06 + +group Si type 1 + +velocity all create ${thi} 5287286 mom yes rot yes dist gaussian + +# make a vacancy + +group del id 300 +delete_atoms group del +kim_style define ex_sim_model_Si_mod_tersoff Si + +thermo 10 + +fix 1 all nve +fix 2 all langevin ${thi} ${thi} 0.1 48278 + +timestep 1.0e-3 +neighbor 1.0 bin +neigh_modify every 1 delay 10 check yes + +run 100 + diff --git a/examples/kim/in.kim.ex_si_2.simulator_model b/examples/kim/in.kim.ex_si_2.simulator_model new file mode 100644 index 0000000000..18efd94222 --- /dev/null +++ b/examples/kim/in.kim.ex_si_2.simulator_model @@ -0,0 +1,69 @@ + +units metal +kim_style init ex_sim_model_Si_mod_tersoff + +atom_style atomic +atom_modify map array +boundary p p p + +# temperatures +variable tlo equal 1800.0 +variable thi equal 2400.0 + +# coordination number cutoff + +variable r equal 2.835 + +# minimization parameters + +variable etol equal 1.0e-5 +variable ftol equal 1.0e-5 +variable maxiter equal 100 +variable maxeval equal 100 +variable dmax equal 1.0e-1 + +# diamond unit cell + +variable a equal 5.431 +lattice custom $a & + a1 1.0 0.0 0.0 & + a2 0.0 1.0 0.0 & + a3 0.0 0.0 1.0 & + basis 0.0 0.0 0.0 & + basis 0.0 0.5 0.5 & + basis 0.5 0.0 0.5 & + basis 0.5 0.5 0.0 & + basis 0.25 0.25 0.25 & + basis 0.25 0.75 0.75 & + basis 0.75 0.25 0.75 & + basis 0.75 0.75 0.25 + +region myreg block 0 4 & + 0 4 & + 0 4 +create_box 1 myreg +create_atoms 1 region myreg + +mass 1 28.06 + +group Si type 1 + +velocity all create ${thi} 5287286 mom yes rot yes dist gaussian + +# make a vacancy + +group del id 300 +delete_atoms group del +kim_style define NULL Si + +thermo 10 + +fix 1 all nve +fix 2 all langevin ${thi} ${thi} 0.1 48278 + +timestep 1.0e-3 +neighbor 1.0 bin +neigh_modify every 1 delay 10 check yes + +run 100 + diff --git a/examples/kim/in.kim.simulator-model b/examples/kim/in.kim.lj.simulator-model similarity index 88% rename from examples/kim/in.kim.simulator-model rename to examples/kim/in.kim.lj.simulator-model index 1e6e9dec89..21d60a48d9 100644 --- a/examples/kim/in.kim.simulator-model +++ b/examples/kim/in.kim.lj.simulator-model @@ -16,18 +16,19 @@ variable zz equal 20*$z units metal atom_style atomic +newton on lattice fcc 4.4300 region box block 0 ${xx} 0 ${yy} 0 ${zz} -create_box 2 box +create_box 1 box create_atoms 1 box #pair_style lj/cut 8.1500 #pair_coeff 1 1 0.0104 3.4000 -kim_style define ex_sim_model_Si_mod_tersoff Si Si +kim_style define LennardJones_Ar Ar -mass * 39.95 +mass 1 39.95 velocity all create 200.0 232345 loop geom neighbor 0.3 bin From eb6287d2e8877c3b56af90b89a692c64d9a00036 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 27 May 2019 23:26:46 -0400 Subject: [PATCH 017/107] correctly check for supported species --- src/KIM/kim_style.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp index e8aee77b66..eac16f1a8a 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_style.cpp @@ -232,17 +232,26 @@ void KimStyle::do_defn(int narg, char **arg) // validate species selection int sim_num_species; + bool species_is_supported; const std::string *sim_species; simulatorModel->GetNumberOfSupportedSpecies(&sim_num_species); - for (int i=0; i < sim_num_species; ++i) { - simulatorModel->GetSupportedSpecies(i, &sim_species); - strcpy(strbuf,atom_type_sym_list.c_str()); - strword = strtok(strbuf," \t"); - while (strword) { - if ((strcmp(strword,"NULL") != 0) && (strcmp(sim_species->c_str(),strword) != 0)) - error->all(FLERR,"Species not supported by KIM Simulator Model"); - strword = strtok(NULL," \t"); + strcpy(strbuf,atom_type_sym_list.c_str()); + strword = strtok(strbuf," \t"); + while (strword) { + species_is_supported = false; + if (strcmp(strword,"NULL") == 0) continue; + for (int i=0; i < sim_num_species; ++i) { + simulatorModel->GetSupportedSpecies(i, &sim_species); + if (strcmp(sim_species->c_str(),strword) == 0) + species_is_supported = true; } + if (!species_is_supported) { + std::string msg("Species '"); + msg += strword; + msg += "' is not supported by this KIM Simulator Model"; + error->all(FLERR,msg.c_str()); + } + strword = strtok(NULL," \t"); } delete[] strbuf; From b3a01694b7312989554f24817bd94e8ccca2a83d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 27 May 2019 23:34:05 -0400 Subject: [PATCH 018/107] remove leftover fix qeq/reax command --- examples/kim/in.kim.VOH.simulator.model | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/kim/in.kim.VOH.simulator.model b/examples/kim/in.kim.VOH.simulator.model index 3803ceceba..a2dd6983c0 100644 --- a/examples/kim/in.kim.VOH.simulator.model +++ b/examples/kim/in.kim.VOH.simulator.model @@ -14,7 +14,6 @@ neighbor 2 bin neigh_modify every 10 delay 0 check no fix 1 all nve -fix 2 all qeq/reax 1 0.0 10.0 1e-6 param.qeq fix 3 all temp/berendsen 500.0 500.0 100.0 timestep 0.25 From 24a63f0f31446f5a98a32325248cced2d1c6d21a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 30 May 2019 21:51:13 -0400 Subject: [PATCH 019/107] update kim_style command semantics as discussed in PR #1440 this also adds documentation of error messages in the kim_style header --- doc/src/kim_style.txt | 50 ++++++++------ ...lator.model => in.kim.VOH.simulator_model} | 2 +- ...tor_model => in.kim.ex_si.simulator_model} | 2 +- examples/kim/in.kim.ex_si_1.simulator_model | 69 ------------------- ...ulator-model => in.kim.lj.simulator_model} | 4 +- src/KIM/kim_style.cpp | 33 +++------ src/KIM/kim_style.h | 36 ++++++++++ 7 files changed, 79 insertions(+), 117 deletions(-) rename examples/kim/{in.kim.VOH.simulator.model => in.kim.VOH.simulator_model} (92%) rename examples/kim/{in.kim.ex_si_2.simulator_model => in.kim.ex_si.simulator_model} (98%) delete mode 100644 examples/kim/in.kim.ex_si_1.simulator_model rename examples/kim/{in.kim.lj.simulator-model => in.kim.lj.simulator_model} (92%) diff --git a/doc/src/kim_style.txt b/doc/src/kim_style.txt index ab605c017a..dcdfae1cdc 100644 --- a/doc/src/kim_style.txt +++ b/doc/src/kim_style.txt @@ -10,17 +10,18 @@ kim_style command :h3 [Syntax:] -kim_style mode model args :pre +kim_style mode args :pre -mode = {init} or {define} -model = name of the KIM model (potential or simulator model) or NULL -args = atom type to species mapping ({define} option only, one entry per atom type) :ul +mode = {init model} or {define typeargs} +model = name of the KIM model (KIM potential or KIM simulator model) +typeargs = atom type to species mapping (one entry per atom type) :ul [Examples:] kim_style init ex_sim_model_Si_mod_tersoff -kim_style define NULL Si Si -kim_style define LennardJones_Ar Ar :pre +kim_style define Si Si +kim_style init LennardJones_Ar +kim_style define Ar :pre [Description:] @@ -29,27 +30,34 @@ The kim_style command is a high-level wrapper around the repository of interatomic potentials, so that they can be used by LAMMPS scripts. It does not implement any computations directly, but rather will generate LAMMPS input commands based on the information -retrieved from the OpenKIM repository. It is primarily meant to realize -so-called "KIM Simulator Models", which are OpenKIM repository entries -of models using native features of the simulation engine, i.e. LAMMPS +retrieved from the OpenKIM repository. It is able to realize so-called +"KIM Simulator Models", which are OpenKIM repository entries of models +using native features of the simulation engine in use, i.e. LAMMPS in this case, but it also supports realizing conventional KIM models -via the "pair_style kim"_pair_kim.html command. +implicitly via generating a "pair_style kim"_pair_kim.html command +followed by a suitable "pair_coeff"_pair_coeff.html command. The kim_style command has two modes, {init} and {define}, indicated by the first argument to the kim_style command. An {init} mode command must be issued [before] the simulation box is created, while the {define} -mode version may only be used [after] the simulation box exists. The -{init} mode version is only required, if the KIM model requires it. -The second argument to the kim_style command is the KIM model ID. It -can be set to NULL in the kim_style define command, if it was already -set in a kim_style init command. Otherwise, the two model IDs must match. +mode version may only be used [after] the simulation box exists. Both +are required. The {init} mode version sets the model name and may issue +additional commands changing LAMMPS default settings that are required +for using a selected simulator model. If needed, those settings can be +overridden. The second argument to the {kim_style init} command is the +KIM model ID. -Only the kim_style define command allows additional arguments. Those -are used to map the atom types in LAMMPS to the available species in -the KIM model. This is equivalent to the arguments following -"pair_coeff * *" in a "kim"_pair_kim.html pair style. Thus the command +The {kim_style define} command will issue commands that will realize +the selected model (through generating pair_style and pair_coeff commands, +but also other commands, as required). It has to be issued [after] the +the simulation box is defined. The {kim_style define} command allows a +varying numbver of additional arguments. Those are used to map the atom +types in LAMMPS to the available species in the KIM model. This is +equivalent to the arguments following "pair_coeff * *" in a +"kim"_pair_kim.html pair style. Thus the commands: -kim_style define LennardJones_Ar Ar :pre +kim_style init LennardJones_Ar +kim_style define Ar :pre will generate the LAMMPS input commands: @@ -60,7 +68,7 @@ For simulator models, the generated input commands may be more complex and require that LAMMPS is built with the required packages included. The commands generated by the kim_style command, can be copied to the screen or log file, through the "echo"_echo.html command. -The kim_style command will also validate, that the selected simulator +The kim_style command will also validate, that a selected simulator model was generated for the LAMMPS MD code and not some other software. In addition, the version strings for LAMMPS version used for defining the simulator model and the LAMMPS version being currently run are diff --git a/examples/kim/in.kim.VOH.simulator.model b/examples/kim/in.kim.VOH.simulator_model similarity index 92% rename from examples/kim/in.kim.VOH.simulator.model rename to examples/kim/in.kim.VOH.simulator_model index a2dd6983c0..8696cf265a 100644 --- a/examples/kim/in.kim.VOH.simulator.model +++ b/examples/kim/in.kim.VOH.simulator_model @@ -8,7 +8,7 @@ kim_style init Sim_LAMMPS_ReaxFF_ChenowethVanDuinPersson_2008_CHOV__SM_429148913 read_data data.VOH -kim_style define NULL H C O V +kim_style define H C O V neighbor 2 bin neigh_modify every 10 delay 0 check no diff --git a/examples/kim/in.kim.ex_si_2.simulator_model b/examples/kim/in.kim.ex_si.simulator_model similarity index 98% rename from examples/kim/in.kim.ex_si_2.simulator_model rename to examples/kim/in.kim.ex_si.simulator_model index 18efd94222..2f9e79ef4e 100644 --- a/examples/kim/in.kim.ex_si_2.simulator_model +++ b/examples/kim/in.kim.ex_si.simulator_model @@ -54,7 +54,7 @@ velocity all create ${thi} 5287286 mom yes rot yes dist gaussian group del id 300 delete_atoms group del -kim_style define NULL Si +kim_style define Si thermo 10 diff --git a/examples/kim/in.kim.ex_si_1.simulator_model b/examples/kim/in.kim.ex_si_1.simulator_model deleted file mode 100644 index 03f9c25a33..0000000000 --- a/examples/kim/in.kim.ex_si_1.simulator_model +++ /dev/null @@ -1,69 +0,0 @@ - -units metal -kim_style init ex_sim_model_Si_mod_tersoff - -atom_style atomic -atom_modify map array -boundary p p p - -# temperatures -variable tlo equal 1800.0 -variable thi equal 2400.0 - -# coordination number cutoff - -variable r equal 2.835 - -# minimization parameters - -variable etol equal 1.0e-5 -variable ftol equal 1.0e-5 -variable maxiter equal 100 -variable maxeval equal 100 -variable dmax equal 1.0e-1 - -# diamond unit cell - -variable a equal 5.431 -lattice custom $a & - a1 1.0 0.0 0.0 & - a2 0.0 1.0 0.0 & - a3 0.0 0.0 1.0 & - basis 0.0 0.0 0.0 & - basis 0.0 0.5 0.5 & - basis 0.5 0.0 0.5 & - basis 0.5 0.5 0.0 & - basis 0.25 0.25 0.25 & - basis 0.25 0.75 0.75 & - basis 0.75 0.25 0.75 & - basis 0.75 0.75 0.25 - -region myreg block 0 4 & - 0 4 & - 0 4 -create_box 1 myreg -create_atoms 1 region myreg - -mass 1 28.06 - -group Si type 1 - -velocity all create ${thi} 5287286 mom yes rot yes dist gaussian - -# make a vacancy - -group del id 300 -delete_atoms group del -kim_style define ex_sim_model_Si_mod_tersoff Si - -thermo 10 - -fix 1 all nve -fix 2 all langevin ${thi} ${thi} 0.1 48278 - -timestep 1.0e-3 -neighbor 1.0 bin -neigh_modify every 1 delay 10 check yes - -run 100 - diff --git a/examples/kim/in.kim.lj.simulator-model b/examples/kim/in.kim.lj.simulator_model similarity index 92% rename from examples/kim/in.kim.lj.simulator-model rename to examples/kim/in.kim.lj.simulator_model index 21d60a48d9..15b26c3c64 100644 --- a/examples/kim/in.kim.lj.simulator-model +++ b/examples/kim/in.kim.lj.simulator_model @@ -18,6 +18,8 @@ units metal atom_style atomic newton on +kim_style init LennardJones_Ar + lattice fcc 4.4300 region box block 0 ${xx} 0 ${yy} 0 ${zz} create_box 1 box @@ -26,7 +28,7 @@ create_atoms 1 box #pair_style lj/cut 8.1500 #pair_coeff 1 1 0.0104 3.4000 -kim_style define LennardJones_Ar Ar +kim_style define Ar mass 1 39.95 velocity all create 200.0 232345 loop geom diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp index eac16f1a8a..856fb94c9e 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_style.cpp @@ -79,7 +79,7 @@ void KimStyle::command(int narg, char **arg) if (narg < 2) error->all(FLERR,"Illegal kim_style command"); if (strcmp(arg[0],"init") == 0) { - if (narg > 2) error->all(FLERR,"Illegal kim_style init command"); + if (narg > 2) error->all(FLERR,"Illegal kim_style command"); if (domain->box_exist) error->all(FLERR,"Must use 'kim_style init' command before " "simulation box is defined"); @@ -167,10 +167,10 @@ void KimStyle::do_init(char *model) void KimStyle::do_defn(int narg, char **arg) { - if (narg != atom->ntypes + 1) - error->all(FLERR,"Incorrect number of arguments for kim_style define command"); + if (narg != atom->ntypes) + error->all(FLERR,"Illegal kim_style command"); - char *model = arg[0]; + char *model = NULL; KIM::SimulatorModel *simulatorModel(NULL); int kimerror; @@ -182,17 +182,9 @@ void KimStyle::do_defn(int narg, char **arg) int ifix = modify->find_fix("KIM_MODEL_STORE"); if (ifix >= 0) { FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; - if (strcmp(model,"NULL") == 0) - model = (char *)fix_store->getptr("model_name"); - else if (strcmp(model,(const char*)fix_store->getptr("model_name")) != 0) - error->all(FLERR,"Inconsistent KIM model name"); - + model = (char *)fix_store->getptr("model_name"); simulatorModel = (KIM::SimulatorModel *)fix_store->getptr("simulator_model"); - } else { - - kimerror = KIM::SimulatorModel::Create(model,&simulatorModel); - if (kimerror) simulatorModel = NULL; - } + } else error->all(FLERR,"Must use 'kim_style init' before 'kim_style define'"); if (simulatorModel) { @@ -219,7 +211,7 @@ void KimStyle::do_defn(int narg, char **arg) if (*sim_name != "LAMMPS") error->all(FLERR,"Incompatible KIM Simulator Model"); - for (int i = 1; i < narg; i++) + for (int i = 0; i < narg; i++) atom_type_sym_list += std::string(" ") + arg[i]; simulatorModel->AddTemplateMap("atom-type-sym-list",atom_type_sym_list); @@ -268,14 +260,6 @@ void KimStyle::do_defn(int narg, char **arg) if (*sim_value != update->unit_style) error->all(FLERR,"Incompatible units for KIM Simulator Model"); } - - if ((ifix < 0) && ( *sim_field == "model-init")) { - for (int j=0; j < sim_lines; ++j) { - simulatorModel->GetSimulatorFieldLine(i,j,&sim_value); - if (*sim_value != "") - error->all(FLERR,"Must use 'kim_style init' with this model"); - } - } } int sim_model_idx=-1; @@ -294,6 +278,7 @@ void KimStyle::do_defn(int narg, char **arg) error->all(FLERR,"KIM Simulator Model has no Model definition"); simulatorModel->ClearTemplateMap(); + } else { // not a simulator model. issue pair_style and pair_coeff commands. @@ -304,7 +289,7 @@ void KimStyle::do_defn(int narg, char **arg) cmd1 += model; std::string cmd2("pair_coeff * * "); - for (int i=1; i < narg; ++i) { + for (int i=0; i < narg; ++i) { cmd2 += arg[i]; cmd2 += " "; } diff --git a/src/KIM/kim_style.h b/src/KIM/kim_style.h index 588de6e620..eddc22eebc 100644 --- a/src/KIM/kim_style.h +++ b/src/KIM/kim_style.h @@ -83,5 +83,41 @@ class KimStyle : protected Pointers { /* ERROR/WARNING messages: +E: Illegal kim_style command + +Incorrect number or kind of arguments to kim_style + +E: Must use 'kim_style init' command before simulation box is defined + +Self-explanatory + +E: Must use 'kim_style define' command after simulation box is defined + +Self-explanatory + +E: Must use 'kim_style init' command before 'kim_style define' + +Self-explanatory + +E: Incompatible KIM Simulator Model + +The requested KIM Simulator Model was defined for a different MD code +and thus is not compatible with LAMMPS + +E: Species XXX is not supported by this KIM Simulator Model + +The kim_style define command was referencing a species that is not +present in the requested KIM Simulator Model + +E: Incompatible units for KIM Simulator Model + +The selected unit style is not compatible with the requested KIM +Simulator Model + +E: KIM Simulator Model has no Model definition + +There is no model definition (key: model-defn) in the KIM Simulator +Model. Please contact the OpenKIM database maintainers to verify +and potentially correct this. */ From c9fe5810c1c0029e42fa3ef1d1b4d6b0ea0f1c32 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 30 May 2019 21:52:23 -0400 Subject: [PATCH 020/107] add log outputs for updated kim_style command input examples --- ...og.30Apr2019.kim.VOH.simulator_model.g++.1 | 92 ++++++++++++ ....30Apr2019.kim.ex_si.simulator_model.g++.1 | 132 ++++++++++++++++++ ....30Apr2019.kim.ex_si.simulator_model.g++.4 | 132 ++++++++++++++++++ ...log.30Apr2019.kim.lj.simulator_model.g++.1 | 104 ++++++++++++++ ...log.30Apr2019.kim.lj.simulator_model.g++.4 | 104 ++++++++++++++ 5 files changed, 564 insertions(+) create mode 100644 examples/kim/log.30Apr2019.kim.VOH.simulator_model.g++.1 create mode 100644 examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.1 create mode 100644 examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.4 create mode 100644 examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.1 create mode 100644 examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.4 diff --git a/examples/kim/log.30Apr2019.kim.VOH.simulator_model.g++.1 b/examples/kim/log.30Apr2019.kim.VOH.simulator_model.g++.1 new file mode 100644 index 0000000000..e9d1f17d76 --- /dev/null +++ b/examples/kim/log.30Apr2019.kim.VOH.simulator_model.g++.1 @@ -0,0 +1,92 @@ +LAMMPS (30 Apr 2019) + using 1 OpenMP thread(s) per MPI task +# REAX potential for VOH system +# ..... + +units real +atom_style charge + +kim_style init Sim_LAMMPS_ReaxFF_ChenowethVanDuinPersson_2008_CHOV__SM_429148913211_000 +units real +atom_style charge +neigh_modify one 4000 + +read_data data.VOH + orthogonal box = (0 0 0) to (25 25 25) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 100 atoms + read_data CPU = 0.000217199 secs + +kim_style define H C O V +Using KIM Simulator Model : Sim_LAMMPS_ReaxFF_ChenowethVanDuinPersson_2008_CHOV__SM_429148913211_000 +For Simulator : LAMMPS 28-Feb-2019 +Running on : LAMMPS 30 Apr 2019 +pair_style reax/c /tmp/kim-simulator-model-parameter-file-XXXXXXFRmlac safezone 2.0 mincap 100 +pair_coeff * * /tmp/kim-simulator-model-parameter-file-XXXXXX363kge H C O V +Reading potential file /tmp/kim-simulator-model-parameter-file-XXXXXX363kge with DATE: 2011-02-18 +WARNING: Changed valency_val to valency_boc for X (src/USER-REAXC/reaxc_ffield.cpp:311) +fix reaxqeq all qeq/reax 1 0.0 10.0 1.0e-6 /tmp/kim-simulator-model-parameter-file-XXXXXXzgDl49 + +neighbor 2 bin +neigh_modify every 10 delay 0 check no + +fix 1 all nve +fix 3 all temp/berendsen 500.0 500.0 100.0 + +timestep 0.25 + +#dump 1 all atom 30 dump.reax.voh + +run 300 +Neighbor list info ... + update every 10 steps, delay 0 steps, check no + max neighbors/atom: 4000, page size: 100000 + master list distance cutoff = 12 + ghost atom cutoff = 12 + binsize = 6, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair reax/c, perpetual + attributes: half, newton off, ghost + pair build: half/bin/newtoff/ghost + stencil: half/ghost/bin/3d/newtoff + bin: standard + (2) fix qeq/reax, perpetual, copy from (1) + attributes: half, newton off, ghost + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 25.97 | 25.97 | 25.97 Mbytes +Step Temp E_pair E_mol TotEng Press + 0 0 -10246.825 0 -10246.825 42.256089 + 300 199.45773 -10218.342 0 -10159.482 -66.730725 +Loop time of 1.06721 on 1 procs for 300 steps with 100 atoms + +Performance: 6.072 ns/day, 3.953 hours/ns, 281.107 timesteps/s +98.8% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.93954 | 0.93954 | 0.93954 | 0.0 | 88.04 +Neigh | 0.029087 | 0.029087 | 0.029087 | 0.0 | 2.73 +Comm | 0.0018935 | 0.0018935 | 0.0018935 | 0.0 | 0.18 +Output | 1.8358e-05 | 1.8358e-05 | 1.8358e-05 | 0.0 | 0.00 +Modify | 0.096112 | 0.096112 | 0.096112 | 0.0 | 9.01 +Other | | 0.0005522 | | | 0.05 + +Nlocal: 100 ave 100 max 100 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 608 ave 608 max 608 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 3441 ave 3441 max 3441 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 3441 +Ave neighs/atom = 34.41 +Neighbor list builds = 30 +Dangerous builds not checked + +Please see the log.cite file for references relevant to this simulation + +Total wall time: 0:00:01 diff --git a/examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.1 b/examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.1 new file mode 100644 index 0000000000..a6d1c4a955 --- /dev/null +++ b/examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.1 @@ -0,0 +1,132 @@ +LAMMPS (30 Apr 2019) + using 1 OpenMP thread(s) per MPI task + +units metal +kim_style init ex_sim_model_Si_mod_tersoff +units metal +newton on + +atom_style atomic +atom_modify map array +boundary p p p + +# temperatures +variable tlo equal 1800.0 +variable thi equal 2400.0 + +# coordination number cutoff + +variable r equal 2.835 + +# minimization parameters + +variable etol equal 1.0e-5 +variable ftol equal 1.0e-5 +variable maxiter equal 100 +variable maxeval equal 100 +variable dmax equal 1.0e-1 + +# diamond unit cell + +variable a equal 5.431 +lattice custom $a a1 1.0 0.0 0.0 a2 0.0 1.0 0.0 a3 0.0 0.0 1.0 basis 0.0 0.0 0.0 basis 0.0 0.5 0.5 basis 0.5 0.0 0.5 basis 0.5 0.5 0.0 basis 0.25 0.25 0.25 basis 0.25 0.75 0.75 basis 0.75 0.25 0.75 basis 0.75 0.75 0.25 +lattice custom 5.431 a1 1.0 0.0 0.0 a2 0.0 1.0 0.0 a3 0.0 0.0 1.0 basis 0.0 0.0 0.0 basis 0.0 0.5 0.5 basis 0.5 0.0 0.5 basis 0.5 0.5 0.0 basis 0.25 0.25 0.25 basis 0.25 0.75 0.75 basis 0.75 0.25 0.75 basis 0.75 0.75 0.25 +Lattice spacing in x,y,z = 5.431 5.431 5.431 + +region myreg block 0 4 0 4 0 4 +create_box 1 myreg +Created orthogonal box = (0 0 0) to (21.724 21.724 21.724) + 1 by 1 by 1 MPI processor grid +create_atoms 1 region myreg +Created 512 atoms + create_atoms CPU = 0.000393867 secs + +mass 1 28.06 + +group Si type 1 +512 atoms in group Si + +velocity all create ${thi} 5287286 mom yes rot yes dist gaussian +velocity all create 2400 5287286 mom yes rot yes dist gaussian + +# make a vacancy + +group del id 300 +1 atoms in group del +delete_atoms group del +Deleted 1 atoms, new total = 511 +kim_style define Si +Using KIM Simulator Model : ex_sim_model_Si_mod_tersoff +For Simulator : LAMMPS 12-Dec-2018 +Running on : LAMMPS 30 Apr 2019 +pair_style tersoff/mod +pair_coeff * * /tmp/kim-simulator-model-parameter-file-XXXXXXVWG8uV Si +Reading potential file /tmp/kim-simulator-model-parameter-file-XXXXXXVWG8uV with DATE: 2013-07-26 + +thermo 10 + +fix 1 all nve +fix 2 all langevin ${thi} ${thi} 0.1 48278 +fix 2 all langevin 2400 ${thi} 0.1 48278 +fix 2 all langevin 2400 2400 0.1 48278 + +timestep 1.0e-3 +neighbor 1.0 bin +neigh_modify every 1 delay 10 check yes + +run 100 +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 4.3 + ghost atom cutoff = 4.3 + binsize = 2.15, bins = 11 11 11 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair tersoff/mod, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 3.11 | 3.11 | 3.11 Mbytes +Step Temp E_pair E_mol TotEng Press + 0 2397.3877 -2363.0694 0 -2205.0272 15086.224 + 10 1328.4035 -2289.1682 0 -2201.5963 29164.666 + 20 1086.1557 -2254.4447 0 -2182.8424 31906.878 + 30 1528.8439 -2270.2968 0 -2169.5113 21610.528 + 40 1345.227 -2250.3915 0 -2161.7105 22146.886 + 50 1300.3329 -2235.8593 0 -2150.1379 23557.875 + 60 1546.1664 -2241.3019 0 -2139.3744 21648.774 + 70 1662.2896 -2236.2369 0 -2126.6543 23958.738 + 80 1631.7284 -2223.45 0 -2115.8821 28842.194 + 90 1795.3629 -2225.2998 0 -2106.9447 29522.37 + 100 1830.156 -2224.3733 0 -2103.7245 28805.09 +Loop time of 0.201725 on 1 procs for 100 steps with 511 atoms + +Performance: 42.831 ns/day, 0.560 hours/ns, 495.724 timesteps/s +99.3% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.19292 | 0.19292 | 0.19292 | 0.0 | 95.63 +Neigh | 0.0037313 | 0.0037313 | 0.0037313 | 0.0 | 1.85 +Comm | 0.00074744 | 0.00074744 | 0.00074744 | 0.0 | 0.37 +Output | 0.00026727 | 0.00026727 | 0.00026727 | 0.0 | 0.13 +Modify | 0.0036564 | 0.0036564 | 0.0036564 | 0.0 | 1.81 +Other | | 0.0004075 | | | 0.20 + +Nlocal: 511 ave 511 max 511 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 970 ave 970 max 970 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 0 ave 0 max 0 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 9174 ave 9174 max 9174 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 9174 +Ave neighs/atom = 17.953 +Neighbor list builds = 4 +Dangerous builds = 0 + +Total wall time: 0:00:00 diff --git a/examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.4 b/examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.4 new file mode 100644 index 0000000000..dcb170aeb6 --- /dev/null +++ b/examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.4 @@ -0,0 +1,132 @@ +LAMMPS (30 Apr 2019) + using 1 OpenMP thread(s) per MPI task + +units metal +kim_style init ex_sim_model_Si_mod_tersoff +units metal +newton on + +atom_style atomic +atom_modify map array +boundary p p p + +# temperatures +variable tlo equal 1800.0 +variable thi equal 2400.0 + +# coordination number cutoff + +variable r equal 2.835 + +# minimization parameters + +variable etol equal 1.0e-5 +variable ftol equal 1.0e-5 +variable maxiter equal 100 +variable maxeval equal 100 +variable dmax equal 1.0e-1 + +# diamond unit cell + +variable a equal 5.431 +lattice custom $a a1 1.0 0.0 0.0 a2 0.0 1.0 0.0 a3 0.0 0.0 1.0 basis 0.0 0.0 0.0 basis 0.0 0.5 0.5 basis 0.5 0.0 0.5 basis 0.5 0.5 0.0 basis 0.25 0.25 0.25 basis 0.25 0.75 0.75 basis 0.75 0.25 0.75 basis 0.75 0.75 0.25 +lattice custom 5.431 a1 1.0 0.0 0.0 a2 0.0 1.0 0.0 a3 0.0 0.0 1.0 basis 0.0 0.0 0.0 basis 0.0 0.5 0.5 basis 0.5 0.0 0.5 basis 0.5 0.5 0.0 basis 0.25 0.25 0.25 basis 0.25 0.75 0.75 basis 0.75 0.25 0.75 basis 0.75 0.75 0.25 +Lattice spacing in x,y,z = 5.431 5.431 5.431 + +region myreg block 0 4 0 4 0 4 +create_box 1 myreg +Created orthogonal box = (0 0 0) to (21.724 21.724 21.724) + 1 by 2 by 2 MPI processor grid +create_atoms 1 region myreg +Created 512 atoms + create_atoms CPU = 0.102434 secs + +mass 1 28.06 + +group Si type 1 +512 atoms in group Si + +velocity all create ${thi} 5287286 mom yes rot yes dist gaussian +velocity all create 2400 5287286 mom yes rot yes dist gaussian + +# make a vacancy + +group del id 300 +1 atoms in group del +delete_atoms group del +Deleted 1 atoms, new total = 511 +kim_style define Si +Using KIM Simulator Model : ex_sim_model_Si_mod_tersoff +For Simulator : LAMMPS 12-Dec-2018 +Running on : LAMMPS 30 Apr 2019 +pair_style tersoff/mod +pair_coeff * * /tmp/kim-simulator-model-parameter-file-XXXXXXqDlERL Si +Reading potential file /tmp/kim-simulator-model-parameter-file-XXXXXXqDlERL with DATE: 2013-07-26 + +thermo 10 + +fix 1 all nve +fix 2 all langevin ${thi} ${thi} 0.1 48278 +fix 2 all langevin 2400 ${thi} 0.1 48278 +fix 2 all langevin 2400 2400 0.1 48278 + +timestep 1.0e-3 +neighbor 1.0 bin +neigh_modify every 1 delay 10 check yes + +run 100 +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 4.3 + ghost atom cutoff = 4.3 + binsize = 2.15, bins = 11 11 11 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair tersoff/mod, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 3.082 | 3.082 | 3.082 Mbytes +Step Temp E_pair E_mol TotEng Press + 0 2397.5824 -2363.0694 0 -2205.0143 15087.562 + 10 1298.5003 -2292.5456 0 -2206.945 28361.893 + 20 1114.7065 -2260.7006 0 -2187.2161 30574.077 + 30 1504.9472 -2271.8639 0 -2172.6537 20395.651 + 40 1357.5949 -2248.6066 0 -2159.1103 21779.773 + 50 1351.7212 -2235.0803 0 -2145.9713 23404.844 + 60 1582.4191 -2238.3233 0 -2134.006 21711.26 + 70 1654.3988 -2230.0965 0 -2121.0341 24276.504 + 80 1654.9629 -2218.6654 0 -2109.5658 27571.472 + 90 1815.7206 -2219.2065 0 -2099.5093 28475.757 + 100 1901.1544 -2216.5428 0 -2091.2137 28962.04 +Loop time of 4.36959 on 4 procs for 100 steps with 511 atoms + +Performance: 1.977 ns/day, 12.138 hours/ns, 22.885 timesteps/s +47.8% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.051784 | 0.056551 | 0.064825 | 2.1 | 1.29 +Neigh | 0.00093389 | 0.001028 | 0.0011392 | 0.3 | 0.02 +Comm | 2.8964 | 2.9342 | 3.016 | 2.8 | 67.15 +Output | 0.673 | 0.68159 | 0.69707 | 1.1 | 15.60 +Modify | 0.0011303 | 0.0029655 | 0.0081694 | 5.5 | 0.07 +Other | | 0.6933 | | | 15.87 + +Nlocal: 127.75 ave 134 max 123 min +Histogram: 1 0 0 2 0 0 0 0 0 1 +Nghost: 495 ave 498 max 489 min +Histogram: 1 0 0 0 0 0 0 1 1 1 +Neighs: 0 ave 0 max 0 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 2302 ave 2443 max 2194 min +Histogram: 1 0 0 2 0 0 0 0 0 1 + +Total # of neighbors = 9208 +Ave neighs/atom = 18.0196 +Neighbor list builds = 4 +Dangerous builds = 0 + +Total wall time: 0:00:05 diff --git a/examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.1 b/examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.1 new file mode 100644 index 0000000000..94aaf1aaef --- /dev/null +++ b/examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.1 @@ -0,0 +1,104 @@ +LAMMPS (30 Apr 2019) + using 1 OpenMP thread(s) per MPI task +# 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 xx equal 20*1 +variable yy equal 20*$y +variable yy equal 20*1 +variable zz equal 20*$z +variable zz equal 20*1 + +units metal +atom_style atomic +newton on + +kim_style init LennardJones_Ar + +lattice fcc 4.4300 +Lattice spacing in x,y,z = 4.43 4.43 4.43 +region box block 0 ${xx} 0 ${yy} 0 ${zz} +region box block 0 20 0 ${yy} 0 ${zz} +region box block 0 20 0 20 0 ${zz} +region box block 0 20 0 20 0 20 +create_box 1 box +Created orthogonal box = (0 0 0) to (88.6 88.6 88.6) + 1 by 1 by 1 MPI processor grid +create_atoms 1 box +Created 32000 atoms + create_atoms CPU = 0.00314307 secs + +#pair_style lj/cut 8.1500 +#pair_coeff 1 1 0.0104 3.4000 + +kim_style define Ar +pair_style kim LennardJones_Ar +WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:980) +WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:985) +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 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 8.45 + ghost atom cutoff = 8.45 + binsize = 4.225, bins = 21 21 21 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair kim, perpetual + attributes: full, newton off, cut 8.45 + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 28.12 | 28.12 | 28.12 Mbytes +Step Temp E_pair E_mol TotEng Press + 0 200 6290.8194 0 7118.0584 129712.25 + 100 95.179725 6718.814 0 7112.496 133346.59 +Loop time of 4.91804 on 1 procs for 100 steps with 32000 atoms + +Performance: 1.757 ns/day, 13.661 hours/ns, 20.333 timesteps/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 4.3033 | 4.3033 | 4.3033 | 0.0 | 87.50 +Neigh | 0.53176 | 0.53176 | 0.53176 | 0.0 | 10.81 +Comm | 0.024606 | 0.024606 | 0.024606 | 0.0 | 0.50 +Output | 0.00016403 | 0.00016403 | 0.00016403 | 0.0 | 0.00 +Modify | 0.038671 | 0.038671 | 0.038671 | 0.0 | 0.79 +Other | | 0.01951 | | | 0.40 + +Nlocal: 32000 ave 32000 max 32000 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 19911 ave 19911 max 19911 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 0 ave 0 max 0 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 4.25375e+06 ave 4.25375e+06 max 4.25375e+06 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 4253750 +Ave neighs/atom = 132.93 +Neighbor list builds = 3 +Dangerous builds = 0 +Total wall time: 0:00:05 diff --git a/examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.4 b/examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.4 new file mode 100644 index 0000000000..3377f22d02 --- /dev/null +++ b/examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.4 @@ -0,0 +1,104 @@ +LAMMPS (30 Apr 2019) + using 1 OpenMP thread(s) per MPI task +# 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 xx equal 20*1 +variable yy equal 20*$y +variable yy equal 20*1 +variable zz equal 20*$z +variable zz equal 20*1 + +units metal +atom_style atomic +newton on + +kim_style init LennardJones_Ar + +lattice fcc 4.4300 +Lattice spacing in x,y,z = 4.43 4.43 4.43 +region box block 0 ${xx} 0 ${yy} 0 ${zz} +region box block 0 20 0 ${yy} 0 ${zz} +region box block 0 20 0 20 0 ${zz} +region box block 0 20 0 20 0 20 +create_box 1 box +Created orthogonal box = (0 0 0) to (88.6 88.6 88.6) + 1 by 2 by 2 MPI processor grid +create_atoms 1 box +Created 32000 atoms + create_atoms CPU = 0.0979962 secs + +#pair_style lj/cut 8.1500 +#pair_coeff 1 1 0.0104 3.4000 + +kim_style define Ar +pair_style kim LennardJones_Ar +WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:980) +WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:985) +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 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 8.45 + ghost atom cutoff = 8.45 + binsize = 4.225, bins = 21 21 21 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair kim, perpetual + attributes: full, newton off, cut 8.45 + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 9.789 | 9.789 | 9.789 Mbytes +Step Temp E_pair E_mol TotEng Press + 0 200 6290.8194 0 7118.0584 129712.25 + 100 95.179725 6718.814 0 7112.496 133346.59 +Loop time of 6.29539 on 4 procs for 100 steps with 32000 atoms + +Performance: 1.372 ns/day, 17.487 hours/ns, 15.885 timesteps/s +48.4% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 1.9399 | 2.079 | 2.2181 | 9.1 | 33.02 +Neigh | 0.25924 | 0.26632 | 0.2692 | 0.8 | 4.23 +Comm | 2.5011 | 2.6605 | 2.751 | 5.9 | 42.26 +Output | 0.069904 | 0.07097 | 0.071545 | 0.3 | 1.13 +Modify | 0.011383 | 0.012206 | 0.01419 | 1.0 | 0.19 +Other | | 1.206 | | | 19.16 + +Nlocal: 8000 ave 8018 max 7967 min +Histogram: 1 0 0 0 0 0 1 0 0 2 +Nghost: 9131 ave 9164 max 9113 min +Histogram: 2 0 0 1 0 0 0 0 0 1 +Neighs: 0 ave 0 max 0 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 1.06344e+06 ave 1.06594e+06 max 1.05881e+06 min +Histogram: 1 0 0 0 0 0 1 0 0 2 + +Total # of neighbors = 4253750 +Ave neighs/atom = 132.93 +Neighbor list builds = 3 +Dangerous builds = 0 +Total wall time: 0:00:07 From df1308ad922c4fd47bcd90bb5253540902ac2aff Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 30 May 2019 21:58:18 -0400 Subject: [PATCH 021/107] add kim_style error messages to Errors_messages.txt doc file --- doc/src/Errors_messages.txt | 33 +++++++++++++++++++++++++++++++++ src/KIM/kim_style.h | 14 +++++++------- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/doc/src/Errors_messages.txt b/doc/src/Errors_messages.txt index fb5003e602..7f6e80948c 100644 --- a/doc/src/Errors_messages.txt +++ b/doc/src/Errors_messages.txt @@ -5729,6 +5729,16 @@ definitions. :dd The data file header lists improper but no improper types. :dd +{Incompatible KIM Simulator Model} :dt + +The requested KIM Simulator Model was defined for a different MD code +and thus is not compatible with LAMMPS. :dd + +{Incompatible units for KIM Simulator Model} :dt + +The selected unit style is not compatible with the requested KIM +Simulator Model. :dd + {Incomplete use of variables in create_atoms command} :dt The var and set options must be used together. :dd @@ -6988,6 +6998,12 @@ The atom style defined does not have this attribute. :dd The atom style defined does not have these attributes. :dd +{KIM Simulator Model has no Model definition} :dt + +There is no model definition (key: model-defn) in the KIM Simulator +Model. Please contact the OpenKIM database maintainers to verify +and potentially correct this. :dd + {KOKKOS package does not yet support comm_style tiled} :dt Self-explanatory. :dd @@ -7475,6 +7491,18 @@ Self-explanatory. :dd Self-explanatory. :dd +{Must use 'kim_style init' command before simulation box is defined} :dt + +Self-explanatory. :dd + +{Must use 'kim_style define' command after simulation box is defined} :dt + +Self-explanatory. :dd + +{Must use 'kim_style init' command before 'kim_style define'} :dt + +Self-explanatory. :dd + {Must use 'kspace_modify pressure/scalar no' for rRESPA with kspace_style MSM} :dt The kspace scalar pressure option cannot (yet) be used with rRESPA. :dd @@ -9418,6 +9446,11 @@ See the "read_data extra/special/per/atom" command for info on how to leave space in the special bonds list to allow for additional bonds to be formed. :dd +{Species XXX is not supported by this KIM Simulator Model} :dt + +The kim_style define command was referencing a species that is not +present in the requested KIM Simulator Model. :dd + {Specified processors != physical processors} :dt The 3d grid of processors defined by the processors command does not diff --git a/src/KIM/kim_style.h b/src/KIM/kim_style.h index eddc22eebc..f8c0602beb 100644 --- a/src/KIM/kim_style.h +++ b/src/KIM/kim_style.h @@ -85,34 +85,34 @@ class KimStyle : protected Pointers { E: Illegal kim_style command -Incorrect number or kind of arguments to kim_style +Incorrect number or kind of arguments to kim_style. E: Must use 'kim_style init' command before simulation box is defined -Self-explanatory +Self-explanatory. E: Must use 'kim_style define' command after simulation box is defined -Self-explanatory +Self-explanatory. E: Must use 'kim_style init' command before 'kim_style define' -Self-explanatory +Self-explanatory. E: Incompatible KIM Simulator Model The requested KIM Simulator Model was defined for a different MD code -and thus is not compatible with LAMMPS +and thus is not compatible with LAMMPS. E: Species XXX is not supported by this KIM Simulator Model The kim_style define command was referencing a species that is not -present in the requested KIM Simulator Model +present in the requested KIM Simulator Model. E: Incompatible units for KIM Simulator Model The selected unit style is not compatible with the requested KIM -Simulator Model +Simulator Model. E: KIM Simulator Model has no Model definition From edecd2b7601f900e99b6eaeb9c3acb25dfe35edc Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 30 May 2019 22:19:47 -0400 Subject: [PATCH 022/107] fix typo and update list of false positives for updated docs --- doc/src/kim_style.txt | 2 +- doc/utils/sphinx-config/false_positives.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/src/kim_style.txt b/doc/src/kim_style.txt index dcdfae1cdc..afa7a19fab 100644 --- a/doc/src/kim_style.txt +++ b/doc/src/kim_style.txt @@ -51,7 +51,7 @@ The {kim_style define} command will issue commands that will realize the selected model (through generating pair_style and pair_coeff commands, but also other commands, as required). It has to be issued [after] the the simulation box is defined. The {kim_style define} command allows a -varying numbver of additional arguments. Those are used to map the atom +varying number of additional arguments. Those are used to map the atom types in LAMMPS to the available species in the KIM model. This is equivalent to the arguments following "pair_coeff * *" in a "kim"_pair_kim.html pair style. Thus the commands: diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 7160800c50..a8bfa8f193 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -521,6 +521,7 @@ decrementing deeppink deepskyblue defgrad +defn deformable del deleteIDs @@ -2792,6 +2793,7 @@ txt typeI typeJ typeN +typeargs Tz Tzou ub From 22fd12b56c803e6e0e5939bb0a950adf080c31a9 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 10 Jun 2019 17:14:17 -0400 Subject: [PATCH 023/107] support storing unit conversion variable setting between kim_style calls --- src/KIM/fix_store_kim.cpp | 29 ++++++++++++++++++++++++++++- src/KIM/fix_store_kim.h | 2 ++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/KIM/fix_store_kim.cpp b/src/KIM/fix_store_kim.cpp index 8e9946c20d..6423a57e18 100644 --- a/src/KIM/fix_store_kim.cpp +++ b/src/KIM/fix_store_kim.cpp @@ -65,7 +65,8 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixStoreKIM::FixStoreKIM(LAMMPS *lmp, int narg, char **arg) - : Fix(lmp, narg, arg), simulator_model(NULL), model_name(NULL) + : Fix(lmp, narg, arg), simulator_model(NULL), model_name(NULL), + units_from(NULL), units_to(NULL) { if (narg != 3) error->all(FLERR,"Illegal fix STORE/KIM command"); } @@ -87,6 +88,18 @@ FixStoreKIM::~FixStoreKIM() delete[] mn; model_name = NULL; } + + if (units_from) { + char *uf = (char *)units_from; + delete[] uf; + units_from = NULL; + } + + if (units_to) { + char *ut = (char *)units_to; + delete[] ut; + units_to = NULL; + } } /* ---------------------------------------------------------------------- */ @@ -114,6 +127,18 @@ void FixStoreKIM::setptr(const char *name, void *ptr) delete[] mn; } model_name = ptr; + } else if (strcmp(name,"units_from") == 0) { + if (units_from) { + char *uf = (char *)units_from; + delete[] uf; + } + units_from = ptr; + } else if (strcmp(name,"units_to") == 0) { + if (units_to) { + char *ut = (char *)units_to; + delete[] ut; + } + units_to = ptr; } } @@ -123,5 +148,7 @@ void *FixStoreKIM::getptr(const char *name) { if (strcmp(name,"simulator_model") == 0) return simulator_model; else if (strcmp(name,"model_name") == 0) return model_name; + else if (strcmp(name,"units_from") == 0) return units_from; + else if (strcmp(name,"units_to") == 0) return units_to; else return NULL; } diff --git a/src/KIM/fix_store_kim.h b/src/KIM/fix_store_kim.h index 04081fd6dc..5bca2a3dd0 100644 --- a/src/KIM/fix_store_kim.h +++ b/src/KIM/fix_store_kim.h @@ -80,6 +80,8 @@ class FixStoreKIM : public Fix { private: void *simulator_model; // pointer to KIM simulator model class void *model_name; // string of KIM model name + void *units_from; // string of unit conversion origin or NULL + void *units_to; // string of unit conversion target or NULL }; } From 9a428217d9f9d864e7ff66618645dfab4be04341 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 10 Jun 2019 17:19:18 -0400 Subject: [PATCH 024/107] prototype implementation of unit conversion variable support --- src/KIM/kim_style.cpp | 161 +++++++++++++++++++++++++++++++++++++++++- src/KIM/kim_style.h | 4 ++ 2 files changed, 162 insertions(+), 3 deletions(-) diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp index 856fb94c9e..814da6b188 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_style.cpp @@ -65,6 +65,7 @@ #include "update.h" #include "universe.h" #include "input.h" +#include "variable.h" #include "fix_store_kim.h" #include "KIM_SimulatorModel.hpp" @@ -78,20 +79,33 @@ void KimStyle::command(int narg, char **arg) { if (narg < 2) error->all(FLERR,"Illegal kim_style command"); + units_from = NULL; + units_to = NULL; + if (strcmp(arg[0],"init") == 0) { - if (narg > 2) error->all(FLERR,"Illegal kim_style command"); if (domain->box_exist) error->all(FLERR,"Must use 'kim_style init' command before " "simulation box is defined"); int len = strlen(arg[1])+1; char *model = new char[len]; strcpy(model,arg[1]); + + int args_done = do_units(narg-2,arg-2); + if (narg > (args_done + 2)) + error->all(FLERR,"Illegal kim_style command"); do_init(model); + do_variables(); } else if (strcmp(arg[0],"define") == 0) { if (!domain->box_exist) error->all(FLERR,"Must use 'kim_style define' command after " "simulation box is defined"); - do_defn(narg-1,arg+1); + int args_done = do_units(narg-1,arg-1); + do_defn(narg - (args_done+1),arg + (args_done+1)); + } else if (strcmp(arg[0],"unit_variables") == 0) { + int args_done = do_units(narg,arg); + if (narg > args_done) + error->all(FLERR,"Illegal kim_style command"); + do_variables(); } else error->all(FLERR,"Illegal kim_style command"); } @@ -113,6 +127,8 @@ void KimStyle::do_init(char *model) FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; fix_store->setptr("model_name", (void *) model); + fix_store->setptr("units_from", (void *) units_from); + fix_store->setptr("units_to", (void *) units_to); int kimerror; KIM::SimulatorModel * simulatorModel; @@ -172,7 +188,6 @@ void KimStyle::do_defn(int narg, char **arg) char *model = NULL; KIM::SimulatorModel *simulatorModel(NULL); - int kimerror; // check if we had a kim_style init command by finding fix STORE/KIM // retrieve model name and pointer to simulator model class instance. @@ -298,3 +313,143 @@ void KimStyle::do_defn(int narg, char **arg) input->one(cmd2.c_str()); } } + +/* ---------------------------------------------------------------------- */ + +int KimStyle::do_units(int narg, char **arg) +{ + // retrieve custom units setting if kim_style had been called before + + int ifix = modify->find_fix("KIM_MODEL_STORE"); + FixStoreKIM *fix_store = NULL; + if (ifix >= 0) { + fix_store = (FixStoreKIM *) modify->fix[ifix]; + units_from = (char *)fix_store->getptr("units_from"); + units_to = (char *)fix_store->getptr("units_to"); + } + + if (narg < 2) return 0; + int iarg=0; + for (iarg = 0; iarg < narg; iarg += 2) { + if (strcmp(arg[iarg],"unit_variables") == 0) { + if (narg > iarg+2) error->all(FLERR,"Illegal kim_style command"); + if (strcmp(arg[iarg+1],"NULL") == 0) { + delete[] units_to; + units_to = NULL; + } else { + int len = strlen(arg[iarg+1])+1; + delete[] units_to; + units_to = new char[len]; + strcpy(units_to,arg[iarg+1]); + } + if (fix_store) fix_store->setptr("units_to",units_to); + } else if (strcmp(arg[iarg],"unit_from") == 0) { + if (narg > iarg+2) error->all(FLERR,"Illegal kim_style command"); + if (strcmp(arg[iarg+1],"NULL") == 0) { + delete[] units_from; + units_from = NULL; + } else { + int len = strlen(arg[iarg+1])+1; + delete[] units_from; + units_from = new char[len]; + strcpy(units_from,arg[iarg+1]); + } + if (fix_store) fix_store->setptr("units_from",units_from); + } else return iarg; + } + return iarg; +} + +/* ---------------------------------------------------------------------- */ + +void KimStyle::do_variables() +{ + char *from, *to; + Variable *variable = input->variable; + + if (units_from) from = units_from; + else from = update->unit_style; + if (units_to) to = units_to; + else to = update->unit_style; + + // refuse convertion from or to reduced units + + if ((strcmp(from,"lj") == 0) || (strcmp(to,"lj") == 0)) + error->all(FLERR,"Cannot set up conversion variables for 'lj' units"); + + // get index to internal style variables. create, if needed. + // default to conversion factor 1.0 for newly created variables + + int v_length, v_mass, v_time; + char *args[3]; + args[1] = (char *)"internal"; + args[2] = (char *)"1.0"; + + args[0] = (char *)"_u_length"; + v_length = variable->find(args[0]); + if (v_length < 0) { + variable->set(3,args); + v_length = variable->find(args[0]); + } + + args[0] = (char *)"_u_mass"; + v_mass = variable->find(args[0]); + if (v_mass < 0) { + variable->set(3,args); + v_mass = variable->find(args[0]); + } + + args[0] = (char *)"_u_time"; + v_time = variable->find(args[0]); + if (v_time < 0) { + variable->set(3,args); + v_time = variable->find(args[0]); + } + + // special case: both unit styles are the same => conversion factor 1.0 + + if (strcmp(from,to) == 0) { + variable->internal_set(v_length,1.0); + variable->internal_set(v_mass,1.0); + variable->internal_set(v_time,1.0); + return; + } + + if (strcmp(from,"real") == 0) { + if (strcmp(to,"metal") == 0) { + variable->internal_set(v_length,1.0); + variable->internal_set(v_mass,1.0); + variable->internal_set(v_time,0.001); + } else { + std::string err("Do not know how to set up conversion variables "); + err += "between '"; + err += from; + err += "' and '"; + err += to; + err += "' units"; + error->all(FLERR,err.c_str()); + } + } else if (strcmp(from,"metal") == 0) { + if (strcmp(to,"real") == 0) { + variable->internal_set(v_length,1.0); + variable->internal_set(v_mass,1.0); + variable->internal_set(v_time,1000.0); + } else { + std::string err("Do not know how to set up conversion variables "); + err += "between '"; + err += from; + err += "' and '"; + err += to; + err += "' units"; + error->all(FLERR,err.c_str()); + } + } else { + std::string err("Do not know how to set up conversion variables "); + err += "between '"; + err += from; + err += "' and '"; + err += to; + err += "' units"; + error->all(FLERR,err.c_str()); + } +} diff --git a/src/KIM/kim_style.h b/src/KIM/kim_style.h index f8c0602beb..36084183ee 100644 --- a/src/KIM/kim_style.h +++ b/src/KIM/kim_style.h @@ -72,8 +72,12 @@ class KimStyle : protected Pointers { KimStyle(class LAMMPS *lmp) : Pointers(lmp) {}; void command(int, char **); private: + char *units_from; + char *units_to; void do_init(char *); void do_defn(int, char **); + int do_units(int, char **); + void do_variables(); }; } From 664b938ed12cafc2fa232a34abccd4d79278a494 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 10 Jun 2019 17:45:07 -0400 Subject: [PATCH 025/107] document kim_style changes --- doc/src/kim_style.txt | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/src/kim_style.txt b/doc/src/kim_style.txt index afa7a19fab..c24cfe8581 100644 --- a/doc/src/kim_style.txt +++ b/doc/src/kim_style.txt @@ -12,15 +12,18 @@ kim_style command :h3 kim_style mode args :pre -mode = {init model} or {define typeargs} +mode = {init model} or {define typeargs} or no mode chosen model = name of the KIM model (KIM potential or KIM simulator model) -typeargs = atom type to species mapping (one entry per atom type) :ul +typeargs = atom type to species mapping (one entry per atom type) +args = {unit_variables unit_style} or {unit_from unit_style} (optional):ul [Examples:] -kim_style init ex_sim_model_Si_mod_tersoff +kim_style init ex_sim_model_Si_mod_tersoff unit_variables metal kim_style define Si Si -kim_style init LennardJones_Ar +kim_style unit_variables real +kim_style init LennardJones_Ar unit_variables metal +kim_style unit_variables real unit_from metal kim_style define Ar :pre [Description:] @@ -47,6 +50,21 @@ for using a selected simulator model. If needed, those settings can be overridden. The second argument to the {kim_style init} command is the KIM model ID. +In both modes, the keywords {unit_variables} and {unit_from} may be +added. They control the values of a set of +"internal style variables"_variable.html that can be used to convert +between different unit styles in LAMMPS. The argument to +each keyword is a LAMMPS unit style or NULL, which means to look up +the unit style from what was set with the "units"_units.html command. +Please note, that KIM simulator models will set their preferred unit style. +By default all conversion variables are set to 1.0. Converting to or +from the "lj" unit style is not supported. The following variables are defined: + +_u_length +_u_mass +_u_time :ul + + The {kim_style define} command will issue commands that will realize the selected model (through generating pair_style and pair_coeff commands, but also other commands, as required). It has to be issued [after] the From 128d021c10c2c0d4fd54bd81d7c49f82bf2dc0a9 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Thu, 20 Jun 2019 13:13:13 -0500 Subject: [PATCH 026/107] Update to latest prototype for SimulatorModel interface --- src/KIM/kim_style.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp index 814da6b188..b67360ce82 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_style.cpp @@ -68,8 +68,9 @@ #include "variable.h" #include "fix_store_kim.h" +//@@@@@ Need to switch to c-bindings when they are available. #include "KIM_SimulatorModel.hpp" - +//@@@@@ using namespace LAMMPS_NS; @@ -131,6 +132,7 @@ void KimStyle::do_init(char *model) fix_store->setptr("units_to", (void *) units_to); int kimerror; + // @@@@@ switch to c-bindings when they are available KIM::SimulatorModel * simulatorModel; kimerror = KIM::SimulatorModel::Create(model,&simulatorModel); @@ -176,7 +178,7 @@ void KimStyle::do_init(char *model) // reset template map. - simulatorModel->ClearTemplateMap(); + simulatorModel->OpenAndInitializeTemplateMap(); } /* ---------------------------------------------------------------------- */ @@ -206,8 +208,7 @@ void KimStyle::do_defn(int narg, char **arg) const std::string *sim_name, *sim_version; std::string atom_type_sym_list; - simulatorModel->GetSimulatorName(&sim_name); - simulatorModel->GetSimulatorVersion(&sim_version); + simulatorModel->GetSimulatorNameAndVersion(&sim_name, &sim_version); if (comm->me == 0) { std::string mesg("Using KIM Simulator Model : "); @@ -292,7 +293,7 @@ void KimStyle::do_defn(int narg, char **arg) if (sim_model_idx < 0) error->all(FLERR,"KIM Simulator Model has no Model definition"); - simulatorModel->ClearTemplateMap(); + simulatorModel->OpenAndInitializeTemplateMap(); } else { From 0613c10395ab286a0dd7c82e1f0ab092bdacbb5a Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Thu, 20 Jun 2019 16:45:45 -0500 Subject: [PATCH 027/107] Work on kim_style for latest definition prototype --- examples/kim/in.kim.lj.simulator_model | 9 +- src/KIM/kim_style.cpp | 286 ++++++++++++++++--------- src/KIM/kim_style.h | 34 ++- 3 files changed, 217 insertions(+), 112 deletions(-) diff --git a/examples/kim/in.kim.lj.simulator_model b/examples/kim/in.kim.lj.simulator_model index 15b26c3c64..01ee5aa64c 100644 --- a/examples/kim/in.kim.lj.simulator_model +++ b/examples/kim/in.kim.lj.simulator_model @@ -14,12 +14,11 @@ variable xx equal 20*$x variable yy equal 20*$y variable zz equal 20*$z -units metal -atom_style atomic +echo both +#kim_style model LennardJones_Ar metal +kim_style model Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu real unit_conversion_mode newton on -kim_style init LennardJones_Ar - lattice fcc 4.4300 region box block 0 ${xx} 0 ${yy} 0 ${zz} create_box 1 box @@ -28,7 +27,7 @@ create_atoms 1 box #pair_style lj/cut 8.1500 #pair_coeff 1 1 0.0104 3.4000 -kim_style define Ar +kim_style setup Au mass 1 39.95 velocity all create 200.0 232345 loop geom diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp index b67360ce82..fcc3f33aa2 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_style.cpp @@ -51,7 +51,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Designed for use with the kim-api-2.0.2 (and newer) package + Designed for use with the kim-api-2.1.0 (and newer) package ------------------------------------------------------------------------- */ #include @@ -68,6 +68,9 @@ #include "variable.h" #include "fix_store_kim.h" +extern "C" { +#include "KIM_SimulatorHeaders.h" +} //@@@@@ Need to switch to c-bindings when they are available. #include "KIM_SimulatorModel.hpp" //@@@@@ @@ -78,42 +81,188 @@ using namespace LAMMPS_NS; void KimStyle::command(int narg, char **arg) { - if (narg < 2) error->all(FLERR,"Illegal kim_style command"); + if ((narg < 2) || (narg > 4)) error->all(FLERR,"Illegal kim_style command"); - units_from = NULL; - units_to = NULL; - - if (strcmp(arg[0],"init") == 0) { + if (strcmp(arg[0],"model") == 0) { if (domain->box_exist) - error->all(FLERR,"Must use 'kim_style init' command before " + error->all(FLERR,"Must use 'kim_style model' command before " "simulation box is defined"); - int len = strlen(arg[1])+1; - char *model = new char[len]; - strcpy(model,arg[1]); + int len1 = strlen(arg[1])+1; + int len2 = strlen(arg[2])+1; + char *model_name = new char[len1]; strcpy(model_name,arg[1]); + char *user_units = new char[len2]; strcpy(user_units,arg[2]); + if (narg == 4) { + if (strcmp(arg[3],"unit_conversion_mode")==0) unit_conversion_mode = true; + else { error->all(FLERR,"Illegal kim_style command"); } + } else unit_conversion_mode = false; - int args_done = do_units(narg-2,arg-2); - if (narg > (args_done + 2)) - error->all(FLERR,"Illegal kim_style command"); - do_init(model); - do_variables(); - } else if (strcmp(arg[0],"define") == 0) { + char *model_units; + determine_model_type_and_units(model_name, user_units, &model_units); + + do_init(model_name, user_units, model_units); + if (unit_conversion_mode) do_variables(user_units, model_units); + } else if (strcmp(arg[0],"setup") == 0) { if (!domain->box_exist) - error->all(FLERR,"Must use 'kim_style define' command after " + error->all(FLERR,"Must use 'kim_style setup' command after " "simulation box is defined"); - int args_done = do_units(narg-1,arg-1); - do_defn(narg - (args_done+1),arg + (args_done+1)); - } else if (strcmp(arg[0],"unit_variables") == 0) { - int args_done = do_units(narg,arg); - if (narg > args_done) - error->all(FLERR,"Illegal kim_style command"); - do_variables(); + do_setup(narg-1,++arg); } else error->all(FLERR,"Illegal kim_style command"); } /* ---------------------------------------------------------------------- */ +namespace { +void get_kim_unit_names( + char const * const system, + KIM_LengthUnit & lengthUnit, + KIM_EnergyUnit & energyUnit, + KIM_ChargeUnit & chargeUnit, + KIM_TemperatureUnit & temperatureUnit, + KIM_TimeUnit & timeUnit, + Error * error) +{ + if ((strcmp(system,"real")==0)) { + lengthUnit = KIM_LENGTH_UNIT_A; + energyUnit = KIM_ENERGY_UNIT_kcal_mol; + chargeUnit = KIM_CHARGE_UNIT_e; + temperatureUnit = KIM_TEMPERATURE_UNIT_K; + timeUnit = KIM_TIME_UNIT_fs; + } else if ((strcmp(system,"metal")==0)) { + lengthUnit = KIM_LENGTH_UNIT_A; + energyUnit = KIM_ENERGY_UNIT_eV; + chargeUnit = KIM_CHARGE_UNIT_e; + temperatureUnit = KIM_TEMPERATURE_UNIT_K; + timeUnit = KIM_TIME_UNIT_ps; + } else if ((strcmp(system,"si")==0)) { + lengthUnit = KIM_LENGTH_UNIT_m; + energyUnit = KIM_ENERGY_UNIT_J; + chargeUnit = KIM_CHARGE_UNIT_C; + temperatureUnit = KIM_TEMPERATURE_UNIT_K; + timeUnit = KIM_TIME_UNIT_s; + } else if ((strcmp(system,"cgs")==0)) { + lengthUnit = KIM_LENGTH_UNIT_cm; + energyUnit = KIM_ENERGY_UNIT_erg; + chargeUnit = KIM_CHARGE_UNIT_statC; + temperatureUnit = KIM_TEMPERATURE_UNIT_K; + timeUnit = KIM_TIME_UNIT_s; + } else if ((strcmp(system,"electron")==0)) { + lengthUnit = KIM_LENGTH_UNIT_Bohr; + energyUnit = KIM_ENERGY_UNIT_Hartree; + chargeUnit = KIM_CHARGE_UNIT_e; + temperatureUnit = KIM_TEMPERATURE_UNIT_K; + timeUnit = KIM_TIME_UNIT_fs; + } else if ((strcmp(system,"lj")==0)) { + error->all(FLERR,"LAMMPS unit_style lj not supported by KIM models"); + } else { + error->all(FLERR,"Unknown unit_style"); + } +} +} // namespace +void KimStyle::determine_model_type_and_units(char * model_name, + char * user_units, + char ** model_units) +{ + KIM_LengthUnit lengthUnit; + KIM_EnergyUnit energyUnit; + KIM_ChargeUnit chargeUnit; + KIM_TemperatureUnit temperatureUnit; + KIM_TimeUnit timeUnit; + int units_accepted; + KIM_Model * kim_MO; -void KimStyle::do_init(char *model) + get_kim_unit_names(user_units, lengthUnit, energyUnit, + chargeUnit, temperatureUnit, timeUnit, error); + int kim_error = KIM_Model_Create(KIM_NUMBERING_zeroBased, + lengthUnit, + energyUnit, + chargeUnit, + temperatureUnit, + timeUnit, + model_name, + &units_accepted, + &kim_MO); + + if (!kim_error) // model is an MO + { + model_type = MO; + KIM_Model_Destroy(&kim_MO); + + if (units_accepted) + { + int len=strlen(user_units); + *model_units = new char[len]; strcpy(*model_units,user_units); + return; + } + else if (unit_conversion_mode) + { + int const num_systems = 5; + char const * const systems[num_systems] + = {"metal", "real", "si", "cgs", "electron"}; + for (int i=0; i < num_systems; ++i) + { + get_kim_unit_names(systems[i], lengthUnit, energyUnit, + chargeUnit, temperatureUnit, timeUnit, error); + kim_error = KIM_Model_Create(KIM_NUMBERING_zeroBased, + lengthUnit, + energyUnit, + chargeUnit, + temperatureUnit, + timeUnit, + model_name, + &units_accepted, + &kim_MO); + KIM_Model_Destroy(&kim_MO); + if (units_accepted) + { + int len=strlen(systems[i]); + *model_units = new char[len]; strcpy(*model_units,systems[i]); + return; + } + } + error->all(FLERR,"KIM Model does not support any lammps unit system"); + } + else + { + error->all(FLERR,"KIM Model does not support the requested unit system"); + } + } + + KIM::SimulatorModel * kim_SM; + kim_error = KIM::SimulatorModel::Create(model_name, &kim_SM); + if (kim_error) + { + error->all(FLERR,"KIM model name not found"); + } + model_type = SM; + + int sim_fields; + int sim_lines; + std::string const * sim_field; + std::string const * sim_value; + kim_SM->GetNumberOfSimulatorFields(&sim_fields); + kim_SM->CloseTemplateMap(); + for (int i=0; i < sim_fields; ++i) { + kim_SM->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + + if (*sim_field == "units") { + kim_SM->GetSimulatorFieldLine(i,0,&sim_value); + int len=(*sim_value).length(); + *model_units = new char[len]; strcpy(*model_units,sim_value->c_str()); + break; + } + } + KIM::SimulatorModel::Destroy(&kim_SM); + + if ((! unit_conversion_mode) && (strcmp(*model_units, user_units)!=0)) + { + error->all(FLERR,"Incompatible units for KIM Simulator Model"); + } +} + + +/* ---------------------------------------------------------------------- */ + +void KimStyle::do_init(char *model_name, char *user_units, char* model_units) { // create storage proxy fix. delete existing fix, if needed. @@ -127,14 +276,20 @@ void KimStyle::do_init(char *model) ifix = modify->find_fix("KIM_MODEL_STORE"); FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; - fix_store->setptr("model_name", (void *) model); - fix_store->setptr("units_from", (void *) units_from); - fix_store->setptr("units_to", (void *) units_to); + fix_store->setptr("model_name", (void *) model_name); + fix_store->setptr("user_units", (void *) user_units); + fix_store->setptr("model_units", (void *) model_units); + + // set units + + std::string cmd("units "); + cmd += model_units; + input->one(cmd.c_str()); int kimerror; // @@@@@ switch to c-bindings when they are available KIM::SimulatorModel * simulatorModel; - kimerror = KIM::SimulatorModel::Create(model,&simulatorModel); + kimerror = KIM::SimulatorModel::Create(model_name,&simulatorModel); // not a Kim Simulator Model; nothing else to do here. @@ -150,19 +305,6 @@ void KimStyle::do_init(char *model) const std::string *sim_field, *sim_value; simulatorModel->GetNumberOfSimulatorFields(&sim_fields); - // set units - - for (int i=0; i < sim_fields; ++i) { - simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); - if (*sim_field == "units") { - simulatorModel->GetSimulatorFieldLine(i,0,&sim_value); - std::string cmd("units "); - cmd += *sim_value; - input->one(cmd.c_str()); - break; - } - } - // init model for (int i=0; i < sim_fields; ++i) { @@ -183,7 +325,7 @@ void KimStyle::do_init(char *model) /* ---------------------------------------------------------------------- */ -void KimStyle::do_defn(int narg, char **arg) +void KimStyle::do_setup(int narg, char **arg) { if (narg != atom->ntypes) error->all(FLERR,"Illegal kim_style command"); @@ -201,7 +343,7 @@ void KimStyle::do_defn(int narg, char **arg) FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; model = (char *)fix_store->getptr("model_name"); simulatorModel = (KIM::SimulatorModel *)fix_store->getptr("simulator_model"); - } else error->all(FLERR,"Must use 'kim_style init' before 'kim_style define'"); + } else error->all(FLERR,"Must use 'kim_style model' before 'kim_style setup'"); if (simulatorModel) { @@ -317,62 +459,11 @@ void KimStyle::do_defn(int narg, char **arg) /* ---------------------------------------------------------------------- */ -int KimStyle::do_units(int narg, char **arg) +void KimStyle::do_variables(char *user_units, char *model_units) { - // retrieve custom units setting if kim_style had been called before - - int ifix = modify->find_fix("KIM_MODEL_STORE"); - FixStoreKIM *fix_store = NULL; - if (ifix >= 0) { - fix_store = (FixStoreKIM *) modify->fix[ifix]; - units_from = (char *)fix_store->getptr("units_from"); - units_to = (char *)fix_store->getptr("units_to"); - } - - if (narg < 2) return 0; - int iarg=0; - for (iarg = 0; iarg < narg; iarg += 2) { - if (strcmp(arg[iarg],"unit_variables") == 0) { - if (narg > iarg+2) error->all(FLERR,"Illegal kim_style command"); - if (strcmp(arg[iarg+1],"NULL") == 0) { - delete[] units_to; - units_to = NULL; - } else { - int len = strlen(arg[iarg+1])+1; - delete[] units_to; - units_to = new char[len]; - strcpy(units_to,arg[iarg+1]); - } - if (fix_store) fix_store->setptr("units_to",units_to); - } else if (strcmp(arg[iarg],"unit_from") == 0) { - if (narg > iarg+2) error->all(FLERR,"Illegal kim_style command"); - if (strcmp(arg[iarg+1],"NULL") == 0) { - delete[] units_from; - units_from = NULL; - } else { - int len = strlen(arg[iarg+1])+1; - delete[] units_from; - units_from = new char[len]; - strcpy(units_from,arg[iarg+1]); - } - if (fix_store) fix_store->setptr("units_from",units_from); - } else return iarg; - } - return iarg; -} - -/* ---------------------------------------------------------------------- */ - -void KimStyle::do_variables() -{ - char *from, *to; + char *from = user_units, *to = model_units; Variable *variable = input->variable; - if (units_from) from = units_from; - else from = update->unit_style; - if (units_to) to = units_to; - else to = update->unit_style; - // refuse convertion from or to reduced units if ((strcmp(from,"lj") == 0) || (strcmp(to,"lj") == 0)) @@ -381,6 +472,7 @@ void KimStyle::do_variables() // get index to internal style variables. create, if needed. // default to conversion factor 1.0 for newly created variables + // @@@@@@ below needs to be updated to use Ellad's luc. int v_length, v_mass, v_time; char *args[3]; args[1] = (char *)"internal"; diff --git a/src/KIM/kim_style.h b/src/KIM/kim_style.h index 36084183ee..b7ff47404f 100644 --- a/src/KIM/kim_style.h +++ b/src/KIM/kim_style.h @@ -51,7 +51,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Designed for use with the kim-api-2.0.2 (and newer) package + Designed for use with the kim-api-2.1.0 (and newer) package ------------------------------------------------------------------------- */ #ifdef COMMAND_CLASS @@ -72,12 +72,14 @@ class KimStyle : protected Pointers { KimStyle(class LAMMPS *lmp) : Pointers(lmp) {}; void command(int, char **); private: - char *units_from; - char *units_to; - void do_init(char *); - void do_defn(int, char **); - int do_units(int, char **); - void do_variables(); + enum model_type_enum {MO, SM}; + model_type_enum model_type; + bool unit_conversion_mode; + + void determine_model_type_and_units(char *, char *, char **); + void do_init(char *, char *, char *); + void do_setup(int, char **); + void do_variables(char*, char*); }; } @@ -91,15 +93,27 @@ E: Illegal kim_style command Incorrect number or kind of arguments to kim_style. -E: Must use 'kim_style init' command before simulation box is defined +E: Must use 'kim_style model' command before simulation box is defined Self-explanatory. -E: Must use 'kim_style define' command after simulation box is defined +E: Must use 'kim_style setup' command after simulation box is defined Self-explanatory. -E: Must use 'kim_style init' command before 'kim_style define' +E: Must use 'kim_style model' command before 'kim_style setup' + +Self-explanatory. + +E: KIM Model does not support the requested unit system + +Self-explanatory. + +E: KIM Model does not support any lammps unit system + +Self-explanatory. + +E: KIM model name not found Self-explanatory. From 88994d813aeba181736d7c80f2578e74731238df Mon Sep 17 00:00:00 2001 From: "Ellad B. Tadmor" Date: Fri, 21 Jun 2019 18:38:48 -0500 Subject: [PATCH 028/107] Ignore kim.log in examples/kim --- examples/kim/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/kim/.gitignore diff --git a/examples/kim/.gitignore b/examples/kim/.gitignore new file mode 100644 index 0000000000..63421e4217 --- /dev/null +++ b/examples/kim/.gitignore @@ -0,0 +1 @@ +/kim.log From 08cee18f3207b6cea777dbbd24e17ca1a1f39ded Mon Sep 17 00:00:00 2001 From: "Ellad B. Tadmor" Date: Fri, 21 Jun 2019 18:39:18 -0500 Subject: [PATCH 029/107] Added code to define unit conversion factors --- src/KIM/kim_style.cpp | 219 ++++--- src/KIM/kim_style.h | 2 + src/KIM/kim_units.cpp | 1411 +++++++++++++++++++++++++++++++++++++++++ src/KIM/kim_units.h | 59 ++ 4 files changed, 1596 insertions(+), 95 deletions(-) create mode 100644 src/KIM/kim_units.cpp create mode 100644 src/KIM/kim_units.h diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp index fcc3f33aa2..44d5c411ab 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_style.cpp @@ -56,6 +56,7 @@ #include #include +#include #include "kim_style.h" #include "error.h" #include "atom.h" @@ -67,6 +68,7 @@ #include "input.h" #include "variable.h" #include "fix_store_kim.h" +#include "kim_units.h" extern "C" { #include "KIM_SimulatorHeaders.h" @@ -100,7 +102,6 @@ void KimStyle::command(int narg, char **arg) determine_model_type_and_units(model_name, user_units, &model_units); do_init(model_name, user_units, model_units); - if (unit_conversion_mode) do_variables(user_units, model_units); } else if (strcmp(arg[0],"setup") == 0) { if (!domain->box_exist) error->all(FLERR,"Must use 'kim_style setup' command after " @@ -255,7 +256,10 @@ void KimStyle::determine_model_type_and_units(char * model_name, if ((! unit_conversion_mode) && (strcmp(*model_units, user_units)!=0)) { - error->all(FLERR,"Incompatible units for KIM Simulator Model"); + std::stringstream mesg; + mesg << "Incompatible units for KIM Simulator Model, required units = " + << *model_units; + error->all(FLERR,mesg.str().c_str()); } } @@ -280,17 +284,43 @@ void KimStyle::do_init(char *model_name, char *user_units, char* model_units) fix_store->setptr("user_units", (void *) user_units); fix_store->setptr("model_units", (void *) model_units); + int kimerror; + // @@@@@ switch to c-bindings when they are available + KIM::SimulatorModel * simulatorModel; + kimerror = KIM::SimulatorModel::Create(model_name,&simulatorModel); + + const std::string *sim_name, *sim_version; + simulatorModel->GetSimulatorNameAndVersion(&sim_name, &sim_version); + + if (*sim_name != "LAMMPS") + error->all(FLERR,"Incompatible KIM Simulator Model"); + + // Begin output to log file + kim_style_log_delimiter("begin","model"); + if (comm->me == 0) { + std::string mesg("# Using KIM Simulator Model : "); + mesg += model_name; + mesg += "\n"; + mesg += "# For Simulator : "; + mesg += *sim_name + " " + *sim_version + "\n"; + mesg += "# Running on : LAMMPS "; + mesg += universe->version; + mesg += "\n"; + mesg += "#\n"; + + if (screen) fputs(mesg.c_str(),screen); + if (logfile) fputs(mesg.c_str(),logfile); + } + + // Define unit conversion factor variables and print to log + if (unit_conversion_mode) do_variables(user_units, model_units); + // set units std::string cmd("units "); cmd += model_units; input->one(cmd.c_str()); - int kimerror; - // @@@@@ switch to c-bindings when they are available - KIM::SimulatorModel * simulatorModel; - kimerror = KIM::SimulatorModel::Create(model_name,&simulatorModel); - // not a Kim Simulator Model; nothing else to do here. if (kimerror) return; @@ -318,13 +348,36 @@ void KimStyle::do_init(char *model_name, char *user_units, char* model_units) } } - // reset template map. + // End output to log file + kim_style_log_delimiter("end","model"); + // reset template map. simulatorModel->OpenAndInitializeTemplateMap(); } /* ---------------------------------------------------------------------- */ +void KimStyle::kim_style_log_delimiter(std::string begin_end, + std::string model_setup) +{ + if (comm->me == 0) { + std::string mesg; + if ((begin_end == "begin") && (model_setup == "model")) mesg = + "#=== BEGIN kim-style MODEL ==================================\n"; + else if ((begin_end == "begin") && (model_setup == "setup")) mesg = + "#=== BEGIN kim-style SETUP ==================================\n"; + else if ((begin_end == "end") && (model_setup == "model")) mesg = + "#=== END kim-style MODEL ====================================\n\n"; + else if ((begin_end == "end") && (model_setup == "setup")) mesg = + "#=== END kim-style SETUP ====================================\n\n"; + + if (screen) fputs(mesg.c_str(),screen); + if (logfile) fputs(mesg.c_str(),logfile); + } +} + +/* ---------------------------------------------------------------------- */ + void KimStyle::do_setup(int narg, char **arg) { if (narg != atom->ntypes) @@ -345,30 +398,13 @@ void KimStyle::do_setup(int narg, char **arg) simulatorModel = (KIM::SimulatorModel *)fix_store->getptr("simulator_model"); } else error->all(FLERR,"Must use 'kim_style model' before 'kim_style setup'"); + // Begin output to log file + kim_style_log_delimiter("begin","setup"); + if (simulatorModel) { - const std::string *sim_name, *sim_version; std::string atom_type_sym_list; - simulatorModel->GetSimulatorNameAndVersion(&sim_name, &sim_version); - - if (comm->me == 0) { - std::string mesg("Using KIM Simulator Model : "); - mesg += model; - mesg += "\n"; - mesg += "For Simulator : "; - mesg += *sim_name + " " + *sim_version + "\n"; - mesg += "Running on : LAMMPS "; - mesg += universe->version; - mesg += "\n"; - - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); - } - - if (*sim_name != "LAMMPS") - error->all(FLERR,"Incompatible KIM Simulator Model"); - for (int i = 0; i < narg; i++) atom_type_sym_list += std::string(" ") + arg[i]; @@ -455,6 +491,10 @@ void KimStyle::do_setup(int narg, char **arg) input->one(cmd1.c_str()); input->one(cmd2.c_str()); } + + // End output to log file + kim_style_log_delimiter("end","setup"); + } /* ---------------------------------------------------------------------- */ @@ -464,85 +504,74 @@ void KimStyle::do_variables(char *user_units, char *model_units) char *from = user_units, *to = model_units; Variable *variable = input->variable; - // refuse convertion from or to reduced units + // refuse conversion from or to reduced units if ((strcmp(from,"lj") == 0) || (strcmp(to,"lj") == 0)) error->all(FLERR,"Cannot set up conversion variables for 'lj' units"); // get index to internal style variables. create, if needed. - // default to conversion factor 1.0 for newly created variables - - // @@@@@@ below needs to be updated to use Ellad's luc. - int v_length, v_mass, v_time; + // set conversion factors for newly created variables. + double conversion_factor; + int ier; char *args[3]; + std::string var_str; args[1] = (char *)"internal"; args[2] = (char *)"1.0"; - - args[0] = (char *)"_u_length"; - v_length = variable->find(args[0]); - if (v_length < 0) { - variable->set(3,args); - v_length = variable->find(args[0]); + int v_unit; + int const nunits = 14; + char *units[nunits] = {(char *)"mass", + (char *)"distance", + (char *)"time", + (char *)"energy", + (char *)"velocity", + (char *)"force", + (char *)"torque", + (char *)"temperature", + (char *)"pressure", + (char *)"viscosity", + (char *)"charge", + (char *)"dipole", + (char *)"efield", + (char *)"density"}; + + if (comm->me == 0) { + std::stringstream mesg; + mesg << "# Conversion factors from " << from << " to " << to + << ":" << std::endl; + if (screen) fputs(mesg.str().c_str(),screen); + if (logfile) fputs(mesg.str().c_str(),logfile); } - args[0] = (char *)"_u_mass"; - v_mass = variable->find(args[0]); - if (v_mass < 0) { - variable->set(3,args); - v_mass = variable->find(args[0]); - } - - args[0] = (char *)"_u_time"; - v_time = variable->find(args[0]); - if (v_time < 0) { - variable->set(3,args); - v_time = variable->find(args[0]); - } - - // special case: both unit styles are the same => conversion factor 1.0 - - if (strcmp(from,to) == 0) { - variable->internal_set(v_length,1.0); - variable->internal_set(v_mass,1.0); - variable->internal_set(v_time,1.0); - return; - } - - if (strcmp(from,"real") == 0) { - if (strcmp(to,"metal") == 0) { - variable->internal_set(v_length,1.0); - variable->internal_set(v_mass,1.0); - variable->internal_set(v_time,0.001); - } else { - std::string err("Do not know how to set up conversion variables "); - err += "between '"; - err += from; - err += "' and '"; - err += to; - err += "' units"; + for (int i = 0; i < nunits; i++) + { + var_str = std::string("_u_") + std::string(units[i]); + args[0] = (char *)var_str.c_str(); + v_unit = variable->find(args[0]); + if (v_unit < 0) { + variable->set(3,args); + v_unit = variable->find(args[0]); + } + ier = lammps_unit_conversion(units[i], + from, + to, + conversion_factor); + if (ier != 0) { + std::string err = std::string("Unable to obtain conversion factor: ") + + "unit = " + units[i] + "; " + "from = " + from + "; " + "to = " + to + "."; error->all(FLERR,err.c_str()); } - } else if (strcmp(from,"metal") == 0) { - if (strcmp(to,"real") == 0) { - variable->internal_set(v_length,1.0); - variable->internal_set(v_mass,1.0); - variable->internal_set(v_time,1000.0); - } else { - std::string err("Do not know how to set up conversion variables "); - err += "between '"; - err += from; - err += "' and '"; - err += to; - err += "' units"; - error->all(FLERR,err.c_str()); + variable->internal_set(v_unit,conversion_factor); + if (comm->me == 0) { + std::stringstream mesg; + mesg << "# " << var_str << " = " << conversion_factor << std::endl; + if (screen) fputs(mesg.str().c_str(),screen); + if (logfile) fputs(mesg.str().c_str(),logfile); } - } else { - std::string err("Do not know how to set up conversion variables "); - err += "between '"; - err += from; - err += "' and '"; - err += to; - err += "' units"; - error->all(FLERR,err.c_str()); + } + if (comm->me == 0) { + if (screen) fputs("#\n",screen); + if (logfile) fputs("#\n",logfile); } } diff --git a/src/KIM/kim_style.h b/src/KIM/kim_style.h index b7ff47404f..b18f6627ea 100644 --- a/src/KIM/kim_style.h +++ b/src/KIM/kim_style.h @@ -80,6 +80,8 @@ class KimStyle : protected Pointers { void do_init(char *, char *, char *); void do_setup(int, char **); void do_variables(char*, char*); + void kim_style_log_delimiter(std::string begin_end, + std::string model_setup); }; } diff --git a/src/KIM/kim_units.cpp b/src/KIM/kim_units.cpp new file mode 100644 index 0000000000..fe90d58e9e --- /dev/null +++ b/src/KIM/kim_units.cpp @@ -0,0 +1,1411 @@ +/* ---------------------------------------------------------------------- + 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: Ellad B. Tadmor (UMN) +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, see . + + Linking LAMMPS statically or dynamically with other modules is making a + combined work based on LAMMPS. Thus, the terms and conditions of the GNU + General Public License cover the whole combination. + + In addition, as a special exception, the copyright holders of LAMMPS give + you permission to combine LAMMPS with free software programs or libraries + that are released under the GNU LGPL and with code included in the standard + release of the "kim-api" under the CDDL (or modified versions of such code, + with unchanged license). You may copy and distribute such a system following + the terms of the GNU GPL for LAMMPS and the licenses of the other code + concerned, provided that you include the source code of that other code + when and as the GNU GPL requires distribution of source code. + + Note that people who make modified versions of LAMMPS are not obligated to + grant this special exception for their modified versions; it is their choice + whether to do so. The GNU General Public License gives permission to release + a modified version without this exception; this exception also makes it + possible to release a modified version which carries forward this exception. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Designed for use with the kim-api-2.0.2 (and newer) package +------------------------------------------------------------------------- */ + +#include +#include +#include +#include +using namespace std; + +namespace +{ + +// Constants of nature and basic conversion factors +// Source: https://physics.nist.gov/cuu/Constants/Table/allascii.txt +// Working with NIST values even when there are newer values for +// compatibility with LAMMPS + +/*---------------------- + Fundamental constants +------------------------ */ +double const boltz_si = 1.38064852e-23; // [J K^-1] Boltzmann's factor + // (NIST value) +double const Nav = 6.022140857e23; // [unitless] Avogadro's number + // (NIST value) +// double const Nav = 6.02214076e23; // [unitless] Avogadro's number + // (official value May 2019) +double const me = 9.10938356e-31; // [kg] electron rest mass + // (NIST value) +// double me = 9.10938291e-31; // [kg] electron rest mass +double const e_si = 1.6021766208e-19; // [C] elementary charge + // (charge of an electron/proton) + // (NIST value) + +/*---------------------- + Distance units +------------------------ */ +double const bohr_si = 5.2917721067e-11; // [m] Bohr unit (distance between + // nucleus and electron in H) + // (NIST value) +double const angstrom_si = 1e-10; // [m] Angstrom +double const centimeter_si = 1e-2; // [m] centimeter +double const micrometer_si = 1e-6; // [m] micrometer (micron) +double const nanometer_si = 1e-9; // [m] nanometer + +/*---------------------- + Mass units +------------------------ */ +double const gram_per_mole_si = 1e-3/Nav; // [kg] gram per mole +double const amu_si = 1e-3/Nav; // [kg] atomic mass unit (molecular + // weight) For example, the mean + // molecular weight of water + // is 18.015 atomic mass units + // (amu), so one mole of water + // weight 18.015 grams. +double const gram_si = 1e-3; // [kg] gram +double const picogram_si = 1e-15; // [kg] picogram +double const attogram_si = 1e-21; // [kg[ attogram + +/*---------------------- + Time units +------------------------ */ +double const atu_si = 2.418884326509e-17; // [s] atomic time unit + // ( = hbar/E_h where E_h is the + // Hartree energy) (NIST value) +double const atu_electron_si = atu_si*sqrt(amu_si/me); // [s] atomic time unit + // used in electron system (see https://sourceforge.net/p/lammps/mailman/lammps-users/thread/BCA2BDB2-BA03-4280-896F-1E6120EF47B2%40caltech.edu/) +double const microsecond_si = 1e-6; // [s] microsecond +double const nanosecond_si = 1e-9; // [s] nanosecond +double const picosecond_si = 1e-12; // [s] picosecond +double const femtosecond_si = 1e-15; // [s] femtosecond + +/*---------------------- + Density units +------------------------ */ +double const gram_per_centimetercu_si = + gram_si/pow(centimeter_si,3); // [kg/m^3] gram/centimeter^3 +double const amu_per_bohrcu_si = amu_si/pow(bohr_si,3); // [kg/m^3] amu/bohr^3 +double const picogram_per_micrometercu_si = + picogram_si/pow(micrometer_si,3); // [kg/m^3] picogram/micrometer^3 +double const attogram_per_nanometercu_si = + attogram_si/pow(nanometer_si,3); // [kg/m^3] attogram/ + // nanomaterial^3 + +/*---------------------- + Energy/torque units +------------------------ */ +double const kcal_si = 4184.0; // [J] kilocalroie (heat energy + // involved in warming up one + // kilogram of water by one + // degree Kelvin) +double const ev_si = 1.6021766208e-19; // [J] electon volt (amount of + // energy gained or lost by the + // charge of a single electron + // moving across an electric + // potential difference of one + // volt.) (NIST value) +double const hartree_si = 4.359744650e-18; // [J] Hartree (approximately the + // electric potential energy of + // the hydrogen atom in its + // ground state) (NIST value) +double const kcal_per_mole_si = kcal_si/Nav;// [J] kcal/mole +double const erg_si = 1e-7; // [J] erg +double const dyne_centimeter_si = 1e-7; // [J[ dyne*centimeter +double const picogram_micrometersq_per_microsecondsq_si = + picogram_si*pow(micrometer_si,2)/pow(microsecond_si,2); + // [J] pigogram*micrometer^2/ + // micorsecond^2 +double const attogram_nanometersq_per_nanosecondsq_si = + attogram_si*pow(nanometer_si,2)/pow(nanosecond_si,2); + // [J] attogram*nanometer^2/ + // nanosecond^2 + +/*---------------------- + Velocity units +------------------------ */ +double const angstrom_per_femtosecond_si = + angstrom_si/femtosecond_si; // [m/s] Angstrom/femtosecond +double const angstrom_per_picosecond_si = + angstrom_si/picosecond_si; // [m/s] Angstrom/picosecond +double const micrometer_per_microsecond_si = + micrometer_si/microsecond_si; // [m/s] micrometer/microsecond +double const nanometer_per_nanosecond_si = + nanometer_si/nanosecond_si; // [m/s] nanometer/nanosecond +double const centimeter_per_second_si = + centimeter_si; // [m/s] centimeter/second +double const bohr_per_atu_si = + bohr_si/atu_electron_si; // [m/s] bohr/atu + +/*---------------------- + Force units +------------------------ */ +double const kcal_per_mole_angstrom_si = + kcal_per_mole_si/angstrom_si; // [N] kcal/(mole*Angstrom) +double const ev_per_angstrom_si = + ev_si/angstrom_si; // [N] eV/Angstrom +double const dyne_si = + dyne_centimeter_si/centimeter_si; // [N] dyne +double const hartree_per_bohr_si = + hartree_si/bohr_si; // [N] hartree/bohr +double const picogram_micrometer_per_microsecondsq_si = + picogram_si*micrometer_si/pow(microsecond_si,2); + // [N] picogram*micrometer/ + // microsecond^2 +double const attogram_nanometer_per_nanosecondsq_si = + attogram_si*nanometer_si/pow(nanosecond_si,2); + // [N] attogram*nanometer/ + // nanosecond^2 + +/*---------------------- + Pressure units +------------------------ */ +double const atmosphere_si = 101325.0; // [Pa] standard atmosphere (NIST value) +double const bar_si = 1e5; // [Pa] bar +double const dyne_per_centimetersq_si = + dyne_centimeter_si/pow(centimeter_si,3); + // [Pa] dyne/centimeter^2 +double const picogram_per_micrometer_microsecondsq_si = + picogram_si/(micrometer_si*pow(microsecond_si,2)); + // [Pa] picogram/(micrometer* + // microsecond^2) +double const attogram_per_nanometer_nanosecondsq_si = + attogram_si/(nanometer_si*pow(nanosecond_si,2)); + // [Pa] attogram/(nanometer*nanosecond^2) + +/*---------------------- + Viscosity units +------------------------ */ +double const poise_si = 0.1; // [Pa*s] Poise +double const amu_per_bohr_femtosecond_si = + amu_si/(bohr_si*femtosecond_si); // [Pa*s] amu/(bohr*femtosecond) +double const picogram_per_micrometer_microsecond_si = + picogram_si/(micrometer_si*microsecond_si); + // [Pa*s] picogram/(micrometer* + // microsecond) +double const attogram_per_nanometer_nanosecond_si = + attogram_si/(nanometer_si*nanosecond_si); + // [Pa*s] attogram/(nanometer* + // nanosecond) + +/*---------------------- + Charge units +------------------------ */ +double const echarge_si = e_si; // [C] electron charge unit +double const statcoulomb_si = e_si/4.8032044e-10; // [C] Statcoulomb or esu + // (value from LAMMPS units + // documentation) +double const picocoulomb_si = 1e-12; // [C] picocoulomb + +/*---------------------- + Dipole units +------------------------ */ +double const electron_angstrom_si = echarge_si*angstrom_si; + // [C*m] electron*angstrom +double const statcoulomb_centimeter_si = statcoulomb_si*centimeter_si; + // [C*m] statcoulomb*centimeter +double const debye_si = 1e-18*statcoulomb_centimeter_si; + // [C*m] Debye +double const picocoulomb_micrometer_si = picocoulomb_si*micrometer_si; + // [C*m] picocoulomb*micrometer +double const electron_nanometer_si = echarge_si*nanometer_si; + // [C*m] electron*nanometer + +/*---------------------- + Electric field units +------------------------ */ +double const volt_per_angstrom_si = 1.0/angstrom_si;// [V/m] volt/angstrom +double const statvolt_per_centimeter_si = + erg_si/(statcoulomb_si*centimeter_si); // [V/m] statvolt/centimeter +double const volt_per_centimeter_si = + 1.0/centimeter_si; // [V/m] volt/centimeter +double const volt_per_micrometer_si = + 1.0/micrometer_si; // [V/m] volt/micrometer +double const volt_per_nanometer_si = + 1.0/nanometer_si; // [V/m] volt/nanometer + +// Define enumerations +enum sys_type +{ + real = 1, + metal = 2, + si = 3, + cgs = 4, + electron = 5, + micro = 6, + nano = 7 +}; + +enum unit_type +{ + mass = 1, + distance = 2, + time = 3, + energy = 4, + velocity = 5, + force = 6, + torque = 7, + temperature = 8, + pressure = 9, + viscosity = 10, + charge = 11, + dipole = 12, + efield = 13, + density = 14 +}; + +enum units +{ + // mass + gram_per_mole = 101, + kilogram = 102, + gram = 103, + amu = 104, + picogram = 105, + attogram = 106, + // distance + angstrom = 201, + meter = 202, + centimeter = 203, + bohr = 204, + micrometer = 205, + nanometer = 206, + // time + femtosecond = 301, + picosecond = 302, + second = 303, + microsecond = 304, + nanosecond = 305, + // energy + kcal_per_mole = 401, + ev = 402, + joule = 403, + erg = 404, + hartree = 405, + picogram_micrometersq_per_microsecondsq = 406, + attogram_nanometersq_per_nanosecondsq = 407, + // velocity + angstrom_per_femtosecond = 501, + angstrom_per_picosecond = 502, + meter_per_second = 503, + centimeter_per_second = 504, + bohr_per_atu = 505, + micrometer_per_microsecond = 506, + nanometer_per_nanosecond = 507, + // force + kcal_per_mole_angstrom = 601, + ev_per_angstrom = 602, + newton = 603, + dyne = 604, + hartree_per_bohr = 605, + picogram_micrometer_per_microsecondsq = 606, + attogram_nanometer_per_nanosecondsq = 607, + // torque + newton_meter = 701, + dyne_centimeter = 702, + // temperature + kelvin = 801, + // pressure + atmosphere = 901, + bar = 902, + pascal = 903, + dyne_per_centimetersq = 904, + picogram_per_micrometer_microsecondsq = 905, + attogram_per_nanometer_nanosecondsq = 906, + // viscosity + poise = 1001, + pascal_second = 1002, + amu_per_bohr_femtosecond = 1003, // electron system, not in docs, GUESSED + picogram_per_micrometer_microsecond = 1004, + attogram_per_nanometer_nanosecond = 1005, + // charge + echarge = 1101, + coulomb = 1102, + statcoulomb = 1103, + picocoulomb = 1104, + // dipole + electron_angstrom = 1201, + coulomb_meter = 1202, + statcoulomb_centimeter = 1203, + debye = 1204, + picocoulomb_micrometer = 1205, + electron_nanometer = 1206, + // electric field + volt_per_angstrom = 1301, + volt_per_meter = 1302, + statvolt_per_centimeter = 1303, + volt_per_centimeter = 1304, + volt_per_micrometer = 1305, + volt_per_nanometer = 1306, + // density + gram_per_centimetercu = 1401, + kilogram_per_metercu = 1402, + amu_per_bohrcu = 1403, // electron system, not in docs, GUESSED + picogram_per_micrometercu = 1404, + attogram_per_nanometercu = 1405 +}; + +// Define dictionaries +map system_dic; +map unit_dic; +map units_real_dic; +map units_metal_dic; +map units_si_dic; +map units_cgs_dic; +map units_electron_dic; +map units_micro_dic; +map units_nano_dic; + +/* ---------------------------------------------------------------------- */ + +void initialize_dictionaries() +{ + system_dic["real"] = real; + system_dic["metal"] = metal; + system_dic["si"] = si; + system_dic["cgs"] = cgs; + system_dic["electron"] = electron; + system_dic["micro"] = micro; + system_dic["nano"] = nano; + + unit_dic["mass"] = mass; + unit_dic["distance"] = distance; + unit_dic["time"] = time; + unit_dic["energy"] = energy; + unit_dic["velocity"] = velocity; + unit_dic["force"] = force; + unit_dic["torque"] = torque; + unit_dic["temperature"]= temperature; + unit_dic["pressure"] = pressure; + unit_dic["viscosity"] = viscosity; + unit_dic["charge"] = charge; + unit_dic["dipole"] = dipole; + unit_dic["efield"] = efield; + unit_dic["density"] = density; + + units_real_dic[mass] = gram_per_mole; + units_real_dic[distance] = angstrom; + units_real_dic[time] = femtosecond; + units_real_dic[energy] = kcal_per_mole; + units_real_dic[velocity] = angstrom_per_femtosecond; + units_real_dic[force] = kcal_per_mole_angstrom; + units_real_dic[torque] = kcal_per_mole; + units_real_dic[temperature]= kelvin; + units_real_dic[pressure] = atmosphere; + units_real_dic[viscosity] = poise; + units_real_dic[charge] = echarge; + units_real_dic[dipole] = electron_angstrom; + units_real_dic[efield] = volt_per_angstrom; + units_real_dic[density] = gram_per_centimetercu; + + units_metal_dic[mass] = gram_per_mole; + units_metal_dic[distance] = angstrom; + units_metal_dic[time] = picosecond; + units_metal_dic[energy] = ev; + units_metal_dic[velocity] = angstrom_per_picosecond; + units_metal_dic[force] = ev_per_angstrom; + units_metal_dic[torque] = ev; + units_metal_dic[temperature]= kelvin; + units_metal_dic[pressure] = bar; + units_metal_dic[viscosity] = poise; + units_metal_dic[charge] = echarge; + units_metal_dic[dipole] = electron_angstrom; + units_metal_dic[efield] = volt_per_angstrom; + units_metal_dic[density] = gram_per_centimetercu; + + units_si_dic[mass] = kilogram; + units_si_dic[distance] = meter; + units_si_dic[time] = second; + units_si_dic[energy] = joule; + units_si_dic[velocity] = meter_per_second; + units_si_dic[force] = newton; + units_si_dic[torque] = newton_meter; + units_si_dic[temperature]= kelvin; + units_si_dic[pressure] = pascal; + units_si_dic[viscosity] = pascal_second; + units_si_dic[charge] = coulomb; + units_si_dic[dipole] = coulomb_meter; + units_si_dic[efield] = volt_per_meter; + units_si_dic[density] = kilogram_per_metercu; + + units_cgs_dic[mass] = gram; + units_cgs_dic[distance] = centimeter; + units_cgs_dic[time] = second; + units_cgs_dic[energy] = erg; + units_cgs_dic[velocity] = centimeter_per_second; + units_cgs_dic[force] = dyne; + units_cgs_dic[torque] = dyne_centimeter; + units_cgs_dic[temperature]= kelvin; + units_cgs_dic[pressure] = dyne_per_centimetersq; + units_cgs_dic[viscosity] = poise; + units_cgs_dic[charge] = statcoulomb; + units_cgs_dic[dipole] = statcoulomb_centimeter; + units_cgs_dic[efield] = statvolt_per_centimeter; + units_cgs_dic[density] = gram_per_centimetercu; + + units_electron_dic[mass] = amu; + units_electron_dic[distance] = bohr; + units_electron_dic[time] = femtosecond; + units_electron_dic[energy] = hartree; + units_electron_dic[velocity] = bohr_per_atu; + units_electron_dic[force] = hartree_per_bohr; + units_electron_dic[torque] = hartree; // unknown, GUESSED + units_electron_dic[temperature]= kelvin; + units_electron_dic[pressure] = pascal; + units_electron_dic[viscosity] = pascal_second; // unknown, GUESSED + units_electron_dic[charge] = echarge; + units_electron_dic[dipole] = debye; + units_electron_dic[efield] = volt_per_centimeter; + units_electron_dic[density] = amu_per_bohrcu; // unknown, GUESSED + + units_micro_dic[mass] = picogram; + units_micro_dic[distance] = micrometer; + units_micro_dic[time] = microsecond; + units_micro_dic[energy] = picogram_micrometersq_per_microsecondsq; + units_micro_dic[velocity] = micrometer_per_microsecond; + units_micro_dic[force] = picogram_micrometer_per_microsecondsq; + units_micro_dic[torque] = picogram_micrometersq_per_microsecondsq; + units_micro_dic[temperature]= kelvin; + units_micro_dic[pressure] = picogram_per_micrometer_microsecondsq; + units_micro_dic[viscosity] = picogram_per_micrometer_microsecond; + units_micro_dic[charge] = picocoulomb; + units_micro_dic[dipole] = picocoulomb_micrometer; + units_micro_dic[efield] = volt_per_micrometer; + units_micro_dic[density] = picogram_per_micrometercu; + + units_nano_dic[mass] = attogram; + units_nano_dic[distance] = nanometer; + units_nano_dic[time] = nanosecond; + units_nano_dic[energy] = attogram_nanometersq_per_nanosecondsq; + units_nano_dic[velocity] = nanometer_per_nanosecond; + units_nano_dic[force] = attogram_nanometer_per_nanosecondsq; + units_nano_dic[torque] = attogram_nanometersq_per_nanosecondsq; + units_nano_dic[temperature]= kelvin; + units_nano_dic[pressure] = attogram_per_nanometer_nanosecondsq; + units_nano_dic[viscosity] = attogram_per_nanometer_nanosecond; + units_nano_dic[charge] = echarge; + units_nano_dic[dipole] = electron_nanometer; + units_nano_dic[efield] = volt_per_nanometer; + units_nano_dic[density] = attogram_per_nanometercu; + +} + +/* ---------------------------------------------------------------------- */ + +// Get the enumeration for the unit of type `unit_type_enum` +// for LAMMPS system `system_enum`. +units get_lammps_system_unit(sys_type system_enum, unit_type unit_type_enum) +{ + switch(system_enum) { + case real : + return units_real_dic[unit_type_enum]; + case metal : + return units_metal_dic[unit_type_enum]; + case si : + return units_si_dic[unit_type_enum]; + case cgs : + return units_cgs_dic[unit_type_enum]; + case electron : + return units_electron_dic[unit_type_enum]; + case micro : + return units_micro_dic[unit_type_enum]; + case nano : + default : // This is here to a prevent a compiler warning + return units_nano_dic[unit_type_enum]; + } +} + +/* ---------------------------------------------------------------------- */ + +// Mass conversion +double get_mass_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[kilogram][kilogram] = 1.0; + conv[kilogram][gram_per_mole] = 1.0/gram_per_mole_si; + conv[kilogram][gram] = 1.0/gram_si; + conv[kilogram][amu] = 1.0/amu_si; + conv[kilogram][picogram] = 1.0/picogram_si; + conv[kilogram][attogram] = 1.0/attogram_si; + + to_si = 1.0/conv[kilogram][gram_per_mole]; + conv[gram_per_mole][kilogram] = to_si*conv[kilogram][kilogram]; + conv[gram_per_mole][gram_per_mole] = 1.0; + conv[gram_per_mole][gram] = to_si*conv[kilogram][gram]; + conv[gram_per_mole][amu] = to_si*conv[kilogram][amu]; + conv[gram_per_mole][picogram] = to_si*conv[kilogram][picogram]; + conv[gram_per_mole][attogram] = to_si*conv[kilogram][attogram]; + + to_si = 1.0/conv[kilogram][gram]; + conv[gram][kilogram] = to_si*conv[kilogram][kilogram]; + conv[gram][gram_per_mole] = to_si*conv[kilogram][gram_per_mole]; + conv[gram][gram] = 1.0; + conv[gram][amu] = to_si*conv[kilogram][amu]; + conv[gram][picogram] = to_si*conv[kilogram][picogram]; + conv[gram][attogram] = to_si*conv[kilogram][attogram]; + + to_si = 1.0/conv[kilogram][amu]; + conv[amu][kilogram] = to_si*conv[kilogram][kilogram]; + conv[amu][gram_per_mole] = to_si*conv[kilogram][gram_per_mole]; + conv[amu][gram] = to_si*conv[kilogram][gram]; + conv[amu][amu] = 1.0; + conv[amu][picogram] = to_si*conv[kilogram][picogram]; + conv[amu][attogram] = to_si*conv[kilogram][attogram]; + + to_si = 1.0/conv[kilogram][picogram]; + conv[picogram][kilogram] = to_si*conv[kilogram][kilogram]; + conv[picogram][gram_per_mole] = to_si*conv[kilogram][gram_per_mole]; + conv[picogram][gram] = to_si*conv[kilogram][gram]; + conv[picogram][amu] = to_si*conv[kilogram][amu]; + conv[picogram][picogram] = 1.0; + conv[picogram][attogram] = to_si*conv[kilogram][attogram]; + + to_si = 1.0/conv[kilogram][attogram]; + conv[attogram][kilogram] = to_si*conv[kilogram][kilogram]; + conv[attogram][gram_per_mole] = to_si*conv[kilogram][gram_per_mole]; + conv[attogram][gram] = to_si*conv[kilogram][gram]; + conv[attogram][amu] = to_si*conv[kilogram][amu]; + conv[attogram][picogram] = to_si*conv[kilogram][picogram]; + conv[attogram][attogram] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Distance conversion +double get_distance_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[meter][meter] = 1.0; + conv[meter][angstrom] = 1.0/angstrom_si; + conv[meter][centimeter] = 1.0/centimeter_si; + conv[meter][bohr] = 1.0/bohr_si; + conv[meter][micrometer] = 1.0/micrometer_si; + conv[meter][nanometer] = 1.0/nanometer_si; + + to_si = 1.0/conv[meter][angstrom]; + conv[angstrom][meter] = to_si*conv[meter][meter]; + conv[angstrom][angstrom] = 1.0; + conv[angstrom][centimeter] = to_si*conv[meter][centimeter]; + conv[angstrom][bohr] = to_si*conv[meter][bohr]; + conv[angstrom][micrometer] = to_si*conv[meter][micrometer]; + conv[angstrom][nanometer] = to_si*conv[meter][nanometer]; + + to_si = 1.0/conv[meter][centimeter]; + conv[centimeter][meter] = to_si*conv[meter][meter]; + conv[centimeter][angstrom] = to_si*conv[meter][angstrom]; + conv[centimeter][centimeter] = 1.0; + conv[centimeter][bohr] = to_si*conv[meter][bohr]; + conv[centimeter][micrometer] = to_si*conv[meter][micrometer]; + conv[centimeter][nanometer] = to_si*conv[meter][nanometer]; + + to_si = 1.0/conv[meter][bohr]; + conv[bohr][meter] = to_si*conv[meter][meter]; + conv[bohr][angstrom] = to_si*conv[meter][angstrom]; + conv[bohr][centimeter] = to_si*conv[meter][centimeter]; + conv[bohr][bohr] = 1.0; + conv[bohr][micrometer] = to_si*conv[meter][micrometer]; + conv[bohr][nanometer] = to_si*conv[meter][nanometer]; + + to_si = 1.0/conv[meter][micrometer]; + conv[micrometer][meter] = to_si*conv[meter][meter]; + conv[micrometer][angstrom] = to_si*conv[meter][angstrom]; + conv[micrometer][centimeter] = to_si*conv[meter][centimeter]; + conv[micrometer][bohr] = to_si*conv[meter][bohr]; + conv[micrometer][micrometer] = 1.0; + conv[micrometer][nanometer] = to_si*conv[meter][nanometer]; + + to_si = 1.0/conv[meter][nanometer]; + conv[nanometer][meter] = to_si*conv[meter][meter]; + conv[nanometer][angstrom] = to_si*conv[meter][angstrom]; + conv[nanometer][centimeter] = to_si*conv[meter][centimeter]; + conv[nanometer][bohr] = to_si*conv[meter][bohr]; + conv[nanometer][micrometer] = to_si*conv[meter][micrometer]; + conv[nanometer][nanometer] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Time conversion +double get_time_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[second][second] = 1.0; + conv[second][femtosecond] = 1.0/femtosecond_si; + conv[second][picosecond] = 1.0/picosecond_si; + conv[second][microsecond] = 1.0/microsecond_si; + conv[second][nanosecond] = 1.0/nanosecond_si; + + to_si = 1.0/conv[second][femtosecond]; + conv[femtosecond][second] = to_si*conv[second][second]; + conv[femtosecond][femtosecond] = 1.0; + conv[femtosecond][picosecond] = to_si*conv[second][picosecond]; + conv[femtosecond][microsecond] = to_si*conv[second][microsecond]; + conv[femtosecond][nanosecond] = to_si*conv[second][nanosecond]; + + to_si = 1.0/conv[second][picosecond]; + conv[picosecond][second] = to_si*conv[second][second]; + conv[picosecond][femtosecond] = to_si*conv[second][femtosecond]; + conv[picosecond][picosecond] = 1.0; + conv[picosecond][microsecond] = to_si*conv[second][microsecond]; + conv[picosecond][nanosecond] = to_si*conv[second][nanosecond]; + + to_si = 1.0/conv[second][microsecond]; + conv[microsecond][second] = to_si*conv[second][second]; + conv[microsecond][femtosecond] = to_si*conv[second][femtosecond]; + conv[microsecond][picosecond] = to_si*conv[second][picosecond]; + conv[microsecond][microsecond] = 1.0; + conv[microsecond][nanosecond] = to_si*conv[second][nanosecond]; + + to_si = 1.0/conv[second][nanosecond]; + conv[nanosecond][second] = to_si*conv[second][second]; + conv[nanosecond][femtosecond] = to_si*conv[second][femtosecond]; + conv[nanosecond][picosecond] = to_si*conv[second][picosecond]; + conv[nanosecond][microsecond] = to_si*conv[second][microsecond]; + conv[nanosecond][nanosecond] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Energy conversion +double get_energy_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + + map > conv; + double to_si; + + conv[joule][joule] = 1.0; + conv[joule][kcal_per_mole] = 1.0/kcal_per_mole_si; + conv[joule][ev] = 1.0/ev_si; + conv[joule][erg] = 1.0/erg_si; + conv[joule][hartree] = 1.0/hartree_si; + conv[joule][picogram_micrometersq_per_microsecondsq] = 1.0/picogram_micrometersq_per_microsecondsq_si; + conv[joule][attogram_nanometersq_per_nanosecondsq] = 1.0/attogram_nanometersq_per_nanosecondsq_si; + + to_si = 1.0/conv[joule][kcal_per_mole]; + conv[kcal_per_mole][joule] = to_si*conv[joule][joule]; + conv[kcal_per_mole][kcal_per_mole] = 1.0; + conv[kcal_per_mole][ev] = to_si*conv[joule][ev]; + conv[kcal_per_mole][erg] = to_si*conv[joule][erg]; + conv[kcal_per_mole][hartree] = to_si*conv[joule][hartree]; + conv[kcal_per_mole][picogram_micrometersq_per_microsecondsq] = to_si*conv[joule][picogram_micrometersq_per_microsecondsq]; + conv[kcal_per_mole][attogram_nanometersq_per_nanosecondsq] = to_si*conv[joule][attogram_nanometersq_per_nanosecondsq]; + + to_si = 1.0/conv[joule][ev]; + conv[ev][joule] = to_si*conv[joule][joule]; + conv[ev][kcal_per_mole] = to_si*conv[joule][kcal_per_mole]; + conv[ev][ev] = 1.0; + conv[ev][erg] = to_si*conv[joule][erg]; + conv[ev][hartree] = to_si*conv[joule][hartree]; + conv[ev][picogram_micrometersq_per_microsecondsq] = to_si*conv[joule][picogram_micrometersq_per_microsecondsq]; + conv[ev][attogram_nanometersq_per_nanosecondsq] = to_si*conv[joule][attogram_nanometersq_per_nanosecondsq]; + + to_si = 1.0/conv[joule][erg]; + conv[erg][joule] = to_si*conv[joule][joule]; + conv[erg][kcal_per_mole] = to_si*conv[joule][kcal_per_mole]; + conv[erg][ev] = to_si*conv[joule][ev]; + conv[erg][erg] = 1.0; + conv[erg][hartree] = to_si*conv[joule][hartree]; + conv[erg][picogram_micrometersq_per_microsecondsq] = to_si*conv[joule][picogram_micrometersq_per_microsecondsq]; + conv[erg][attogram_nanometersq_per_nanosecondsq] = to_si*conv[joule][attogram_nanometersq_per_nanosecondsq]; + + to_si = 1.0/conv[joule][hartree]; + conv[hartree][joule] = to_si*conv[joule][joule]; + conv[hartree][kcal_per_mole] = to_si*conv[joule][kcal_per_mole]; + conv[hartree][ev] = to_si*conv[joule][ev]; + conv[hartree][erg] = to_si*conv[joule][erg]; + conv[hartree][hartree] = 1.0; + conv[hartree][picogram_micrometersq_per_microsecondsq] = to_si*conv[joule][picogram_micrometersq_per_microsecondsq]; + conv[hartree][attogram_nanometersq_per_nanosecondsq] = to_si*conv[joule][attogram_nanometersq_per_nanosecondsq]; + + to_si = 1.0/conv[joule][picogram_micrometersq_per_microsecondsq]; + conv[picogram_micrometersq_per_microsecondsq][joule] = to_si*conv[joule][joule]; + conv[picogram_micrometersq_per_microsecondsq][kcal_per_mole] = to_si*conv[joule][kcal_per_mole]; + conv[picogram_micrometersq_per_microsecondsq][ev] = to_si*conv[joule][ev]; + conv[picogram_micrometersq_per_microsecondsq][erg] = to_si*conv[joule][erg]; + conv[picogram_micrometersq_per_microsecondsq][hartree] = to_si*conv[joule][hartree]; + conv[picogram_micrometersq_per_microsecondsq][picogram_micrometersq_per_microsecondsq] = 1.0; + conv[picogram_micrometersq_per_microsecondsq][attogram_nanometersq_per_nanosecondsq] = to_si*conv[joule][attogram_nanometersq_per_nanosecondsq]; + + to_si = 1.0/conv[joule][attogram_nanometersq_per_nanosecondsq]; + conv[attogram_nanometersq_per_nanosecondsq][joule] = to_si*conv[joule][joule]; + conv[attogram_nanometersq_per_nanosecondsq][kcal_per_mole] = to_si*conv[joule][kcal_per_mole]; + conv[attogram_nanometersq_per_nanosecondsq][ev] = to_si*conv[joule][ev]; + conv[attogram_nanometersq_per_nanosecondsq][erg] = to_si*conv[joule][erg]; + conv[attogram_nanometersq_per_nanosecondsq][hartree] = to_si*conv[joule][hartree]; + conv[attogram_nanometersq_per_nanosecondsq][picogram_micrometersq_per_microsecondsq] = to_si*conv[joule][picogram_micrometersq_per_microsecondsq]; + conv[attogram_nanometersq_per_nanosecondsq][attogram_nanometersq_per_nanosecondsq] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Velocity conversion +double get_velocity_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[meter_per_second][meter_per_second] = 1.0; + conv[meter_per_second][angstrom_per_femtosecond] = 1.0/angstrom_per_femtosecond_si; + conv[meter_per_second][angstrom_per_picosecond] = 1.0/angstrom_per_picosecond_si; + conv[meter_per_second][centimeter_per_second] = 1.0/centimeter_per_second_si; + conv[meter_per_second][bohr_per_atu] = 1.0/bohr_per_atu_si; + conv[meter_per_second][micrometer_per_microsecond] = 1.0/micrometer_per_microsecond_si; + conv[meter_per_second][nanometer_per_nanosecond] = 1.0/nanometer_per_nanosecond_si; + + to_si = 1.0/conv[meter_per_second][angstrom_per_femtosecond]; + conv[angstrom_per_femtosecond][meter_per_second] = to_si*conv[meter_per_second][meter_per_second]; + conv[angstrom_per_femtosecond][angstrom_per_femtosecond] = 1.0; + conv[angstrom_per_femtosecond][angstrom_per_picosecond] = to_si*conv[meter_per_second][angstrom_per_picosecond]; + conv[angstrom_per_femtosecond][centimeter_per_second] = to_si*conv[meter_per_second][centimeter_per_second]; + conv[angstrom_per_femtosecond][bohr_per_atu] = to_si*conv[meter_per_second][bohr_per_atu]; + conv[angstrom_per_femtosecond][micrometer_per_microsecond] = to_si*conv[meter_per_second][micrometer_per_microsecond]; + conv[angstrom_per_femtosecond][nanometer_per_nanosecond] = to_si*conv[meter_per_second][nanometer_per_nanosecond]; + + to_si = 1.0/conv[meter_per_second][angstrom_per_picosecond]; + conv[angstrom_per_picosecond][meter_per_second] = to_si*conv[meter_per_second][meter_per_second]; + conv[angstrom_per_picosecond][angstrom_per_femtosecond] = to_si*conv[meter_per_second][angstrom_per_femtosecond]; + conv[angstrom_per_picosecond][angstrom_per_picosecond] = 1.0; + conv[angstrom_per_picosecond][centimeter_per_second] = to_si*conv[meter_per_second][centimeter_per_second]; + conv[angstrom_per_picosecond][bohr_per_atu] = to_si*conv[meter_per_second][bohr_per_atu]; + conv[angstrom_per_picosecond][micrometer_per_microsecond] = to_si*conv[meter_per_second][micrometer_per_microsecond]; + conv[angstrom_per_picosecond][nanometer_per_nanosecond] = to_si*conv[meter_per_second][nanometer_per_nanosecond]; + + to_si = 1.0/conv[meter_per_second][centimeter_per_second]; + conv[centimeter_per_second][meter_per_second] = to_si*conv[meter_per_second][meter_per_second]; + conv[centimeter_per_second][angstrom_per_femtosecond] = to_si*conv[meter_per_second][angstrom_per_femtosecond]; + conv[centimeter_per_second][angstrom_per_picosecond] = to_si*conv[meter_per_second][angstrom_per_picosecond]; + conv[centimeter_per_second][centimeter_per_second] = 1.0; + conv[centimeter_per_second][bohr_per_atu] = to_si*conv[meter_per_second][bohr_per_atu]; + conv[centimeter_per_second][micrometer_per_microsecond] = to_si*conv[meter_per_second][micrometer_per_microsecond]; + conv[centimeter_per_second][nanometer_per_nanosecond] = to_si*conv[meter_per_second][nanometer_per_nanosecond]; + + to_si = 1.0/conv[meter_per_second][bohr_per_atu]; + conv[bohr_per_atu][meter_per_second] = to_si*conv[meter_per_second][meter_per_second]; + conv[bohr_per_atu][angstrom_per_femtosecond] = to_si*conv[meter_per_second][angstrom_per_femtosecond]; + conv[bohr_per_atu][angstrom_per_picosecond] = to_si*conv[meter_per_second][angstrom_per_picosecond]; + conv[bohr_per_atu][centimeter_per_second] = to_si*conv[meter_per_second][centimeter_per_second]; + conv[bohr_per_atu][bohr_per_atu] = 1.0; + conv[bohr_per_atu][micrometer_per_microsecond] = to_si*conv[meter_per_second][micrometer_per_microsecond]; + conv[bohr_per_atu][nanometer_per_nanosecond] = to_si*conv[meter_per_second][nanometer_per_nanosecond]; + + to_si = 1.0/conv[meter_per_second][micrometer_per_microsecond]; + conv[micrometer_per_microsecond][meter_per_second] = to_si*conv[meter_per_second][meter_per_second]; + conv[micrometer_per_microsecond][angstrom_per_femtosecond] = to_si*conv[meter_per_second][angstrom_per_femtosecond]; + conv[micrometer_per_microsecond][angstrom_per_picosecond] = to_si*conv[meter_per_second][angstrom_per_picosecond]; + conv[micrometer_per_microsecond][centimeter_per_second] = to_si*conv[meter_per_second][centimeter_per_second]; + conv[micrometer_per_microsecond][bohr_per_atu] = to_si*conv[meter_per_second][bohr_per_atu]; + conv[micrometer_per_microsecond][micrometer_per_microsecond] = 1.0; + conv[micrometer_per_microsecond][nanometer_per_nanosecond] = to_si*conv[meter_per_second][nanometer_per_nanosecond]; + + to_si = 1.0/conv[meter_per_second][nanometer_per_nanosecond]; + conv[nanometer_per_nanosecond][meter_per_second] = to_si*conv[meter_per_second][meter_per_second]; + conv[nanometer_per_nanosecond][angstrom_per_femtosecond] = to_si*conv[meter_per_second][angstrom_per_femtosecond]; + conv[nanometer_per_nanosecond][angstrom_per_picosecond] = to_si*conv[meter_per_second][angstrom_per_picosecond]; + conv[nanometer_per_nanosecond][centimeter_per_second] = to_si*conv[meter_per_second][centimeter_per_second]; + conv[nanometer_per_nanosecond][bohr_per_atu] = to_si*conv[meter_per_second][bohr_per_atu]; + conv[nanometer_per_nanosecond][micrometer_per_microsecond] = to_si*conv[meter_per_second][micrometer_per_microsecond]; + conv[nanometer_per_nanosecond][nanometer_per_nanosecond] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Force conversion +double get_force_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[newton][newton] = 1.0; + conv[newton][kcal_per_mole_angstrom] = 1.0/kcal_per_mole_angstrom_si; + conv[newton][ev_per_angstrom] = 1.0/ev_per_angstrom_si; + conv[newton][dyne] = 1.0/dyne_si; + conv[newton][hartree_per_bohr] = 1.0/hartree_per_bohr_si; + conv[newton][picogram_micrometer_per_microsecondsq] = 1.0/picogram_micrometer_per_microsecondsq_si; + conv[newton][attogram_nanometer_per_nanosecondsq] = 1.0/attogram_nanometer_per_nanosecondsq_si; + + to_si = 1.0/conv[newton][kcal_per_mole_angstrom]; + conv[kcal_per_mole_angstrom][newton] = to_si*conv[newton][newton]; + conv[kcal_per_mole_angstrom][kcal_per_mole_angstrom] = 1.0; + conv[kcal_per_mole_angstrom][ev_per_angstrom] = to_si*conv[newton][ev_per_angstrom]; + conv[kcal_per_mole_angstrom][dyne] = to_si*conv[newton][dyne]; + conv[kcal_per_mole_angstrom][hartree_per_bohr] = to_si*conv[newton][hartree_per_bohr]; + conv[kcal_per_mole_angstrom][picogram_micrometer_per_microsecondsq] = to_si*conv[newton][picogram_micrometer_per_microsecondsq]; + conv[kcal_per_mole_angstrom][attogram_nanometer_per_nanosecondsq] = to_si*conv[newton][attogram_nanometer_per_nanosecondsq]; + + to_si = 1.0/conv[newton][ev_per_angstrom]; + conv[ev_per_angstrom][newton] = to_si*conv[newton][newton]; + conv[ev_per_angstrom][kcal_per_mole_angstrom] = to_si*conv[newton][kcal_per_mole_angstrom]; + conv[ev_per_angstrom][ev_per_angstrom] = 1.0; + conv[ev_per_angstrom][dyne] = to_si*conv[newton][dyne]; + conv[ev_per_angstrom][hartree_per_bohr] = to_si*conv[newton][hartree_per_bohr]; + conv[ev_per_angstrom][picogram_micrometer_per_microsecondsq] = to_si*conv[newton][picogram_micrometer_per_microsecondsq]; + conv[ev_per_angstrom][attogram_nanometer_per_nanosecondsq] = to_si*conv[newton][attogram_nanometer_per_nanosecondsq]; + + to_si = 1.0/conv[newton][dyne]; + conv[dyne][newton] = to_si*conv[newton][newton]; + conv[dyne][kcal_per_mole_angstrom] = to_si*conv[newton][kcal_per_mole_angstrom]; + conv[dyne][ev_per_angstrom] = to_si*conv[newton][ev_per_angstrom]; + conv[dyne][dyne] = 1.0; + conv[dyne][hartree_per_bohr] = to_si*conv[newton][hartree_per_bohr]; + conv[dyne][picogram_micrometer_per_microsecondsq] = to_si*conv[newton][picogram_micrometer_per_microsecondsq]; + conv[dyne][attogram_nanometer_per_nanosecondsq] = to_si*conv[newton][attogram_nanometer_per_nanosecondsq]; + + to_si = 1.0/conv[newton][hartree_per_bohr]; + conv[hartree_per_bohr][newton] = to_si*conv[newton][newton]; + conv[hartree_per_bohr][kcal_per_mole_angstrom] = to_si*conv[newton][kcal_per_mole_angstrom]; + conv[hartree_per_bohr][ev_per_angstrom] = to_si*conv[newton][ev_per_angstrom]; + conv[hartree_per_bohr][dyne] = to_si*conv[newton][dyne]; + conv[hartree_per_bohr][hartree_per_bohr] = 1.0; + conv[hartree_per_bohr][picogram_micrometer_per_microsecondsq] = to_si*conv[newton][picogram_micrometer_per_microsecondsq]; + conv[hartree_per_bohr][attogram_nanometer_per_nanosecondsq] = to_si*conv[newton][attogram_nanometer_per_nanosecondsq]; + + to_si = 1.0/conv[newton][picogram_micrometer_per_microsecondsq]; + conv[picogram_micrometer_per_microsecondsq][newton] = to_si*conv[newton][newton]; + conv[picogram_micrometer_per_microsecondsq][kcal_per_mole_angstrom] = to_si*conv[newton][kcal_per_mole_angstrom]; + conv[picogram_micrometer_per_microsecondsq][ev_per_angstrom] = to_si*conv[newton][ev_per_angstrom]; + conv[picogram_micrometer_per_microsecondsq][dyne] = to_si*conv[newton][dyne]; + conv[picogram_micrometer_per_microsecondsq][hartree_per_bohr] = to_si*conv[newton][hartree_per_bohr]; + conv[picogram_micrometer_per_microsecondsq][picogram_micrometer_per_microsecondsq] = 1.0; + conv[picogram_micrometer_per_microsecondsq][attogram_nanometer_per_nanosecondsq] = to_si*conv[newton][attogram_nanometer_per_nanosecondsq]; + + to_si = 1.0/conv[newton][attogram_nanometer_per_nanosecondsq]; + conv[attogram_nanometer_per_nanosecondsq][newton] = to_si*conv[newton][newton]; + conv[attogram_nanometer_per_nanosecondsq][kcal_per_mole_angstrom] = to_si*conv[newton][kcal_per_mole_angstrom]; + conv[attogram_nanometer_per_nanosecondsq][ev_per_angstrom] = to_si*conv[newton][ev_per_angstrom]; + conv[attogram_nanometer_per_nanosecondsq][dyne] = to_si*conv[newton][dyne]; + conv[attogram_nanometer_per_nanosecondsq][hartree_per_bohr] = to_si*conv[newton][hartree_per_bohr]; + conv[attogram_nanometer_per_nanosecondsq][picogram_micrometer_per_microsecondsq] = to_si*conv[newton][picogram_micrometer_per_microsecondsq]; + conv[attogram_nanometer_per_nanosecondsq][attogram_nanometer_per_nanosecondsq] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Torque conversion +double get_torque_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[newton_meter][newton_meter] = 1.0; + conv[newton_meter][kcal_per_mole] = 1.0/kcal_per_mole_si; + conv[newton_meter][ev] = 1.0/ev_si; + conv[newton_meter][dyne_centimeter] = 1.0/dyne_centimeter_si; + conv[newton_meter][hartree] = 1.0/hartree_si; + conv[newton_meter][picogram_micrometersq_per_microsecondsq] = 1.0/picogram_micrometersq_per_microsecondsq_si; + conv[newton_meter][attogram_nanometersq_per_nanosecondsq] = 1.0/attogram_nanometersq_per_nanosecondsq_si; + + to_si = 1.0/conv[newton_meter][kcal_per_mole]; + conv[kcal_per_mole][newton_meter] = to_si*conv[newton_meter][newton_meter]; + conv[kcal_per_mole][kcal_per_mole] = 1.0; + conv[kcal_per_mole][ev] = to_si*conv[newton_meter][ev]; + conv[kcal_per_mole][dyne_centimeter] = to_si*conv[newton_meter][dyne_centimeter]; + conv[kcal_per_mole][hartree] = to_si*conv[newton_meter][hartree]; + conv[kcal_per_mole][picogram_micrometersq_per_microsecondsq] = to_si*conv[newton_meter][picogram_micrometersq_per_microsecondsq]; + conv[kcal_per_mole][attogram_nanometersq_per_nanosecondsq] = to_si*conv[newton_meter][attogram_nanometersq_per_nanosecondsq]; + + to_si = 1.0/conv[newton_meter][ev]; + conv[ev][newton_meter] = to_si*conv[newton_meter][newton_meter]; + conv[ev][kcal_per_mole] = to_si*conv[newton_meter][kcal_per_mole]; + conv[ev][ev] = 1.0; + conv[ev][dyne_centimeter] = to_si*conv[newton_meter][dyne_centimeter]; + conv[ev][hartree] = to_si*conv[newton_meter][hartree]; + conv[ev][picogram_micrometersq_per_microsecondsq] = to_si*conv[newton_meter][picogram_micrometersq_per_microsecondsq]; + conv[ev][attogram_nanometersq_per_nanosecondsq] = to_si*conv[newton_meter][attogram_nanometersq_per_nanosecondsq]; + + to_si = 1.0/conv[newton_meter][dyne_centimeter]; + conv[dyne_centimeter][newton_meter] = to_si*conv[newton_meter][newton_meter]; + conv[dyne_centimeter][kcal_per_mole] = to_si*conv[newton_meter][kcal_per_mole]; + conv[dyne_centimeter][ev] = to_si*conv[newton_meter][ev]; + conv[dyne_centimeter][dyne_centimeter] = 1.0; + conv[dyne_centimeter][hartree] = to_si*conv[newton_meter][hartree]; + conv[dyne_centimeter][picogram_micrometersq_per_microsecondsq] = to_si*conv[newton_meter][picogram_micrometersq_per_microsecondsq]; + conv[dyne_centimeter][attogram_nanometersq_per_nanosecondsq] = to_si*conv[newton_meter][attogram_nanometersq_per_nanosecondsq]; + + to_si = 1.0/conv[newton_meter][hartree]; + conv[hartree][newton_meter] = to_si*conv[newton_meter][newton_meter]; + conv[hartree][kcal_per_mole] = to_si*conv[newton_meter][kcal_per_mole]; + conv[hartree][ev] = to_si*conv[newton_meter][ev]; + conv[hartree][dyne_centimeter] = to_si*conv[newton_meter][dyne_centimeter]; + conv[hartree][hartree] = 1.0; + conv[hartree][picogram_micrometersq_per_microsecondsq] = to_si*conv[newton_meter][picogram_micrometersq_per_microsecondsq]; + conv[hartree][attogram_nanometersq_per_nanosecondsq] = to_si*conv[newton_meter][attogram_nanometersq_per_nanosecondsq]; + + to_si = 1.0/conv[newton_meter][picogram_micrometersq_per_microsecondsq]; + conv[picogram_micrometersq_per_microsecondsq][newton_meter] = to_si*conv[newton_meter][newton_meter]; + conv[picogram_micrometersq_per_microsecondsq][kcal_per_mole] = to_si*conv[newton_meter][kcal_per_mole]; + conv[picogram_micrometersq_per_microsecondsq][ev] = to_si*conv[newton_meter][ev]; + conv[picogram_micrometersq_per_microsecondsq][dyne_centimeter] = to_si*conv[newton_meter][dyne_centimeter]; + conv[picogram_micrometersq_per_microsecondsq][hartree] = to_si*conv[newton_meter][hartree]; + conv[picogram_micrometersq_per_microsecondsq][picogram_micrometersq_per_microsecondsq] = 1.0; + conv[picogram_micrometersq_per_microsecondsq][attogram_nanometersq_per_nanosecondsq] = to_si*conv[newton_meter][attogram_nanometersq_per_nanosecondsq]; + + to_si = 1.0/conv[newton_meter][attogram_nanometersq_per_nanosecondsq]; + conv[attogram_nanometersq_per_nanosecondsq][newton_meter] = to_si*conv[newton_meter][newton_meter]; + conv[attogram_nanometersq_per_nanosecondsq][kcal_per_mole] = to_si*conv[newton_meter][kcal_per_mole]; + conv[attogram_nanometersq_per_nanosecondsq][ev] = to_si*conv[newton_meter][ev]; + conv[attogram_nanometersq_per_nanosecondsq][dyne_centimeter] = to_si*conv[newton_meter][dyne_centimeter]; + conv[attogram_nanometersq_per_nanosecondsq][hartree] = to_si*conv[newton_meter][hartree]; + conv[attogram_nanometersq_per_nanosecondsq][picogram_micrometersq_per_microsecondsq] = to_si*conv[newton_meter][picogram_micrometersq_per_microsecondsq]; + conv[attogram_nanometersq_per_nanosecondsq][attogram_nanometersq_per_nanosecondsq] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Temperature conversion +double get_temperature_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[kelvin][kelvin] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Pressure conversion +double get_pressure_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[pascal][pascal] = 1.0; + conv[pascal][atmosphere] = 1.0/atmosphere_si; + conv[pascal][bar] = 1.0/bar_si; + conv[pascal][dyne_per_centimetersq] = 1.0/dyne_per_centimetersq_si; + conv[pascal][picogram_per_micrometer_microsecondsq] = 1.0/picogram_per_micrometer_microsecondsq_si; + conv[pascal][attogram_per_nanometer_nanosecondsq] = 1.0/attogram_per_nanometer_nanosecondsq_si; + + to_si = 1.0/conv[pascal][atmosphere]; + conv[atmosphere][pascal] = to_si*conv[pascal][pascal]; + conv[atmosphere][atmosphere] = 1.0; + conv[atmosphere][bar] = to_si*conv[pascal][bar]; + conv[atmosphere][dyne_per_centimetersq] = to_si*conv[pascal][dyne_per_centimetersq]; + conv[atmosphere][picogram_per_micrometer_microsecondsq] = to_si*conv[pascal][picogram_per_micrometer_microsecondsq]; + conv[atmosphere][attogram_per_nanometer_nanosecondsq] = to_si*conv[pascal][attogram_per_nanometer_nanosecondsq]; + + to_si = 1.0/conv[pascal][bar]; + conv[bar][pascal] = to_si*conv[pascal][pascal]; + conv[bar][atmosphere] = to_si*conv[pascal][atmosphere]; + conv[bar][bar] = 1.0; + conv[bar][dyne_per_centimetersq] = to_si*conv[pascal][dyne_per_centimetersq]; + conv[bar][picogram_per_micrometer_microsecondsq] = to_si*conv[pascal][picogram_per_micrometer_microsecondsq]; + conv[bar][attogram_per_nanometer_nanosecondsq] = to_si*conv[pascal][attogram_per_nanometer_nanosecondsq]; + + to_si = 1.0/conv[pascal][dyne_per_centimetersq]; + conv[dyne_per_centimetersq][pascal] = to_si*conv[pascal][pascal]; + conv[dyne_per_centimetersq][atmosphere] = to_si*conv[pascal][atmosphere]; + conv[dyne_per_centimetersq][bar] = to_si*conv[pascal][bar]; + conv[dyne_per_centimetersq][dyne_per_centimetersq] = 1.0; + conv[dyne_per_centimetersq][picogram_per_micrometer_microsecondsq] = to_si*conv[pascal][picogram_per_micrometer_microsecondsq]; + conv[dyne_per_centimetersq][attogram_per_nanometer_nanosecondsq] = to_si*conv[pascal][attogram_per_nanometer_nanosecondsq]; + + to_si = 1.0/conv[pascal][picogram_per_micrometer_microsecondsq]; + conv[picogram_per_micrometer_microsecondsq][pascal] = to_si*conv[pascal][pascal]; + conv[picogram_per_micrometer_microsecondsq][atmosphere] = to_si*conv[pascal][atmosphere]; + conv[picogram_per_micrometer_microsecondsq][bar] = to_si*conv[pascal][bar]; + conv[picogram_per_micrometer_microsecondsq][dyne_per_centimetersq] = to_si*conv[pascal][dyne_per_centimetersq]; + conv[picogram_per_micrometer_microsecondsq][picogram_per_micrometer_microsecondsq] = 1.0; + conv[picogram_per_micrometer_microsecondsq][attogram_per_nanometer_nanosecondsq] = to_si*conv[pascal][attogram_per_nanometer_nanosecondsq]; + + to_si = 1.0/conv[pascal][attogram_per_nanometer_nanosecondsq]; + conv[attogram_per_nanometer_nanosecondsq][pascal] = to_si*conv[pascal][pascal]; + conv[attogram_per_nanometer_nanosecondsq][atmosphere] = to_si*conv[pascal][atmosphere]; + conv[attogram_per_nanometer_nanosecondsq][bar] = to_si*conv[pascal][bar]; + conv[attogram_per_nanometer_nanosecondsq][dyne_per_centimetersq] = to_si*conv[pascal][dyne_per_centimetersq]; + conv[attogram_per_nanometer_nanosecondsq][picogram_per_micrometer_microsecondsq] = to_si*conv[pascal][picogram_per_micrometer_microsecondsq]; + conv[attogram_per_nanometer_nanosecondsq][attogram_per_nanometer_nanosecondsq] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Viscosity conversion +double get_viscosity_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[pascal_second][pascal_second] = 1.0; + conv[pascal_second][poise] = 1.0/poise_si; + conv[pascal_second][amu_per_bohr_femtosecond] = 1.0/amu_per_bohr_femtosecond_si; + conv[pascal_second][picogram_per_micrometer_microsecond] = 1.0/picogram_per_micrometer_microsecond_si; + conv[pascal_second][attogram_per_nanometer_nanosecond] = 1.0/attogram_per_nanometer_nanosecond_si; + + to_si = 1.0/conv[pascal_second][poise]; + conv[poise][pascal_second] = to_si*conv[pascal_second][pascal_second]; + conv[poise][poise] = 1.0; + conv[poise][amu_per_bohr_femtosecond] = to_si*conv[pascal_second][amu_per_bohr_femtosecond]; + conv[poise][picogram_per_micrometer_microsecond] = to_si*conv[pascal_second][picogram_per_micrometer_microsecond]; + conv[poise][attogram_per_nanometer_nanosecond] = to_si*conv[pascal_second][attogram_per_nanometer_nanosecond]; + + to_si = 1.0/conv[pascal_second][amu_per_bohr_femtosecond]; + conv[amu_per_bohr_femtosecond][pascal_second] = to_si*conv[pascal_second][pascal_second]; + conv[amu_per_bohr_femtosecond][poise] = to_si*conv[pascal_second][poise]; + conv[amu_per_bohr_femtosecond][amu_per_bohr_femtosecond] = 1.0; + conv[amu_per_bohr_femtosecond][picogram_per_micrometer_microsecond] = to_si*conv[pascal_second][picogram_per_micrometer_microsecond]; + conv[amu_per_bohr_femtosecond][attogram_per_nanometer_nanosecond] = to_si*conv[pascal_second][attogram_per_nanometer_nanosecond]; + + to_si = 1.0/conv[pascal_second][picogram_per_micrometer_microsecond]; + conv[picogram_per_micrometer_microsecond][pascal_second] = to_si*conv[pascal_second][pascal_second]; + conv[picogram_per_micrometer_microsecond][poise] = to_si*conv[pascal_second][poise]; + conv[picogram_per_micrometer_microsecond][amu_per_bohr_femtosecond] = to_si*conv[pascal_second][amu_per_bohr_femtosecond]; + conv[picogram_per_micrometer_microsecond][picogram_per_micrometer_microsecond] = 1.0; + conv[picogram_per_micrometer_microsecond][attogram_per_nanometer_nanosecond] = to_si*conv[pascal_second][attogram_per_nanometer_nanosecond]; + + to_si = 1.0/conv[pascal_second][attogram_per_nanometer_nanosecond]; + conv[attogram_per_nanometer_nanosecond][pascal_second] = to_si*conv[pascal_second][pascal_second]; + conv[attogram_per_nanometer_nanosecond][poise] = to_si*conv[pascal_second][poise]; + conv[attogram_per_nanometer_nanosecond][amu_per_bohr_femtosecond] = to_si*conv[pascal_second][amu_per_bohr_femtosecond]; + conv[attogram_per_nanometer_nanosecond][picogram_per_micrometer_microsecond] = to_si*conv[pascal_second][picogram_per_micrometer_microsecond]; + conv[attogram_per_nanometer_nanosecond][attogram_per_nanometer_nanosecond] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Charge conversion +double get_charge_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[coulomb][coulomb] = 1.0; + conv[coulomb][echarge] = 1.0/echarge_si; + conv[coulomb][statcoulomb] = 1.0/statcoulomb_si; + conv[coulomb][picocoulomb] = 1.0/picocoulomb_si; + + to_si = 1.0/conv[coulomb][echarge]; + conv[echarge][coulomb] = to_si*conv[coulomb][coulomb]; + conv[echarge][echarge] = 1.0; + conv[echarge][statcoulomb] = to_si*conv[coulomb][statcoulomb]; + conv[echarge][picocoulomb] = to_si*conv[coulomb][picocoulomb]; + + to_si = 1.0/conv[coulomb][statcoulomb]; + conv[statcoulomb][coulomb] = to_si*conv[coulomb][coulomb]; + conv[statcoulomb][echarge] = to_si*conv[coulomb][echarge]; + conv[statcoulomb][statcoulomb] = 1.0; + conv[statcoulomb][picocoulomb] = to_si*conv[coulomb][picocoulomb]; + + to_si = 1.0/conv[coulomb][picocoulomb]; + conv[picocoulomb][coulomb] = to_si*conv[coulomb][coulomb]; + conv[picocoulomb][echarge] = to_si*conv[coulomb][echarge]; + conv[picocoulomb][statcoulomb] = to_si*conv[coulomb][statcoulomb]; + conv[picocoulomb][picocoulomb] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Dipole conversion +double get_dipole_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[coulomb_meter][coulomb_meter] = 1.0; + conv[coulomb_meter][electron_angstrom] = 1.0/electron_angstrom_si; + conv[coulomb_meter][statcoulomb_centimeter] = 1.0/statcoulomb_centimeter_si; + conv[coulomb_meter][debye] = 1.0/debye_si; + conv[coulomb_meter][picocoulomb_micrometer] = 1.0/picocoulomb_micrometer_si; + conv[coulomb_meter][electron_nanometer] = 1.0/electron_nanometer_si; + + to_si = 1.0/conv[coulomb_meter][electron_angstrom]; + conv[electron_angstrom][coulomb_meter] = to_si*conv[coulomb_meter][coulomb_meter]; + conv[electron_angstrom][electron_angstrom] = 1.0; + conv[electron_angstrom][statcoulomb_centimeter] = to_si*conv[coulomb_meter][statcoulomb_centimeter]; + conv[electron_angstrom][debye] = to_si*conv[coulomb_meter][debye]; + conv[electron_angstrom][picocoulomb_micrometer] = to_si*conv[coulomb_meter][picocoulomb_micrometer]; + conv[electron_angstrom][electron_nanometer] = to_si*conv[coulomb_meter][electron_nanometer]; + + to_si = 1.0/conv[coulomb_meter][statcoulomb_centimeter]; + conv[statcoulomb_centimeter][coulomb_meter] = to_si*conv[coulomb_meter][coulomb_meter]; + conv[statcoulomb_centimeter][electron_angstrom] = to_si*conv[coulomb_meter][electron_angstrom]; + conv[statcoulomb_centimeter][statcoulomb_centimeter] = 1.0; + conv[statcoulomb_centimeter][debye] = to_si*conv[coulomb_meter][debye]; + conv[statcoulomb_centimeter][picocoulomb_micrometer] = to_si*conv[coulomb_meter][picocoulomb_micrometer]; + conv[statcoulomb_centimeter][electron_nanometer] = to_si*conv[coulomb_meter][electron_nanometer]; + + to_si = 1.0/conv[coulomb_meter][debye]; + conv[debye][coulomb_meter] = to_si*conv[coulomb_meter][coulomb_meter]; + conv[debye][electron_angstrom] = to_si*conv[coulomb_meter][electron_angstrom]; + conv[debye][statcoulomb_centimeter] = to_si*conv[coulomb_meter][statcoulomb_centimeter]; + conv[debye][debye] = 1.0; + conv[debye][picocoulomb_micrometer] = to_si*conv[coulomb_meter][picocoulomb_micrometer]; + conv[debye][electron_nanometer] = to_si*conv[coulomb_meter][electron_nanometer]; + + to_si = 1.0/conv[coulomb_meter][picocoulomb_micrometer]; + conv[picocoulomb_micrometer][coulomb_meter] = to_si*conv[coulomb_meter][coulomb_meter]; + conv[picocoulomb_micrometer][electron_angstrom] = to_si*conv[coulomb_meter][electron_angstrom]; + conv[picocoulomb_micrometer][statcoulomb_centimeter] = to_si*conv[coulomb_meter][statcoulomb_centimeter]; + conv[picocoulomb_micrometer][debye] = to_si*conv[coulomb_meter][debye]; + conv[picocoulomb_micrometer][picocoulomb_micrometer] = 1.0; + conv[picocoulomb_micrometer][electron_nanometer] = to_si*conv[coulomb_meter][electron_nanometer]; + + to_si = 1.0/conv[coulomb_meter][electron_nanometer]; + conv[electron_nanometer][coulomb_meter] = to_si*conv[coulomb_meter][coulomb_meter]; + conv[electron_nanometer][electron_angstrom] = to_si*conv[coulomb_meter][electron_angstrom]; + conv[electron_nanometer][statcoulomb_centimeter] = to_si*conv[coulomb_meter][statcoulomb_centimeter]; + conv[electron_nanometer][debye] = to_si*conv[coulomb_meter][debye]; + conv[electron_nanometer][picocoulomb_micrometer] = to_si*conv[coulomb_meter][picocoulomb_micrometer]; + conv[electron_nanometer][electron_nanometer] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Electric field conversion +double get_efield_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[volt_per_meter][volt_per_meter] = 1.0; + conv[volt_per_meter][volt_per_angstrom] = 1.0/volt_per_angstrom_si; + conv[volt_per_meter][statvolt_per_centimeter] = 1.0/statvolt_per_centimeter_si; + conv[volt_per_meter][volt_per_centimeter] = 1.0/volt_per_centimeter_si; + conv[volt_per_meter][volt_per_micrometer] = 1.0/volt_per_micrometer_si; + conv[volt_per_meter][volt_per_nanometer] = 1.0/volt_per_nanometer_si; + + to_si = 1.0/conv[volt_per_meter][volt_per_angstrom]; + conv[volt_per_angstrom][volt_per_meter] = to_si*conv[volt_per_meter][volt_per_meter]; + conv[volt_per_angstrom][volt_per_angstrom] = 1.0; + conv[volt_per_angstrom][statvolt_per_centimeter] = to_si*conv[volt_per_meter][statvolt_per_centimeter]; + conv[volt_per_angstrom][volt_per_centimeter] = to_si*conv[volt_per_meter][volt_per_centimeter]; + conv[volt_per_angstrom][volt_per_micrometer] = to_si*conv[volt_per_meter][volt_per_micrometer]; + conv[volt_per_angstrom][volt_per_nanometer] = to_si*conv[volt_per_meter][volt_per_nanometer]; + + to_si = 1.0/conv[volt_per_meter][statvolt_per_centimeter]; + conv[statvolt_per_centimeter][volt_per_meter] = to_si*conv[volt_per_meter][volt_per_meter]; + conv[statvolt_per_centimeter][volt_per_angstrom] = to_si*conv[volt_per_meter][volt_per_angstrom]; + conv[statvolt_per_centimeter][statvolt_per_centimeter] = 1.0; + conv[statvolt_per_centimeter][volt_per_centimeter] = to_si*conv[volt_per_meter][volt_per_centimeter]; + conv[statvolt_per_centimeter][volt_per_micrometer] = to_si*conv[volt_per_meter][volt_per_micrometer]; + conv[statvolt_per_centimeter][volt_per_nanometer] = to_si*conv[volt_per_meter][volt_per_nanometer]; + + to_si = 1.0/conv[volt_per_meter][volt_per_centimeter]; + conv[volt_per_centimeter][volt_per_meter] = to_si*conv[volt_per_meter][volt_per_meter]; + conv[volt_per_centimeter][volt_per_angstrom] = to_si*conv[volt_per_meter][volt_per_angstrom]; + conv[volt_per_centimeter][statvolt_per_centimeter] = to_si*conv[volt_per_meter][statvolt_per_centimeter]; + conv[volt_per_centimeter][volt_per_centimeter] = 1.0; + conv[volt_per_centimeter][volt_per_micrometer] = to_si*conv[volt_per_meter][volt_per_micrometer]; + conv[volt_per_centimeter][volt_per_nanometer] = to_si*conv[volt_per_meter][volt_per_nanometer]; + + to_si = 1.0/conv[volt_per_meter][volt_per_micrometer]; + conv[volt_per_micrometer][volt_per_meter] = to_si*conv[volt_per_meter][volt_per_meter]; + conv[volt_per_micrometer][volt_per_angstrom] = to_si*conv[volt_per_meter][volt_per_angstrom]; + conv[volt_per_micrometer][statvolt_per_centimeter] = to_si*conv[volt_per_meter][statvolt_per_centimeter]; + conv[volt_per_micrometer][volt_per_centimeter] = to_si*conv[volt_per_meter][volt_per_centimeter]; + conv[volt_per_micrometer][volt_per_micrometer] = 1.0; + conv[volt_per_micrometer][volt_per_nanometer] = to_si*conv[volt_per_meter][volt_per_nanometer]; + + to_si = 1.0/conv[volt_per_meter][volt_per_nanometer]; + conv[volt_per_nanometer][volt_per_meter] = to_si*conv[volt_per_meter][volt_per_meter]; + conv[volt_per_nanometer][volt_per_angstrom] = to_si*conv[volt_per_meter][volt_per_angstrom]; + conv[volt_per_nanometer][statvolt_per_centimeter] = to_si*conv[volt_per_meter][statvolt_per_centimeter]; + conv[volt_per_nanometer][volt_per_centimeter] = to_si*conv[volt_per_meter][volt_per_centimeter]; + conv[volt_per_nanometer][volt_per_micrometer] = to_si*conv[volt_per_meter][volt_per_micrometer]; + conv[volt_per_nanometer][volt_per_nanometer] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// Demsity conversion +double get_density_conversion_factor(units from_unit_enum, units to_unit_enum) +{ + map > conv; + double to_si; + + conv[kilogram_per_metercu][kilogram_per_metercu] = 1.0; + conv[kilogram_per_metercu][gram_per_centimetercu] = 1.0/gram_per_centimetercu_si; + conv[kilogram_per_metercu][amu_per_bohrcu] = 1.0/amu_per_bohrcu_si; + conv[kilogram_per_metercu][picogram_per_micrometercu] = 1.0/picogram_per_micrometercu_si; + conv[kilogram_per_metercu][attogram_per_nanometercu] = 1.0/attogram_per_nanometercu_si; + + to_si = 1.0/conv[kilogram_per_metercu][gram_per_centimetercu]; + conv[gram_per_centimetercu][kilogram_per_metercu] = to_si*conv[kilogram_per_metercu][kilogram_per_metercu]; + conv[gram_per_centimetercu][gram_per_centimetercu] = 1.0; + conv[gram_per_centimetercu][amu_per_bohrcu] = to_si*conv[kilogram_per_metercu][amu_per_bohrcu]; + conv[gram_per_centimetercu][picogram_per_micrometercu] = to_si*conv[kilogram_per_metercu][picogram_per_micrometercu]; + conv[gram_per_centimetercu][attogram_per_nanometercu] = to_si*conv[kilogram_per_metercu][attogram_per_nanometercu]; + + to_si = 1.0/conv[kilogram_per_metercu][amu_per_bohrcu]; + conv[amu_per_bohrcu][kilogram_per_metercu] = to_si*conv[kilogram_per_metercu][kilogram_per_metercu]; + conv[amu_per_bohrcu][gram_per_centimetercu] = to_si*conv[kilogram_per_metercu][gram_per_centimetercu]; + conv[amu_per_bohrcu][amu_per_bohrcu] = 1.0; + conv[amu_per_bohrcu][picogram_per_micrometercu] = to_si*conv[kilogram_per_metercu][picogram_per_micrometercu]; + conv[amu_per_bohrcu][attogram_per_nanometercu] = to_si*conv[kilogram_per_metercu][attogram_per_nanometercu]; + + to_si = 1.0/conv[kilogram_per_metercu][picogram_per_micrometercu]; + conv[picogram_per_micrometercu][kilogram_per_metercu] = to_si*conv[kilogram_per_metercu][kilogram_per_metercu]; + conv[picogram_per_micrometercu][gram_per_centimetercu] = to_si*conv[kilogram_per_metercu][gram_per_centimetercu]; + conv[picogram_per_micrometercu][amu_per_bohrcu] = to_si*conv[kilogram_per_metercu][amu_per_bohrcu]; + conv[picogram_per_micrometercu][picogram_per_micrometercu] = 1.0; + conv[picogram_per_micrometercu][attogram_per_nanometercu] = to_si*conv[kilogram_per_metercu][attogram_per_nanometercu]; + + to_si = 1.0/conv[kilogram_per_metercu][attogram_per_nanometercu]; + conv[attogram_per_nanometercu][kilogram_per_metercu] = to_si*conv[kilogram_per_metercu][kilogram_per_metercu]; + conv[attogram_per_nanometercu][gram_per_centimetercu] = to_si*conv[kilogram_per_metercu][gram_per_centimetercu]; + conv[attogram_per_nanometercu][amu_per_bohrcu] = to_si*conv[kilogram_per_metercu][amu_per_bohrcu]; + conv[attogram_per_nanometercu][picogram_per_micrometercu] = to_si*conv[kilogram_per_metercu][picogram_per_micrometercu]; + conv[attogram_per_nanometercu][attogram_per_nanometercu] = 1.0; + + return conv[from_unit_enum][to_unit_enum]; +} + +/* ---------------------------------------------------------------------- */ + +// This routine returns the unit conversion factor between the +// `from_system_enum` to the `to_system_enum` for the `unit_type_enum`. +double get_unit_conversion_factor(unit_type &unit_type_enum, + sys_type from_system_enum, + sys_type to_system_enum) +{ + units from_unit = get_lammps_system_unit(from_system_enum, unit_type_enum); + units to_unit = get_lammps_system_unit(to_system_enum, unit_type_enum); + switch(unit_type_enum) { + case mass : + return get_mass_conversion_factor(from_unit, to_unit); + case distance : + return get_distance_conversion_factor(from_unit, to_unit); + case time : + return get_time_conversion_factor(from_unit, to_unit); + case energy : + return get_energy_conversion_factor(from_unit, to_unit); + case velocity : + return get_velocity_conversion_factor(from_unit, to_unit); + case force : + return get_force_conversion_factor(from_unit, to_unit); + case torque : + return get_torque_conversion_factor(from_unit, to_unit); + case temperature : + return get_temperature_conversion_factor(from_unit, to_unit); + case pressure : + return get_pressure_conversion_factor(from_unit, to_unit); + case viscosity : + return get_viscosity_conversion_factor(from_unit, to_unit); + case charge : + return get_charge_conversion_factor(from_unit, to_unit); + case dipole : + return get_dipole_conversion_factor(from_unit, to_unit); + case efield : + return get_efield_conversion_factor(from_unit, to_unit); + case density : + default : // This is here to a prevent a compiler warning + return get_density_conversion_factor(from_unit, to_unit); + } +} + +} // end of anonymous name space + +/* ---------------------------------------------------------------------- */ + +// Wrapper to the routine that gets the unit conversion. Translates strings +// to enumerations and then call get_unit_conversion_factor() +int lammps_unit_conversion(string const &unit_type_str, + string const &from_system_str, + string const &to_system_str, + double &conversion_factor) +{ + // initialize + conversion_factor = 0.0; + initialize_dictionaries(); + + // convert input to enumeration + unit_type unit_type_enum; + { + map::const_iterator itr = unit_dic.find(unit_type_str); + if (itr != unit_dic.end()) unit_type_enum = itr->second; + else return 1; // error + } + sys_type from_system_enum; + { + map::const_iterator + itr = system_dic.find(from_system_str); + if (itr != system_dic.end()) from_system_enum = itr->second; + else return 1; // error + } + sys_type to_system_enum; + { + map::const_iterator + itr = system_dic.find(to_system_str); + if (itr != system_dic.end()) to_system_enum = itr->second; + else return 1; + } + + // process unit conversions + conversion_factor = get_unit_conversion_factor(unit_type_enum, + from_system_enum, + to_system_enum); + return 0; +} + + diff --git a/src/KIM/kim_units.h b/src/KIM/kim_units.h new file mode 100644 index 0000000000..97e81a6222 --- /dev/null +++ b/src/KIM/kim_units.h @@ -0,0 +1,59 @@ +/* -*- 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: Ellad B. Tadmor (UMN) +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, see . + + Linking LAMMPS statically or dynamically with other modules is making a + combined work based on LAMMPS. Thus, the terms and conditions of the GNU + General Public License cover the whole combination. + + In addition, as a special exception, the copyright holders of LAMMPS give + you permission to combine LAMMPS with free software programs or libraries + that are released under the GNU LGPL and with code included in the standard + release of the "kim-api" under the CDDL (or modified versions of such code, + with unchanged license). You may copy and distribute such a system following + the terms of the GNU GPL for LAMMPS and the licenses of the other code + concerned, provided that you include the source code of that other code + when and as the GNU GPL requires distribution of source code. + + Note that people who make modified versions of LAMMPS are not obligated to + grant this special exception for their modified versions; it is their choice + whether to do so. The GNU General Public License gives permission to release + a modified version without this exception; this exception also makes it + possible to release a modified version which carries forward this exception. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Designed for use with the kim-api-2.0.2 (and newer) package +------------------------------------------------------------------------- */ + +int lammps_unit_conversion(std::string const &unit_type_str, + std::string const &from_system_str, + std::string const &to_system_str, + double &conversion_factor); From dbfd1fd0e739aa9ff263fe5e6d88f73d44d2569d Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Fri, 21 Jun 2019 22:11:58 -0500 Subject: [PATCH 030/107] Added atom-type-num-list mapping to kim_style --- src/KIM/kim_style.cpp | 156 +++++++++++++++++++++++++++++++++++++++--- src/KIM/kim_style.h | 5 +- 2 files changed, 149 insertions(+), 12 deletions(-) diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp index 44d5c411ab..161bc31643 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_style.cpp @@ -77,6 +77,10 @@ extern "C" { #include "KIM_SimulatorModel.hpp" //@@@@@ +#define SNUM(x) \ + static_cast(std::ostringstream() \ + << std::dec << x).str() + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ @@ -257,7 +261,7 @@ void KimStyle::determine_model_type_and_units(char * model_name, if ((! unit_conversion_mode) && (strcmp(*model_units, user_units)!=0)) { std::stringstream mesg; - mesg << "Incompatible units for KIM Simulator Model, required units = " + mesg << "Incompatible units for KIM Simulator Model, required units = " << *model_units; error->all(FLERR,mesg.str().c_str()); } @@ -357,18 +361,18 @@ void KimStyle::do_init(char *model_name, char *user_units, char* model_units) /* ---------------------------------------------------------------------- */ -void KimStyle::kim_style_log_delimiter(std::string begin_end, - std::string model_setup) +void KimStyle::kim_style_log_delimiter(std::string const begin_end, + std::string const model_setup) const { if (comm->me == 0) { std::string mesg; - if ((begin_end == "begin") && (model_setup == "model")) mesg = + if ((begin_end == "begin") && (model_setup == "model")) mesg = "#=== BEGIN kim-style MODEL ==================================\n"; - else if ((begin_end == "begin") && (model_setup == "setup")) mesg = + else if ((begin_end == "begin") && (model_setup == "setup")) mesg = "#=== BEGIN kim-style SETUP ==================================\n"; - else if ((begin_end == "end") && (model_setup == "model")) mesg = + else if ((begin_end == "end") && (model_setup == "model")) mesg = "#=== END kim-style MODEL ====================================\n\n"; - else if ((begin_end == "end") && (model_setup == "setup")) mesg = + else if ((begin_end == "end") && (model_setup == "setup")) mesg = "#=== END kim-style SETUP ====================================\n\n"; if (screen) fputs(mesg.c_str(),screen); @@ -403,12 +407,19 @@ void KimStyle::do_setup(int narg, char **arg) if (simulatorModel) { + std::string delimiter(""); std::string atom_type_sym_list; + std::string atom_type_num_list; for (int i = 0; i < narg; i++) - atom_type_sym_list += std::string(" ") + arg[i]; + { + atom_type_sym_list += delimiter + arg[i]; + atom_type_num_list += delimiter + SNUM(species_to_atomic_no(arg[i])); + delimiter = " "; + } simulatorModel->AddTemplateMap("atom-type-sym-list",atom_type_sym_list); + simulatorModel->AddTemplateMap("atom-type-num-list",atom_type_num_list); simulatorModel->CloseTemplateMap(); int len = strlen(atom_type_sym_list.c_str())+1; @@ -533,10 +544,10 @@ void KimStyle::do_variables(char *user_units, char *model_units) (char *)"dipole", (char *)"efield", (char *)"density"}; - + if (comm->me == 0) { std::stringstream mesg; - mesg << "# Conversion factors from " << from << " to " << to + mesg << "# Conversion factors from " << from << " to " << to << ":" << std::endl; if (screen) fputs(mesg.str().c_str(),screen); if (logfile) fputs(mesg.str().c_str(),logfile); @@ -575,3 +586,128 @@ void KimStyle::do_variables(char *user_units, char *model_units) if (logfile) fputs("#\n",logfile); } } + +/* ---------------------------------------------------------------------- */ + +int KimStyle::species_to_atomic_no(std::string const species) const +{ + if (species == "H") return 1; + else if (species == "He") return 2; + else if (species == "Li") return 3; + else if (species == "Be") return 4; + else if (species == "B") return 5; + else if (species == "C") return 6; + else if (species == "N") return 7; + else if (species == "O") return 8; + else if (species == "F") return 9; + else if (species == "Ne") return 10; + else if (species == "Na") return 11; + else if (species == "Mg") return 12; + else if (species == "Al") return 13; + else if (species == "Si") return 14; + else if (species == "P") return 15; + else if (species == "S") return 16; + else if (species == "Cl") return 17; + else if (species == "Ar") return 18; + else if (species == "K") return 19; + else if (species == "Ca") return 20; + else if (species == "Sc") return 21; + else if (species == "Ti") return 22; + else if (species == "V") return 23; + else if (species == "Cr") return 24; + else if (species == "Mn") return 25; + else if (species == "Fe") return 26; + else if (species == "Co") return 27; + else if (species == "Ni") return 28; + else if (species == "Cu") return 29; + else if (species == "Zn") return 30; + else if (species == "Ga") return 31; + else if (species == "Ge") return 32; + else if (species == "As") return 33; + else if (species == "Se") return 34; + else if (species == "Br") return 35; + else if (species == "Kr") return 36; + else if (species == "Rb") return 37; + else if (species == "Sr") return 38; + else if (species == "Y") return 39; + else if (species == "Zr") return 40; + else if (species == "Nb") return 41; + else if (species == "Mo") return 42; + else if (species == "Tc") return 43; + else if (species == "Ru") return 44; + else if (species == "Rh") return 45; + else if (species == "Pd") return 46; + else if (species == "Ag") return 47; + else if (species == "Cd") return 48; + else if (species == "In") return 49; + else if (species == "Sn") return 50; + else if (species == "Sb") return 51; + else if (species == "Te") return 52; + else if (species == "I") return 53; + else if (species == "Xe") return 54; + else if (species == "Cs") return 55; + else if (species == "Ba") return 56; + else if (species == "La") return 57; + else if (species == "Ce") return 58; + else if (species == "Pr") return 59; + else if (species == "Nd") return 60; + else if (species == "Pm") return 61; + else if (species == "Sm") return 62; + else if (species == "Eu") return 63; + else if (species == "Gd") return 64; + else if (species == "Tb") return 65; + else if (species == "Dy") return 66; + else if (species == "Ho") return 67; + else if (species == "Er") return 68; + else if (species == "Tm") return 69; + else if (species == "Yb") return 70; + else if (species == "Lu") return 71; + else if (species == "Hf") return 72; + else if (species == "Ta") return 73; + else if (species == "W") return 74; + else if (species == "Re") return 75; + else if (species == "Os") return 76; + else if (species == "Ir") return 77; + else if (species == "Pt") return 78; + else if (species == "Au") return 79; + else if (species == "Hg") return 80; + else if (species == "Tl") return 81; + else if (species == "Pb") return 82; + else if (species == "Bi") return 83; + else if (species == "Po") return 84; + else if (species == "At") return 85; + else if (species == "Rn") return 86; + else if (species == "Fr") return 87; + else if (species == "Ra") return 88; + else if (species == "Ac") return 89; + else if (species == "Th") return 90; + else if (species == "Pa") return 91; + else if (species == "U") return 92; + else if (species == "Np") return 93; + else if (species == "Pu") return 94; + else if (species == "Am") return 95; + else if (species == "Cm") return 96; + else if (species == "Bk") return 97; + else if (species == "Cf") return 98; + else if (species == "Es") return 99; + else if (species == "Fm") return 100; + else if (species == "Md") return 101; + else if (species == "No") return 102; + else if (species == "Lr") return 103; + else if (species == "Rf") return 104; + else if (species == "Db") return 105; + else if (species == "Sg") return 106; + else if (species == "Bh") return 107; + else if (species == "Hs") return 108; + else if (species == "Mt") return 109; + else if (species == "Ds") return 110; + else if (species == "Rg") return 111; + else if (species == "Cn") return 112; + else if (species == "Nh") return 113; + else if (species == "Fl") return 114; + else if (species == "Mc") return 115; + else if (species == "Lv") return 116; + else if (species == "Ts") return 117; + else if (species == "Og") return 118; + else return -1; +} diff --git a/src/KIM/kim_style.h b/src/KIM/kim_style.h index b18f6627ea..626f2395bc 100644 --- a/src/KIM/kim_style.h +++ b/src/KIM/kim_style.h @@ -80,8 +80,9 @@ class KimStyle : protected Pointers { void do_init(char *, char *, char *); void do_setup(int, char **); void do_variables(char*, char*); - void kim_style_log_delimiter(std::string begin_end, - std::string model_setup); + int species_to_atomic_no(std::string const species) const; + void kim_style_log_delimiter(std::string const begin_end, + std::string const model_setup) const; }; } From f81c9c5322aa0d8e067f240639528b0292f83bb8 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Sat, 22 Jun 2019 10:21:05 -0500 Subject: [PATCH 031/107] Changed _u_* output to log to variable commands --- src/KIM/kim_style.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_style.cpp index 161bc31643..a583908fc7 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_style.cpp @@ -576,7 +576,8 @@ void KimStyle::do_variables(char *user_units, char *model_units) variable->internal_set(v_unit,conversion_factor); if (comm->me == 0) { std::stringstream mesg; - mesg << "# " << var_str << " = " << conversion_factor << std::endl; + mesg << "variable " << var_str << " internal " << conversion_factor + << std::endl; if (screen) fputs(mesg.str().c_str(),screen); if (logfile) fputs(mesg.str().c_str(),logfile); } From 4a22e3bf70d03dd292319bdab315f2731da41eab Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Sat, 22 Jun 2019 15:21:57 -0500 Subject: [PATCH 032/107] Implement kim_init, kim_interactions & various updates --- src/KIM/README | 27 +- src/KIM/{kim_style.cpp => kim_init.cpp} | 423 +++++------------------- src/KIM/{kim_style.h => kim_init.h} | 35 +- src/KIM/kim_interactions.cpp | 367 ++++++++++++++++++++ src/KIM/kim_interactions.h | 116 +++++++ 5 files changed, 591 insertions(+), 377 deletions(-) rename src/KIM/{kim_style.cpp => kim_init.cpp} (52%) rename src/KIM/{kim_style.h => kim_init.h} (82%) create mode 100644 src/KIM/kim_interactions.cpp create mode 100644 src/KIM/kim_interactions.h diff --git a/src/KIM/README b/src/KIM/README index 4f52d69a67..e61f47426f 100644 --- a/src/KIM/README +++ b/src/KIM/README @@ -1,29 +1,30 @@ -This package provides a pair_style kim command which is a wrapper on -the Knowledge Base for Interatomic Models (KIM) repository of -interatomic potentials, so that they can be used by LAMMPS scripts. +This package provides the kim_init, kim_query, kim_interactions, and +the pair_style kim command which are wrappers on the Knowledgebase of +Interatomic Models (KIM) repository of interatomic potentials, so that +they can be used by LAMMPS scripts. Information about the KIM project can be found at https://openkim.org. -The KIM project is lead by Ellad Tadmor and Ryan Elliott (U Minn) and -James Sethna (Cornell U). Ryan Elliott is the main developer for the -KIM API and he also maintains the code that implements the pair_style -kim command. +The KIM project is lead by Ellad B. Tadmor and Ryan S. Elliott (UMN). +Ryan Elliott is the main developer for the KIM API and he also +maintains the code that implements these commands. -Using this package requires the KIM library and its models +Using this package requires the KIM-API library and its models (interatomic potentials) to be downloaded and installed on your system. The library can be downloaded and built in lib/kim or elsewhere on your system, which must be done before bulding LAMMPS with this package. Details of the download, build, and install -process for KIM are given in the lib/kim/README file, and scripts -are provided to help automate the process. Also see the LAMMPS -manual for general information on building LAMMPS with external +process for the KIM-API are given in the lib/kim/README file, and +scripts are provided to help automate the process. Also see the +LAMMPS manual for general information on building LAMMPS with external libraries. The settings in the Makefile.lammps file in lib/kim must be correct for LAMMPS to build correctly with this package installed. However, the default settings should be correct in most cases and the Makefile.lammps file usually will not need to be changed. Once you have successfully built LAMMPS with this package and the KIM -library you can test it using an input file from the examples dir: +library you can test it using an input files in the examples dir: ./lmp_serial -in lammps/examples/kim/in.kim.lj -This pair_style was written by Ryan S. Elliott (U Minn). +These commands were written by Ryan S. Elliott (UMN), Ellad B. Tadmor +(UMN) and Axel Kohlmeyer (Temple U). diff --git a/src/KIM/kim_style.cpp b/src/KIM/kim_init.cpp similarity index 52% rename from src/KIM/kim_style.cpp rename to src/KIM/kim_init.cpp index a583908fc7..695db0aa0d 100644 --- a/src/KIM/kim_style.cpp +++ b/src/KIM/kim_init.cpp @@ -14,6 +14,7 @@ /* ---------------------------------------------------------------------- Contributing authors: Axel Kohlmeyer (Temple U), Ryan S. Elliott (UMN) + Ellad B. Tadmor (UMN) ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- @@ -57,7 +58,8 @@ #include #include #include -#include "kim_style.h" +#include +#include "kim_init.h" #include "error.h" #include "atom.h" #include "comm.h" @@ -85,33 +87,26 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -void KimStyle::command(int narg, char **arg) +void KimInit::command(int narg, char **arg) { - if ((narg < 2) || (narg > 4)) error->all(FLERR,"Illegal kim_style command"); + if ((narg < 2) || (narg > 3)) error->all(FLERR,"Illegal kim_init command"); - if (strcmp(arg[0],"model") == 0) { - if (domain->box_exist) - error->all(FLERR,"Must use 'kim_style model' command before " - "simulation box is defined"); - int len1 = strlen(arg[1])+1; - int len2 = strlen(arg[2])+1; - char *model_name = new char[len1]; strcpy(model_name,arg[1]); - char *user_units = new char[len2]; strcpy(user_units,arg[2]); - if (narg == 4) { - if (strcmp(arg[3],"unit_conversion_mode")==0) unit_conversion_mode = true; - else { error->all(FLERR,"Illegal kim_style command"); } - } else unit_conversion_mode = false; + if (domain->box_exist) + error->all(FLERR,"Must use 'kim_init' command before " + "simulation box is defined"); + int len0 = strlen(arg[0])+1; + int len1 = strlen(arg[1])+1; + char *model_name = new char[len0]; strcpy(model_name,arg[0]); + char *user_units = new char[len1]; strcpy(user_units,arg[1]); + if (narg == 3) { + if (strcmp(arg[2],"unit_conversion_mode")==0) unit_conversion_mode = true; + else { error->all(FLERR,"Illegal kim_init command"); } + } else unit_conversion_mode = false; - char *model_units; - determine_model_type_and_units(model_name, user_units, &model_units); + char *model_units; + determine_model_type_and_units(model_name, user_units, &model_units); - do_init(model_name, user_units, model_units); - } else if (strcmp(arg[0],"setup") == 0) { - if (!domain->box_exist) - error->all(FLERR,"Must use 'kim_style setup' command after " - "simulation box is defined"); - do_setup(narg-1,++arg); - } else error->all(FLERR,"Illegal kim_style command"); + do_init(model_name, user_units, model_units); } @@ -163,9 +158,9 @@ void get_kim_unit_names( } } } // namespace -void KimStyle::determine_model_type_and_units(char * model_name, - char * user_units, - char ** model_units) +void KimInit::determine_model_type_and_units(char * model_name, + char * user_units, + char ** model_units) { KIM_LengthUnit lengthUnit; KIM_EnergyUnit energyUnit; @@ -270,7 +265,7 @@ void KimStyle::determine_model_type_and_units(char * model_name, /* ---------------------------------------------------------------------- */ -void KimStyle::do_init(char *model_name, char *user_units, char* model_units) +void KimInit::do_init(char *model_name, char *user_units, char* model_units) { // create storage proxy fix. delete existing fix, if needed. @@ -288,32 +283,42 @@ void KimStyle::do_init(char *model_name, char *user_units, char* model_units) fix_store->setptr("user_units", (void *) user_units); fix_store->setptr("model_units", (void *) model_units); + // Begin output to log file + kim_init_log_delimiter("begin"); + int kimerror; // @@@@@ switch to c-bindings when they are available KIM::SimulatorModel * simulatorModel; - kimerror = KIM::SimulatorModel::Create(model_name,&simulatorModel); + if (model_type == SM) + { + kimerror = KIM::SimulatorModel::Create(model_name,&simulatorModel); - const std::string *sim_name, *sim_version; - simulatorModel->GetSimulatorNameAndVersion(&sim_name, &sim_version); + const std::string *sim_name, *sim_version; + simulatorModel->GetSimulatorNameAndVersion(&sim_name, &sim_version); - if (*sim_name != "LAMMPS") - error->all(FLERR,"Incompatible KIM Simulator Model"); + if (*sim_name != "LAMMPS") + error->all(FLERR,"Incompatible KIM Simulator Model"); - // Begin output to log file - kim_style_log_delimiter("begin","model"); - if (comm->me == 0) { - std::string mesg("# Using KIM Simulator Model : "); - mesg += model_name; - mesg += "\n"; - mesg += "# For Simulator : "; - mesg += *sim_name + " " + *sim_version + "\n"; - mesg += "# Running on : LAMMPS "; - mesg += universe->version; - mesg += "\n"; - mesg += "#\n"; + if (comm->me == 0) { + std::string mesg("# Using KIM Simulator Model : "); + mesg += model_name; + mesg += "\n"; + mesg += "# For Simulator : "; + mesg += *sim_name + " " + *sim_version + "\n"; + mesg += "# Running on : LAMMPS "; + mesg += universe->version; + mesg += "\n"; + mesg += "#\n"; - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); + if (screen) fputs(mesg.c_str(),screen); + if (logfile) fputs(mesg.c_str(),logfile); + } + + fix_store->setptr("simulator_model", (void *) simulatorModel); + + // need to call this to have access to (some) simulator model init data. + + simulatorModel->CloseTemplateMap(); } // Define unit conversion factor variables and print to log @@ -325,192 +330,55 @@ void KimStyle::do_init(char *model_name, char *user_units, char* model_units) cmd += model_units; input->one(cmd.c_str()); - // not a Kim Simulator Model; nothing else to do here. - - if (kimerror) return; - - fix_store->setptr("simulator_model", (void *) simulatorModel); - - // need to call this to have access to (some) simulator model init data. - - simulatorModel->CloseTemplateMap(); - - int sim_fields, sim_lines; - const std::string *sim_field, *sim_value; - simulatorModel->GetNumberOfSimulatorFields(&sim_fields); - - // init model - - for (int i=0; i < sim_fields; ++i) { - simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); - if (*sim_field == "model-init") { - for (int j=0; j < sim_lines; ++j) { - simulatorModel->GetSimulatorFieldLine(i,j,&sim_value); - input->one(sim_value->c_str()); - } - break; - } - } - - // End output to log file - kim_style_log_delimiter("end","model"); - - // reset template map. - simulatorModel->OpenAndInitializeTemplateMap(); -} - -/* ---------------------------------------------------------------------- */ - -void KimStyle::kim_style_log_delimiter(std::string const begin_end, - std::string const model_setup) const -{ - if (comm->me == 0) { - std::string mesg; - if ((begin_end == "begin") && (model_setup == "model")) mesg = - "#=== BEGIN kim-style MODEL ==================================\n"; - else if ((begin_end == "begin") && (model_setup == "setup")) mesg = - "#=== BEGIN kim-style SETUP ==================================\n"; - else if ((begin_end == "end") && (model_setup == "model")) mesg = - "#=== END kim-style MODEL ====================================\n\n"; - else if ((begin_end == "end") && (model_setup == "setup")) mesg = - "#=== END kim-style SETUP ====================================\n\n"; - - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); - } -} - -/* ---------------------------------------------------------------------- */ - -void KimStyle::do_setup(int narg, char **arg) -{ - if (narg != atom->ntypes) - error->all(FLERR,"Illegal kim_style command"); - - char *model = NULL; - KIM::SimulatorModel *simulatorModel(NULL); - - // check if we had a kim_style init command by finding fix STORE/KIM - // retrieve model name and pointer to simulator model class instance. - // validate model name if not given as NULL. - // if kim_style init wasn't run try to initialize simulator model now. - - int ifix = modify->find_fix("KIM_MODEL_STORE"); - if (ifix >= 0) { - FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; - model = (char *)fix_store->getptr("model_name"); - simulatorModel = (KIM::SimulatorModel *)fix_store->getptr("simulator_model"); - } else error->all(FLERR,"Must use 'kim_style model' before 'kim_style setup'"); - - // Begin output to log file - kim_style_log_delimiter("begin","setup"); - - if (simulatorModel) { - - std::string delimiter(""); - std::string atom_type_sym_list; - std::string atom_type_num_list; - - for (int i = 0; i < narg; i++) - { - atom_type_sym_list += delimiter + arg[i]; - atom_type_num_list += delimiter + SNUM(species_to_atomic_no(arg[i])); - delimiter = " "; - } - - simulatorModel->AddTemplateMap("atom-type-sym-list",atom_type_sym_list); - simulatorModel->AddTemplateMap("atom-type-num-list",atom_type_num_list); - simulatorModel->CloseTemplateMap(); - - int len = strlen(atom_type_sym_list.c_str())+1; - char *strbuf = new char[len]; - char *strword; - - // validate species selection - - int sim_num_species; - bool species_is_supported; - const std::string *sim_species; - simulatorModel->GetNumberOfSupportedSpecies(&sim_num_species); - strcpy(strbuf,atom_type_sym_list.c_str()); - strword = strtok(strbuf," \t"); - while (strword) { - species_is_supported = false; - if (strcmp(strword,"NULL") == 0) continue; - for (int i=0; i < sim_num_species; ++i) { - simulatorModel->GetSupportedSpecies(i, &sim_species); - if (strcmp(sim_species->c_str(),strword) == 0) - species_is_supported = true; - } - if (!species_is_supported) { - std::string msg("Species '"); - msg += strword; - msg += "' is not supported by this KIM Simulator Model"; - error->all(FLERR,msg.c_str()); - } - strword = strtok(NULL," \t"); - } - delete[] strbuf; - - // check if units are unchanged, and if kim_style init was required - + if (model_type == SM) + { int sim_fields, sim_lines; const std::string *sim_field, *sim_value; simulatorModel->GetNumberOfSimulatorFields(&sim_fields); + + // init model + for (int i=0; i < sim_fields; ++i) { simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); - - if (*sim_field == "units") { - simulatorModel->GetSimulatorFieldLine(i,0,&sim_value); - if (*sim_value != update->unit_style) - error->all(FLERR,"Incompatible units for KIM Simulator Model"); - } - } - - int sim_model_idx=-1; - for (int i=0; i < sim_fields; ++i) { - simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); - if (*sim_field == "model-defn") { - sim_model_idx = i; + if (*sim_field == "model-init") { for (int j=0; j < sim_lines; ++j) { - simulatorModel->GetSimulatorFieldLine(sim_model_idx,j,&sim_value); + simulatorModel->GetSimulatorFieldLine(i,j,&sim_value); input->one(sim_value->c_str()); } + break; } } - if (sim_model_idx < 0) - error->all(FLERR,"KIM Simulator Model has no Model definition"); - + // reset template map. simulatorModel->OpenAndInitializeTemplateMap(); - - } else { - - // not a simulator model. issue pair_style and pair_coeff commands. - // NOTE: all references to arg must appear before calls to input->one() - // as that will reset the argument vector. - - std::string cmd1("pair_style kim "); - cmd1 += model; - - std::string cmd2("pair_coeff * * "); - for (int i=0; i < narg; ++i) { - cmd2 += arg[i]; - cmd2 += " "; - } - - input->one(cmd1.c_str()); - input->one(cmd2.c_str()); } // End output to log file - kim_style_log_delimiter("end","setup"); + kim_init_log_delimiter("end"); } /* ---------------------------------------------------------------------- */ -void KimStyle::do_variables(char *user_units, char *model_units) +void KimInit::kim_init_log_delimiter(std::string const begin_end) const +{ + if (comm->me == 0) { + std::string mesg; + if (begin_end == "begin") + mesg = + "#=== BEGIN kim-init ==========================================\n"; + else if (begin_end == "end") + mesg = + "#=== END kim-init ============================================\n\n"; + + if (screen) fputs(mesg.c_str(),screen); + if (logfile) fputs(mesg.c_str(),logfile); + } +} + +/* ---------------------------------------------------------------------- */ + +void KimInit::do_variables(char *user_units, char *model_units) { char *from = user_units, *to = model_units; Variable *variable = input->variable; @@ -576,7 +444,9 @@ void KimStyle::do_variables(char *user_units, char *model_units) variable->internal_set(v_unit,conversion_factor); if (comm->me == 0) { std::stringstream mesg; - mesg << "variable " << var_str << " internal " << conversion_factor + mesg << "variable " << std::setw(15) << std::left << var_str + << " internal " + << std::setprecision(12) << std::scientific << conversion_factor << std::endl; if (screen) fputs(mesg.str().c_str(),screen); if (logfile) fputs(mesg.str().c_str(),logfile); @@ -587,128 +457,3 @@ void KimStyle::do_variables(char *user_units, char *model_units) if (logfile) fputs("#\n",logfile); } } - -/* ---------------------------------------------------------------------- */ - -int KimStyle::species_to_atomic_no(std::string const species) const -{ - if (species == "H") return 1; - else if (species == "He") return 2; - else if (species == "Li") return 3; - else if (species == "Be") return 4; - else if (species == "B") return 5; - else if (species == "C") return 6; - else if (species == "N") return 7; - else if (species == "O") return 8; - else if (species == "F") return 9; - else if (species == "Ne") return 10; - else if (species == "Na") return 11; - else if (species == "Mg") return 12; - else if (species == "Al") return 13; - else if (species == "Si") return 14; - else if (species == "P") return 15; - else if (species == "S") return 16; - else if (species == "Cl") return 17; - else if (species == "Ar") return 18; - else if (species == "K") return 19; - else if (species == "Ca") return 20; - else if (species == "Sc") return 21; - else if (species == "Ti") return 22; - else if (species == "V") return 23; - else if (species == "Cr") return 24; - else if (species == "Mn") return 25; - else if (species == "Fe") return 26; - else if (species == "Co") return 27; - else if (species == "Ni") return 28; - else if (species == "Cu") return 29; - else if (species == "Zn") return 30; - else if (species == "Ga") return 31; - else if (species == "Ge") return 32; - else if (species == "As") return 33; - else if (species == "Se") return 34; - else if (species == "Br") return 35; - else if (species == "Kr") return 36; - else if (species == "Rb") return 37; - else if (species == "Sr") return 38; - else if (species == "Y") return 39; - else if (species == "Zr") return 40; - else if (species == "Nb") return 41; - else if (species == "Mo") return 42; - else if (species == "Tc") return 43; - else if (species == "Ru") return 44; - else if (species == "Rh") return 45; - else if (species == "Pd") return 46; - else if (species == "Ag") return 47; - else if (species == "Cd") return 48; - else if (species == "In") return 49; - else if (species == "Sn") return 50; - else if (species == "Sb") return 51; - else if (species == "Te") return 52; - else if (species == "I") return 53; - else if (species == "Xe") return 54; - else if (species == "Cs") return 55; - else if (species == "Ba") return 56; - else if (species == "La") return 57; - else if (species == "Ce") return 58; - else if (species == "Pr") return 59; - else if (species == "Nd") return 60; - else if (species == "Pm") return 61; - else if (species == "Sm") return 62; - else if (species == "Eu") return 63; - else if (species == "Gd") return 64; - else if (species == "Tb") return 65; - else if (species == "Dy") return 66; - else if (species == "Ho") return 67; - else if (species == "Er") return 68; - else if (species == "Tm") return 69; - else if (species == "Yb") return 70; - else if (species == "Lu") return 71; - else if (species == "Hf") return 72; - else if (species == "Ta") return 73; - else if (species == "W") return 74; - else if (species == "Re") return 75; - else if (species == "Os") return 76; - else if (species == "Ir") return 77; - else if (species == "Pt") return 78; - else if (species == "Au") return 79; - else if (species == "Hg") return 80; - else if (species == "Tl") return 81; - else if (species == "Pb") return 82; - else if (species == "Bi") return 83; - else if (species == "Po") return 84; - else if (species == "At") return 85; - else if (species == "Rn") return 86; - else if (species == "Fr") return 87; - else if (species == "Ra") return 88; - else if (species == "Ac") return 89; - else if (species == "Th") return 90; - else if (species == "Pa") return 91; - else if (species == "U") return 92; - else if (species == "Np") return 93; - else if (species == "Pu") return 94; - else if (species == "Am") return 95; - else if (species == "Cm") return 96; - else if (species == "Bk") return 97; - else if (species == "Cf") return 98; - else if (species == "Es") return 99; - else if (species == "Fm") return 100; - else if (species == "Md") return 101; - else if (species == "No") return 102; - else if (species == "Lr") return 103; - else if (species == "Rf") return 104; - else if (species == "Db") return 105; - else if (species == "Sg") return 106; - else if (species == "Bh") return 107; - else if (species == "Hs") return 108; - else if (species == "Mt") return 109; - else if (species == "Ds") return 110; - else if (species == "Rg") return 111; - else if (species == "Cn") return 112; - else if (species == "Nh") return 113; - else if (species == "Fl") return 114; - else if (species == "Mc") return 115; - else if (species == "Lv") return 116; - else if (species == "Ts") return 117; - else if (species == "Og") return 118; - else return -1; -} diff --git a/src/KIM/kim_style.h b/src/KIM/kim_init.h similarity index 82% rename from src/KIM/kim_style.h rename to src/KIM/kim_init.h index 626f2395bc..c22e2be720 100644 --- a/src/KIM/kim_style.h +++ b/src/KIM/kim_init.h @@ -14,6 +14,7 @@ /* ---------------------------------------------------------------------- Contributing authors: Axel Kohlmeyer (Temple U), Ryan S. Elliott (UMN) + Ellad B. Tadmor (UMN) ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- @@ -56,20 +57,20 @@ #ifdef COMMAND_CLASS -CommandStyle(kim_style,KimStyle) +CommandStyle(kim_init,KimInit) #else -#ifndef LMP_KIM_STYLE_H -#define LMP_KIM_STYLE_H +#ifndef LMP_KIM_INIT_H +#define LMP_KIM_INIT_H #include "pointers.h" namespace LAMMPS_NS { -class KimStyle : protected Pointers { +class KimInit : protected Pointers { public: - KimStyle(class LAMMPS *lmp) : Pointers(lmp) {}; + KimInit(class LAMMPS *lmp) : Pointers(lmp) {}; void command(int, char **); private: enum model_type_enum {MO, SM}; @@ -78,11 +79,8 @@ class KimStyle : protected Pointers { void determine_model_type_and_units(char *, char *, char **); void do_init(char *, char *, char *); - void do_setup(int, char **); void do_variables(char*, char*); - int species_to_atomic_no(std::string const species) const; - void kim_style_log_delimiter(std::string const begin_end, - std::string const model_setup) const; + void kim_init_log_delimiter(std::string const begin_end) const; }; } @@ -92,19 +90,11 @@ class KimStyle : protected Pointers { /* ERROR/WARNING messages: -E: Illegal kim_style command +E: Illegal kim_init command -Incorrect number or kind of arguments to kim_style. +Incorrect number or kind of arguments to kim_init. -E: Must use 'kim_style model' command before simulation box is defined - -Self-explanatory. - -E: Must use 'kim_style setup' command after simulation box is defined - -Self-explanatory. - -E: Must use 'kim_style model' command before 'kim_style setup' +E: Must use 'kim_init' command before simulation box is defined Self-explanatory. @@ -125,11 +115,6 @@ E: Incompatible KIM Simulator Model The requested KIM Simulator Model was defined for a different MD code and thus is not compatible with LAMMPS. -E: Species XXX is not supported by this KIM Simulator Model - -The kim_style define command was referencing a species that is not -present in the requested KIM Simulator Model. - E: Incompatible units for KIM Simulator Model The selected unit style is not compatible with the requested KIM diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp new file mode 100644 index 0000000000..491d406ae6 --- /dev/null +++ b/src/KIM/kim_interactions.cpp @@ -0,0 +1,367 @@ +/* ---------------------------------------------------------------------- + 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: Axel Kohlmeyer (Temple U), + Ryan S. Elliott (UMN) + Ellad B. Tadmor (UMN) +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, see . + + Linking LAMMPS statically or dynamically with other modules is making a + combined work based on LAMMPS. Thus, the terms and conditions of the GNU + General Public License cover the whole combination. + + In addition, as a special exception, the copyright holders of LAMMPS give + you permission to combine LAMMPS with free software programs or libraries + that are released under the GNU LGPL and with code included in the standard + release of the "kim-api" under the CDDL (or modified versions of such code, + with unchanged license). You may copy and distribute such a system following + the terms of the GNU GPL for LAMMPS and the licenses of the other code + concerned, provided that you include the source code of that other code + when and as the GNU GPL requires distribution of source code. + + Note that people who make modified versions of LAMMPS are not obligated to + grant this special exception for their modified versions; it is their choice + whether to do so. The GNU General Public License gives permission to release + a modified version without this exception; this exception also makes it + possible to release a modified version which carries forward this exception. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Designed for use with the kim-api-2.1.0 (and newer) package +------------------------------------------------------------------------- */ + +#include +#include +#include +#include "kim_interactions.h" +#include "error.h" +#include "atom.h" +#include "comm.h" +#include "domain.h" +#include "modify.h" +#include "update.h" +#include "universe.h" +#include "input.h" +#include "variable.h" +#include "fix_store_kim.h" + +extern "C" { +#include "KIM_SimulatorHeaders.h" +} +//@@@@@ Need to switch to c-bindings when they are available. +#include "KIM_SimulatorModel.hpp" +//@@@@@ + +#define SNUM(x) \ + static_cast(std::ostringstream() \ + << std::dec << x).str() + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +void KimInteractions::command(int narg, char **arg) +{ + if (narg < 1) error->all(FLERR,"Illegal kim_interactions command"); + + if (!domain->box_exist) + error->all(FLERR,"Must use 'kim_interactions' command after " + "simulation box is defined"); + do_setup(narg,arg); +} + +/* ---------------------------------------------------------------------- */ + +void KimInteractions::kim_interactions_log_delimiter( + std::string const begin_end) const +{ + if (comm->me == 0) { + std::string mesg; + if (begin_end == "begin") + mesg = + "#=== BEGIN kim_interactions ==================================\n"; + else if (begin_end == "end") + mesg = + "#=== END kim_interactions ====================================\n\n"; + + if (screen) fputs(mesg.c_str(),screen); + if (logfile) fputs(mesg.c_str(),logfile); + } +} + +/* ---------------------------------------------------------------------- */ + +void KimInteractions::do_setup(int narg, char **arg) +{ + if (narg != atom->ntypes) + error->all(FLERR,"Illegal kim_interactions command"); + + char *model_name = NULL; + KIM::SimulatorModel *simulatorModel(NULL); + + // check if we had a kim_init command by finding fix STORE/KIM + // retrieve model name and pointer to simulator model class instance. + // validate model name if not given as NULL. + + int ifix = modify->find_fix("KIM_MODEL_STORE"); + if (ifix >= 0) { + FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; + model_name = (char *)fix_store->getptr("model_name"); + simulatorModel = (KIM::SimulatorModel *)fix_store->getptr("simulator_model"); + } else error->all(FLERR,"Must use 'kim_init' before 'kim_interactions'"); + + // Begin output to log file + kim_interactions_log_delimiter("begin"); + + if (simulatorModel) { + + std::string delimiter(""); + std::string atom_type_sym_list; + std::string atom_type_num_list; + + for (int i = 0; i < narg; i++) + { + atom_type_sym_list += delimiter + arg[i]; + atom_type_num_list += delimiter + SNUM(species_to_atomic_no(arg[i])); + delimiter = " "; + } + + simulatorModel->AddTemplateMap("atom-type-sym-list",atom_type_sym_list); + simulatorModel->AddTemplateMap("atom-type-num-list",atom_type_num_list); + simulatorModel->CloseTemplateMap(); + + int len = strlen(atom_type_sym_list.c_str())+1; + char *strbuf = new char[len]; + char *strword; + + // validate species selection + + int sim_num_species; + bool species_is_supported; + const std::string *sim_species; + simulatorModel->GetNumberOfSupportedSpecies(&sim_num_species); + strcpy(strbuf,atom_type_sym_list.c_str()); + strword = strtok(strbuf," \t"); + while (strword) { + species_is_supported = false; + if (strcmp(strword,"NULL") == 0) continue; + for (int i=0; i < sim_num_species; ++i) { + simulatorModel->GetSupportedSpecies(i, &sim_species); + if (strcmp(sim_species->c_str(),strword) == 0) + species_is_supported = true; + } + if (!species_is_supported) { + std::string msg("Species '"); + msg += strword; + msg += "' is not supported by this KIM Simulator Model"; + error->all(FLERR,msg.c_str()); + } + strword = strtok(NULL," \t"); + } + delete[] strbuf; + + // check if units are unchanged + + int sim_fields, sim_lines; + const std::string *sim_field, *sim_value; + simulatorModel->GetNumberOfSimulatorFields(&sim_fields); + for (int i=0; i < sim_fields; ++i) { + simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + + if (*sim_field == "units") { + simulatorModel->GetSimulatorFieldLine(i,0,&sim_value); + if (*sim_value != update->unit_style) + error->all(FLERR,"Incompatible units for KIM Simulator Model"); + } + } + + int sim_model_idx=-1; + for (int i=0; i < sim_fields; ++i) { + simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + if (*sim_field == "model-defn") { + sim_model_idx = i; + for (int j=0; j < sim_lines; ++j) { + simulatorModel->GetSimulatorFieldLine(sim_model_idx,j,&sim_value); + input->one(sim_value->c_str()); + } + } + } + + if (sim_model_idx < 0) + error->all(FLERR,"KIM Simulator Model has no Model definition"); + + simulatorModel->OpenAndInitializeTemplateMap(); + + } else { + + // not a simulator model. issue pair_style and pair_coeff commands. + // NOTE: all references to arg must appear before calls to input->one() + // as that will reset the argument vector. + + std::string cmd1("pair_style kim "); + cmd1 += model_name; + + std::string cmd2("pair_coeff * * "); + for (int i=0; i < narg; ++i) { + cmd2 += arg[i]; + cmd2 += " "; + } + + input->one(cmd1.c_str()); + input->one(cmd2.c_str()); + } + + // End output to log file + kim_interactions_log_delimiter("end"); + +} + +/* ---------------------------------------------------------------------- */ + +int KimInteractions::species_to_atomic_no(std::string const species) const +{ + if (species == "H") return 1; + else if (species == "He") return 2; + else if (species == "Li") return 3; + else if (species == "Be") return 4; + else if (species == "B") return 5; + else if (species == "C") return 6; + else if (species == "N") return 7; + else if (species == "O") return 8; + else if (species == "F") return 9; + else if (species == "Ne") return 10; + else if (species == "Na") return 11; + else if (species == "Mg") return 12; + else if (species == "Al") return 13; + else if (species == "Si") return 14; + else if (species == "P") return 15; + else if (species == "S") return 16; + else if (species == "Cl") return 17; + else if (species == "Ar") return 18; + else if (species == "K") return 19; + else if (species == "Ca") return 20; + else if (species == "Sc") return 21; + else if (species == "Ti") return 22; + else if (species == "V") return 23; + else if (species == "Cr") return 24; + else if (species == "Mn") return 25; + else if (species == "Fe") return 26; + else if (species == "Co") return 27; + else if (species == "Ni") return 28; + else if (species == "Cu") return 29; + else if (species == "Zn") return 30; + else if (species == "Ga") return 31; + else if (species == "Ge") return 32; + else if (species == "As") return 33; + else if (species == "Se") return 34; + else if (species == "Br") return 35; + else if (species == "Kr") return 36; + else if (species == "Rb") return 37; + else if (species == "Sr") return 38; + else if (species == "Y") return 39; + else if (species == "Zr") return 40; + else if (species == "Nb") return 41; + else if (species == "Mo") return 42; + else if (species == "Tc") return 43; + else if (species == "Ru") return 44; + else if (species == "Rh") return 45; + else if (species == "Pd") return 46; + else if (species == "Ag") return 47; + else if (species == "Cd") return 48; + else if (species == "In") return 49; + else if (species == "Sn") return 50; + else if (species == "Sb") return 51; + else if (species == "Te") return 52; + else if (species == "I") return 53; + else if (species == "Xe") return 54; + else if (species == "Cs") return 55; + else if (species == "Ba") return 56; + else if (species == "La") return 57; + else if (species == "Ce") return 58; + else if (species == "Pr") return 59; + else if (species == "Nd") return 60; + else if (species == "Pm") return 61; + else if (species == "Sm") return 62; + else if (species == "Eu") return 63; + else if (species == "Gd") return 64; + else if (species == "Tb") return 65; + else if (species == "Dy") return 66; + else if (species == "Ho") return 67; + else if (species == "Er") return 68; + else if (species == "Tm") return 69; + else if (species == "Yb") return 70; + else if (species == "Lu") return 71; + else if (species == "Hf") return 72; + else if (species == "Ta") return 73; + else if (species == "W") return 74; + else if (species == "Re") return 75; + else if (species == "Os") return 76; + else if (species == "Ir") return 77; + else if (species == "Pt") return 78; + else if (species == "Au") return 79; + else if (species == "Hg") return 80; + else if (species == "Tl") return 81; + else if (species == "Pb") return 82; + else if (species == "Bi") return 83; + else if (species == "Po") return 84; + else if (species == "At") return 85; + else if (species == "Rn") return 86; + else if (species == "Fr") return 87; + else if (species == "Ra") return 88; + else if (species == "Ac") return 89; + else if (species == "Th") return 90; + else if (species == "Pa") return 91; + else if (species == "U") return 92; + else if (species == "Np") return 93; + else if (species == "Pu") return 94; + else if (species == "Am") return 95; + else if (species == "Cm") return 96; + else if (species == "Bk") return 97; + else if (species == "Cf") return 98; + else if (species == "Es") return 99; + else if (species == "Fm") return 100; + else if (species == "Md") return 101; + else if (species == "No") return 102; + else if (species == "Lr") return 103; + else if (species == "Rf") return 104; + else if (species == "Db") return 105; + else if (species == "Sg") return 106; + else if (species == "Bh") return 107; + else if (species == "Hs") return 108; + else if (species == "Mt") return 109; + else if (species == "Ds") return 110; + else if (species == "Rg") return 111; + else if (species == "Cn") return 112; + else if (species == "Nh") return 113; + else if (species == "Fl") return 114; + else if (species == "Mc") return 115; + else if (species == "Lv") return 116; + else if (species == "Ts") return 117; + else if (species == "Og") return 118; + else return -1; +} diff --git a/src/KIM/kim_interactions.h b/src/KIM/kim_interactions.h new file mode 100644 index 0000000000..6da1880f84 --- /dev/null +++ b/src/KIM/kim_interactions.h @@ -0,0 +1,116 @@ +/* -*- 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: Axel Kohlmeyer (Temple U), + Ryan S. Elliott (UMN) + Ellad B. Tadmor (UMN) +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, see . + + Linking LAMMPS statically or dynamically with other modules is making a + combined work based on LAMMPS. Thus, the terms and conditions of the GNU + General Public License cover the whole combination. + + In addition, as a special exception, the copyright holders of LAMMPS give + you permission to combine LAMMPS with free software programs or libraries + that are released under the GNU LGPL and with code included in the standard + release of the "kim-api" under the CDDL (or modified versions of such code, + with unchanged license). You may copy and distribute such a system following + the terms of the GNU GPL for LAMMPS and the licenses of the other code + concerned, provided that you include the source code of that other code + when and as the GNU GPL requires distribution of source code. + + Note that people who make modified versions of LAMMPS are not obligated to + grant this special exception for their modified versions; it is their choice + whether to do so. The GNU General Public License gives permission to release + a modified version without this exception; this exception also makes it + possible to release a modified version which carries forward this exception. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Designed for use with the kim-api-2.1.0 (and newer) package +------------------------------------------------------------------------- */ + +#ifdef COMMAND_CLASS + +CommandStyle(kim_interactions,KimInteractions) + +#else + +#ifndef LMP_KIM_INTERACTIONS_H +#define LMP_KIM_INTERACTIONS_H + +#include "pointers.h" + +namespace LAMMPS_NS { + +class KimInteractions : protected Pointers { + public: + KimInteractions(class LAMMPS *lmp) : Pointers(lmp) {}; + void command(int, char **); + private: + void do_setup(int, char **); + int species_to_atomic_no(std::string const species) const; + void kim_interactions_log_delimiter(std::string const begin_end) const; +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal kim_interactions command + +Incorrect number or kind of arguments to kim_interactions. + +E: Must use 'kim_interactions' command after simulation box is defined + +Self-explanatory. + +E: Must use 'kim_init' command before 'kim_interactions' + +Self-explanatory. + +E: Species XXX is not supported by this KIM Simulator Model + +The kim_interactions command was referencing a species that is not +present in the requested KIM Simulator Model. + +E: Incompatible units for KIM Simulator Model + +The selected unit style is not compatible with the requested KIM +Simulator Model. + +E: KIM Simulator Model has no Model definition + +There is no model definition (key: model-defn) in the KIM Simulator +Model. Please contact the OpenKIM database maintainers to verify +and potentially correct this. + +*/ From 17fa2f787b58cb4c17bc6aa04b1015a9b2778a93 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Sat, 22 Jun 2019 15:25:21 -0500 Subject: [PATCH 033/107] Added kim_command documentation structure --- doc/src/Commands_all.txt | 5 +- doc/src/commands_list.txt | 3 +- doc/src/kim_commands.txt | 108 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 4 deletions(-) create mode 100644 doc/src/kim_commands.txt diff --git a/doc/src/Commands_all.txt b/doc/src/Commands_all.txt index d76ffac14c..a201fd3f2d 100644 --- a/doc/src/Commands_all.txt +++ b/doc/src/Commands_all.txt @@ -68,8 +68,9 @@ An alphabetic list of all general LAMMPS commands. "improper_style"_improper_style.html, "include"_include.html, "jump"_jump.html, -"kim_query"_kim_query.html, -"kim_style"_kim_style.html, +"kim_init"_kim_commands.html, +"kim_interactions"_kim_commands.html, +"kim_query"_kim_commands.html, "kspace_modify"_kspace_modify.html, "kspace_style"_kspace_style.html, "label"_label.html, diff --git a/doc/src/commands_list.txt b/doc/src/commands_list.txt index 39d2f7c7d0..a5c9b568ed 100644 --- a/doc/src/commands_list.txt +++ b/doc/src/commands_list.txt @@ -53,8 +53,7 @@ Commands :h1 include info jump - kim_query - kim_style + kim_commands kspace_modify kspace_style label diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt new file mode 100644 index 0000000000..4c53746317 --- /dev/null +++ b/doc/src/kim_commands.txt @@ -0,0 +1,108 @@ +"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c + +:link(lws,http://lammps.sandia.gov) +:link(ld,Manual.html) +:link(lc,Commands_all.html) + +:line + +kim_commands :h3 + +[Syntax:] + +kim_init model user_units :pre +kim_interactions typeargs :pre + +mode = {init model} or {define typeargs} or no mode chosen +model = name of the KIM model (KIM potential or KIM simulator model) +typeargs = atom type to species mapping (one entry per atom type) +args = {unit_variables unit_style} or {unit_from unit_style} (optional):ul + +[Examples:] + +kim_style init ex_sim_model_Si_mod_tersoff unit_variables metal +kim_style define Si Si +kim_style unit_variables real +kim_style init LennardJones_Ar unit_variables metal +kim_style unit_variables real unit_from metal +kim_style define Ar :pre + +[Description:] + +The kim_style command is a high-level wrapper around the +"Knowledge Base for Interatomic Models (OpenKIM)"_https://openkim.org +repository of interatomic potentials, so that they can be used by +LAMMPS scripts. It does not implement any computations directly, but +rather will generate LAMMPS input commands based on the information +retrieved from the OpenKIM repository. It is able to realize so-called +"KIM Simulator Models", which are OpenKIM repository entries of models +using native features of the simulation engine in use, i.e. LAMMPS +in this case, but it also supports realizing conventional KIM models +implicitly via generating a "pair_style kim"_pair_kim.html command +followed by a suitable "pair_coeff"_pair_coeff.html command. + +The kim_style command has two modes, {init} and {define}, indicated by +the first argument to the kim_style command. An {init} mode command +must be issued [before] the simulation box is created, while the {define} +mode version may only be used [after] the simulation box exists. Both +are required. The {init} mode version sets the model name and may issue +additional commands changing LAMMPS default settings that are required +for using a selected simulator model. If needed, those settings can be +overridden. The second argument to the {kim_style init} command is the +KIM model ID. + +In both modes, the keywords {unit_variables} and {unit_from} may be +added. They control the values of a set of +"internal style variables"_variable.html that can be used to convert +between different unit styles in LAMMPS. The argument to +each keyword is a LAMMPS unit style or NULL, which means to look up +the unit style from what was set with the "units"_units.html command. +Please note, that KIM simulator models will set their preferred unit style. +By default all conversion variables are set to 1.0. Converting to or +from the "lj" unit style is not supported. The following variables are defined: + +_u_length +_u_mass +_u_time :ul + + +The {kim_style define} command will issue commands that will realize +the selected model (through generating pair_style and pair_coeff commands, +but also other commands, as required). It has to be issued [after] the +the simulation box is defined. The {kim_style define} command allows a +varying number of additional arguments. Those are used to map the atom +types in LAMMPS to the available species in the KIM model. This is +equivalent to the arguments following "pair_coeff * *" in a +"kim"_pair_kim.html pair style. Thus the commands: + +kim_style init LennardJones_Ar +kim_style define Ar :pre + +will generate the LAMMPS input commands: + +pair_style kim LennardJones_Ar +pair_coeff * * Ar :pre + +For simulator models, the generated input commands may be more complex +and require that LAMMPS is built with the required packages included. +The commands generated by the kim_style command, can be copied to the +screen or log file, through the "echo"_echo.html command. +The kim_style command will also validate, that a selected simulator +model was generated for the LAMMPS MD code and not some other software. +In addition, the version strings for LAMMPS version used for defining +the simulator model and the LAMMPS version being currently run are +printed, so that it can be tracked down, if there are any incompatible +changes to input script or command syntax between the two LAMMPS versions. + +[Restrictions:] + +This command is part of the KIM package. It is only enabled if +LAMMPS was built with that package. Furthermore, its correct +functioning depends on compiling LAMMPS with all required packages +installed that are required by the commands embedded in any KIM +simulator models used. +See the "Build package"_Build_package.html doc page for more info. + +[Related commands:] + +"pair_style kim"_pair_kim.html, "kim_query"_kim_query.html From 33be7f259be9446edf9f75e17309d8bfe7f05e84 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Sat, 22 Jun 2019 21:49:29 -0500 Subject: [PATCH 034/107] Working on kim_commands documentation --- doc/src/kim_commands.txt | 232 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 221 insertions(+), 11 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 4c53746317..06ad841240 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -10,25 +10,235 @@ kim_commands :h3 [Syntax:] -kim_init model user_units :pre -kim_interactions typeargs :pre +kim_init model user_units unitarg +kim_interactions typeargs +kim_query variable query_function web_query_flags :pre -mode = {init model} or {define typeargs} or no mode chosen -model = name of the KIM model (KIM potential or KIM simulator model) +model = designation of the KIM interatomic model (the KIM ID for models archived in OpenKIM) +user_units = the LAMMPS "units"_units.html style assumed in the user input script +unitarg = {unit_conversion_mode} (optional) typeargs = atom type to species mapping (one entry per atom type) -args = {unit_variables unit_style} or {unit_from unit_style} (optional):ul +variable = name of a (string style) variable where the result of the query is stored +query_function = name of the OpenKIM web API query function to be used +web_query_flags = a series of keyword=value pairs that represent the web query; supported keywords depend on query function :ul + [Examples:] -kim_style init ex_sim_model_Si_mod_tersoff unit_variables metal -kim_style define Si Si -kim_style unit_variables real -kim_style init LennardJones_Ar unit_variables metal -kim_style unit_variables real unit_from metal -kim_style define Ar :pre +kim_init SW_StillingerWeber_1985_Si__MO_405512056662_005 metal +kim_interactions Si +kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 real +kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 metal unit_conversion_mode +kim_interactions C H O +kim_query NEED EXAMPLES :pre [Description:] +The "Open Knowledgebase for Interatomic Models (OpenKIM)"_https://openkim.org +archives interatomic models (IMs) (potentials and force fields) in a format +that can be directly used with LAMMPS using the commands documented on this +page. + +Benefits of Using OpenKIM IMs :h4 + +Employing OpenKIM IMs provides LAMMPS users with multiple benefits: + +Reliability :h5 + +All content archived in OpenKIM is subject to quality control by the "KIM Editor"_https://openkim.org/governance/. +IMs in OpenKIM are archived with full provenance control. Each is associated with a maintainer responsible for the integrity of the content. All changes are tracked and recorded. +IMs in OpenKIM are exhaustively tested using "KIM Tests"_https://openkim.org/getting-started/kim-tests/ that compute a host of material properties, and "KIM Verification Checks"_https://openkim.org/about-verification-checks/ that provide the user with information on various aspects of the IM behavior and coding correctness. This information is displayed on the IM's page on "OpenKIM"_https://openkim.org. :ul + +Reproducibility :h5 + +Each IM in OpenKIM is issued a unique identifier ("KIM ID"_https://openkim.org/about-kim-ids/), which includes a version number (last three digits). Any changes that can result in different numerical values lead to a version increment in the KIM ID. This makes it possible to reproduce simulations since the specific version of a specific IM used can be retrieved using its KIM ID. +OpenKIM is a member organization of "DataCite"_https://datacite.org/ and issues digitial object identifiers (DOIs) to all IMs archived in OpenKIM. This makes it possible to cite the IM code used in a simulation in a publications to give credit to the developers and further facilitate reproducibility. :ul + +Convenience :h5 + +IMs in OpenKIM are distributed in binary form along with LAMMPS and can be used in a LAMMPS input script simply by providing their KIM ID in the {kim_init} command documented on this page. (For more on using KIM with LAMMPS, see the KIM section of the "Packages details"_Packages_details.html doc page.) +The {kim_query} web query tool provides the ability to use the predictions of IMs for supported material properties (computed via "KIM Tests"https://openkim.org/getting-started/kim-tests/) as part of a LAMMPS input script setup and analysis. +Support is provided for unit conversion between the "units"_units.html system used in the LAMMPS input script and the OpenKIM IM. This makes it possible to use a single input script with IMs using different units without change and minimizes the liklihood of errors due to incompatible units. :ul + +Types of KIM IMs :h4 + +There are two types of IMs archived in OpenKIM: + +The first type is called a {KIM Model}. A KIM Model is an independent computer implemention of an IM written in one of the languages supported by KIM (C, C++, Fortran, Python), which conforms to the KIM Application Programming Interface ("KIM API"_https://openkim.org/kim-api/). A KIM Model will work seamlessly with any simulation code that support the KIM API (including LAMMPS; see "complete list of supported code"_https://openkim.org/projects-using-kim/). +The second type is called a {KIM Simulator Model} (SM). In this case, the IM is implemented natively within the simulation code ({simulator}), i.e. LAMMPS. A separate SM package is archived in OpenKIM for each parameterization of the IM, which includes all of the necessary parameter files, LAMMPS commands, and metadata (supported species, units, etc.) needed to run the IM in LAMMPS. :ol + +With these two IM tpes, OpenKIM can archive and test almost all IMs that +can be used by LAMMPS. (It is easy to contribute new IMs to OpenKIM, see +the "upload instructions"_https://openkim.org/getting-started/adding-content/.) + +OpenKIM IMs are uniquely identified by a +"KIM ID"_https://openkim.org/about-kim-ids/. The extended KIM ID consists of +a human-readable prefix identifying the type of IM, authors, publication year, +and supported species, separated by two underscores from the KIM ID itself, +which begins with an IM code +({MO} for a KIM Model, and {SM} for a KIM Simulator Model) +followed by a unique 12-digit code and a 3-digit version identifier. +By convension SM prefixes begin with {SM} to readily identify them. + +SW_StillingerWeber_1985_Si__MO_405512056662_005 +Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 :pre + +NOTE: It is also possible to locally install IMs not archived in OpenKIM, +in which case their designation does not have to conform to the KIM ID format. + +Using OpenKIM IMs with LAMMPS :h4 + +Two commands are employed when using OpenKIM IMs, one to select the +IM and perform necessary initializations ({kim_init}), and the second +to set up the IM for use by executing any necessary LAMMPS commands +({kim_interactions}). + +OpenKIM IM Initialization :h5 + +The kim_init command must be located at the top of the input script +before any other commands. Input scripts containing a kim_init command +shoud {not} include a "units"_units.html command or an +"atom_style"_atom_style.html command. These are set by the kim_init +command based on its arguments. + +The required arguments of kim_init are the {model} designation of the +IM to be used in the simulation (for an IM archived in OpenKIM this is +its "extended KIM ID"_https://openkim.org/about-kim-ids/), and +the {user_units}, which are the LAMMPS "units"_units.html system used +in the input script. (Any numerical values in the input script and values +read in from files are expected to be in the {user_units} system.) + +Based on the selected model kim_init may modify "atom_style"_atom_style.html. +Some SMs have requirements for this variable. If this is the case, then +atom_style will be set to the required style. Otherwise, the value is left +unchanged (which in the absence of an atom_style command in the input script +is the default LAMMPS value). + +Regarding units, the kim_init command behaves in different ways depending +on whether or not "unit conversion mode" is activated as indicated by the +optional {unitarg} argument. +If unit conversion mode is {not} active, then {user_units} must +either match the required units of the IM or the IM must be able +to adjust its units to match. (The latter is only possible with some KIM Models; +SMs can never adjust their units.) If a match is possible, the LAMMPS +"units"_units.html command is called to set the units to +{user_units}. If the match fails, the simulation is terminated with +an error. + +If unit conversion mode {is} active, then the LAMMPS "units"_units.html +command is called to set the units to the IM's required or preferred units. +Conversion factors between the IM's units and the {user_units} are +defined for all "physical quantities"_units.html (mass, distance, etc.). +These factors are stored as internal "variables"_variable.html with +standard names: + +_u_mass +_u_distance +_u_time +_u_energy +_u_velocity +_u_force +_u_torque +_u_temperature +_u_pressure +_u_viscosity +_u_charge +_u_dipole +_u_efield +_u_density :pre + +If desired, the input script can be designed to work with these conversion +factors so that the script will work without change with any OpenKIM IM. +(This approach is used in the +"OpenKIM Testing Framework"_https://openkim.org/getting-started/kim-tests/.) +For example, the following simple script constructs an fcc lattice with +a lattice parameter defined in meters, computes the total energy, +and prints the cohesive energy in Joules regardless of the units of the IM. + +kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 si unit_conversion_mode +boundary p p p +lattice fcc 4.032e-10*$\{_u_distance\} +region simbox block 0 1 0 1 0 1 units lattice +create_box 1 simbox +create_atoms 1 box +mass 1 4.480134e-26*$\{_u_mass\} +kim_interactions Al +run 0 +variable Ec_in_J equal (pe/count(all))/$\{_u_energy\} +print "Cohesive Energy = $\{Ec_in_J\} J" :pre + +Note the multiplication by $\{_u_distance\} and $\{_u_mass\} to convert +from SI units (specified in the kim_init command) to whatever units the +IM uses (metal in this case), and the division by $\{_u_energy\} +to convert from the IM's energy units to SI units (Joule). This script +will work correctly for any IM for Al (KIM Model or SM) selected by the +kim_init command. + +Care must be taken to apply unit conversion to dimensional variables read in +from a file. For example if a configuration of atoms is read in from a +dump file using the "read_dump"_read_dump.html command, the following can +be done to convert the box and all atomic positions to the correct units: + +change_box all x scale $\{_u_distance\} y scale $\{_u_distance\} z scale $\{_u_distance\} remap :pre + +NOTE: Unit conversion will only work if the conversion factors are placed in +all appropriate places in the input script. It is up to the user to do this +correctly. + +OpenKIM IM Execution :h5 + +The second and final step in using an OpenKIM IM is to execute the +kim_interaction command. This command must be preceded by a kim_init +command and must follow the "create_box"_create_box.html command, +which defines the number of atom types {N}. +The kim_interaction command has one argument {typeargs}, which contains +a list of {N} chemical species that are mapped to the atom types. + +For example, imagine the OpenKIM IM supports Si and C species. +If the LAMMPS simulation has 4 atom types and you want the first three to be Si, +and the fourth to be C, you would use the following kim_interaction command: + +kim_interaction Si Si Si C :pre + +The kim_interaction command performs all the necessary steps to set up +the OpenKIM IM set in the kim_init command. The specific actions depend +on whether the IM is a KIM Model or a KIM SM. For a KIM Model, +a "pair_style kim"_pair_kim.html command will be executed followed by +the appropriate pair_coeff command. + +For a KIM SM, the set of commands defined in the SM speficiation file +will be executed. For example, consider the ReaxFF SM due to +Strachan et al. (2003) executed by the following commands: + +kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 real +... +... box specification lines skipped +... +kim_interactions C H N O :pre + +The kim_interactions command executes the following commands defined for this +SM: + +pair_style reax/c lmp_control safezone 2.0 mincap 100 +pair_coeff * * ffield.reax.rdx C H N O +fix reaxqeq all qeq/reax 1 0.0 10.0 1.0e-6 param.qeq :pre + +Note that the files lmp_control, ffield.reax.rdx and param.qeq are specific +to Strachan et al. (2003) ReaxFF parameterization and are archived as part +of the SM package in OpenKIM. Note also that parameters like cutoff radii +and charge tolerances that have an effect on IM predictions are also +included in the SM definition ensuring reproducibility. + +NOTE: Clearly when using using kim_init and kim_interactions to select +and set up an OpenKIM IM, other LAMMPS commands +for the same functions (such as pair_style, pair_coeff, bond_style, +bond_coeff, fixes related to charge equilibration, etc.) should not +appear in the input script. + +Using OpenKIM Web Queries in LAMMPS :h4 + +@@@@@@@@@ + The kim_style command is a high-level wrapper around the "Knowledge Base for Interatomic Models (OpenKIM)"_https://openkim.org repository of interatomic potentials, so that they can be used by From c11caf45095d96aeb2a1477ce78d6e0c03ea7505 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Sun, 23 Jun 2019 10:34:43 -0500 Subject: [PATCH 035/107] update kim examples to temp. current state of code --- examples/kim/data.VOH | 118 ---------------------- examples/kim/in.kim.VOH.simulator_model | 23 ----- examples/kim/in.kim.ex_si.simulator_model | 69 ------------- examples/kim/in.kim.lj.simulator_model | 10 +- 4 files changed, 2 insertions(+), 218 deletions(-) delete mode 100644 examples/kim/data.VOH delete mode 100644 examples/kim/in.kim.VOH.simulator_model delete mode 100644 examples/kim/in.kim.ex_si.simulator_model diff --git a/examples/kim/data.VOH b/examples/kim/data.VOH deleted file mode 100644 index c093705adc..0000000000 --- a/examples/kim/data.VOH +++ /dev/null @@ -1,118 +0,0 @@ -# VOH example - -100 atoms -4 atom types - -0 25.000 xlo xhi -0 25.000 ylo yhi -0 25.000 zlo zhi - -Masses - -1 1.0080 -2 12.0107 -3 15.9994 -4 50.9415 - -Atoms - - 1 2 0.0 12.35333 12.56112 11.08925 - 2 4 0.0 12.32916 12.62071 13.13099 - 3 3 0.0 14.09425 12.56218 13.76130 - 4 3 0.0 11.42814 11.10330 13.76732 - 5 3 0.0 11.63260 13.89286 13.64097 - 6 1 0.0 10.61647 11.29221 14.30535 - 7 1 0.0 14.38026 13.34626 14.29055 - 8 1 0.0 11.32479 12.58820 10.70253 - 9 1 0.0 12.90918 13.42567 10.69612 - 10 1 0.0 12.84043 11.63643 10.74688 - 11 2 0.0 0.93670 23.74637 24.45218 - 12 4 0.0 2.18151 24.36876 0.94725 - 13 3 0.0 3.93452 24.44779 0.28384 - 14 3 0.0 2.13668 23.10529 2.33362 - 15 3 0.0 1.76108 0.74666 1.48323 - 16 1 0.0 1.82070 23.45305 3.20745 - 17 1 0.0 4.35555 0.34186 0.31083 - 18 1 0.0 24.90472 23.68735 24.82586 - 19 1 0.0 0.97611 24.45631 23.61244 - 20 1 0.0 1.24583 22.75250 24.09589 - 21 2 0.0 2.25730 12.18969 18.74792 - 22 4 0.0 0.67140 13.31162 19.37385 - 23 3 0.0 0.71106 13.43250 21.24545 - 24 3 0.0 24.08603 12.44025 18.87949 - 25 3 0.0 0.70486 14.71920 18.75808 - 26 1 0.0 23.49516 12.95430 18.26686 - 27 1 0.0 0.79723 14.34808 21.60818 - 28 1 0.0 2.24383 12.10285 17.65239 - 29 1 0.0 3.19860 12.66607 19.06030 - 30 1 0.0 2.20214 11.18299 19.18774 - 31 2 0.0 9.32237 8.16220 23.74501 - 32 4 0.0 9.41775 7.26178 21.91463 - 33 3 0.0 8.54752 8.34565 20.65588 - 34 3 0.0 8.50942 5.62151 22.00137 - 35 3 0.0 10.87539 7.02683 21.48455 - 36 1 0.0 9.06507 4.82324 21.80615 - 37 1 0.0 9.11458 8.67119 19.91477 - 38 1 0.0 9.82196 7.53487 24.49616 - 39 1 0.0 9.81855 9.14254 23.70532 - 40 1 0.0 8.27176 8.30387 24.03831 - 41 2 0.0 9.10113 13.98748 23.44281 - 42 4 0.0 8.84954 12.89163 21.73780 - 43 3 0.0 10.01387 13.54293 20.42005 - 44 3 0.0 7.08992 13.11522 21.12954 - 45 3 0.0 9.12937 11.39982 21.99065 - 46 1 0.0 6.55309 12.28287 21.08224 - 47 1 0.0 10.67858 12.89258 20.08249 - 48 1 0.0 8.42108 13.62252 24.22498 - 49 1 0.0 10.13926 13.89766 23.79639 - 50 1 0.0 8.88118 15.04646 23.24289 - 51 2 0.0 17.73225 3.40708 8.28945 - 52 4 0.0 18.49877 5.29835 8.37599 - 53 3 0.0 19.48472 5.62627 6.81505 - 54 3 0.0 19.66498 5.40961 9.84118 - 55 3 0.0 17.38120 6.34466 8.51889 - 56 1 0.0 19.41208 6.07779 10.52927 - 57 1 0.0 19.15960 6.37609 6.25924 - 58 1 0.0 17.15579 3.19557 9.20103 - 59 1 0.0 17.07197 3.31049 7.41454 - 60 1 0.0 18.54903 2.67524 8.20436 - 61 2 0.0 5.18346 20.97409 24.28840 - 62 4 0.0 7.06396 20.17968 24.34847 - 63 3 0.0 7.63220 19.82889 22.59578 - 64 3 0.0 7.00272 18.55243 0.28036 - 65 3 0.0 8.05085 21.13715 0.03620 - 66 1 0.0 7.56109 18.51690 1.09952 - 67 1 0.0 8.44257 20.31624 22.30833 - 68 1 0.0 4.83239 21.17976 0.30904 - 69 1 0.0 5.19182 21.91237 23.71419 - 70 1 0.0 4.49282 20.26573 23.80772 - 71 2 0.0 21.82701 12.79861 20.63056 - 72 4 0.0 21.27646 11.09990 19.63611 - 73 3 0.0 19.52930 10.64327 20.13923 - 74 3 0.0 22.41924 9.70346 20.14638 - 75 3 0.0 21.34556 11.30206 18.11274 - 76 1 0.0 22.94464 9.30084 19.40876 - 77 1 0.0 18.86743 10.62817 19.40629 - 78 1 0.0 22.85378 13.07853 20.35349 - 79 1 0.0 21.14666 13.62206 20.37063 - 80 1 0.0 21.78702 12.62668 21.71522 - 81 2 0.0 4.84801 10.63893 5.85720 - 82 4 0.0 2.99668 11.06158 5.10490 - 83 3 0.0 3.09505 11.09458 3.23258 - 84 3 0.0 2.48053 12.76555 5.69567 - 85 3 0.0 1.96195 10.01780 5.55634 - 86 1 0.0 1.65323 12.78746 6.24245 - 87 1 0.0 2.52753 10.43264 2.76734 - 88 1 0.0 4.80984 10.62196 6.95551 - 89 1 0.0 5.18492 9.65688 5.49273 - 90 1 0.0 5.56737 11.40648 5.53568 - 91 2 0.0 13.58126 9.47098 19.40329 - 92 4 0.0 14.17691 10.17243 21.22692 - 93 3 0.0 14.44428 12.02521 21.10583 - 94 3 0.0 15.81206 9.37183 21.67632 - 95 3 0.0 13.12907 9.86545 22.30960 - 96 1 0.0 15.80034 8.83149 22.50703 - 97 1 0.0 13.87232 12.57457 21.69672 - 98 1 0.0 13.42563 8.38456 19.45392 - 99 1 0.0 12.63978 9.95672 19.10431 - 100 1 0.0 14.35123 9.68789 18.64825 diff --git a/examples/kim/in.kim.VOH.simulator_model b/examples/kim/in.kim.VOH.simulator_model deleted file mode 100644 index 8696cf265a..0000000000 --- a/examples/kim/in.kim.VOH.simulator_model +++ /dev/null @@ -1,23 +0,0 @@ -# REAX potential for VOH system -# ..... - -units real -atom_style charge - -kim_style init Sim_LAMMPS_ReaxFF_ChenowethVanDuinPersson_2008_CHOV__SM_429148913211_000 - -read_data data.VOH - -kim_style define H C O V - -neighbor 2 bin -neigh_modify every 10 delay 0 check no - -fix 1 all nve -fix 3 all temp/berendsen 500.0 500.0 100.0 - -timestep 0.25 - -#dump 1 all atom 30 dump.reax.voh - -run 300 diff --git a/examples/kim/in.kim.ex_si.simulator_model b/examples/kim/in.kim.ex_si.simulator_model deleted file mode 100644 index 2f9e79ef4e..0000000000 --- a/examples/kim/in.kim.ex_si.simulator_model +++ /dev/null @@ -1,69 +0,0 @@ - -units metal -kim_style init ex_sim_model_Si_mod_tersoff - -atom_style atomic -atom_modify map array -boundary p p p - -# temperatures -variable tlo equal 1800.0 -variable thi equal 2400.0 - -# coordination number cutoff - -variable r equal 2.835 - -# minimization parameters - -variable etol equal 1.0e-5 -variable ftol equal 1.0e-5 -variable maxiter equal 100 -variable maxeval equal 100 -variable dmax equal 1.0e-1 - -# diamond unit cell - -variable a equal 5.431 -lattice custom $a & - a1 1.0 0.0 0.0 & - a2 0.0 1.0 0.0 & - a3 0.0 0.0 1.0 & - basis 0.0 0.0 0.0 & - basis 0.0 0.5 0.5 & - basis 0.5 0.0 0.5 & - basis 0.5 0.5 0.0 & - basis 0.25 0.25 0.25 & - basis 0.25 0.75 0.75 & - basis 0.75 0.25 0.75 & - basis 0.75 0.75 0.25 - -region myreg block 0 4 & - 0 4 & - 0 4 -create_box 1 myreg -create_atoms 1 region myreg - -mass 1 28.06 - -group Si type 1 - -velocity all create ${thi} 5287286 mom yes rot yes dist gaussian - -# make a vacancy - -group del id 300 -delete_atoms group del -kim_style define Si - -thermo 10 - -fix 1 all nve -fix 2 all langevin ${thi} ${thi} 0.1 48278 - -timestep 1.0e-3 -neighbor 1.0 bin -neigh_modify every 1 delay 10 check yes - -run 100 - diff --git a/examples/kim/in.kim.lj.simulator_model b/examples/kim/in.kim.lj.simulator_model index 01ee5aa64c..cb7a2e14ed 100644 --- a/examples/kim/in.kim.lj.simulator_model +++ b/examples/kim/in.kim.lj.simulator_model @@ -14,9 +14,7 @@ variable xx equal 20*$x variable yy equal 20*$y variable zz equal 20*$z -echo both -#kim_style model LennardJones_Ar metal -kim_style model Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu real unit_conversion_mode +kim_init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu real unit_conversion_mode newton on lattice fcc 4.4300 @@ -24,10 +22,7 @@ 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 - -kim_style setup Au +kim_interactions Au mass 1 39.95 velocity all create 200.0 232345 loop geom @@ -36,6 +31,5 @@ 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 From d08867ce0a05e090056f9dea1e3bbdd2fc4c6afa Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Sun, 23 Jun 2019 11:39:06 -0500 Subject: [PATCH 036/107] Completed first version of kim_commands documentation --- doc/src/kim_commands.txt | 304 +++++++++++++++++++++++---------------- 1 file changed, 182 insertions(+), 122 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 06ad841240..c3ab799821 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -12,15 +12,15 @@ kim_commands :h3 kim_init model user_units unitarg kim_interactions typeargs -kim_query variable query_function web_query_flags :pre +kim_query variable query_function queryargs :pre -model = designation of the KIM interatomic model (the KIM ID for models archived in OpenKIM) -user_units = the LAMMPS "units"_units.html style assumed in the user input script +model = name of the KIM interatomic model (the KIM ID for models archived in OpenKIM) +user_units = the LAMMPS "units"_units.html style assumed in the LAMMPS input script unitarg = {unit_conversion_mode} (optional) typeargs = atom type to species mapping (one entry per atom type) variable = name of a (string style) variable where the result of the query is stored query_function = name of the OpenKIM web API query function to be used -web_query_flags = a series of keyword=value pairs that represent the web query; supported keywords depend on query function :ul +queryargs = a series of {keyword=value} pairs that represent the web query; supported keywords depend on the query function :ul [Examples:] @@ -30,14 +30,20 @@ kim_interactions Si kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 real kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 metal unit_conversion_mode kim_interactions C H O -kim_query NEED EXAMPLES :pre +kim_query a0 get_lattice_constant_fcc units=\["angstrom"\] :pre + [Description:] -The "Open Knowledgebase for Interatomic Models (OpenKIM)"_https://openkim.org -archives interatomic models (IMs) (potentials and force fields) in a format -that can be directly used with LAMMPS using the commands documented on this -page. +The set of {kim_commands} provide a high-level wrapper around the +"Open Knowledgebase of Interatomic Models (OpenKIM)"_https://openkim.org +repository of interatomic models (IMs) (potentials and force fields), +so that they can be used by LAMMPS scripts. These commands do not implement +any computations directly, but rather generate LAMMPS input commands based +on the information retrieved from the OpenKIM repository to initialize and +activate OpenKIM IMs and query their predictions for use in the LAMMPS script. +All LAMMPS input commands executed by {kim_commands} are echoed to the +LAMMPS log file. Benefits of Using OpenKIM IMs :h4 @@ -52,22 +58,23 @@ IMs in OpenKIM are exhaustively tested using "KIM Tests"_https://openkim.org/get Reproducibility :h5 Each IM in OpenKIM is issued a unique identifier ("KIM ID"_https://openkim.org/about-kim-ids/), which includes a version number (last three digits). Any changes that can result in different numerical values lead to a version increment in the KIM ID. This makes it possible to reproduce simulations since the specific version of a specific IM used can be retrieved using its KIM ID. -OpenKIM is a member organization of "DataCite"_https://datacite.org/ and issues digitial object identifiers (DOIs) to all IMs archived in OpenKIM. This makes it possible to cite the IM code used in a simulation in a publications to give credit to the developers and further facilitate reproducibility. :ul +OpenKIM is a member organization of "DataCite"_https://datacite.org/ and issues digital object identifiers (DOIs) to all IMs archived in OpenKIM. This makes it possible to cite the IM code used in a simulation in a publications to give credit to the developers and further facilitate reproducibility. :ul Convenience :h5 -IMs in OpenKIM are distributed in binary form along with LAMMPS and can be used in a LAMMPS input script simply by providing their KIM ID in the {kim_init} command documented on this page. (For more on using KIM with LAMMPS, see the KIM section of the "Packages details"_Packages_details.html doc page.) +IMs in OpenKIM are distributed in binary form along with LAMMPS and can be used in a LAMMPS input script simply by providing their KIM ID in the {kim_init} command documented on this page. The {kim_query} web query tool provides the ability to use the predictions of IMs for supported material properties (computed via "KIM Tests"https://openkim.org/getting-started/kim-tests/) as part of a LAMMPS input script setup and analysis. -Support is provided for unit conversion between the "units"_units.html system used in the LAMMPS input script and the OpenKIM IM. This makes it possible to use a single input script with IMs using different units without change and minimizes the liklihood of errors due to incompatible units. :ul +Support is provided for unit conversion between the "units style"_units.html used in the LAMMPS input script and the units required by the OpenKIM IM. This makes it possible to use a single input script with IMs using different units without change and minimizes the likelihood of errors due to incompatible units. :ul +:link(IM_types) Types of KIM IMs :h4 There are two types of IMs archived in OpenKIM: -The first type is called a {KIM Model}. A KIM Model is an independent computer implemention of an IM written in one of the languages supported by KIM (C, C++, Fortran, Python), which conforms to the KIM Application Programming Interface ("KIM API"_https://openkim.org/kim-api/). A KIM Model will work seamlessly with any simulation code that support the KIM API (including LAMMPS; see "complete list of supported code"_https://openkim.org/projects-using-kim/). +The first type is called a {KIM Model}. A KIM Model is an independent computer implementation of an IM written in one of the languages supported by KIM (C, C++, Fortran, Python), which conforms to the KIM Application Programming Interface ("KIM API"_https://openkim.org/kim-api/). A KIM Model will work seamlessly with any simulation code that support the KIM API (including LAMMPS; see "complete list of supported code"_https://openkim.org/projects-using-kim/). The second type is called a {KIM Simulator Model} (SM). In this case, the IM is implemented natively within the simulation code ({simulator}), i.e. LAMMPS. A separate SM package is archived in OpenKIM for each parameterization of the IM, which includes all of the necessary parameter files, LAMMPS commands, and metadata (supported species, units, etc.) needed to run the IM in LAMMPS. :ol -With these two IM tpes, OpenKIM can archive and test almost all IMs that +With these two IM types, OpenKIM can archive and test almost all IMs that can be used by LAMMPS. (It is easy to contribute new IMs to OpenKIM, see the "upload instructions"_https://openkim.org/getting-started/adding-content/.) @@ -78,46 +85,59 @@ and supported species, separated by two underscores from the KIM ID itself, which begins with an IM code ({MO} for a KIM Model, and {SM} for a KIM Simulator Model) followed by a unique 12-digit code and a 3-digit version identifier. -By convension SM prefixes begin with {SM} to readily identify them. +By convention SM prefixes begin with {Sim_} to readily identify them. SW_StillingerWeber_1985_Si__MO_405512056662_005 Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 :pre NOTE: It is also possible to locally install IMs not archived in OpenKIM, -in which case their designation does not have to conform to the KIM ID format. +in which case their names do not have to conform to the KIM ID format. Using OpenKIM IMs with LAMMPS :h4 Two commands are employed when using OpenKIM IMs, one to select the IM and perform necessary initializations ({kim_init}), and the second to set up the IM for use by executing any necessary LAMMPS commands -({kim_interactions}). +({kim_interactions}). Both are required. -OpenKIM IM Initialization :h5 +OpenKIM IM Initialization ({kim_init}) :h5 -The kim_init command must be located at the top of the input script -before any other commands. Input scripts containing a kim_init command -shoud {not} include a "units"_units.html command or an -"atom_style"_atom_style.html command. These are set by the kim_init -command based on its arguments. +The {kim_init} mode command must be issued [before] +the simulation box is created (normally at the top of the file). +This command sets the OpenKIM IM that will be used and may issue +additional commands changing LAMMPS default settings that are required +for using the selected IM (such as "units"_units.html or +"atom_style"_atom_style.html). If needed, those settings can be overridden, +however, typically a script containing a {kim_init} command +would not include {units} and {atom_style} commands. -The required arguments of kim_init are the {model} designation of the +The required arguments of {kim_init} are the {model} name of the IM to be used in the simulation (for an IM archived in OpenKIM this is its "extended KIM ID"_https://openkim.org/about-kim-ids/), and -the {user_units}, which are the LAMMPS "units"_units.html system used -in the input script. (Any numerical values in the input script and values -read in from files are expected to be in the {user_units} system.) +the {user_units}, which are the LAMMPS "units style"_units.html used +in the input script. (Any dimensioned numerical values in the input +script and values read in from files are expected to be in the +{user_units} system.) -Based on the selected model kim_init may modify "atom_style"_atom_style.html. +The selected IM can be either a "KIM Model or a KIM SM"_#IM_types. +For a KIM SM, the {kim_init} command verifies that the SM is designed +to work with LAMMPS (and not another simulation code). +In addition, the version strings for the LAMMPS version used for defining +the SM and the LAMMPS version being currently run are +printed, to help diagnose any incompatible changes to input script or +command syntax between the two LAMMPS versions. + +Based on the selected model {kim_init} may modify the +"atom_style"_atom_style.html. Some SMs have requirements for this variable. If this is the case, then -atom_style will be set to the required style. Otherwise, the value is left -unchanged (which in the absence of an atom_style command in the input script -is the default LAMMPS value). +{atom_style} will be set to the required style. Otherwise, the value is left +unchanged (which in the absence of an {atom_style} command in the input script +is the "default atom_style value"_atom_style.html). -Regarding units, the kim_init command behaves in different ways depending -on whether or not "unit conversion mode" is activated as indicated by the +Regarding units, the {kim_init} command behaves in different ways depending +on whether or not {unit conversion mode} is activated as indicated by the optional {unitarg} argument. -If unit conversion mode is {not} active, then {user_units} must +If unit conversion mode is [not] active, then {user_units} must either match the required units of the IM or the IM must be able to adjust its units to match. (The latter is only possible with some KIM Models; SMs can never adjust their units.) If a match is possible, the LAMMPS @@ -129,7 +149,8 @@ If unit conversion mode {is} active, then the LAMMPS "units"_units.html command is called to set the units to the IM's required or preferred units. Conversion factors between the IM's units and the {user_units} are defined for all "physical quantities"_units.html (mass, distance, etc.). -These factors are stored as internal "variables"_variable.html with +(Note that converting to or from the "lj" unit style is not supported.) +These factors are stored as "internal style variables"_variable.html with standard names: _u_mass @@ -168,11 +189,11 @@ variable Ec_in_J equal (pe/count(all))/$\{_u_energy\} print "Cohesive Energy = $\{Ec_in_J\} J" :pre Note the multiplication by $\{_u_distance\} and $\{_u_mass\} to convert -from SI units (specified in the kim_init command) to whatever units the +from SI units (specified in the {kim_init} command) to whatever units the IM uses (metal in this case), and the division by $\{_u_energy\} to convert from the IM's energy units to SI units (Joule). This script will work correctly for any IM for Al (KIM Model or SM) selected by the -kim_init command. +{kim_init} command. Care must be taken to apply unit conversion to dimensional variables read in from a file. For example if a configuration of atoms is read in from a @@ -185,30 +206,47 @@ NOTE: Unit conversion will only work if the conversion factors are placed in all appropriate places in the input script. It is up to the user to do this correctly. -OpenKIM IM Execution :h5 +OpenKIM IM Execution ({kim_interactions}) :h5 The second and final step in using an OpenKIM IM is to execute the -kim_interaction command. This command must be preceded by a kim_init -command and must follow the "create_box"_create_box.html command, +{kim_interaction} command. This command must be preceded by a {kim_init} +command and a "create_box"_create_box.html command, which defines the number of atom types {N}. -The kim_interaction command has one argument {typeargs}, which contains -a list of {N} chemical species that are mapped to the atom types. +The {kim_interaction} command has one argument {typeargs}. This argument +contains a list of {N} chemical species, which defines a mapping between +atom types in LAMMPS to the available species in the OpenKIM IM. -For example, imagine the OpenKIM IM supports Si and C species. -If the LAMMPS simulation has 4 atom types and you want the first three to be Si, -and the fourth to be C, you would use the following kim_interaction command: +For example, consider an OpenKIM IM that supports Si and C species. +If the LAMMPS simulation has four atom types, where the first three are Si, +and the fourth is C, the following {kim_interaction} command would be used: kim_interaction Si Si Si C :pre -The kim_interaction command performs all the necessary steps to set up -the OpenKIM IM set in the kim_init command. The specific actions depend +The {kim_interaction} command performs all the necessary steps to set up +the OpenKIM IM selected in the {kim_init} command. The specific actions depend on whether the IM is a KIM Model or a KIM SM. For a KIM Model, -a "pair_style kim"_pair_kim.html command will be executed followed by -the appropriate pair_coeff command. +a "pair_style kim"_pair_kim.html command is executed followed by +the appropriate {pair_coeff} command. For example, for the +Ercolessi and Adams (1994) KIM Model for Al set by the following commands: -For a KIM SM, the set of commands defined in the SM speficiation file -will be executed. For example, consider the ReaxFF SM due to -Strachan et al. (2003) executed by the following commands: +kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal +... +... box specification lines skipped +... +kim_interactions Al :pre + +the {kim_interactions} command executes the following LAMMPS input commands: + +pair_style kim EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 +pair_coeff * * Al :pre + +For a KIM SM, the generated input commands may be more complex +and require that LAMMPS is built with the required packages included +for the type of potential being used. The set of commands to be executed +is defined in the SM specification file, which is part of the SM package +on "OpenKIM"_https://openkim.org. +For example, for the Strachan et al. (2003) ReaxFF SM +set by the following commands: kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 real ... @@ -216,103 +254,125 @@ kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657 ... kim_interactions C H N O :pre -The kim_interactions command executes the following commands defined for this -SM: +the {kim_interactions} command executes the following LAMMPS input commands: pair_style reax/c lmp_control safezone 2.0 mincap 100 pair_coeff * * ffield.reax.rdx C H N O fix reaxqeq all qeq/reax 1 0.0 10.0 1.0e-6 param.qeq :pre -Note that the files lmp_control, ffield.reax.rdx and param.qeq are specific -to Strachan et al. (2003) ReaxFF parameterization and are archived as part -of the SM package in OpenKIM. Note also that parameters like cutoff radii -and charge tolerances that have an effect on IM predictions are also -included in the SM definition ensuring reproducibility. +Note that the files {lmp_control}, {ffield.reax.rdx} and {param.qeq} +are specific to the Strachan et al. (2003) ReaxFF parameterization +and are archived as part of the SM package in OpenKIM. +Note also that parameters like cutoff radii and charge tolerances, +which have an effect on IM predictions, are also included in the +SM definition ensuring reproducibility. -NOTE: Clearly when using using kim_init and kim_interactions to select +NOTE: When using using {kim_init} and {kim_interactions} to select and set up an OpenKIM IM, other LAMMPS commands for the same functions (such as pair_style, pair_coeff, bond_style, -bond_coeff, fixes related to charge equilibration, etc.) should not -appear in the input script. +bond_coeff, fixes related to charge equilibration, etc.) should normally +not appear in the input script. -Using OpenKIM Web Queries in LAMMPS :h4 +Using OpenKIM Web Queries in LAMMPS ({kim_query}) :h5 -@@@@@@@@@ +The {kim_query} command performs a web query to retrieve the predictions +of the IM set by {kim_init} for material properties archived in +"OpenKIM"_https://openkim.org. The {kim_query} command must be preceded +by a {kim_init} command. The result of the query is stored in a +"string style variable"_variable.html, the name of which is given as the first +argument of the {kim_query command}. The second required argument +{query_function} is the name of the query function to be called +(e.g. {get_lattice_constant_fcc}). +All following arguments are parameters handed over to the web query +in the format {keyword=value}. The list of supported keywords and +and the type and format of their values depend on the query function +used. -The kim_style command is a high-level wrapper around the -"Knowledge Base for Interatomic Models (OpenKIM)"_https://openkim.org -repository of interatomic potentials, so that they can be used by -LAMMPS scripts. It does not implement any computations directly, but -rather will generate LAMMPS input commands based on the information -retrieved from the OpenKIM repository. It is able to realize so-called -"KIM Simulator Models", which are OpenKIM repository entries of models -using native features of the simulation engine in use, i.e. LAMMPS -in this case, but it also supports realizing conventional KIM models -implicitly via generating a "pair_style kim"_pair_kim.html command -followed by a suitable "pair_coeff"_pair_coeff.html command. +NOTE: The current list of supported query functions is available on the OpenKIM +webpage at "https://query.openkim.org"_https://query.openkim.org/ -The kim_style command has two modes, {init} and {define}, indicated by -the first argument to the kim_style command. An {init} mode command -must be issued [before] the simulation box is created, while the {define} -mode version may only be used [after] the simulation box exists. Both -are required. The {init} mode version sets the model name and may issue -additional commands changing LAMMPS default settings that are required -for using a selected simulator model. If needed, those settings can be -overridden. The second argument to the {kim_style init} command is the -KIM model ID. +The data obtained by {kim_query} commands can be used as part of the setup +or analysis phases of LAMMPS simulations. Some examples are given below. -In both modes, the keywords {unit_variables} and {unit_from} may be -added. They control the values of a set of -"internal style variables"_variable.html that can be used to convert -between different unit styles in LAMMPS. The argument to -each keyword is a LAMMPS unit style or NULL, which means to look up -the unit style from what was set with the "units"_units.html command. -Please note, that KIM simulator models will set their preferred unit style. -By default all conversion variables are set to 1.0. Converting to or -from the "lj" unit style is not supported. The following variables are defined: +[Define a crystal at its equilibrium lattice constant] -_u_length -_u_mass -_u_time :ul +kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal +boundary p p p +kim_query a0 get_lattice_constant_fcc units=\["angstrom"\] +lattice fcc $\{a0\} +... :pre +The {kim_query} command retrieves from "OpenKIM"_https://openkim.org +the equilibrium lattice constant predicted by the Ercolessi and Adams (1994) +potential for the face-centered cubic (fcc) structure and places it in +variable {a0}. This variable is then used on the next line to set up the +crystal. By using {kim_query}, the user is saved the trouble and possible +error of tracking this value down, or of having to perform an energy +minimization to find the equilibrium lattice constant. -The {kim_style define} command will issue commands that will realize -the selected model (through generating pair_style and pair_coeff commands, -but also other commands, as required). It has to be issued [after] the -the simulation box is defined. The {kim_style define} command allows a -varying number of additional arguments. Those are used to map the atom -types in LAMMPS to the available species in the KIM model. This is -equivalent to the arguments following "pair_coeff * *" in a -"kim"_pair_kim.html pair style. Thus the commands: +[Define a crystal at finite temperature accounting for thermal expansion] -kim_style init LennardJones_Ar -kim_style define Ar :pre +kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal +boundary p p p +kim_query a0 get_lattice_constant_fcc units=\["angstrom"\] +kim_query alpha get_linear_thermal_expansion_fcc +variable DeltaT equal 300 +lattice fcc $\{a0\}*$\{alpha\}*$\{DeltaT\} +... :pre -will generate the LAMMPS input commands: +As in the previous example, the equilibrium lattice constant is obtained +for the Ercolessi and Adams (1994) potential. However, in this case the +crystal is scaled to the appropriate lattice constant at 300 K by using +the linear thermal expansion coefficient predicted by the potential. -pair_style kim LennardJones_Ar -pair_coeff * * Ar :pre +[Compute defect formation energy] + +kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal +... +... Build fcc crystal containing some defect and compute the total energy +... which is stored in the variable {Etot} +... +kim_query Ec get_cohesive_energy_fcc units=\["eV"\] +variable Eform equal $\{Etot\} - count(all)*$\{Ec\} +... :pre + +The defect formation energy {Eform} is computed by subtracting from {Etot} the +ideal fcc cohesive energy of the atoms in the system obtained from +"OpenKIM"_https://openkim.org for the Ercolessi and Adams (1994) potential. + +Citation of OpenKIM IMs :h4 + +When publishing results obtained using OpenKIM IMs researchers are requested +to cite the OpenKIM project "(Tadmor)"_#kim-mainpaper and KIM API +"(Elliott)"_#kim-api as well as the specific IM codes used in the simulations. +The citation format for an IM is displayed on its page on +"OpenKIM"_https://openkim.org along with the corresponding BibTex file. + +Citing the codes used in the simulation gives credit +to the researchers who developed them and enables open source efforts like +OpenKIM to function. -For simulator models, the generated input commands may be more complex -and require that LAMMPS is built with the required packages included. -The commands generated by the kim_style command, can be copied to the -screen or log file, through the "echo"_echo.html command. -The kim_style command will also validate, that a selected simulator -model was generated for the LAMMPS MD code and not some other software. -In addition, the version strings for LAMMPS version used for defining -the simulator model and the LAMMPS version being currently run are -printed, so that it can be tracked down, if there are any incompatible -changes to input script or command syntax between the two LAMMPS versions. [Restrictions:] -This command is part of the KIM package. It is only enabled if +The set of {kim_commands} is part of the KIM package. It is only enabled if LAMMPS was built with that package. Furthermore, its correct functioning depends on compiling LAMMPS with all required packages installed that are required by the commands embedded in any KIM -simulator models used. +SM used. See the "Build package"_Build_package.html doc page for more info. [Related commands:] -"pair_style kim"_pair_kim.html, "kim_query"_kim_query.html +"pair_style kim"_pair_kim.html + +:line + +:link(kim-mainpaper) +[(Tadmor)] Tadmor, Elliott, Sethna, Miller and Becker, JOM, 63, 17 (2011). +doi: "https://doi.org/10.1007/s11837-011-0102-6"_https://doi.org/10.1007/s11837-011-0102-6 + +:link(kim-api) +[(Elliott)] Elliott, Tadmor and Bernstein, "https://openkim.org/kim-api"_https://openkim.org/kim-api (2011) +doi: "https://doi.org/10.25950/FF8F563A"_https://doi.org/10.25950/FF8F563A + From a6f6c9bed0c804f039e83943cb9c22a1a66d1429 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 12:41:29 -0400 Subject: [PATCH 037/107] fix up links, spelling issues, and inconsistent names in kim commands docs --- doc/src/Build_extras.txt | 2 +- doc/src/Packages_details.txt | 14 ++++----- doc/src/kim_commands.txt | 34 +++++++++++---------- doc/src/pair_kim.txt | 4 +-- doc/utils/sphinx-config/false_positives.txt | 6 ++++ 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/doc/src/Build_extras.txt b/doc/src/Build_extras.txt index 17d18243f2..220e9420fc 100644 --- a/doc/src/Build_extras.txt +++ b/doc/src/Build_extras.txt @@ -173,7 +173,7 @@ KIM package :h4,link(kim) To build with this package, the KIM library with API v2 must be downloaded and built on your system. It must include the KIM models that you want to -use with LAMMPS. If you want to use the "kim_query"_kim_query.html +use with LAMMPS. If you want to use the "kim_query"_kim_commands.html command, you also need to have libcurl installed with the matching development headers and the curl-config tool. diff --git a/doc/src/Packages_details.txt b/doc/src/Packages_details.txt index 19c7e96fe9..d6e8f8639f 100644 --- a/doc/src/Packages_details.txt +++ b/doc/src/Packages_details.txt @@ -341,11 +341,11 @@ KIM package :link(PKG-KIM),h4 A "pair_style kim"_pair_kim.html command which is a wrapper on the Knowledge Base for Interatomic Models (KIM) repository of interatomic potentials, enabling any of them to be used in LAMMPS simulations. -Also a "kim_query"_kim_query.html command, which allows to query -the OpenKIM database for stored properties, and a -"kim_style"_kim_style.html command, which serves as a front end to -generating LAMMPS input on-the-fly for KIM simulator models and native -KIM models. +Also a "kim_query"_kim_commands.html command, which allows to query +the OpenKIM database for stored properties, and the commands +"kim_init and kim_interactions"_kim_commands.html, which serve as +front end to generating LAMMPS input on-the-fly for KIM simulator +models and native KIM models. To use this package you must have the KIM library available on your system. @@ -357,8 +357,8 @@ Elliott (U Minnesota). [Authors:] Ryan Elliott (U Minnesota) is the main developer for the KIM API which the "pair_style kim"_pair_kim.html command uses. He developed the pair style. Axel Kohlmeyer (Temple U) contributed the -"kim_query"_kim_query.html and "kim_style"_kim_style.html commands in -close collaboration with Ryan. +"kim_query"_kim_commands.html and "kim_init"_kim_commands.html commands +in close collaboration with Ryan. [Install:] diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 06ad841240..7377c0186c 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -30,7 +30,8 @@ kim_interactions Si kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 real kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 metal unit_conversion_mode kim_interactions C H O -kim_query NEED EXAMPLES :pre +kim_query latconst get_test_result test=TE_156715955670 model=MO_800509458712 & + prop=structure-cubic-crystal-npt species=\["Al"\] keys=\["a"\] units=\["angstrom"\] :pre [Description:] @@ -52,22 +53,22 @@ IMs in OpenKIM are exhaustively tested using "KIM Tests"_https://openkim.org/get Reproducibility :h5 Each IM in OpenKIM is issued a unique identifier ("KIM ID"_https://openkim.org/about-kim-ids/), which includes a version number (last three digits). Any changes that can result in different numerical values lead to a version increment in the KIM ID. This makes it possible to reproduce simulations since the specific version of a specific IM used can be retrieved using its KIM ID. -OpenKIM is a member organization of "DataCite"_https://datacite.org/ and issues digitial object identifiers (DOIs) to all IMs archived in OpenKIM. This makes it possible to cite the IM code used in a simulation in a publications to give credit to the developers and further facilitate reproducibility. :ul +OpenKIM is a member organization of "DataCite"_https://datacite.org/ and issues digital object identifiers (DOIs) to all IMs archived in OpenKIM. This makes it possible to cite the IM code used in a simulation in a publications to give credit to the developers and further facilitate reproducibility. :ul Convenience :h5 IMs in OpenKIM are distributed in binary form along with LAMMPS and can be used in a LAMMPS input script simply by providing their KIM ID in the {kim_init} command documented on this page. (For more on using KIM with LAMMPS, see the KIM section of the "Packages details"_Packages_details.html doc page.) The {kim_query} web query tool provides the ability to use the predictions of IMs for supported material properties (computed via "KIM Tests"https://openkim.org/getting-started/kim-tests/) as part of a LAMMPS input script setup and analysis. -Support is provided for unit conversion between the "units"_units.html system used in the LAMMPS input script and the OpenKIM IM. This makes it possible to use a single input script with IMs using different units without change and minimizes the liklihood of errors due to incompatible units. :ul +Support is provided for unit conversion between the "units"_units.html system used in the LAMMPS input script and the OpenKIM IM. This makes it possible to use a single input script with IMs using different units without change and minimizes the likelihood of errors due to incompatible units. :ul Types of KIM IMs :h4 There are two types of IMs archived in OpenKIM: -The first type is called a {KIM Model}. A KIM Model is an independent computer implemention of an IM written in one of the languages supported by KIM (C, C++, Fortran, Python), which conforms to the KIM Application Programming Interface ("KIM API"_https://openkim.org/kim-api/). A KIM Model will work seamlessly with any simulation code that support the KIM API (including LAMMPS; see "complete list of supported code"_https://openkim.org/projects-using-kim/). +The first type is called a {KIM Model}. A KIM Model is an independent computer implementation of an IM written in one of the languages supported by KIM (C, C++, Fortran, Python), which conforms to the KIM Application Programming Interface ("KIM API"_https://openkim.org/kim-api/). A KIM Model will work seamlessly with any simulation code that support the KIM API (including LAMMPS; see "complete list of supported code"_https://openkim.org/projects-using-kim/). The second type is called a {KIM Simulator Model} (SM). In this case, the IM is implemented natively within the simulation code ({simulator}), i.e. LAMMPS. A separate SM package is archived in OpenKIM for each parameterization of the IM, which includes all of the necessary parameter files, LAMMPS commands, and metadata (supported species, units, etc.) needed to run the IM in LAMMPS. :ol -With these two IM tpes, OpenKIM can archive and test almost all IMs that +With these two IM types, OpenKIM can archive and test almost all IMs that can be used by LAMMPS. (It is easy to contribute new IMs to OpenKIM, see the "upload instructions"_https://openkim.org/getting-started/adding-content/.) @@ -78,7 +79,7 @@ and supported species, separated by two underscores from the KIM ID itself, which begins with an IM code ({MO} for a KIM Model, and {SM} for a KIM Simulator Model) followed by a unique 12-digit code and a 3-digit version identifier. -By convension SM prefixes begin with {SM} to readily identify them. +By convention SM prefixes begin with {SM} to readily identify them. SW_StillingerWeber_1985_Si__MO_405512056662_005 Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 :pre @@ -89,7 +90,7 @@ in which case their designation does not have to conform to the KIM ID format. Using OpenKIM IMs with LAMMPS :h4 Two commands are employed when using OpenKIM IMs, one to select the -IM and perform necessary initializations ({kim_init}), and the second +IM and perform necessary initialization ({kim_init}), and the second to set up the IM for use by executing any necessary LAMMPS commands ({kim_interactions}). @@ -97,7 +98,7 @@ OpenKIM IM Initialization :h5 The kim_init command must be located at the top of the input script before any other commands. Input scripts containing a kim_init command -shoud {not} include a "units"_units.html command or an +should {not} include a "units"_units.html command or an "atom_style"_atom_style.html command. These are set by the kim_init command based on its arguments. @@ -188,25 +189,26 @@ correctly. OpenKIM IM Execution :h5 The second and final step in using an OpenKIM IM is to execute the -kim_interaction command. This command must be preceded by a kim_init +kim_interactions command. This command must be preceded by a kim_init command and must follow the "create_box"_create_box.html command, which defines the number of atom types {N}. -The kim_interaction command has one argument {typeargs}, which contains +The kim_interactions command has one argument {typeargs}, which contains a list of {N} chemical species that are mapped to the atom types. For example, imagine the OpenKIM IM supports Si and C species. If the LAMMPS simulation has 4 atom types and you want the first three to be Si, -and the fourth to be C, you would use the following kim_interaction command: +and the fourth to be C, you would use the following kim_interactions command: -kim_interaction Si Si Si C :pre +kim_interactions Si Si Si C +:pre -The kim_interaction command performs all the necessary steps to set up +The kim_interactions command performs all the necessary steps to set up the OpenKIM IM set in the kim_init command. The specific actions depend on whether the IM is a KIM Model or a KIM SM. For a KIM Model, a "pair_style kim"_pair_kim.html command will be executed followed by the appropriate pair_coeff command. -For a KIM SM, the set of commands defined in the SM speficiation file +For a KIM SM, the set of commands defined in the SM specification file will be executed. For example, consider the ReaxFF SM due to Strachan et al. (2003) executed by the following commands: @@ -306,7 +308,7 @@ changes to input script or command syntax between the two LAMMPS versions. [Restrictions:] -This command is part of the KIM package. It is only enabled if +These commands are part of the KIM package. It is only enabled if LAMMPS was built with that package. Furthermore, its correct functioning depends on compiling LAMMPS with all required packages installed that are required by the commands embedded in any KIM @@ -315,4 +317,4 @@ See the "Build package"_Build_package.html doc page for more info. [Related commands:] -"pair_style kim"_pair_kim.html, "kim_query"_kim_query.html +"pair_style kim"_pair_kim.html, "units"_units.html diff --git a/doc/src/pair_kim.txt b/doc/src/pair_kim.txt index 523bd89d7c..7e399b7ce0 100644 --- a/doc/src/pair_kim.txt +++ b/doc/src/pair_kim.txt @@ -112,7 +112,7 @@ kim-api package version 2.0.0 and higher. [Related commands:] -"pair_coeff"_pair_coeff.html, "kim_style"_kim_style.html, -"kim_query"_kim_query.html +"pair_coeff"_pair_coeff.html, "kim_init"_kim_commands.html, +"kim_interactions"_kim_commands, "kim_query"_kim_commands.html [Default:] none diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index a8bfa8f193..6a75f0555a 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -1606,6 +1606,7 @@ meso mesoparticle mesoscale mesoscopic +metadata metadynamics Metadynamics Methfessel @@ -2271,6 +2272,7 @@ rcutfac rdc rdf RDideal +rdx README realtime reamin @@ -2297,6 +2299,8 @@ Rensselaer reparameterizing repo representable +Reproducibility +reproducibility repuls rescale rescaled @@ -2585,6 +2589,7 @@ Stoll stopstep Stouch Straatsma +Strachan Stratford Strathclyde Straub @@ -2822,6 +2827,7 @@ undump uniaxial uniaxially unimodal +unitarg unitless Universite unix From c9cb6e3658e66f4cf9086e9ed50232e477f7ed3e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 13:12:23 -0400 Subject: [PATCH 038/107] remove obsolete files --- doc/src/kim_query.txt | 47 ------------------- doc/src/kim_style.txt | 107 ------------------------------------------ 2 files changed, 154 deletions(-) delete mode 100644 doc/src/kim_query.txt delete mode 100644 doc/src/kim_style.txt diff --git a/doc/src/kim_query.txt b/doc/src/kim_query.txt deleted file mode 100644 index 84eca6e676..0000000000 --- a/doc/src/kim_query.txt +++ /dev/null @@ -1,47 +0,0 @@ -"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c - -:link(lws,http://lammps.sandia.gov) -:link(ld,Manual.html) -:link(lc,Commands_all.html) - -:line - -kim_query command :h3 - -[Syntax:] - -kim_query variable query_function web_query_flags :pre - -variable = name of a (string style) variable where the result of the query is stored -query_function = name of the OpenKIM web API query function to be used -web_query_flags = a series of keyword=value pairs that represent the web query; supported keywords depend on query function :ul - -[Examples:] - -kim_query latconst get_test_result test=TE_156715955670 model=MO_800509458712 & - prop=structure-cubic-crystal-npt species=\["Al"\] keys=\["a"\] units=\["angstrom"\] :pre - -[Description:] - -The kim_query command allows to retrieve properties from the OpenKIM -through a web query. The result is stored in a string style -"variable"_variable.html, the name of which must be given as the first -argument of the kim_query command. The second required argument is the -name of the actual query function (e.g. {get_test_result}). All following -arguments are parameters handed over to the web query in the format -{keyword=value}. The list of supported keywords and the type of how -the value has to be encoded depends on the query function used. This -mirrors the functionality available on the OpenKIM webpage at -"https://query.openkim.org"_https://query.openkim.org/ - -[Restrictions:] - -This command is part of the KIM package. It is only enabled if -LAMMPS was built with that package. Furthermore, its correct -functioning depends on compiling LAMMPS with libcurl support. -See the "Build package"_Build_package.html doc page for more info. - -[Related commands:] - -"pair_style kim"_pair_kim.html, "kim_style"_kim_style.html, -"variable"_variable.html diff --git a/doc/src/kim_style.txt b/doc/src/kim_style.txt deleted file mode 100644 index c24cfe8581..0000000000 --- a/doc/src/kim_style.txt +++ /dev/null @@ -1,107 +0,0 @@ -"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c - -:link(lws,http://lammps.sandia.gov) -:link(ld,Manual.html) -:link(lc,Commands_all.html) - -:line - -kim_style command :h3 - -[Syntax:] - -kim_style mode args :pre - -mode = {init model} or {define typeargs} or no mode chosen -model = name of the KIM model (KIM potential or KIM simulator model) -typeargs = atom type to species mapping (one entry per atom type) -args = {unit_variables unit_style} or {unit_from unit_style} (optional):ul - -[Examples:] - -kim_style init ex_sim_model_Si_mod_tersoff unit_variables metal -kim_style define Si Si -kim_style unit_variables real -kim_style init LennardJones_Ar unit_variables metal -kim_style unit_variables real unit_from metal -kim_style define Ar :pre - -[Description:] - -The kim_style command is a high-level wrapper around the -"Knowledge Base for Interatomic Models (OpenKIM)"_https://openkim.org -repository of interatomic potentials, so that they can be used by -LAMMPS scripts. It does not implement any computations directly, but -rather will generate LAMMPS input commands based on the information -retrieved from the OpenKIM repository. It is able to realize so-called -"KIM Simulator Models", which are OpenKIM repository entries of models -using native features of the simulation engine in use, i.e. LAMMPS -in this case, but it also supports realizing conventional KIM models -implicitly via generating a "pair_style kim"_pair_kim.html command -followed by a suitable "pair_coeff"_pair_coeff.html command. - -The kim_style command has two modes, {init} and {define}, indicated by -the first argument to the kim_style command. An {init} mode command -must be issued [before] the simulation box is created, while the {define} -mode version may only be used [after] the simulation box exists. Both -are required. The {init} mode version sets the model name and may issue -additional commands changing LAMMPS default settings that are required -for using a selected simulator model. If needed, those settings can be -overridden. The second argument to the {kim_style init} command is the -KIM model ID. - -In both modes, the keywords {unit_variables} and {unit_from} may be -added. They control the values of a set of -"internal style variables"_variable.html that can be used to convert -between different unit styles in LAMMPS. The argument to -each keyword is a LAMMPS unit style or NULL, which means to look up -the unit style from what was set with the "units"_units.html command. -Please note, that KIM simulator models will set their preferred unit style. -By default all conversion variables are set to 1.0. Converting to or -from the "lj" unit style is not supported. The following variables are defined: - -_u_length -_u_mass -_u_time :ul - - -The {kim_style define} command will issue commands that will realize -the selected model (through generating pair_style and pair_coeff commands, -but also other commands, as required). It has to be issued [after] the -the simulation box is defined. The {kim_style define} command allows a -varying number of additional arguments. Those are used to map the atom -types in LAMMPS to the available species in the KIM model. This is -equivalent to the arguments following "pair_coeff * *" in a -"kim"_pair_kim.html pair style. Thus the commands: - -kim_style init LennardJones_Ar -kim_style define Ar :pre - -will generate the LAMMPS input commands: - -pair_style kim LennardJones_Ar -pair_coeff * * Ar :pre - -For simulator models, the generated input commands may be more complex -and require that LAMMPS is built with the required packages included. -The commands generated by the kim_style command, can be copied to the -screen or log file, through the "echo"_echo.html command. -The kim_style command will also validate, that a selected simulator -model was generated for the LAMMPS MD code and not some other software. -In addition, the version strings for LAMMPS version used for defining -the simulator model and the LAMMPS version being currently run are -printed, so that it can be tracked down, if there are any incompatible -changes to input script or command syntax between the two LAMMPS versions. - -[Restrictions:] - -This command is part of the KIM package. It is only enabled if -LAMMPS was built with that package. Furthermore, its correct -functioning depends on compiling LAMMPS with all required packages -installed that are required by the commands embedded in any KIM -simulator models used. -See the "Build package"_Build_package.html doc page for more info. - -[Related commands:] - -"pair_style kim"_pair_kim.html, "kim_query"_kim_query.html From ac82aa754b583886e193471bc042635c9c82955c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 13:13:05 -0400 Subject: [PATCH 039/107] correct off-by-one error and simplify code by using std::string instead of std::stringstream --- src/KIM/kim_init.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 695db0aa0d..6339f7397e 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -246,7 +246,7 @@ void KimInit::determine_model_type_and_units(char * model_name, if (*sim_field == "units") { kim_SM->GetSimulatorFieldLine(i,0,&sim_value); - int len=(*sim_value).length(); + int len=(*sim_value).length()+1; *model_units = new char[len]; strcpy(*model_units,sim_value->c_str()); break; } @@ -414,15 +414,16 @@ void KimInit::do_variables(char *user_units, char *model_units) (char *)"density"}; if (comm->me == 0) { - std::stringstream mesg; - mesg << "# Conversion factors from " << from << " to " << to - << ":" << std::endl; - if (screen) fputs(mesg.str().c_str(),screen); - if (logfile) fputs(mesg.str().c_str(),logfile); + std::string mesg("# Conversion factors from "); + mesg += from; + mesg += " to "; + mesg += to; + mesg += ":\n"; + if (screen) fputs(mesg.c_str(),screen); + if (logfile) fputs(mesg.c_str(),logfile); } - for (int i = 0; i < nunits; i++) - { + for (int i = 0; i < nunits; i++) { var_str = std::string("_u_") + std::string(units[i]); args[0] = (char *)var_str.c_str(); v_unit = variable->find(args[0]); From c557c7492b4ce0ab90ca80e2ba6c100b9a83c825 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 13:31:12 -0400 Subject: [PATCH 040/107] adapt names of stored properties to code that uses fix STORE/KIM --- src/KIM/fix_store_kim.cpp | 43 ++++++++++++++++++--------------------- src/KIM/fix_store_kim.h | 4 ++-- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/KIM/fix_store_kim.cpp b/src/KIM/fix_store_kim.cpp index 6423a57e18..8209a6d13e 100644 --- a/src/KIM/fix_store_kim.cpp +++ b/src/KIM/fix_store_kim.cpp @@ -66,7 +66,7 @@ using namespace FixConst; FixStoreKIM::FixStoreKIM(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), simulator_model(NULL), model_name(NULL), - units_from(NULL), units_to(NULL) + model_units(NULL), user_units(NULL) { if (narg != 3) error->all(FLERR,"Illegal fix STORE/KIM command"); } @@ -89,16 +89,15 @@ FixStoreKIM::~FixStoreKIM() model_name = NULL; } - if (units_from) { - char *uf = (char *)units_from; - delete[] uf; - units_from = NULL; + if (model_units) { + char *mu = (char *)model_units; + delete[] mu; + model_units = NULL; } - - if (units_to) { - char *ut = (char *)units_to; - delete[] ut; - units_to = NULL; + if (user_units) { + char *uu = (char *)user_units; + delete[] uu; + user_units = NULL; } } @@ -127,19 +126,17 @@ void FixStoreKIM::setptr(const char *name, void *ptr) delete[] mn; } model_name = ptr; - } else if (strcmp(name,"units_from") == 0) { - if (units_from) { - char *uf = (char *)units_from; - delete[] uf; + } else if (strcmp(name,"model_units") == 0) { + if (model_units) { + char *mu = (char *)model_units; + delete[] mu; } - units_from = ptr; - } else if (strcmp(name,"units_to") == 0) { - if (units_to) { - char *ut = (char *)units_to; - delete[] ut; + } else if (strcmp(name,"user_units") == 0) { + if (user_units) { + char *uu = (char *)user_units; + delete[] uu; } - units_to = ptr; - } + } else error->all(FLERR,"Unknown property in fix STORE/KIM"); } /* ---------------------------------------------------------------------- */ @@ -148,7 +145,7 @@ void *FixStoreKIM::getptr(const char *name) { if (strcmp(name,"simulator_model") == 0) return simulator_model; else if (strcmp(name,"model_name") == 0) return model_name; - else if (strcmp(name,"units_from") == 0) return units_from; - else if (strcmp(name,"units_to") == 0) return units_to; + else if (strcmp(name,"model_units") == 0) return model_units; + else if (strcmp(name,"user_units") == 0) return user_units; else return NULL; } diff --git a/src/KIM/fix_store_kim.h b/src/KIM/fix_store_kim.h index 5bca2a3dd0..655be83ad0 100644 --- a/src/KIM/fix_store_kim.h +++ b/src/KIM/fix_store_kim.h @@ -80,8 +80,8 @@ class FixStoreKIM : public Fix { private: void *simulator_model; // pointer to KIM simulator model class void *model_name; // string of KIM model name - void *units_from; // string of unit conversion origin or NULL - void *units_to; // string of unit conversion target or NULL + void *model_units; // string of unit conversion origin or NULL + void *user_units; // string of unit conversion target or NULL }; } From 065638edba999ab91b078e089b807d58c205b6ae Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 13:31:43 -0400 Subject: [PATCH 041/107] remove unused macro and reformat to closer match LAMMPS programming style --- src/KIM/kim_init.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 6339f7397e..0d8849c51c 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -79,10 +79,6 @@ extern "C" { #include "KIM_SimulatorModel.hpp" //@@@@@ -#define SNUM(x) \ - static_cast(std::ostringstream() \ - << std::dec << x).str() - using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ @@ -187,14 +183,11 @@ void KimInit::determine_model_type_and_units(char * model_name, model_type = MO; KIM_Model_Destroy(&kim_MO); - if (units_accepted) - { + if (units_accepted) { int len=strlen(user_units); *model_units = new char[len]; strcpy(*model_units,user_units); return; - } - else if (unit_conversion_mode) - { + } else if (unit_conversion_mode) { int const num_systems = 5; char const * const systems[num_systems] = {"metal", "real", "si", "cgs", "electron"}; From 27d1f79fe37e5ba2153590731092997d0bdf9890 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 13:39:12 -0400 Subject: [PATCH 042/107] simplify another case of stringstream to use plain std::string --- src/KIM/kim_init.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 0d8849c51c..1ca55d7adc 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -246,12 +246,11 @@ void KimInit::determine_model_type_and_units(char * model_name, } KIM::SimulatorModel::Destroy(&kim_SM); - if ((! unit_conversion_mode) && (strcmp(*model_units, user_units)!=0)) - { - std::stringstream mesg; - mesg << "Incompatible units for KIM Simulator Model, required units = " - << *model_units; - error->all(FLERR,mesg.str().c_str()); + if ((! unit_conversion_mode) && (strcmp(*model_units, user_units)!=0)) { + std::string mesg("Incompatible units for KIM Simulator Model, " + "required units = "); + mesg += *model_units; + error->all(FLERR,mesg.c_str()); } } From c6d0f807b569bdf6ab6e9ed0665ca81d80f1d3d5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 14:13:24 -0400 Subject: [PATCH 043/107] output messages that would otherwise only show up in logs only when logs are enable for screen or logfile --- src/KIM/kim_init.cpp | 16 ++++++++-------- src/KIM/kim_interactions.cpp | 4 ++-- src/input.h | 6 ++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 1ca55d7adc..ce1b944792 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -363,8 +363,8 @@ void KimInit::kim_init_log_delimiter(std::string const begin_end) const mesg = "#=== END kim-init ============================================\n\n"; - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); + if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen); + if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile); } } @@ -411,8 +411,8 @@ void KimInit::do_variables(char *user_units, char *model_units) mesg += " to "; mesg += to; mesg += ":\n"; - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); + if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen); + if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile); } for (int i = 0; i < nunits; i++) { @@ -441,12 +441,12 @@ void KimInit::do_variables(char *user_units, char *model_units) << " internal " << std::setprecision(12) << std::scientific << conversion_factor << std::endl; - if (screen) fputs(mesg.str().c_str(),screen); - if (logfile) fputs(mesg.str().c_str(),logfile); + if ((screen) && (input->echo_screen)) fputs(mesg.str().c_str(),screen); + if ((logfile) && (input->echo_log)) fputs(mesg.str().c_str(),logfile); } } if (comm->me == 0) { - if (screen) fputs("#\n",screen); - if (logfile) fputs("#\n",logfile); + if ((screen) && (input->echo_screen)) fputs("#\n",screen); + if ((logfile) && (input->echo_log)) fputs("#\n",logfile); } } diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index 491d406ae6..4771272ff8 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -109,8 +109,8 @@ void KimInteractions::kim_interactions_log_delimiter( mesg = "#=== END kim_interactions ====================================\n\n"; - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); + if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen); + if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile); } } diff --git a/src/input.h b/src/input.h index 47ad7779f1..ebd015619c 100644 --- a/src/input.h +++ b/src/input.h @@ -25,6 +25,8 @@ class Input : protected Pointers { friend class Info; friend class Error; friend class Deprecated; + friend class KimInit; + friend class KimInteractions; public: int narg; // # of command args @@ -42,14 +44,14 @@ class Input : protected Pointers { protected: char *command; // ptr to current command + int echo_screen; // 0 = no, 1 = yes + int echo_log; // 0 = no, 1 = yes private: int me; // proc ID int maxarg; // max # of args in arg char *line,*copy,*work; // input line & copy and work string int maxline,maxcopy,maxwork; // max lengths of char strings - int echo_screen; // 0 = no, 1 = yes - int echo_log; // 0 = no, 1 = yes int nfile,maxfile; // current # and max # of open input files int label_active; // 0 = no label, 1 = looking for label char *labelstr; // label string being looked for From 493269431c354d5177a10acaec2b94c3aed18b67 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 14:16:38 -0400 Subject: [PATCH 044/107] add a few more false positives --- doc/utils/sphinx-config/false_positives.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 6a75f0555a..5ea7388cd6 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -570,6 +570,7 @@ Dihedrals dihydride Dij dimdim +dimensioned dimensionality dimgray dipolar @@ -599,6 +600,7 @@ Dobson Dodds dodgerblue dof +doi Donadio dotc Doty @@ -749,6 +751,7 @@ equilibrating equilibration Equilibria equilization +Ercolessi eradius erate erc @@ -2243,6 +2246,7 @@ quati quatj quatk quatw +queryargs Queteschiner qw qx From b2ba0550d70d6829fa3b2b40a86025e2faf95a2e Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Sun, 23 Jun 2019 13:18:57 -0500 Subject: [PATCH 045/107] Some minor typo fixes in kim_commands.txt --- doc/src/kim_commands.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 2e94271763..e51aec5dc7 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -71,7 +71,7 @@ Types of KIM IMs :h4 There are two types of IMs archived in OpenKIM: -The first type is called a {KIM Model}. A KIM Model is an independent computer implementation of an IM written in one of the languages supported by KIM (C, C++, Fortran, Python), which conforms to the KIM Application Programming Interface ("KIM API"_https://openkim.org/kim-api/). A KIM Model will work seamlessly with any simulation code that support the KIM API (including LAMMPS; see "complete list of supported code"_https://openkim.org/projects-using-kim/). +The first type is called a {KIM Model}. A KIM Model is an independent computer implementation of an IM written in one of the languages supported by KIM (C, C++, Fortran), which conforms to the KIM Application Programming Interface ("KIM API"_https://openkim.org/kim-api/). A KIM Model will work seamlessly with any simulation code that supports the KIM API (including LAMMPS; see "complete list of supported code"_https://openkim.org/projects-using-kim/). The second type is called a {KIM Simulator Model} (SM). In this case, the IM is implemented natively within the simulation code ({simulator}), i.e. LAMMPS. A separate SM package is archived in OpenKIM for each parameterization of the IM, which includes all of the necessary parameter files, LAMMPS commands, and metadata (supported species, units, etc.) needed to run the IM in LAMMPS. :ol With these two IM types, OpenKIM can archive and test almost all IMs that @@ -212,13 +212,13 @@ The second and final step in using an OpenKIM IM is to execute the {kim_interactions} command. This command must be preceded by a {kim_init} command and a "create_box"_create_box.html command, which defines the number of atom types {N}. -The {kim_interaction} command has one argument {typeargs}. This argument +The {kim_interactions} command has one argument {typeargs}. This argument contains a list of {N} chemical species, which defines a mapping between atom types in LAMMPS to the available species in the OpenKIM IM. For example, consider an OpenKIM IM that supports Si and C species. If the LAMMPS simulation has four atom types, where the first three are Si, -and the fourth is C, the following {kim_interaction} command would be used: +and the fourth is C, the following {kim_interactions} command would be used: kim_interactions Si Si Si C :pre @@ -376,4 +376,3 @@ doi: "https://doi.org/10.1007/s11837-011-0102-6"_https://doi.org/10.1007/s11837- :link(kim-api) [(Elliott)] Elliott, Tadmor and Bernstein, "https://openkim.org/kim-api"_https://openkim.org/kim-api (2011) doi: "https://doi.org/10.25950/FF8F563A"_https://doi.org/10.25950/FF8F563A - From e42e1e64a894e7b52c3c75a8b830918819cfdafa Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Sun, 23 Jun 2019 14:50:52 -0500 Subject: [PATCH 046/107] Added explanation on Model and SM pages --- doc/src/kim_commands.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index e51aec5dc7..5a50a76879 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -90,6 +90,24 @@ By convention SM prefixes begin with {Sim_} to readily identify them. SW_StillingerWeber_1985_Si__MO_405512056662_005 Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 :pre +Each OpenKIM IM has a dedicated page on "OpenKIM"_https://openkim.org +providing all the information on the IM including a title, description, +authorship and citation information, test and verification check results, +visualizations of results, a wiki with documentation and user comments, and +access to raw files, and other information. +This is referred to as the "Model Page" or "SM Page". +The URL for such a page is constructed from the +"extended KIM ID"_https://openkim.org/about-kim-ids/ of the IM: + +https://openkim.org/id/extended_KIM_ID +:pre + +For example for the Stillinger-Weber potential +listed above the Model Page is located at: + +"https://openkim.org/id/SW_StillingerWeber_1985_Si__MO_405512056662_005"_https://openkim.org/id/SW_StillingerWeber_1985_Si__MO_405512056662_005 +:pre + NOTE: It is also possible to locally install IMs not archived in OpenKIM, in which case their names do not have to conform to the KIM ID format. From 36649f0534d3b20211953c1dbecedc33e7dd3857 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 16:47:12 -0400 Subject: [PATCH 047/107] add workaround for handline include files --- src/input.cpp | 7 +++++++ src/input.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/input.cpp b/src/input.cpp index f88c8ca0c0..dd445b10f3 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -77,6 +77,7 @@ Input::Input(LAMMPS *lmp, int argc, char **argv) : Pointers(lmp) echo_screen = 0; echo_log = 1; + eof_return = 0; label_active = 0; labelstr = NULL; @@ -205,6 +206,7 @@ void Input::file() MPI_Bcast(&n,1,MPI_INT,0,world); if (n == 0) { if (label_active) error->all(FLERR,"Label wasn't found in input script"); + if (eof_return) break; if (me == 0) { if (infile != stdin) { fclose(infile); @@ -1051,6 +1053,11 @@ void Input::include() error->one(FLERR,str); } infiles[nfile++] = infile; + eof_return = 1; + file(); + eof_return = 0; + nfile--; + infile = infiles[nfile-1]; } } diff --git a/src/input.h b/src/input.h index ebd015619c..7fb125ffb5 100644 --- a/src/input.h +++ b/src/input.h @@ -46,6 +46,7 @@ class Input : protected Pointers { char *command; // ptr to current command int echo_screen; // 0 = no, 1 = yes int echo_log; // 0 = no, 1 = yes + int eof_return; // if 1: at EOF return from parsing in file() private: int me; // proc ID From bfe6cc29e81b84c6dada9bc9cbd942b3d0a21c93 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 17:52:43 -0400 Subject: [PATCH 048/107] fix bug of not storing pointers --- src/KIM/fix_store_kim.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/KIM/fix_store_kim.cpp b/src/KIM/fix_store_kim.cpp index 8209a6d13e..c9a99acca9 100644 --- a/src/KIM/fix_store_kim.cpp +++ b/src/KIM/fix_store_kim.cpp @@ -131,11 +131,13 @@ void FixStoreKIM::setptr(const char *name, void *ptr) char *mu = (char *)model_units; delete[] mu; } + model_units = ptr; } else if (strcmp(name,"user_units") == 0) { if (user_units) { char *uu = (char *)user_units; delete[] uu; } + user_units = ptr; } else error->all(FLERR,"Unknown property in fix STORE/KIM"); } From 6d54cf6a07d38d97be5157d4977ea831c10d9f48 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 17:53:12 -0400 Subject: [PATCH 049/107] programming style changes --- src/KIM/kim_init.cpp | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index ce1b944792..080e3dac3f 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -90,10 +90,10 @@ void KimInit::command(int narg, char **arg) if (domain->box_exist) error->all(FLERR,"Must use 'kim_init' command before " "simulation box is defined"); - int len0 = strlen(arg[0])+1; - int len1 = strlen(arg[1])+1; - char *model_name = new char[len0]; strcpy(model_name,arg[0]); - char *user_units = new char[len1]; strcpy(user_units,arg[1]); + char *model_name = new char[strlen(arg[0])+1]; + strcpy(model_name,arg[0]); + char *user_units = new char[strlen(arg[1])+1]; + strcpy(user_units,arg[1]); if (narg == 3) { if (strcmp(arg[2],"unit_conversion_mode")==0) unit_conversion_mode = true; else { error->all(FLERR,"Illegal kim_init command"); } @@ -178,21 +178,19 @@ void KimInit::determine_model_type_and_units(char * model_name, &units_accepted, &kim_MO); - if (!kim_error) // model is an MO - { + if (!kim_error) { // model is an MO model_type = MO; KIM_Model_Destroy(&kim_MO); if (units_accepted) { - int len=strlen(user_units); - *model_units = new char[len]; strcpy(*model_units,user_units); + *model_units = new char[strlen(user_units)+1]; + strcpy(*model_units,user_units); return; } else if (unit_conversion_mode) { int const num_systems = 5; char const * const systems[num_systems] = {"metal", "real", "si", "cgs", "electron"}; - for (int i=0; i < num_systems; ++i) - { + for (int i=0; i < num_systems; ++i) { get_kim_unit_names(systems[i], lengthUnit, energyUnit, chargeUnit, temperatureUnit, timeUnit, error); kim_error = KIM_Model_Create(KIM_NUMBERING_zeroBased, @@ -205,17 +203,13 @@ void KimInit::determine_model_type_and_units(char * model_name, &units_accepted, &kim_MO); KIM_Model_Destroy(&kim_MO); - if (units_accepted) - { - int len=strlen(systems[i]); - *model_units = new char[len]; strcpy(*model_units,systems[i]); + if (units_accepted) { + *model_units = new char[strlen(systems[i])+1]; + strcpy(*model_units,systems[i]); return; } - } - error->all(FLERR,"KIM Model does not support any lammps unit system"); - } - else - { + } error->all(FLERR,"KIM Model does not support any lammps unit system"); + } else { error->all(FLERR,"KIM Model does not support the requested unit system"); } } @@ -223,9 +217,7 @@ void KimInit::determine_model_type_and_units(char * model_name, KIM::SimulatorModel * kim_SM; kim_error = KIM::SimulatorModel::Create(model_name, &kim_SM); if (kim_error) - { error->all(FLERR,"KIM model name not found"); - } model_type = SM; int sim_fields; @@ -257,7 +249,7 @@ void KimInit::determine_model_type_and_units(char * model_name, /* ---------------------------------------------------------------------- */ -void KimInit::do_init(char *model_name, char *user_units, char* model_units) +void KimInit::do_init(char *model_name, char *user_units, char *model_units) { // create storage proxy fix. delete existing fix, if needed. @@ -322,8 +314,7 @@ void KimInit::do_init(char *model_name, char *user_units, char* model_units) cmd += model_units; input->one(cmd.c_str()); - if (model_type == SM) - { + if (model_type == SM) { int sim_fields, sim_lines; const std::string *sim_field, *sim_value; simulatorModel->GetNumberOfSimulatorFields(&sim_fields); From d10fdda6765c6cbe905509bf3eae7888cadb00ad Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 17:53:52 -0400 Subject: [PATCH 050/107] simplify nested include file handling --- src/input.cpp | 17 ++--------------- src/input.h | 1 - 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index dd445b10f3..268be5b774 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -77,7 +77,6 @@ Input::Input(LAMMPS *lmp, int argc, char **argv) : Pointers(lmp) echo_screen = 0; echo_log = 1; - eof_return = 0; label_active = 0; labelstr = NULL; @@ -206,18 +205,7 @@ void Input::file() MPI_Bcast(&n,1,MPI_INT,0,world); if (n == 0) { if (label_active) error->all(FLERR,"Label wasn't found in input script"); - if (eof_return) break; - if (me == 0) { - if (infile != stdin) { - fclose(infile); - infile = NULL; - } - nfile--; - } - MPI_Bcast(&nfile,1,MPI_INT,0,world); - if (nfile == 0) break; - if (me == 0) infile = infiles[nfile-1]; - continue; + break; } if (n > maxline) reallocate(line,maxline,n); @@ -1053,9 +1041,8 @@ void Input::include() error->one(FLERR,str); } infiles[nfile++] = infile; - eof_return = 1; file(); - eof_return = 0; + fclose(infile); nfile--; infile = infiles[nfile-1]; } diff --git a/src/input.h b/src/input.h index 7fb125ffb5..ebd015619c 100644 --- a/src/input.h +++ b/src/input.h @@ -46,7 +46,6 @@ class Input : protected Pointers { char *command; // ptr to current command int echo_screen; // 0 = no, 1 = yes int echo_log; // 0 = no, 1 = yes - int eof_return; // if 1: at EOF return from parsing in file() private: int me; // proc ID From b5d4cf4bfdff3b33a76198bcdb070798bbe908ab Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Sun, 23 Jun 2019 17:23:21 -0500 Subject: [PATCH 051/107] Updated KIM package information --- doc/src/Packages_details.txt | 49 ++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/doc/src/Packages_details.txt b/doc/src/Packages_details.txt index d6e8f8639f..bf71e058f5 100644 --- a/doc/src/Packages_details.txt +++ b/doc/src/Packages_details.txt @@ -338,27 +338,37 @@ KIM package :link(PKG-KIM),h4 [Contents:] -A "pair_style kim"_pair_kim.html command which is a wrapper on the -Knowledge Base for Interatomic Models (KIM) repository of interatomic -potentials, enabling any of them to be used in LAMMPS simulations. -Also a "kim_query"_kim_commands.html command, which allows to query -the OpenKIM database for stored properties, and the commands -"kim_init and kim_interactions"_kim_commands.html, which serve as -front end to generating LAMMPS input on-the-fly for KIM simulator -models and native KIM models. +This package contains a set of commands that serve as a wrapper on the +"Open Knowledgebase of Interatomic Models (OpenKIM)"_https://openkim.org +repository of interatomic models (IMs) +enabling compatible ones to be used in LAMMPS simulations. +This includes "kim_init and kim_interactions"_kim_commands.html +commands to select, initialize and instantiate the IM, and a +"kim_query"_kim_commands.html command to perform web queries +for material property predictions of OpenKIM IMs. +Support for KIM IMs that conform to the +"KIM Application Programming Interface (API)"_https://openkim.org/kim-api/ +is provided by the "pair_style kim"_pair_kim.html command. -To use this package you must have the KIM library available on your -system. +NOTE: The command {pair_style kim} is called by {kim_interactions} and +is not recommended to be directly used in input scripts. + +To use this package you must have the KIM API library available on your +system. The KIM API is available for download on the +"OpenKIM website"_https://openkim.org/kim-api/. +When installing LAMMPS from binary, the kim-api package +is a dependency that is automatically downloaded and installed. Information about the KIM project can be found at its website: -https://openkim.org. The KIM project is led by Ellad Tadmor and Ryan -Elliott (U Minnesota). +"https://openkim.org"_https://openkim.org. +The KIM project is led by Ellad Tadmor and Ryan Elliott (U Minnesota) +and is funded by the "National Science Foundation"_https://www.nsf.gov/. [Authors:] Ryan Elliott (U Minnesota) is the main developer for the KIM -API which the "pair_style kim"_pair_kim.html command uses. He developed -the pair style. Axel Kohlmeyer (Temple U) contributed the -"kim_query"_kim_commands.html and "kim_init"_kim_commands.html commands -in close collaboration with Ryan. +API and the {pair_style kim} command. Axel Kohlmeyer (Temple U) and +Ellad Tadmor (U Minnesota) contributed to the "kim_commands"_kim_commands.html +interface in close collaboration with Ryan Elliott. + [Install:] @@ -368,10 +378,11 @@ extras"_Build_extras.html doc page. [Supporting info:] +"kim_commands"_kim_commands.html +"pair_style kim"_pair_kim.html src/KIM: filenames -> commands src/KIM/README lib/kim/README -"pair_style kim"_pair_kim.html examples/kim :ul :line @@ -987,9 +998,9 @@ USER-ADIOS package :link(PKG-USER-ADIOS),h4 [Contents:] -ADIOS is a high-performance I/O library. This package implements the +ADIOS is a high-performance I/O library. This package implements the dump "atom/adios" and dump "custom/adios" commands to write data using -the ADIOS library. +the ADIOS library. [Authors:] Norbert Podhorszki (ORNL) from the ADIOS developer team. From 881f9ff04337c6e743f2fa9a7e0b71af28e85107 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Sun, 23 Jun 2019 17:36:10 -0500 Subject: [PATCH 052/107] Updated the pair_kim docs --- doc/src/pair_kim.txt | 83 ++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 45 deletions(-) diff --git a/doc/src/pair_kim.txt b/doc/src/pair_kim.txt index 7e399b7ce0..86d13808b0 100644 --- a/doc/src/pair_kim.txt +++ b/doc/src/pair_kim.txt @@ -12,76 +12,71 @@ pair_style kim command :h3 pair_style kim model :pre -model = name of KIM model (potential) +model = name of a KIM model (the KIM ID for models archived in OpenKIM) [Examples:] -pair_style kim ex_model_Ar_P_LJ -pair_coeff * * Ar Ar :pre +pair_style kim SW_StillingerWeber_1985_Si__MO_405512056662_005 +pair_coeff * * Si :pre [Description:] -This pair style is a wrapper on the "Knowledge Base for Interatomic +This pair style is a wrapper on the "Open Knowledgebase of Interatomic Models (OpenKIM)"_https://openkim.org repository of interatomic -potentials, so that they can be used by LAMMPS scripts. +potentials to enable their use in LAMMPS scripts. -Note that in LAMMPS lingo, a KIM model driver is a pair style -(e.g. EAM or Tersoff). A KIM model is a pair style for a particular -element or alloy and set of parameters, e.g. EAM for Cu with a -specific EAM potential file. +The preferred interface for using interatomic models archived in +OpenKIM is the "kim_commands interface"_kim_commands.html. That +interface supports both "KIM Models" that conform to the KIM API +and can be used by any KIM-compliant simulation code, and +"KIM Simulator Models" that are natively implemented within a single +simulation code (like LAMMPS) and can only be used with it. +The {pair_style kim} command is limited to KIM Models. It is +used by the "kim_commands interface"_kim_commands.html as needed. -See the current list of "KIM model -drivers"_https://openkim.org/browse/model-drivers/alphabetical. +NOTE: Since {pair_style kim} is called by {kim_interactions} as needed, +is not recommended to be directly used in input scripts. -See the current list of all "KIM -models"_https://openkim.org/browse/models/by-model-drivers - -To use this pair style, you must first download and install the KIM -API library from the "OpenKIM website"_https://openkim.org. The KIM -section of the "Packages details"_Packages_details.html doc page has -instructions on how to do this with a simple make command, when -building LAMMPS. - -See the examples/kim dir for an input script that uses a KIM model -(potential) for Lennard-Jones. - :line The argument {model} is the name of the KIM model for a specific -potential as KIM defines it. In principle, LAMMPS can invoke any KIM -model. You should get an error or warning message from either LAMMPS -or KIM if there is an incompatibility. +potential as KIM defines it. For potentials archived in OpenKIM +this is the extended KIM ID (see "kim_commands"_kim_commands.html +for details). LAMMPS can invoke any KIM Model, however there can +be incompatibilities (for example unit matching issues). +In the event of an incompatibility, the code will terminate with +an error message. Check both the LAMMPS and KIM log files for details. -Only a single pair_coeff command is used with the {kim} style which -specifies the mapping of LAMMPS atom types to KIM elements. This is -done by specifying N additional arguments after the * * in the -pair_coeff command, where N is the number of LAMMPS atom types: +Only a single {pair_coeff} command is used with the {kim} style, which +specifies the mapping of LAMMPS atom types to the species supported by +the KIM Model. This is done by specifying {N} additional arguments +after the * * in the {pair_coeff} command, where {N} is the number of +LAMMPS atom types: N element names = mapping of KIM elements to atom types :ul -As an example, imagine the KIM model supports Si and C atoms. If your -LAMMPS simulation has 4 atom types and you want the 1st 3 to be Si, -and the 4th to be C, you would use the following pair_coeff command: +For example, consider a KIM Model that supports Si and C species. +If the LAMMPS simulation has four atom types, where the first three are Si, +and the fourth is C, the following {pair_coeff} command would be used: pair_coeff * * Si Si Si C :pre -The 1st 2 arguments must be * * so as to span all LAMMPS atom types. -The first three Si arguments map LAMMPS atom types 1,2,3 to Si as -defined within KIM. The final C argument maps LAMMPS atom type 4 to C -as defined within KIM. +The first two arguments must be * * so as to span all LAMMPS atom types. +The first three Si arguments map LAMMPS atom types 1, 2, and 3 to Si as +defined within KIM Model. The final C argument maps LAMMPS atom type 4 to C. :line In addition to the usual LAMMPS error messages, the KIM library itself may generate errors, which should be printed to the screen. In this -case it is also useful to check the kim.log file for additional error +case it is also useful to check the {kim.log} file for additional error information. The file kim.log should be generated in the same directory where LAMMPS is running. To download, build, and install the KIM library on your system, see -the lib/kim/README file. Once you have done this and built LAMMPS +the {lib/kim/README} file. Once you have done this and built LAMMPS with the KIM package installed you can run the example input scripts -in examples/kim. +in {examples/kim}. :line @@ -103,16 +98,14 @@ This pair style can only be used via the {pair} keyword of the [Restrictions:] -This pair style is part of the KIM package. It is only enabled if -LAMMPS was built with that package. See the "Build -package"_Build_package.html doc page for more info. +This pair style is part of the KIM package. See details on +restrictions in "kim_commands"_kim_commands.html. This current version of pair_style kim is compatible with the kim-api package version 2.0.0 and higher. [Related commands:] -"pair_coeff"_pair_coeff.html, "kim_init"_kim_commands.html, -"kim_interactions"_kim_commands, "kim_query"_kim_commands.html +"pair_coeff"_pair_coeff.html, "kim_commands"_kim_commands.html [Default:] none From 94e1f87cb81ecd3b6f0d89e457ab94ae82f2641b Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Sun, 23 Jun 2019 17:36:36 -0500 Subject: [PATCH 053/107] Moved some content from pair_kim docs to kim_commands --- doc/src/kim_commands.txt | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 5a50a76879..99ed068c44 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -67,7 +67,7 @@ The {kim_query} web query tool provides the ability to use the predictions of IM Support is provided for unit conversion between the "unit style"_units.html used in the LAMMPS input script and the units required by the OpenKIM IM. This makes it possible to use a single input script with IMs using different units without change and minimizes the likelihood of errors due to incompatible units. :ul :link(IM_types) -Types of KIM IMs :h4 +Types of IMs in OpenKIM :h4 There are two types of IMs archived in OpenKIM: @@ -108,6 +108,10 @@ listed above the Model Page is located at: "https://openkim.org/id/SW_StillingerWeber_1985_Si__MO_405512056662_005"_https://openkim.org/id/SW_StillingerWeber_1985_Si__MO_405512056662_005 :pre +See the "current list of KIM Models and SMs archived in OpenKIM"_https://openkim.org/browse/models/by-species. +This list is sorted by species and can be filtered to display only +IMs for certain species combinations. + NOTE: It is also possible to locally install IMs not archived in OpenKIM, in which case their names do not have to conform to the KIM ID format. @@ -118,6 +122,9 @@ IM and perform necessary initialization ({kim_init}), and the second to set up the IM for use by executing any necessary LAMMPS commands ({kim_interactions}). Both are required. +See the {examples/kim} directory for example input scripts that use KIM Models +and KIM SMs. + OpenKIM IM Initialization ({kim_init}) :h5 The {kim_init} mode command must be issued [before] @@ -375,11 +382,16 @@ OpenKIM to function. [Restrictions:] The set of {kim_commands} is part of the KIM package. It is only enabled if -LAMMPS was built with that package. Furthermore, its correct -functioning depends on compiling LAMMPS with all required packages -installed that are required by the commands embedded in any KIM -SM used. -See the "Build package"_Build_package.html doc page for more info. +LAMMPS is built with that package. A requirement for the KIM package, +is the KIM API library that must be downloaded from the +"OpenKIM website"_https://openkim.org/kim-api/ and installed before +LAMMPS is compiled. When installing LAMMPS from binary, the kim-api package +is a dependency that is automatically downloaded and installed. See the KIM +section of the "Packages details"_Packages_details.html for details. + +Furthermore, when using {kim_commands} to run KIM SMs, any packages required +by the native potential being used or other commands or fixes that it invokes +must be installed. [Related commands:] From d150feb41aa7c13858d56d8dd7ac18212e626492 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Sun, 23 Jun 2019 17:46:00 -0500 Subject: [PATCH 054/107] Small change to KIM package build --- doc/src/Build_extras.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/src/Build_extras.txt b/doc/src/Build_extras.txt index 220e9420fc..38d50522bb 100644 --- a/doc/src/Build_extras.txt +++ b/doc/src/Build_extras.txt @@ -177,11 +177,12 @@ use with LAMMPS. If you want to use the "kim_query"_kim_commands.html command, you also need to have libcurl installed with the matching development headers and the curl-config tool. -Note that in LAMMPS lingo, a KIM model driver is a pair style +Note that in LAMMPS jargon, a KIM model driver is a pair style (e.g. EAM or Tersoff). A KIM model is a pair style for a particular element or alloy and set of parameters, e.g. EAM for Cu with a -specific EAM potential file. Also note that downloading and installing -the KIM API library with all its models, may take a long time (10s of +specific EAM potential file. Also note that when downloading and +installing from source +the KIM API library with all its models, may take a long time (tens of minutes to hours) to build. Of course you only need to do that once. See the list of KIM model drivers here: From cf008c163def0bf64d77c8602b092cf4268261ed Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Sun, 23 Jun 2019 18:01:35 -0500 Subject: [PATCH 055/107] Corrected box rescaling --- doc/src/kim_commands.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 99ed068c44..f039202e4e 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -225,7 +225,16 @@ from a file. For example if a configuration of atoms is read in from a dump file using the "read_dump"_read_dump.html command, the following can be done to convert the box and all atomic positions to the correct units: -change_box all x scale $\{_u_distance\} y scale $\{_u_distance\} z scale $\{_u_distance\} remap :pre +variable xyfinal equal xy*$\{_u_distance\} +variable xzfinal equal xz*$\{_u_distance\} +variable yzfinal equal yz*$\{_u_distance\} +change_box all x scale $\{_u_distance\} & +               y scale $\{_u_distance\} & +               z scale $\{_u_distance\} & +               xy final $\{xyfinal\} & +               xz final $\{xzfinal\} & +               yz final $\{yzfinal\} & +               remap :pre NOTE: Unit conversion will only work if the conversion factors are placed in all appropriate places in the input script. It is up to the user to do this From bfd0c4228d3505da1fad1028cb1629cab68375a6 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Sun, 23 Jun 2019 18:29:59 -0500 Subject: [PATCH 056/107] Added text that ADP potentials are available in KIM as well as NIST --- doc/src/pair_adp.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/src/pair_adp.txt b/doc/src/pair_adp.txt index fc888ffbff..d5b07e8431 100644 --- a/doc/src/pair_adp.txt +++ b/doc/src/pair_adp.txt @@ -42,16 +42,18 @@ the ADP potential files themselves. Likewise, the ADP potential files list atomic masses; thus you do not need to use the "mass"_mass.html command to specify them. -The NIST WWW site distributes and documents ADP potentials: +[ADP potentials are available from:] -http://www.ctcms.nist.gov/potentials :pre +The NIST WWW site at http://www.ctcms.nist.gov/potentials. +Note that ADP potentials obtained from NIST must be converted +into the extended DYNAMO {setfl} format discussed below. +:l -Note that these must be converted into the extended DYNAMO {setfl} -format discussed below. +The OpenKIM Project at https://openkim.org provides ADP potentials +as Simulator Models that can be used directly in LAMMPS with +the "kim_commands interface"_kim_commands.html. +:l -The NIST site is maintained by Chandler Becker (cbecker at nist.gov) -who is good resource for info on interatomic potentials and file -formats. :line From 7afcfccf48fb06deccf9d185cabc377a5124d437 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 24 Jun 2019 13:51:41 -0400 Subject: [PATCH 057/107] follow convention to list all commands in a file as header --- doc/src/kim_commands.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index f039202e4e..2aa705b483 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -6,7 +6,9 @@ :line -kim_commands :h3 +kim_init command :h3 +kim_interactions command :h3 +kim_query command :h3 [Syntax:] From f2380a24ef90945f421a90e5d482c58e0bef49b5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 24 Jun 2019 14:27:05 -0400 Subject: [PATCH 058/107] fix parallel processing input include bug --- src/input.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index 268be5b774..2f617d2cd0 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -239,8 +239,8 @@ void Input::file() } /* ---------------------------------------------------------------------- - process all input from filename - called from library interface + process all input from file at filename + mostly called from library interface ------------------------------------------------------------------------- */ void Input::file(const char *filename) @@ -250,21 +250,30 @@ void Input::file(const char *filename) // call to file() will close filename and decrement nfile if (me == 0) { - if (nfile > 1) - error->one(FLERR,"Invalid use of library file() function"); + if (nfile == maxfile) { + maxfile++; + infiles = (FILE **) + memory->srealloc(infiles,maxfile*sizeof(FILE *),"input:infiles"); + } - if (infile && infile != stdin) fclose(infile); infile = fopen(filename,"r"); if (infile == NULL) { char str[128]; snprintf(str,128,"Cannot open input script %s",filename); error->one(FLERR,str); } - infiles[0] = infile; - nfile = 1; + infiles[nfile++] = infile; } + // process contents of file + file(); + + if (me == 0) { + fclose(infile); + nfile--; + infile = infiles[nfile-1]; + } } /* ---------------------------------------------------------------------- @@ -1041,7 +1050,13 @@ void Input::include() error->one(FLERR,str); } infiles[nfile++] = infile; - file(); + } + + // process contents of file + + file(); + + if (me == 0) { fclose(infile); nfile--; infile = infiles[nfile-1]; From 0ddcc023a5074e10b7e5974011e15542a2c5b105 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Mon, 24 Jun 2019 13:54:55 -0500 Subject: [PATCH 059/107] Improvements and additions to kim_commands doc --- doc/src/kim_commands.txt | 54 +++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index f039202e4e..68306ad6b7 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -170,10 +170,30 @@ SMs can never adjust their units.) If a match is possible, the LAMMPS {user_units}. If the match fails, the simulation is terminated with an error. -If unit conversion mode {is} active, then the LAMMPS "units"_units.html -command is called to set the units to the IM's required or preferred units. -Conversion factors between the IM's units and the {user_units} are -defined for all "physical quantities"_units.html (mass, distance, etc.). +Here is an example of a LAMMPS script to compute the cohesive energy +of a face-centered cubic (fcc) lattice for the Ercolessi and Adams (1994) +potential for Al: + +kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal +boundary p p p +lattice fcc 4.032 +region simbox block 0 1 0 1 0 1 units lattice +create_box 1 simbox +create_atoms 1 box +mass 1 26.981539 +kim_interactions Al +run 0 +variable Ec equal (pe/count(all))/$\{_u_energy\} +print "Cohesive Energy = $\{EcJ\} eV" +:pre + +The above script will end with an error in the {kim_init} line if the +IM is changed to another potential for Al that does not work with {metal} +units. To address this {kim_init} offers the {unit_conversion_mode}. +If unit conversion mode {is} active, then {kim_init} calls the LAMMPS +"units"_units.html command to set the units to the IM's required or +preferred units. Conversion factors between the IM's units and the {user_units} +are defined for all "physical quantities"_units.html (mass, distance, etc.). (Note that converting to or from the "lj" unit style is not supported.) These factors are stored as "internal style variables"_variable.html with standard names: @@ -197,9 +217,11 @@ If desired, the input script can be designed to work with these conversion factors so that the script will work without change with any OpenKIM IM. (This approach is used in the "OpenKIM Testing Framework"_https://openkim.org/getting-started/kim-tests/.) -For example, the following simple script constructs an fcc lattice with -a lattice parameter defined in meters, computes the total energy, -and prints the cohesive energy in Joules regardless of the units of the IM. +For example, the script given above for the cohesive energy of fcc Al +can be rewritten to work with any IM regardless of units. The following +script constructs an fcc lattice with a lattice parameter defined in +meters, computes the total energy, and prints the cohesive energy in +Joules regardless of the units of the IM. kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 si unit_conversion_mode boundary p p p @@ -339,18 +361,23 @@ lattice fcc $\{a0\} The {kim_query} command retrieves from "OpenKIM"_https://openkim.org the equilibrium lattice constant predicted by the Ercolessi and Adams (1994) -potential for the face-centered cubic (fcc) structure and places it in +potential for the fcc structure and places it in variable {a0}. This variable is then used on the next line to set up the crystal. By using {kim_query}, the user is saved the trouble and possible error of tracking this value down, or of having to perform an energy minimization to find the equilibrium lattice constant. +Note that in {unit_conversion_mode} the results obtained from a +{kim_query} would need to be converted to the appropriate units system. +For example, in the above script, the lattice command would need to be +changed to: "lattice fcc $\{a0\}*$\{_u_distance\}". + [Define a crystal at finite temperature accounting for thermal expansion] kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal boundary p p p kim_query a0 get_lattice_constant_fcc units=\["angstrom"\] -kim_query alpha get_linear_thermal_expansion_fcc +kim_query alpha get_linear_thermal_expansion_fcc units=\{"1/K"\} variable DeltaT equal 300 lattice fcc $\{a0\}*$\{alpha\}*$\{DeltaT\} ... :pre @@ -375,6 +402,15 @@ The defect formation energy {Eform} is computed by subtracting from {Etot} the ideal fcc cohesive energy of the atoms in the system obtained from "OpenKIM"_https://openkim.org for the Ercolessi and Adams (1994) potential. +NOTE: {kim_query} commands return results archived in +"OpenKIM"_https://openkim.org. These results are obtained +using programs for computing material properties +(KIM Tests and KIM Test Drivers) that were contributed to OpenKIM. +In order to give credit to Test developers, the number of times results +from these programs are queried is tracked. No other information about +the nature of the query or its source is recorded. + + Citation of OpenKIM IMs :h4 When publishing results obtained using OpenKIM IMs researchers are requested From 1047d8f80e10a8c267eb4b022720da8f61f844c0 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Mon, 24 Jun 2019 14:32:40 -0500 Subject: [PATCH 060/107] Change of terminology to "KIM Portable Model" and streamlining --- doc/src/kim_commands.txt | 55 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index d42b509449..9be4a79db5 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -44,8 +44,8 @@ so that they can be used by LAMMPS scripts. These commands do not implement any computations directly, but rather generate LAMMPS input commands based on the information retrieved from the OpenKIM repository to initialize and activate OpenKIM IMs and query their predictions for use in the LAMMPS script. -All LAMMPS input commands executed by {kim_commands} are echoed to the -LAMMPS log file. +All LAMMPS input commands generated and executed by {kim_commands} are +echoed to the LAMMPS log file. Benefits of Using OpenKIM IMs :h4 @@ -65,7 +65,7 @@ OpenKIM is a member organization of "DataCite"_https://datacite.org/ and issues Convenience :h5 IMs in OpenKIM are distributed in binary form along with LAMMPS and can be used in a LAMMPS input script simply by providing their KIM ID in the {kim_init} command documented on this page. -The {kim_query} web query tool provides the ability to use the predictions of IMs for supported material properties (computed via "KIM Tests"https://openkim.org/getting-started/kim-tests/) as part of a LAMMPS input script setup and analysis. +The {kim_query} web query tool provides the ability to use the predictions of IMs for supported material properties (computed via "KIM Tests"_https://openkim.org/getting-started/kim-tests/) as part of a LAMMPS input script setup and analysis. Support is provided for unit conversion between the "unit style"_units.html used in the LAMMPS input script and the units required by the OpenKIM IM. This makes it possible to use a single input script with IMs using different units without change and minimizes the likelihood of errors due to incompatible units. :ul :link(IM_types) @@ -73,8 +73,8 @@ Types of IMs in OpenKIM :h4 There are two types of IMs archived in OpenKIM: -The first type is called a {KIM Model}. A KIM Model is an independent computer implementation of an IM written in one of the languages supported by KIM (C, C++, Fortran), which conforms to the KIM Application Programming Interface ("KIM API"_https://openkim.org/kim-api/). A KIM Model will work seamlessly with any simulation code that supports the KIM API (including LAMMPS; see "complete list of supported code"_https://openkim.org/projects-using-kim/). -The second type is called a {KIM Simulator Model} (SM). In this case, the IM is implemented natively within the simulation code ({simulator}), i.e. LAMMPS. A separate SM package is archived in OpenKIM for each parameterization of the IM, which includes all of the necessary parameter files, LAMMPS commands, and metadata (supported species, units, etc.) needed to run the IM in LAMMPS. :ol +The first type is called a {KIM Portable Model} (PM). A KIM PM is an independent computer implementation of an IM written in one of the languages supported by KIM (C, C++, Fortran), which conforms to the KIM Application Programming Interface ("KIM API"_https://openkim.org/kim-api/) Portable Model Interface (PMI) standard. A KIM PM will work seamlessly with any simulation code that supports the KIM API/PMI standard (including LAMMPS; see "complete list of supported codes"_https://openkim.org/projects-using-kim/). +The second type is called a {KIM Simulator Model} (SM). A KIM SM is an IM that is implemented natively within a simulation code ({simulator}) that supports the KIM API/SMI (Simulator Model Interface); in this case LAMMPS. A separate SM package is archived in OpenKIM for each parameterization of the IM, which includes all of the necessary parameter files, LAMMPS commands, and metadata (supported species, units, etc.) needed to run the IM in LAMMPS. :ol With these two IM types, OpenKIM can archive and test almost all IMs that can be used by LAMMPS. (It is easy to contribute new IMs to OpenKIM, see @@ -85,7 +85,7 @@ OpenKIM IMs are uniquely identified by a a human-readable prefix identifying the type of IM, authors, publication year, and supported species, separated by two underscores from the KIM ID itself, which begins with an IM code -({MO} for a KIM Model, and {SM} for a KIM Simulator Model) +({MO} for a KIM Portable Model, and {SM} for a KIM Simulator Model) followed by a unique 12-digit code and a 3-digit version identifier. By convention SM prefixes begin with {Sim_} to readily identify them. @@ -97,7 +97,7 @@ providing all the information on the IM including a title, description, authorship and citation information, test and verification check results, visualizations of results, a wiki with documentation and user comments, and access to raw files, and other information. -This is referred to as the "Model Page" or "SM Page". +This is referred to as the "PM Page" or "SM Page". The URL for such a page is constructed from the "extended KIM ID"_https://openkim.org/about-kim-ids/ of the IM: @@ -110,7 +110,7 @@ listed above the Model Page is located at: "https://openkim.org/id/SW_StillingerWeber_1985_Si__MO_405512056662_005"_https://openkim.org/id/SW_StillingerWeber_1985_Si__MO_405512056662_005 :pre -See the "current list of KIM Models and SMs archived in OpenKIM"_https://openkim.org/browse/models/by-species. +See the "current list of KIM PMs and SMs archived in OpenKIM"_https://openkim.org/browse/models/by-species. This list is sorted by species and can be filtered to display only IMs for certain species combinations. @@ -124,7 +124,7 @@ IM and perform necessary initialization ({kim_init}), and the second to set up the IM for use by executing any necessary LAMMPS commands ({kim_interactions}). Both are required. -See the {examples/kim} directory for example input scripts that use KIM Models +See the {examples/kim} directory for example input scripts that use KIM PMs and KIM SMs. OpenKIM IM Initialization ({kim_init}) :h5 @@ -146,17 +146,17 @@ in the input script. (Any dimensioned numerical values in the input script and values read in from files are expected to be in the {user_units} system.) -The selected IM can be either a "KIM Model or a KIM SM"_#IM_types. +The selected IM can be either a "KIM PM or a KIM SM"_#IM_types. For a KIM SM, the {kim_init} command verifies that the SM is designed to work with LAMMPS (and not another simulation code). -In addition, the version strings for the LAMMPS version used for defining +In addition, the LAMMPS version used for defining the SM and the LAMMPS version being currently run are -printed, to help diagnose any incompatible changes to input script or +printed to help diagnose any incompatible changes to input script or command syntax between the two LAMMPS versions. Based on the selected model {kim_init} may modify the "atom_style"_atom_style.html. -Some SMs have requirements for this variable. If this is the case, then +Some SMs have requirements for this setting. If this is the case, then {atom_style} will be set to the required style. Otherwise, the value is left unchanged (which in the absence of an {atom_style} command in the input script is the "default atom_style value"_atom_style.html). @@ -166,7 +166,7 @@ on whether or not {unit conversion mode} is activated as indicated by the optional {unitarg} argument. If unit conversion mode is [not] active, then {user_units} must either match the required units of the IM or the IM must be able -to adjust its units to match. (The latter is only possible with some KIM Models; +to adjust its units to match. (The latter is only possible with some KIM PMs; SMs can never adjust their units.) If a match is possible, the LAMMPS "units"_units.html command is called to set the units to {user_units}. If the match fails, the simulation is terminated with @@ -198,7 +198,7 @@ preferred units. Conversion factors between the IM's units and the {user_units} are defined for all "physical quantities"_units.html (mass, distance, etc.). (Note that converting to or from the "lj" unit style is not supported.) These factors are stored as "internal style variables"_variable.html with -standard names: +the following standard names: _u_mass _u_distance @@ -241,7 +241,7 @@ Note the multiplication by $\{_u_distance\} and $\{_u_mass\} to convert from SI units (specified in the {kim_init} command) to whatever units the IM uses (metal in this case), and the division by $\{_u_energy\} to convert from the IM's energy units to SI units (Joule). This script -will work correctly for any IM for Al (KIM Model or SM) selected by the +will work correctly for any IM for Al (KIM PM or SM) selected by the {kim_init} command. Care must be taken to apply unit conversion to dimensional variables read in @@ -283,10 +283,10 @@ kim_interactions Si Si Si C The {kim_interactions} command performs all the necessary steps to set up the OpenKIM IM selected in the {kim_init} command. The specific actions depend -on whether the IM is a KIM Model or a KIM SM. For a KIM Model, +on whether the IM is a KIM PM or a KIM SM. For a KIM PM, a "pair_style kim"_pair_kim.html command is executed followed by the appropriate {pair_coeff} command. For example, for the -Ercolessi and Adams (1994) KIM Model for Al set by the following commands: +Ercolessi and Adams (1994) KIM PM for Al set by the following commands: kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal ... @@ -302,8 +302,7 @@ pair_coeff * * Al :pre For a KIM SM, the generated input commands may be more complex and require that LAMMPS is built with the required packages included for the type of potential being used. The set of commands to be executed -is defined in the SM specification file, which is part of the SM package -on "OpenKIM"_https://openkim.org. +is defined in the SM specification file, which is part of the SM package. For example, for the Strachan et al. (2003) ReaxFF SM set by the following commands: @@ -416,14 +415,16 @@ the nature of the query or its source is recorded. Citation of OpenKIM IMs :h4 When publishing results obtained using OpenKIM IMs researchers are requested -to cite the OpenKIM project "(Tadmor)"_#kim-mainpaper and KIM API -"(Elliott)"_#kim-api as well as the specific IM codes used in the simulations. +to cite the OpenKIM project "(Tadmor)"_#kim-mainpaper, KIM API +"(Elliott)"_#kim-api, and the specific IM codes used in the simulations, +in addition to the relevant scientific references for the IM. The citation format for an IM is displayed on its page on -"OpenKIM"_https://openkim.org along with the corresponding BibTex file. +"OpenKIM"_https://openkim.org along with the corresponding BibTex file, +and is automatically added to the LAMMPS {log.cite} file. -Citing the codes used in the simulation gives credit -to the researchers who developed them and enables open source efforts like -OpenKIM to function. +Citing the IM software (KIM infrastucture and specific PM or SM codes) +used in the simulation gives credit to the researchers who developed them +and enables open source efforts like OpenKIM to function. [Restrictions:] @@ -442,7 +443,7 @@ must be installed. [Related commands:] -"pair_style kim"_pair_kim.html, "units"_units.html +"pair_style kim"_pair_kim.html :line From b6535367501e4f9c3e85c32ade7cea6ef6cd6f9d Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Mon, 24 Jun 2019 14:38:44 -0500 Subject: [PATCH 061/107] Switched pair_style kim doc to "KIM Portable Model" terminology --- doc/src/pair_kim.txt | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/doc/src/pair_kim.txt b/doc/src/pair_kim.txt index 86d13808b0..41593675ba 100644 --- a/doc/src/pair_kim.txt +++ b/doc/src/pair_kim.txt @@ -27,11 +27,12 @@ potentials to enable their use in LAMMPS scripts. The preferred interface for using interatomic models archived in OpenKIM is the "kim_commands interface"_kim_commands.html. That -interface supports both "KIM Models" that conform to the KIM API -and can be used by any KIM-compliant simulation code, and +interface supports both "KIM Portable Models" (PMs) that conform to the +KIM API Portable Model Interface (PMI) and can be used by any +simulation code that conforms to the KIM API/PMI, and "KIM Simulator Models" that are natively implemented within a single simulation code (like LAMMPS) and can only be used with it. -The {pair_style kim} command is limited to KIM Models. It is +The {pair_style kim} command is limited to KIM PMs. It is used by the "kim_commands interface"_kim_commands.html as needed. NOTE: Since {pair_style kim} is called by {kim_interactions} as needed, @@ -39,23 +40,23 @@ is not recommended to be directly used in input scripts. :line -The argument {model} is the name of the KIM model for a specific -potential as KIM defines it. For potentials archived in OpenKIM +The argument {model} is the name of the KIM PM. +For potentials archived in OpenKIM this is the extended KIM ID (see "kim_commands"_kim_commands.html -for details). LAMMPS can invoke any KIM Model, however there can -be incompatibilities (for example unit matching issues). +for details). LAMMPS can invoke any KIM PM, however there can +be incompatibilities (for example due to unit matching issues). In the event of an incompatibility, the code will terminate with an error message. Check both the LAMMPS and KIM log files for details. Only a single {pair_coeff} command is used with the {kim} style, which specifies the mapping of LAMMPS atom types to the species supported by -the KIM Model. This is done by specifying {N} additional arguments +the KIM PM. This is done by specifying {N} additional arguments after the * * in the {pair_coeff} command, where {N} is the number of LAMMPS atom types: N element names = mapping of KIM elements to atom types :ul -For example, consider a KIM Model that supports Si and C species. +For example, consider a KIM PM that supports Si and C species. If the LAMMPS simulation has four atom types, where the first three are Si, and the fourth is C, the following {pair_coeff} command would be used: @@ -63,14 +64,14 @@ pair_coeff * * Si Si Si C :pre The first two arguments must be * * so as to span all LAMMPS atom types. The first three Si arguments map LAMMPS atom types 1, 2, and 3 to Si as -defined within KIM Model. The final C argument maps LAMMPS atom type 4 to C. +defined within KIM PM. The final C argument maps LAMMPS atom type 4 to C. :line In addition to the usual LAMMPS error messages, the KIM library itself may generate errors, which should be printed to the screen. In this case it is also useful to check the {kim.log} file for additional error -information. The file kim.log should be generated in the same +information. The file {kim.log} should be generated in the same directory where LAMMPS is running. To download, build, and install the KIM library on your system, see From 4284a4fac41a36d0d897ff9a3f079719f57973a0 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Mon, 24 Jun 2019 14:51:35 -0500 Subject: [PATCH 062/107] Changed me to me_si and fixed some typos in comments --- src/KIM/kim_units.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/KIM/kim_units.cpp b/src/KIM/kim_units.cpp index fe90d58e9e..40f4917601 100644 --- a/src/KIM/kim_units.cpp +++ b/src/KIM/kim_units.cpp @@ -76,9 +76,9 @@ double const Nav = 6.022140857e23; // [unitless] Avogadro's number // (NIST value) // double const Nav = 6.02214076e23; // [unitless] Avogadro's number // (official value May 2019) -double const me = 9.10938356e-31; // [kg] electron rest mass +double const me_si = 9.10938356e-31; // [kg] electron rest mass // (NIST value) -// double me = 9.10938291e-31; // [kg] electron rest mass +// double me_si = 9.10938291e-31; // [kg] electron rest mass double const e_si = 1.6021766208e-19; // [C] elementary charge // (charge of an electron/proton) // (NIST value) @@ -114,8 +114,9 @@ double const attogram_si = 1e-21; // [kg[ attogram double const atu_si = 2.418884326509e-17; // [s] atomic time unit // ( = hbar/E_h where E_h is the // Hartree energy) (NIST value) -double const atu_electron_si = atu_si*sqrt(amu_si/me); // [s] atomic time unit - // used in electron system (see https://sourceforge.net/p/lammps/mailman/lammps-users/thread/BCA2BDB2-BA03-4280-896F-1E6120EF47B2%40caltech.edu/) +double const atu_electron_si = atu_si*sqrt(amu_si/me_si); + // [s] atomic time unit + // used in electron system (see https://sourceforge.net/p/lammps/mailman/lammps-users/thread/BCA2BDB2-BA03-4280-896F-1E6120EF47B2%40caltech.edu/) double const microsecond_si = 1e-6; // [s] microsecond double const nanosecond_si = 1e-9; // [s] nanosecond double const picosecond_si = 1e-12; // [s] picosecond @@ -130,13 +131,12 @@ double const amu_per_bohrcu_si = amu_si/pow(bohr_si,3); // [kg/m^3] amu/bohr^3 double const picogram_per_micrometercu_si = picogram_si/pow(micrometer_si,3); // [kg/m^3] picogram/micrometer^3 double const attogram_per_nanometercu_si = - attogram_si/pow(nanometer_si,3); // [kg/m^3] attogram/ - // nanomaterial^3 + attogram_si/pow(nanometer_si,3); // [kg/m^3] attogram/nanometer^3 /*---------------------- Energy/torque units ------------------------ */ -double const kcal_si = 4184.0; // [J] kilocalroie (heat energy +double const kcal_si = 4184.0; // [J] kilocalorie (heat energy // involved in warming up one // kilogram of water by one // degree Kelvin) @@ -155,8 +155,8 @@ double const erg_si = 1e-7; // [J] erg double const dyne_centimeter_si = 1e-7; // [J[ dyne*centimeter double const picogram_micrometersq_per_microsecondsq_si = picogram_si*pow(micrometer_si,2)/pow(microsecond_si,2); - // [J] pigogram*micrometer^2/ - // micorsecond^2 + // [J] picogram*micrometer^2/ + // microsecond^2 double const attogram_nanometersq_per_nanosecondsq_si = attogram_si*pow(nanometer_si,2)/pow(nanosecond_si,2); // [J] attogram*nanometer^2/ From 86d878a7eb4b73432eab53538a2c114571be63e0 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Mon, 24 Jun 2019 15:26:41 -0500 Subject: [PATCH 063/107] Updated language on availability of ADP potentials in OpenKIM --- doc/src/pair_adp.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/src/pair_adp.txt b/doc/src/pair_adp.txt index d5b07e8431..de6717a6c3 100644 --- a/doc/src/pair_adp.txt +++ b/doc/src/pair_adp.txt @@ -49,12 +49,11 @@ Note that ADP potentials obtained from NIST must be converted into the extended DYNAMO {setfl} format discussed below. :l -The OpenKIM Project at https://openkim.org provides ADP potentials -as Simulator Models that can be used directly in LAMMPS with -the "kim_commands interface"_kim_commands.html. +The OpenKIM Project at https://openkim.org/browse/models/by-type provides +ADP potentials that can be used directly in LAMMPS with the "kim_commands +interface"_kim_commands.html. :l - :line Only a single pair_coeff command is used with the {adp} style which From f6319146b04b04e4887fdfe44a47ebc45544d97a Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Tue, 25 Jun 2019 15:03:24 -0500 Subject: [PATCH 064/107] Update kim_query to new interface --- src/KIM/kim_query.cpp | 24 ++++++++++++++++++++---- src/KIM/kim_query.h | 3 +-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index e4818abc94..2bb404ec26 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -51,7 +51,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Designed for use with the kim-api-2.0.2 (and newer) package + Designed for use with the kim-api-2.1.0 (and newer) package ------------------------------------------------------------------------- */ #include @@ -61,7 +61,9 @@ #include "comm.h" #include "error.h" #include "input.h" +#include "modify.h" #include "variable.h" +#include "fix_store_kim.h" #if defined(LMP_KIM_CURL) #include @@ -77,7 +79,7 @@ struct WriteBuf { size_t sizeleft; }; -static char *do_query(char *, int, char **, int, MPI_Comm); +static char *do_query(char *, char *, int, char **, int, MPI_Comm); static size_t write_callback(void *, size_t, size_t, void *); #endif @@ -90,12 +92,23 @@ void KimQuery::command(int narg, char **arg) if (narg < 2) error->all(FLERR,"Illegal kim_query command"); + // check if we had a kim_init command by finding fix STORE/KIM + // retrieve model name. + char * model_name; + + int ifix = modify->find_fix("KIM_MODEL_STORE"); + if (ifix >= 0) { + FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; + model_name = (char *)fix_store->getptr("model_name"); + } else error->all(FLERR,"Must use 'kim_init' before 'kim_query'"); + + varname = arg[0]; function = arg[1]; #if defined(LMP_KIM_CURL) - value = do_query(function, narg-2, arg+2, comm->me, world); + value = do_query(function, model_name, narg-2, arg+2, comm->me, world); // check for valid result // on error the content of "value" is a '\0' byte @@ -147,7 +160,8 @@ size_t write_callback(void *data, size_t size, size_t nmemb, void *userp) return 0; // done } -char *do_query(char *qfunction, int narg, char **arg, int rank, MPI_Comm comm) +char *do_query(char *qfunction, char * model_name, int narg, char **arg, + int rank, MPI_Comm comm) { char value[512], *retval; @@ -173,6 +187,8 @@ char *do_query(char *qfunction, int narg, char **arg, int rank, MPI_Comm comm) url += qfunction; std::string query(arg[0]); + query += "&model="; + query += model_name; for (int i=1; i < narg; ++i) { query += '&'; query += arg[i]; diff --git a/src/KIM/kim_query.h b/src/KIM/kim_query.h index 3644e4519b..b5433def79 100644 --- a/src/KIM/kim_query.h +++ b/src/KIM/kim_query.h @@ -51,7 +51,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Designed for use with the kim-api-2.0.2 (and newer) package + Designed for use with the kim-api-2.1.0 (and newer) package ------------------------------------------------------------------------- */ #ifdef COMMAND_CLASS @@ -71,7 +71,6 @@ class KimQuery : protected Pointers { public: KimQuery(class LAMMPS *lmp) : Pointers(lmp) {}; void command(int, char **); - }; } From 312a1fa004bbec6f6e11e800f17c6e3038f0ecdc Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Thu, 27 Jun 2019 07:58:32 -0500 Subject: [PATCH 065/107] Added species to kim_queries in docs and some other edits --- doc/src/kim_commands.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 9be4a79db5..48637ae722 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -32,7 +32,7 @@ kim_interactions Si kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 real kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 metal unit_conversion_mode kim_interactions C H O -kim_query a0 get_lattice_constant_fcc units=\["angstrom"\] :pre +kim_query a0 get_lattice_constant_fcc species=\["Al"] units=\["angstrom"\] :pre [Description:] @@ -53,7 +53,7 @@ Employing OpenKIM IMs provides LAMMPS users with multiple benefits: Reliability :h5 -All content archived in OpenKIM is subject to quality control by the "KIM Editor"_https://openkim.org/governance/. +All content archived in OpenKIM is reviewed by the "KIM Editor"_https://openkim.org/governance/ for quality. IMs in OpenKIM are archived with full provenance control. Each is associated with a maintainer responsible for the integrity of the content. All changes are tracked and recorded. IMs in OpenKIM are exhaustively tested using "KIM Tests"_https://openkim.org/getting-started/kim-tests/ that compute a host of material properties, and "KIM Verification Checks"_https://openkim.org/about-verification-checks/ that provide the user with information on various aspects of the IM behavior and coding correctness. This information is displayed on the IM's page on "OpenKIM"_https://openkim.org. :ul @@ -73,8 +73,8 @@ Types of IMs in OpenKIM :h4 There are two types of IMs archived in OpenKIM: -The first type is called a {KIM Portable Model} (PM). A KIM PM is an independent computer implementation of an IM written in one of the languages supported by KIM (C, C++, Fortran), which conforms to the KIM Application Programming Interface ("KIM API"_https://openkim.org/kim-api/) Portable Model Interface (PMI) standard. A KIM PM will work seamlessly with any simulation code that supports the KIM API/PMI standard (including LAMMPS; see "complete list of supported codes"_https://openkim.org/projects-using-kim/). -The second type is called a {KIM Simulator Model} (SM). A KIM SM is an IM that is implemented natively within a simulation code ({simulator}) that supports the KIM API/SMI (Simulator Model Interface); in this case LAMMPS. A separate SM package is archived in OpenKIM for each parameterization of the IM, which includes all of the necessary parameter files, LAMMPS commands, and metadata (supported species, units, etc.) needed to run the IM in LAMMPS. :ol +The first type is called a {KIM Portable Model} (PM). A KIM PM is an independent computer implementation of an IM written in one of the languages supported by KIM (C, C++, Fortran) that conforms to the KIM Application Programming Interface ("KIM API"_https://openkim.org/kim-api/) Portable Model Interface (PMI) standard. A KIM PM will work seamlessly with any simulation code that supports the KIM API/PMI standard (including LAMMPS; see "complete list of supported codes"_https://openkim.org/projects-using-kim/). +The second type is called a {KIM Simulator Model} (SM). A KIM SM is an IM that is implemented natively within a simulation code ({simulator}) that supports the KIM API Simulator Model Interface (SMI); in this case LAMMPS. A separate SM package is archived in OpenKIM for each parameterization of the IM, which includes all of the necessary parameter files, LAMMPS commands, and metadata (supported species, units, etc.) needed to run the IM in LAMMPS. :ol With these two IM types, OpenKIM can archive and test almost all IMs that can be used by LAMMPS. (It is easy to contribute new IMs to OpenKIM, see @@ -356,7 +356,7 @@ or analysis phases of LAMMPS simulations. Some examples are given below. kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal boundary p p p -kim_query a0 get_lattice_constant_fcc units=\["angstrom"\] +kim_query a0 get_lattice_constant_fcc species=\["Al"\] units=\["angstrom"\] lattice fcc $\{a0\} ... :pre @@ -377,8 +377,8 @@ changed to: "lattice fcc $\{a0\}*$\{_u_distance\}". kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal boundary p p p -kim_query a0 get_lattice_constant_fcc units=\["angstrom"\] -kim_query alpha get_linear_thermal_expansion_fcc units=\{"1/K"\} +kim_query a0 get_lattice_constant_fcc species=\["Al"\] units=\["angstrom"\] +kim_query alpha get_linear_thermal_expansion_fcc species=\["Al"\] units=\{"1/K"\} variable DeltaT equal 300 lattice fcc $\{a0\}*$\{alpha\}*$\{DeltaT\} ... :pre @@ -395,7 +395,7 @@ kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal ... Build fcc crystal containing some defect and compute the total energy ... which is stored in the variable {Etot} ... -kim_query Ec get_cohesive_energy_fcc units=\["eV"\] +kim_query Ec get_cohesive_energy_fcc species=\["Al"\] units=\["eV"\] variable Eform equal $\{Etot\} - count(all)*$\{Ec\} ... :pre From 121947e79d33d2d997bf705ec9b656da2c1edae3 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Thu, 27 Jun 2019 12:52:20 -0500 Subject: [PATCH 066/107] Added hcp query example to kim_commands --- doc/src/kim_commands.txt | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 48637ae722..66319d7a08 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -352,7 +352,7 @@ webpage at "https://query.openkim.org"_https://query.openkim.org/ The data obtained by {kim_query} commands can be used as part of the setup or analysis phases of LAMMPS simulations. Some examples are given below. -[Define a crystal at its equilibrium lattice constant] +[Define an equilibrium fcc crystal] kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal boundary p p p @@ -373,6 +373,26 @@ Note that in {unit_conversion_mode} the results obtained from a For example, in the above script, the lattice command would need to be changed to: "lattice fcc $\{a0\}*$\{_u_distance\}". +[Define an equilibrium hcp crystal] + +kim_init EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000 metal +boundary p p p +kim_query latconst get_lattice_constant_hcp species=\["Zr"\] units=\["angstrom"\] +variable a0 equal latconst_1 +variable c0 equal latconst_2 +variable c_to_a equal $\{c0\}/$\{a0\} +lattice custom $\{a0\} a1 0.5 -0.866025 0 a2 0.5 0.866025 0 a3 0 0 $\{c_to_a\} & + basis 0.333333 0.666666 0.25 basis 0.666666 0.333333 0.75 +... :pre + +In this case the {kim_query} returns two arguments (since the hexagonal +close packed (hcp) structure has two independent lattice constants). +In the case where a query returns multiple results, the default behavior +for {kim_query} is to split these into individual variables of the form +{prefix_I}, where {prefix} is set to the the {kim_query} {variable} argument +and {I} ranges from 1 to the number of returned values. The number and order of +the returned values is determined by the type of query performed. + [Define a crystal at finite temperature accounting for thermal expansion] kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal From 63dcd999d8c5cbfd07d109836d72355bc138281e Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Wed, 3 Jul 2019 11:49:38 -0500 Subject: [PATCH 067/107] Switch to kim-api c-bindings for SimulatorModel --- src/KIM/fix_store_kim.cpp | 12 +++++--- src/KIM/kim_init.cpp | 60 ++++++++++++++++++------------------ src/KIM/kim_interactions.cpp | 49 +++++++++++++++-------------- 3 files changed, 63 insertions(+), 58 deletions(-) diff --git a/src/KIM/fix_store_kim.cpp b/src/KIM/fix_store_kim.cpp index c9a99acca9..1bd924bcfb 100644 --- a/src/KIM/fix_store_kim.cpp +++ b/src/KIM/fix_store_kim.cpp @@ -56,7 +56,9 @@ #include #include "fix_store_kim.h" -#include "KIM_SimulatorModel.hpp" +extern "C" { +#include "KIM_SimulatorModel.h" +} #include "error.h" using namespace LAMMPS_NS; @@ -78,8 +80,8 @@ FixStoreKIM::~FixStoreKIM() // free associated storage if (simulator_model) { - KIM::SimulatorModel *sm = (KIM::SimulatorModel *)simulator_model; - KIM::SimulatorModel::Destroy(&sm); + KIM_SimulatorModel *sm = (KIM_SimulatorModel *)simulator_model; + KIM_SimulatorModel_Destroy(&sm); simulator_model = NULL; } @@ -116,8 +118,8 @@ void FixStoreKIM::setptr(const char *name, void *ptr) { if (strcmp(name,"simulator_model") == 0) { if (simulator_model) { - KIM::SimulatorModel *sm = (KIM::SimulatorModel *)simulator_model; - KIM::SimulatorModel::Destroy(&sm); + KIM_SimulatorModel *sm = (KIM_SimulatorModel *)simulator_model; + KIM_SimulatorModel_Destroy(&sm); } simulator_model = ptr; } else if (strcmp(name,"model_name") == 0) { diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 080e3dac3f..052e63263f 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -75,9 +75,6 @@ extern "C" { #include "KIM_SimulatorHeaders.h" } -//@@@@@ Need to switch to c-bindings when they are available. -#include "KIM_SimulatorModel.hpp" -//@@@@@ using namespace LAMMPS_NS; @@ -214,29 +211,30 @@ void KimInit::determine_model_type_and_units(char * model_name, } } - KIM::SimulatorModel * kim_SM; - kim_error = KIM::SimulatorModel::Create(model_name, &kim_SM); + KIM_SimulatorModel * kim_SM; + kim_error = KIM_SimulatorModel_Create(model_name, &kim_SM); if (kim_error) error->all(FLERR,"KIM model name not found"); model_type = SM; int sim_fields; int sim_lines; - std::string const * sim_field; - std::string const * sim_value; - kim_SM->GetNumberOfSimulatorFields(&sim_fields); - kim_SM->CloseTemplateMap(); + char const * sim_field; + char const * sim_value; + KIM_SimulatorModel_GetNumberOfSimulatorFields(kim_SM, &sim_fields); + KIM_SimulatorModel_CloseTemplateMap(kim_SM); for (int i=0; i < sim_fields; ++i) { - kim_SM->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + KIM_SimulatorModel_GetSimulatorFieldMetadata( + kim_SM,i,&sim_lines,&sim_field); - if (*sim_field == "units") { - kim_SM->GetSimulatorFieldLine(i,0,&sim_value); - int len=(*sim_value).length()+1; - *model_units = new char[len]; strcpy(*model_units,sim_value->c_str()); + if (0 == strcmp(sim_field,"units")) { + KIM_SimulatorModel_GetSimulatorFieldLine(kim_SM,i,0,&sim_value); + int len=strlen(sim_value)+1; + *model_units = new char[len]; strcpy(*model_units,sim_value); break; } } - KIM::SimulatorModel::Destroy(&kim_SM); + KIM_SimulatorModel_Destroy(&kim_SM); if ((! unit_conversion_mode) && (strcmp(*model_units, user_units)!=0)) { std::string mesg("Incompatible units for KIM Simulator Model, " @@ -271,16 +269,16 @@ void KimInit::do_init(char *model_name, char *user_units, char *model_units) kim_init_log_delimiter("begin"); int kimerror; - // @@@@@ switch to c-bindings when they are available - KIM::SimulatorModel * simulatorModel; + KIM_SimulatorModel * simulatorModel; if (model_type == SM) { - kimerror = KIM::SimulatorModel::Create(model_name,&simulatorModel); + kimerror = KIM_SimulatorModel_Create(model_name,&simulatorModel); - const std::string *sim_name, *sim_version; - simulatorModel->GetSimulatorNameAndVersion(&sim_name, &sim_version); + char const *sim_name, *sim_version; + KIM_SimulatorModel_GetSimulatorNameAndVersion( + simulatorModel,&sim_name, &sim_version); - if (*sim_name != "LAMMPS") + if (0 != strcmp(sim_name,"LAMMPS")) error->all(FLERR,"Incompatible KIM Simulator Model"); if (comm->me == 0) { @@ -288,7 +286,7 @@ void KimInit::do_init(char *model_name, char *user_units, char *model_units) mesg += model_name; mesg += "\n"; mesg += "# For Simulator : "; - mesg += *sim_name + " " + *sim_version + "\n"; + mesg += std::string(sim_name) + " " + sim_version + "\n"; mesg += "# Running on : LAMMPS "; mesg += universe->version; mesg += "\n"; @@ -302,7 +300,7 @@ void KimInit::do_init(char *model_name, char *user_units, char *model_units) // need to call this to have access to (some) simulator model init data. - simulatorModel->CloseTemplateMap(); + KIM_SimulatorModel_CloseTemplateMap(simulatorModel); } // Define unit conversion factor variables and print to log @@ -316,24 +314,26 @@ void KimInit::do_init(char *model_name, char *user_units, char *model_units) if (model_type == SM) { int sim_fields, sim_lines; - const std::string *sim_field, *sim_value; - simulatorModel->GetNumberOfSimulatorFields(&sim_fields); + char const *sim_field, *sim_value; + KIM_SimulatorModel_GetNumberOfSimulatorFields(simulatorModel, &sim_fields); // init model for (int i=0; i < sim_fields; ++i) { - simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); - if (*sim_field == "model-init") { + KIM_SimulatorModel_GetSimulatorFieldMetadata( + simulatorModel,i,&sim_lines,&sim_field); + if (0 == strcmp(sim_field,"model-init")) { for (int j=0; j < sim_lines; ++j) { - simulatorModel->GetSimulatorFieldLine(i,j,&sim_value); - input->one(sim_value->c_str()); + KIM_SimulatorModel_GetSimulatorFieldLine( + simulatorModel,i,j,&sim_value); + input->one(sim_value); } break; } } // reset template map. - simulatorModel->OpenAndInitializeTemplateMap(); + KIM_SimulatorModel_OpenAndInitializeTemplateMap(simulatorModel); } // End output to log file diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index 4771272ff8..355df9c3be 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -73,9 +73,6 @@ extern "C" { #include "KIM_SimulatorHeaders.h" } -//@@@@@ Need to switch to c-bindings when they are available. -#include "KIM_SimulatorModel.hpp" -//@@@@@ #define SNUM(x) \ static_cast(std::ostringstream() \ @@ -122,7 +119,7 @@ void KimInteractions::do_setup(int narg, char **arg) error->all(FLERR,"Illegal kim_interactions command"); char *model_name = NULL; - KIM::SimulatorModel *simulatorModel(NULL); + KIM_SimulatorModel *simulatorModel(NULL); // check if we had a kim_init command by finding fix STORE/KIM // retrieve model name and pointer to simulator model class instance. @@ -132,7 +129,7 @@ void KimInteractions::do_setup(int narg, char **arg) if (ifix >= 0) { FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; model_name = (char *)fix_store->getptr("model_name"); - simulatorModel = (KIM::SimulatorModel *)fix_store->getptr("simulator_model"); + simulatorModel = (KIM_SimulatorModel *)fix_store->getptr("simulator_model"); } else error->all(FLERR,"Must use 'kim_init' before 'kim_interactions'"); // Begin output to log file @@ -151,9 +148,11 @@ void KimInteractions::do_setup(int narg, char **arg) delimiter = " "; } - simulatorModel->AddTemplateMap("atom-type-sym-list",atom_type_sym_list); - simulatorModel->AddTemplateMap("atom-type-num-list",atom_type_num_list); - simulatorModel->CloseTemplateMap(); + KIM_SimulatorModel_AddTemplateMap( + simulatorModel,"atom-type-sym-list",atom_type_sym_list.c_str()); + KIM_SimulatorModel_AddTemplateMap( + simulatorModel,"atom-type-num-list",atom_type_num_list.c_str()); + KIM_SimulatorModel_CloseTemplateMap(simulatorModel); int len = strlen(atom_type_sym_list.c_str())+1; char *strbuf = new char[len]; @@ -163,16 +162,17 @@ void KimInteractions::do_setup(int narg, char **arg) int sim_num_species; bool species_is_supported; - const std::string *sim_species; - simulatorModel->GetNumberOfSupportedSpecies(&sim_num_species); + char const *sim_species; + KIM_SimulatorModel_GetNumberOfSupportedSpecies( + simulatorModel,&sim_num_species); strcpy(strbuf,atom_type_sym_list.c_str()); strword = strtok(strbuf," \t"); while (strword) { species_is_supported = false; if (strcmp(strword,"NULL") == 0) continue; for (int i=0; i < sim_num_species; ++i) { - simulatorModel->GetSupportedSpecies(i, &sim_species); - if (strcmp(sim_species->c_str(),strword) == 0) + KIM_SimulatorModel_GetSupportedSpecies(simulatorModel,i,&sim_species); + if (strcmp(sim_species,strword) == 0) species_is_supported = true; } if (!species_is_supported) { @@ -188,26 +188,29 @@ void KimInteractions::do_setup(int narg, char **arg) // check if units are unchanged int sim_fields, sim_lines; - const std::string *sim_field, *sim_value; - simulatorModel->GetNumberOfSimulatorFields(&sim_fields); + const char *sim_field, *sim_value; + KIM_SimulatorModel_GetNumberOfSimulatorFields(simulatorModel, &sim_fields); for (int i=0; i < sim_fields; ++i) { - simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); + KIM_SimulatorModel_GetSimulatorFieldMetadata( + simulatorModel,i,&sim_lines,&sim_field); - if (*sim_field == "units") { - simulatorModel->GetSimulatorFieldLine(i,0,&sim_value); - if (*sim_value != update->unit_style) + if (0 == strcmp(sim_field,"units")) { + KIM_SimulatorModel_GetSimulatorFieldLine(simulatorModel,i,0,&sim_value); + if (0 != strcmp(sim_value,update->unit_style)) error->all(FLERR,"Incompatible units for KIM Simulator Model"); } } int sim_model_idx=-1; for (int i=0; i < sim_fields; ++i) { - simulatorModel->GetSimulatorFieldMetadata(i,&sim_lines,&sim_field); - if (*sim_field == "model-defn") { + KIM_SimulatorModel_GetSimulatorFieldMetadata( + simulatorModel,i,&sim_lines,&sim_field); + if (0 == strcmp(sim_field,"model-defn")) { sim_model_idx = i; for (int j=0; j < sim_lines; ++j) { - simulatorModel->GetSimulatorFieldLine(sim_model_idx,j,&sim_value); - input->one(sim_value->c_str()); + KIM_SimulatorModel_GetSimulatorFieldLine( + simulatorModel,sim_model_idx,j,&sim_value); + input->one(sim_value); } } } @@ -215,7 +218,7 @@ void KimInteractions::do_setup(int narg, char **arg) if (sim_model_idx < 0) error->all(FLERR,"KIM Simulator Model has no Model definition"); - simulatorModel->OpenAndInitializeTemplateMap(); + KIM_SimulatorModel_OpenAndInitializeTemplateMap(simulatorModel); } else { From 00d820dcf98864fdac0e30a0dbeaafbf57271192 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Wed, 3 Jul 2019 13:20:55 -0500 Subject: [PATCH 068/107] Added support for log.cite to kim_init --- src/KIM/kim_init.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++ src/KIM/kim_init.h | 1 + 2 files changed, 53 insertions(+) diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 052e63263f..40e0cbaaed 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -69,6 +69,7 @@ #include "universe.h" #include "input.h" #include "variable.h" +#include "citeme.h" #include "fix_store_kim.h" #include "kim_units.h" @@ -99,6 +100,8 @@ void KimInit::command(int narg, char **arg) char *model_units; determine_model_type_and_units(model_name, user_units, &model_units); + write_log_cite(model_name); + do_init(model_name, user_units, model_units); } @@ -441,3 +444,52 @@ void KimInit::do_variables(char *user_units, char *model_units) if ((logfile) && (input->echo_log)) fputs("#\n",logfile); } } + +/* ---------------------------------------------------------------------- */ + +void KimInit::write_log_cite(char * model_name) +{ + KIM_Collections * coll; + int err = KIM_Collections_Create(&coll); + if (err) return; + + int extent; + if (model_type == MO) + { + err = KIM_Collections_CacheListOfItemMetadataFiles( + coll,KIM_COLLECTION_ITEM_TYPE_portableModel,model_name,&extent); + } + else if (model_type == SM) + { + err = KIM_Collections_CacheListOfItemMetadataFiles( + coll,KIM_COLLECTION_ITEM_TYPE_simulatorModel,model_name,&extent); + } + else + { + error->all(FLERR,"Unknown model type."); + } + + if (err) + { + KIM_Collections_Destroy(&coll); + return; + } + + for (int i = 0; i < extent;++i) + { + char const * fileName; + int availableAsString; + char const * fileString; + err = KIM_Collections_GetItemMetadataFile( + coll,i,&fileName,NULL,NULL,&availableAsString,&fileString); + if (err) continue; + + if (0 == strncmp("kimcite-",fileName,8)) + { + if (lmp->citeme) lmp->citeme->add(fileString); + break; + } + } + + KIM_Collections_Destroy(&coll); +} diff --git a/src/KIM/kim_init.h b/src/KIM/kim_init.h index c22e2be720..7c7a24615b 100644 --- a/src/KIM/kim_init.h +++ b/src/KIM/kim_init.h @@ -78,6 +78,7 @@ class KimInit : protected Pointers { bool unit_conversion_mode; void determine_model_type_and_units(char *, char *, char **); + void write_log_cite(char *); void do_init(char *, char *, char *); void do_variables(char*, char*); void kim_init_log_delimiter(std::string const begin_end) const; From bb5a1c5205c281d23633339c7d700ae0569b63ca Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Wed, 3 Jul 2019 13:38:08 -0500 Subject: [PATCH 069/107] Adjust log.cite behavior --- src/KIM/kim_init.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 40e0cbaaed..5fb6748427 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -484,10 +484,9 @@ void KimInit::write_log_cite(char * model_name) coll,i,&fileName,NULL,NULL,&availableAsString,&fileString); if (err) continue; - if (0 == strncmp("kimcite-",fileName,8)) + if (0 == strncmp("kimcite",fileName,7)) { if (lmp->citeme) lmp->citeme->add(fileString); - break; } } From 1f47da6c51deaac5f29f56bc532a683965d85a82 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Mon, 8 Jul 2019 17:46:47 -0500 Subject: [PATCH 070/107] Add fixed_types to kim_init & split to kim_query --- examples/kim/in.query | 7 ++- src/KIM/kim_interactions.cpp | 108 ++++++++++++++++++++--------------- src/KIM/kim_query.cpp | 32 +++++++++-- 3 files changed, 95 insertions(+), 52 deletions(-) diff --git a/examples/kim/in.query b/examples/kim/in.query index 33272dc298..72e739fb52 100644 --- a/examples/kim/in.query +++ b/examples/kim/in.query @@ -4,8 +4,9 @@ # lattice constant for a specific test used for a specific model and then # assigns it to the variable 'latconst' -units metal +kim_init EAM_CubicNaturalSpline_ErcolessiAdams_1994_Al__MO_800509458712_002 metal info variables out log -kim_query latconst get_test_result test=TE_156715955670 species=["Al"] model=MO_800509458712 prop=structure-cubic-crystal-npt keys=["a"] units=["angstrom"] +kim_query latconst split get_test_result test=TE_156715955670 species=["Al"] prop=structure-cubic-crystal-npt keys=["a","a"] units=["angstrom","angstrom"] info variables out log -lattice fcc ${latconst} +lattice fcc ${latconst_1} +lattice fcc ${latconst_2} diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index 355df9c3be..d0fbb809d2 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -115,8 +115,16 @@ void KimInteractions::kim_interactions_log_delimiter( void KimInteractions::do_setup(int narg, char **arg) { - if (narg != atom->ntypes) + bool fixed_types; + if ((narg == 1) && (0 == strcmp("fixed_types",arg[0]))) { + fixed_types = true; + } + else if (narg != atom->ntypes) { error->all(FLERR,"Illegal kim_interactions command"); + } + else { + fixed_types = false; + } char *model_name = NULL; KIM_SimulatorModel *simulatorModel(NULL); @@ -137,54 +145,60 @@ void KimInteractions::do_setup(int narg, char **arg) if (simulatorModel) { - std::string delimiter(""); - std::string atom_type_sym_list; - std::string atom_type_num_list; + if (!fixed_types) { + std::string delimiter(""); + std::string atom_type_sym_list; + std::string atom_type_num_list; - for (int i = 0; i < narg; i++) + for (int i = 0; i < narg; i++) + { + atom_type_sym_list += delimiter + arg[i]; + atom_type_num_list += delimiter + SNUM(species_to_atomic_no(arg[i])); + delimiter = " "; + } + + KIM_SimulatorModel_AddTemplateMap( + simulatorModel,"atom-type-sym-list",atom_type_sym_list.c_str()); + KIM_SimulatorModel_AddTemplateMap( + simulatorModel,"atom-type-num-list",atom_type_num_list.c_str()); + KIM_SimulatorModel_CloseTemplateMap(simulatorModel); + + int len = strlen(atom_type_sym_list.c_str())+1; + char *strbuf = new char[len]; + char *strword; + + // validate species selection + + int sim_num_species; + bool species_is_supported; + char const *sim_species; + KIM_SimulatorModel_GetNumberOfSupportedSpecies( + simulatorModel,&sim_num_species); + strcpy(strbuf,atom_type_sym_list.c_str()); + strword = strtok(strbuf," \t"); + while (strword) { + species_is_supported = false; + if (strcmp(strword,"NULL") == 0) continue; + for (int i=0; i < sim_num_species; ++i) { + KIM_SimulatorModel_GetSupportedSpecies(simulatorModel,i,&sim_species); + if (strcmp(sim_species,strword) == 0) + species_is_supported = true; + } + if (!species_is_supported) { + std::string msg("Species '"); + msg += strword; + msg += "' is not supported by this KIM Simulator Model"; + error->all(FLERR,msg.c_str()); + } + strword = strtok(NULL," \t"); + } + delete[] strbuf; + } + else { - atom_type_sym_list += delimiter + arg[i]; - atom_type_num_list += delimiter + SNUM(species_to_atomic_no(arg[i])); - delimiter = " "; + KIM_SimulatorModel_CloseTemplateMap(simulatorModel); } - KIM_SimulatorModel_AddTemplateMap( - simulatorModel,"atom-type-sym-list",atom_type_sym_list.c_str()); - KIM_SimulatorModel_AddTemplateMap( - simulatorModel,"atom-type-num-list",atom_type_num_list.c_str()); - KIM_SimulatorModel_CloseTemplateMap(simulatorModel); - - int len = strlen(atom_type_sym_list.c_str())+1; - char *strbuf = new char[len]; - char *strword; - - // validate species selection - - int sim_num_species; - bool species_is_supported; - char const *sim_species; - KIM_SimulatorModel_GetNumberOfSupportedSpecies( - simulatorModel,&sim_num_species); - strcpy(strbuf,atom_type_sym_list.c_str()); - strword = strtok(strbuf," \t"); - while (strword) { - species_is_supported = false; - if (strcmp(strword,"NULL") == 0) continue; - for (int i=0; i < sim_num_species; ++i) { - KIM_SimulatorModel_GetSupportedSpecies(simulatorModel,i,&sim_species); - if (strcmp(sim_species,strword) == 0) - species_is_supported = true; - } - if (!species_is_supported) { - std::string msg("Species '"); - msg += strword; - msg += "' is not supported by this KIM Simulator Model"; - error->all(FLERR,msg.c_str()); - } - strword = strtok(NULL," \t"); - } - delete[] strbuf; - // check if units are unchanged int sim_fields, sim_lines; @@ -223,6 +237,10 @@ void KimInteractions::do_setup(int narg, char **arg) } else { // not a simulator model. issue pair_style and pair_coeff commands. + + if (fixed_types) + error->all(FLERR,"fixed_types cannot be used with a KIM Portable Model"); + // NOTE: all references to arg must appear before calls to input->one() // as that will reset the argument vector. diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index 2bb404ec26..cf4efc2b12 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include "kim_query.h" #include "comm.h" #include "error.h" @@ -104,6 +105,13 @@ void KimQuery::command(int narg, char **arg) varname = arg[0]; + bool split = false; + if (0 == strcmp("split",arg[1])) { + if (narg == 2) error->all(FLERR,"Illegal kim_query command"); + split = true; + arg++; + narg--; + } function = arg[1]; #if defined(LMP_KIM_CURL) @@ -123,11 +131,27 @@ void KimQuery::command(int narg, char **arg) } char **varcmd = new char*[3]; - varcmd[0] = varname; - varcmd[1] = (char *) "string"; - varcmd[2] = value; + if (split) { + int counter = 1; + std::stringstream ss(value); + std::string token; + varcmd[1] = (char *) "string"; - input->variable->set(3,varcmd); + while(std::getline(ss, token, ',')) { + std::stringstream splitname; + splitname << varname << "_" << counter++; + varcmd[0] = const_cast(splitname.str().c_str()); + varcmd[2] = const_cast(token.c_str()); + input->variable->set(3,varcmd); + } + } + else { + varcmd[0] = varname; + varcmd[1] = (char *) "string"; + varcmd[2] = value; + + input->variable->set(3,varcmd); + } delete[] varcmd; delete[] value; From 39c8a7de6e8f4e36f5dc87b775445e7c1c93fd0d Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Tue, 9 Jul 2019 07:35:50 -0400 Subject: [PATCH 071/107] Updated kim_commands doc to descript kim_query split mode --- doc/src/kim_commands.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 66319d7a08..16d8ea785d 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -14,13 +14,14 @@ kim_query command :h3 kim_init model user_units unitarg kim_interactions typeargs -kim_query variable query_function queryargs :pre +kim_query variable formatarg query_function queryargs :pre model = name of the KIM interatomic model (the KIM ID for models archived in OpenKIM) user_units = the LAMMPS "units"_units.html style assumed in the LAMMPS input script unitarg = {unit_conversion_mode} (optional) typeargs = atom type to species mapping (one entry per atom type) variable = name of a (string style) variable where the result of the query is stored +formatarg = {split} (optional) query_function = name of the OpenKIM web API query function to be used queryargs = a series of {keyword=value} pairs that represent the web query; supported keywords depend on the query function :ul @@ -377,7 +378,7 @@ changed to: "lattice fcc $\{a0\}*$\{_u_distance\}". kim_init EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000 metal boundary p p p -kim_query latconst get_lattice_constant_hcp species=\["Zr"\] units=\["angstrom"\] +kim_query latconst split get_lattice_constant_hcp species=\["Zr"\] units=\["angstrom"\] variable a0 equal latconst_1 variable c0 equal latconst_2 variable c_to_a equal $\{c0\}/$\{a0\} @@ -387,6 +388,13 @@ lattice custom $\{a0\} a1 0.5 -0.866025 0 a2 0.5 0.866025 0 a3 0 0 $\{c In this case the {kim_query} returns two arguments (since the hexagonal close packed (hcp) structure has two independent lattice constants). +The default behavior of {kim_query} returns the result as a string +with the values separated by commas. The optional keyword {split} +separates the result values into individual variables of the form +{prefix_I}, where {prefix} is set to the the {kim_query} {variable} argument +and {I} ranges from 1 to the number of returned values. The number and order of +the returned values is determined by the type of query performed. + In the case where a query returns multiple results, the default behavior for {kim_query} is to split these into individual variables of the form {prefix_I}, where {prefix} is set to the the {kim_query} {variable} argument From 30086950b87ccb019b2a723b6c684fce7fd6fe7f Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Tue, 9 Jul 2019 09:43:34 -0400 Subject: [PATCH 072/107] Added preliminary doc for kim_interactions fixed_types --- doc/src/kim_commands.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 16d8ea785d..437b768df6 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -19,7 +19,7 @@ kim_query variable formatarg query_function queryargs :pre model = name of the KIM interatomic model (the KIM ID for models archived in OpenKIM) user_units = the LAMMPS "units"_units.html style assumed in the LAMMPS input script unitarg = {unit_conversion_mode} (optional) -typeargs = atom type to species mapping (one entry per atom type) +typeargs = atom type to species mapping (one entry per atom type) or {fixed_types} for models with a preset fixed mapping variable = name of a (string style) variable where the result of the query is stored formatarg = {split} (optional) query_function = name of the OpenKIM web API query function to be used @@ -33,6 +33,8 @@ kim_interactions Si kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 real kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 metal unit_conversion_mode kim_interactions C H O +kim_init Sim_LAMMPS_IFF_OtherInfo_AuthorList_Year_Species__SM_064312669787_000 real +kim_interactions fixed_types kim_query a0 get_lattice_constant_fcc species=\["Al"] units=\["angstrom"\] :pre @@ -272,8 +274,13 @@ The second and final step in using an OpenKIM IM is to execute the command and a "create_box"_create_box.html command, which defines the number of atom types {N}. The {kim_interactions} command has one argument {typeargs}. This argument -contains a list of {N} chemical species, which defines a mapping between -atom types in LAMMPS to the available species in the OpenKIM IM. +contains either a list of {N} chemical species, which defines a mapping between +atom types in LAMMPS to the available species in the OpenKIM IM, or the +keyword {fixed_types} for models that have a preset fixed mapping (i.e. +the mapping between LAMMPS atom types and chemical species is defined by +the model and cannot be changed). In the latter case, the user must consult +the model documentation to see how many atom types there are and how they +map to the chemcial species. For example, consider an OpenKIM IM that supports Si and C species. If the LAMMPS simulation has four atom types, where the first three are Si, @@ -282,6 +289,11 @@ and the fourth is C, the following {kim_interactions} command would be used: kim_interactions Si Si Si C :pre +Alternatively, for a model with a fixed mapping the command would be: + +kim_interactions fixed_types +:pre + The {kim_interactions} command performs all the necessary steps to set up the OpenKIM IM selected in the {kim_init} command. The specific actions depend on whether the IM is a KIM PM or a KIM SM. For a KIM PM, From 5236497932c7b775480123d6e11516158796f035 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Tue, 9 Jul 2019 18:36:51 -0400 Subject: [PATCH 073/107] Changed 'bohr_per_atu_si' to 'bohr_per_atu_electron_si' --- src/KIM/kim_units.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KIM/kim_units.cpp b/src/KIM/kim_units.cpp index 40f4917601..45f9b81a35 100644 --- a/src/KIM/kim_units.cpp +++ b/src/KIM/kim_units.cpp @@ -175,7 +175,7 @@ double const nanometer_per_nanosecond_si = nanometer_si/nanosecond_si; // [m/s] nanometer/nanosecond double const centimeter_per_second_si = centimeter_si; // [m/s] centimeter/second -double const bohr_per_atu_si = +double const bohr_per_atu_electron_si = bohr_si/atu_electron_si; // [m/s] bohr/atu /*---------------------- @@ -803,7 +803,7 @@ double get_velocity_conversion_factor(units from_unit_enum, units to_unit_enum) conv[meter_per_second][angstrom_per_femtosecond] = 1.0/angstrom_per_femtosecond_si; conv[meter_per_second][angstrom_per_picosecond] = 1.0/angstrom_per_picosecond_si; conv[meter_per_second][centimeter_per_second] = 1.0/centimeter_per_second_si; - conv[meter_per_second][bohr_per_atu] = 1.0/bohr_per_atu_si; + conv[meter_per_second][bohr_per_atu] = 1.0/bohr_per_atu_electron_si; conv[meter_per_second][micrometer_per_microsecond] = 1.0/micrometer_per_microsecond_si; conv[meter_per_second][nanometer_per_nanosecond] = 1.0/nanometer_per_nanosecond_si; From ea68db964a3dcbdab7aec33f9e4edee404469d53 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Wed, 10 Jul 2019 14:21:07 -0500 Subject: [PATCH 074/107] trim (left and right) strings from kim_query xxxx split --- src/KIM/kim_query.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index cf4efc2b12..221dc9e804 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -138,6 +138,8 @@ void KimQuery::command(int narg, char **arg) varcmd[1] = (char *) "string"; while(std::getline(ss, token, ',')) { + token.erase(0,token.find_first_not_of(" \n\r\t")); // ltrim + token.erase(token.find_last_not_of(" \n\r\t") + 1); // rtrim std::stringstream splitname; splitname << varname << "_" << counter++; varcmd[0] = const_cast(splitname.str().c_str()); From 1a0662c3860a68a38ee370812b069b58f8f7821d Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Wed, 10 Jul 2019 22:11:47 -0500 Subject: [PATCH 075/107] Some corrections and additions to kim_commands docs --- doc/src/kim_commands.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 437b768df6..1356ade9e2 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -35,7 +35,7 @@ kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657 kim_interactions C H O kim_init Sim_LAMMPS_IFF_OtherInfo_AuthorList_Year_Species__SM_064312669787_000 real kim_interactions fixed_types -kim_query a0 get_lattice_constant_fcc species=\["Al"] units=\["angstrom"\] :pre +kim_query a0 get_lattice_constant_fcc species=\["Al"\] units=\["angstrom"\] :pre [Description:] @@ -105,12 +105,16 @@ The URL for such a page is constructed from the "extended KIM ID"_https://openkim.org/about-kim-ids/ of the IM: https://openkim.org/id/extended_KIM_ID +or +https://openkim.org/id/short_KIM_ID :pre For example for the Stillinger-Weber potential listed above the Model Page is located at: "https://openkim.org/id/SW_StillingerWeber_1985_Si__MO_405512056662_005"_https://openkim.org/id/SW_StillingerWeber_1985_Si__MO_405512056662_005 +or +"https://openkim.org/id/MO_405512056662_005"_https://openkim.org/id/MO_405512056662_005 :pre See the "current list of KIM PMs and SMs archived in OpenKIM"_https://openkim.org/browse/models/by-species. @@ -271,8 +275,8 @@ OpenKIM IM Execution ({kim_interactions}) :h5 The second and final step in using an OpenKIM IM is to execute the {kim_interactions} command. This command must be preceded by a {kim_init} -command and a "create_box"_create_box.html command, -which defines the number of atom types {N}. +command and a command that creates the simulation box (such as +"create_box"_create_box.html), which defines the number of atom types {N}. The {kim_interactions} command has one argument {typeargs}. This argument contains either a list of {N} chemical species, which defines a mapping between atom types in LAMMPS to the available species in the OpenKIM IM, or the @@ -338,7 +342,7 @@ Note also that parameters like cutoff radii and charge tolerances, which have an effect on IM predictions, are also included in the SM definition ensuring reproducibility. -NOTE: When using using {kim_init} and {kim_interactions} to select +NOTE: When using {kim_init} and {kim_interactions} to select and set up an OpenKIM IM, other LAMMPS commands for the same functions (such as pair_style, pair_coeff, bond_style, bond_coeff, fixes related to charge equilibration, etc.) should normally @@ -356,7 +360,7 @@ argument of the {kim_query command}. The second required argument (e.g. {get_lattice_constant_fcc}). All following arguments are parameters handed over to the web query in the format {keyword=value}. The list of supported keywords and -and the type and format of their values depend on the query function +the type and format of their values depend on the query function used. NOTE: The current list of supported query functions is available on the OpenKIM From dbd0158d3f03abba93a219f8e7c40f097998d72e Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Thu, 11 Jul 2019 12:01:35 -0500 Subject: [PATCH 076/107] Adjust/update kim_query do_query() routine --- src/KIM/kim_query.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index 221dc9e804..6e77b8f859 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -124,7 +124,7 @@ void KimQuery::command(int narg, char **arg) // that was returned by the web server if (0 == strlen(value)) { - char errmsg[512]; + char errmsg[1024]; sprintf(errmsg,"OpenKIM query failed: %s",value+1); error->all(FLERR,errmsg); @@ -258,9 +258,15 @@ char *do_query(char *qfunction, char * model_name, int narg, char **arg, if (value[0] == '[') { int len = strlen(value)-1; - retval = new char[len]; - value[len] = '\0'; - strcpy(retval,value+1); + if (value[len-1] == ']') { + retval = new char[len]; + value[len-1] = '\0'; + strcpy(retval,value+1); + } else { + retval = new char[len+2]; + retval[0] = '\0'; + strcpy(retval+1,value); + } } else if (value[0] == '\0') { int len = strlen(value+1)+2; retval = new char[len]; @@ -268,10 +274,11 @@ char *do_query(char *qfunction, char * model_name, int narg, char **arg, strcpy(retval+1,value+1); } else { // unknown response type. we should not get here. - // copy response without modifications. - int len = strlen(value)+1; + // we return an "empty" string but add error message after it + int len = strlen(value)+2; retval = new char[len]; - strcpy(retval,value); + retval[0] = '\0'; + strcpy(retval+1,value); } return retval; } From 8e2f3e48832115af044efe39861b9a35480327fd Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Thu, 11 Jul 2019 12:04:54 -0500 Subject: [PATCH 077/107] Wording changes and removed duplicate text --- doc/src/kim_commands.txt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 437b768df6..f9615b8d5f 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -58,7 +58,7 @@ Reliability :h5 All content archived in OpenKIM is reviewed by the "KIM Editor"_https://openkim.org/governance/ for quality. IMs in OpenKIM are archived with full provenance control. Each is associated with a maintainer responsible for the integrity of the content. All changes are tracked and recorded. -IMs in OpenKIM are exhaustively tested using "KIM Tests"_https://openkim.org/getting-started/kim-tests/ that compute a host of material properties, and "KIM Verification Checks"_https://openkim.org/about-verification-checks/ that provide the user with information on various aspects of the IM behavior and coding correctness. This information is displayed on the IM's page on "OpenKIM"_https://openkim.org. :ul +IMs in OpenKIM are exhaustively tested using "KIM Tests"_https://openkim.org/getting-started/kim-tests/ that compute a host of material properties, and "KIM Verification Checks"_https://openkim.org/about-verification-checks/ that provide the user with information on various aspects of the IM behavior and coding correctness. This information is displayed on the IM's page accessible through the "OpenKIM browse interface"_https://openkim.org/browse. :ul Reproducibility :h5 @@ -407,12 +407,6 @@ separates the result values into individual variables of the form and {I} ranges from 1 to the number of returned values. The number and order of the returned values is determined by the type of query performed. -In the case where a query returns multiple results, the default behavior -for {kim_query} is to split these into individual variables of the form -{prefix_I}, where {prefix} is set to the the {kim_query} {variable} argument -and {I} ranges from 1 to the number of returned values. The number and order of -the returned values is determined by the type of query performed. - [Define a crystal at finite temperature accounting for thermal expansion] kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal From 3349ed00133553e8f2feac931b18b4cf4903cbdc Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Thu, 11 Jul 2019 12:22:36 -0500 Subject: [PATCH 078/107] Changed PM Page and SM Page to "Model Page" --- doc/src/kim_commands.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 2a8f83e7a8..604aba4449 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -95,13 +95,12 @@ By convention SM prefixes begin with {Sim_} to readily identify them. SW_StillingerWeber_1985_Si__MO_405512056662_005 Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 :pre -Each OpenKIM IM has a dedicated page on "OpenKIM"_https://openkim.org +Each OpenKIM IM has a dedicated "Model Page" on "OpenKIM"_https://openkim.org providing all the information on the IM including a title, description, authorship and citation information, test and verification check results, visualizations of results, a wiki with documentation and user comments, and access to raw files, and other information. -This is referred to as the "PM Page" or "SM Page". -The URL for such a page is constructed from the +The URL for the Model Page is constructed from the "extended KIM ID"_https://openkim.org/about-kim-ids/ of the IM: https://openkim.org/id/extended_KIM_ID From 9718b99af969900fdd62614e9c0ccda418408eb6 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Thu, 11 Jul 2019 13:23:46 -0500 Subject: [PATCH 079/107] Clarification on what preceeds in kim_interactions --- doc/src/kim_commands.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 604aba4449..a6551734f1 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -274,8 +274,8 @@ OpenKIM IM Execution ({kim_interactions}) :h5 The second and final step in using an OpenKIM IM is to execute the {kim_interactions} command. This command must be preceded by a {kim_init} -command and a command that creates the simulation box (such as -"create_box"_create_box.html), which defines the number of atom types {N}. +command and a command that defines the number of atom types {N} (such as +"create_box"_create_box.html). The {kim_interactions} command has one argument {typeargs}. This argument contains either a list of {N} chemical species, which defines a mapping between atom types in LAMMPS to the available species in the OpenKIM IM, or the From 658cda9b670da84e66a695d4f98364ac5202c4f4 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Tue, 16 Jul 2019 15:02:24 -0500 Subject: [PATCH 080/107] Updated kim_query documentation to new format --- doc/src/kim_commands.txt | 69 +++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index a6551734f1..46e437a871 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -35,8 +35,7 @@ kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657 kim_interactions C H O kim_init Sim_LAMMPS_IFF_OtherInfo_AuthorList_Year_Species__SM_064312669787_000 real kim_interactions fixed_types -kim_query a0 get_lattice_constant_fcc species=\["Al"\] units=\["angstrom"\] :pre - +kim_query a0 get_lattice_constant_cubic crystal=\["fcc"\] species=\["Al"\] units=\["angstrom"\] :pre [Description:] @@ -104,16 +103,12 @@ The URL for the Model Page is constructed from the "extended KIM ID"_https://openkim.org/about-kim-ids/ of the IM: https://openkim.org/id/extended_KIM_ID -or -https://openkim.org/id/short_KIM_ID :pre For example for the Stillinger-Weber potential listed above the Model Page is located at: "https://openkim.org/id/SW_StillingerWeber_1985_Si__MO_405512056662_005"_https://openkim.org/id/SW_StillingerWeber_1985_Si__MO_405512056662_005 -or -"https://openkim.org/id/MO_405512056662_005"_https://openkim.org/id/MO_405512056662_005 :pre See the "current list of KIM PMs and SMs archived in OpenKIM"_https://openkim.org/browse/models/by-species. @@ -354,16 +349,34 @@ of the IM set by {kim_init} for material properties archived in "OpenKIM"_https://openkim.org. The {kim_query} command must be preceded by a {kim_init} command. The result of the query is stored in a "string style variable"_variable.html, the name of which is given as the first -argument of the {kim_query command}. The second required argument -{query_function} is the name of the query function to be called -(e.g. {get_lattice_constant_fcc}). -All following arguments are parameters handed over to the web query -in the format {keyword=value}. The list of supported keywords and -the type and format of their values depend on the query function -used. +argument of the {kim_query command}. (For the case of multiple +return values, the optional {split} keyword can be used after the +variable name to separate the results into multiple variables; see +the "example"_#split_example below.) +The second required argument {query_function} is the name of the +query function to be called (e.g. {get_lattice_constant_cubic}). +All following "arguments"_Commands_parse.html are parameters handed over to +the web query in the format {keyword=value}, where {value} is always +an array of one or more comma-separated items in brackets. +The list of supported keywords and the type and format of their values +depend on the query function used. The current list of query functions +is available on the OpenKIM webpage at +"https://openkim.org/doc/repository/kim-query"_https://openkim.org/doc/repository/kim-query. -NOTE: The current list of supported query functions is available on the OpenKIM -webpage at "https://query.openkim.org"_https://query.openkim.org/ +NOTE: All query functions require the {model} keyword, which identifies +the IM whose predictions are being queried. This keyword is automatically +generated by {kim_query} based on the IM set in {kim_init} and must not +be specified as an argument to {kim_query}. + +NOTE: Each {query_function} is associated with a default method (implemented +as a "KIM Test"_https://openkim.org/getting-started/kim-tests/) +used to compute this property. In cases where there are multiple +methods in OpenKIM for computing a property, a {method} keyword can +be provided to select the method of choice. See the +"query documentation"_https://openkim.org/doc/repository/kim-query +to see which methods are available for a given {query function}. + +{kim_query} Usage Examples and Further Clarifications: :h6 The data obtained by {kim_query} commands can be used as part of the setup or analysis phases of LAMMPS simulations. Some examples are given below. @@ -372,7 +385,7 @@ or analysis phases of LAMMPS simulations. Some examples are given below. kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal boundary p p p -kim_query a0 get_lattice_constant_fcc species=\["Al"\] units=\["angstrom"\] +kim_query a0 get_lattice_constant_cubic crystal=\["fcc"\] species=\["Al"\] units=\["angstrom"\] lattice fcc $\{a0\} ... :pre @@ -389,11 +402,12 @@ Note that in {unit_conversion_mode} the results obtained from a For example, in the above script, the lattice command would need to be changed to: "lattice fcc $\{a0\}*$\{_u_distance\}". +:link(split_example) [Define an equilibrium hcp crystal] kim_init EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000 metal boundary p p p -kim_query latconst split get_lattice_constant_hcp species=\["Zr"\] units=\["angstrom"\] +kim_query latconst split get_lattice_constant_hexagonal crystal=\["hcp"\] species=\["Zr"\] units=\["angstrom"\] variable a0 equal latconst_1 variable c0 equal latconst_2 variable c_to_a equal $\{c0\}/$\{a0\} @@ -414,16 +428,27 @@ the returned values is determined by the type of query performed. kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal boundary p p p -kim_query a0 get_lattice_constant_fcc species=\["Al"\] units=\["angstrom"\] -kim_query alpha get_linear_thermal_expansion_fcc species=\["Al"\] units=\{"1/K"\} +kim_query a0 get_lattice_constant_cubic crystal=\["fcc"\] species=\["Al"\] units=\["angstrom"\] +kim_query alpha get_linear_thermal_expansion_constant_cubic crystal=\["fcc"\] species=\["Al"\] units=\{"1/K"\} temperature=[293.15] temperature_units=["K"] variable DeltaT equal 300 lattice fcc $\{a0\}*$\{alpha\}*$\{DeltaT\} ... :pre As in the previous example, the equilibrium lattice constant is obtained for the Ercolessi and Adams (1994) potential. However, in this case the -crystal is scaled to the appropriate lattice constant at 300 K by using -the linear thermal expansion coefficient predicted by the potential. +crystal is scaled to the appropriate lattice constant at room temperature +(293.15 K) by using the linear thermal expansion constant predicted by the +potential. + +NOTE: When passing numerical values as arguments (as in the case +of the temperature in the above example) it is also possible to pass a +tolerance indicating how close to the value is considered a match. +If no tolerance is passed a default value is used. If multiple results +are returned (indicating that the tolerance is too large), {kim_query} +will return an error. See the +"query documentation"_https://openkim.org/doc/repository/kim-query +to see which numerical arguments and tolerances are available for a +given {query function}. [Compute defect formation energy] @@ -432,7 +457,7 @@ kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal ... Build fcc crystal containing some defect and compute the total energy ... which is stored in the variable {Etot} ... -kim_query Ec get_cohesive_energy_fcc species=\["Al"\] units=\["eV"\] +kim_query Ec get_cohesive_energy_cubic crystal=\["fcc"\] species=\["Al"\] units=\["eV"\] variable Eform equal $\{Etot\} - count(all)*$\{Ec\} ... :pre From b61b48235b3e3551a6ad71e188995d6532a5a622 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Tue, 16 Jul 2019 15:19:28 -0500 Subject: [PATCH 081/107] Updated openkim.org documentation URLs to new /doc/* locations --- doc/src/kim_commands.txt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 46e437a871..7c88fd084a 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -57,17 +57,17 @@ Reliability :h5 All content archived in OpenKIM is reviewed by the "KIM Editor"_https://openkim.org/governance/ for quality. IMs in OpenKIM are archived with full provenance control. Each is associated with a maintainer responsible for the integrity of the content. All changes are tracked and recorded. -IMs in OpenKIM are exhaustively tested using "KIM Tests"_https://openkim.org/getting-started/kim-tests/ that compute a host of material properties, and "KIM Verification Checks"_https://openkim.org/about-verification-checks/ that provide the user with information on various aspects of the IM behavior and coding correctness. This information is displayed on the IM's page accessible through the "OpenKIM browse interface"_https://openkim.org/browse. :ul +IMs in OpenKIM are exhaustively tested using "KIM Tests"_https://openkim.org/doc/evaluation/kim-tests/ that compute a host of material properties, and "KIM Verification Checks"_https://openkim.org/doc/evaluation/kim-verification-checks/ that provide the user with information on various aspects of the IM behavior and coding correctness. This information is displayed on the IM's page accessible through the "OpenKIM browse interface"_https://openkim.org/browse. :ul Reproducibility :h5 -Each IM in OpenKIM is issued a unique identifier ("KIM ID"_https://openkim.org/about-kim-ids/), which includes a version number (last three digits). Any changes that can result in different numerical values lead to a version increment in the KIM ID. This makes it possible to reproduce simulations since the specific version of a specific IM used can be retrieved using its KIM ID. +Each IM in OpenKIM is issued a unique identifier ("KIM ID"_https://openkim.org/doc/schema/kim-ids/), which includes a version number (last three digits). Any changes that can result in different numerical values lead to a version increment in the KIM ID. This makes it possible to reproduce simulations since the specific version of a specific IM used can be retrieved using its KIM ID. OpenKIM is a member organization of "DataCite"_https://datacite.org/ and issues digital object identifiers (DOIs) to all IMs archived in OpenKIM. This makes it possible to cite the IM code used in a simulation in a publications to give credit to the developers and further facilitate reproducibility. :ul Convenience :h5 IMs in OpenKIM are distributed in binary form along with LAMMPS and can be used in a LAMMPS input script simply by providing their KIM ID in the {kim_init} command documented on this page. -The {kim_query} web query tool provides the ability to use the predictions of IMs for supported material properties (computed via "KIM Tests"_https://openkim.org/getting-started/kim-tests/) as part of a LAMMPS input script setup and analysis. +The {kim_query} web query tool provides the ability to use the predictions of IMs for supported material properties (computed via "KIM Tests"_https://openkim.org/doc/evaluation/kim-tests/) as part of a LAMMPS input script setup and analysis. Support is provided for unit conversion between the "unit style"_units.html used in the LAMMPS input script and the units required by the OpenKIM IM. This makes it possible to use a single input script with IMs using different units without change and minimizes the likelihood of errors due to incompatible units. :ul :link(IM_types) @@ -80,10 +80,11 @@ The second type is called a {KIM Simulator Model} (SM). A KIM SM is an IM that i With these two IM types, OpenKIM can archive and test almost all IMs that can be used by LAMMPS. (It is easy to contribute new IMs to OpenKIM, see -the "upload instructions"_https://openkim.org/getting-started/adding-content/.) +the "upload instructions"_https://openkim.org/doc/repository/adding-content/.) OpenKIM IMs are uniquely identified by a -"KIM ID"_https://openkim.org/about-kim-ids/. The extended KIM ID consists of +"KIM ID"_https://openkim.org/doc/schema/kim-ids/. +The extended KIM ID consists of a human-readable prefix identifying the type of IM, authors, publication year, and supported species, separated by two underscores from the KIM ID itself, which begins with an IM code @@ -100,7 +101,7 @@ authorship and citation information, test and verification check results, visualizations of results, a wiki with documentation and user comments, and access to raw files, and other information. The URL for the Model Page is constructed from the -"extended KIM ID"_https://openkim.org/about-kim-ids/ of the IM: +"extended KIM ID"_https://openkim.org/doc/schema/kim-ids/ of the IM: https://openkim.org/id/extended_KIM_ID :pre @@ -141,7 +142,7 @@ would not include {units} and {atom_style} commands. The required arguments of {kim_init} are the {model} name of the IM to be used in the simulation (for an IM archived in OpenKIM this is -its "extended KIM ID"_https://openkim.org/about-kim-ids/), and +its "extended KIM ID"_https://openkim.org/doc/schema/kim-ids/, and the {user_units}, which are the LAMMPS "units style"_units.html used in the input script. (Any dimensioned numerical values in the input script and values read in from files are expected to be in the @@ -219,7 +220,7 @@ _u_density :pre If desired, the input script can be designed to work with these conversion factors so that the script will work without change with any OpenKIM IM. (This approach is used in the -"OpenKIM Testing Framework"_https://openkim.org/getting-started/kim-tests/.) +"OpenKIM Testing Framework"_https://openkim.org/doc/evaluation/kim-tests/.) For example, the script given above for the cohesive energy of fcc Al can be rewritten to work with any IM regardless of units. The following script constructs an fcc lattice with a lattice parameter defined in @@ -369,7 +370,7 @@ generated by {kim_query} based on the IM set in {kim_init} and must not be specified as an argument to {kim_query}. NOTE: Each {query_function} is associated with a default method (implemented -as a "KIM Test"_https://openkim.org/getting-started/kim-tests/) +as a "KIM Test"_https://openkim.org/doc/evaluation/kim-tests/) used to compute this property. In cases where there are multiple methods in OpenKIM for computing a property, a {method} keyword can be provided to select the method of choice. See the From 5b4f77b919b251ba8130abb9b15946999f738faa Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Tue, 16 Jul 2019 16:20:48 -0500 Subject: [PATCH 082/107] kim_query check for explicit 'model=' key in arguments (give error if present). --- src/KIM/kim_query.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index 6e77b8f859..dc8d0544f6 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -113,6 +113,13 @@ void KimQuery::command(int narg, char **arg) narg--; } function = arg[1]; + for (int i = 2; i < narg; ++i) + { + if (0 == strncmp("model=",arg[i], 6)) { + error->all(FLERR,"Illegal 'model' key in kim_query command"); + } + } + #if defined(LMP_KIM_CURL) @@ -258,9 +265,9 @@ char *do_query(char *qfunction, char * model_name, int narg, char **arg, if (value[0] == '[') { int len = strlen(value)-1; - if (value[len-1] == ']') { + if (value[len] == ']') { retval = new char[len]; - value[len-1] = '\0'; + value[len] = '\0'; strcpy(retval,value+1); } else { retval = new char[len+2]; From 354f4d19fd67094ca50ef83cb627abdf85f9a087 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Tue, 16 Jul 2019 22:11:23 -0500 Subject: [PATCH 083/107] Update to kim-api-2.1.0 release --- cmake/Modules/Packages/KIM.cmake | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 5803ea23c4..5c0b8e2ee8 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -21,10 +21,8 @@ if(PKG_KIM) enable_language(Fortran) include(ExternalProject) ExternalProject_Add(kim_build - 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 + URL https://s3.openkim.org/kim-api/kim-api-2.1.0.txz + URL_MD5 9ada58e677a545a1987b1ecb98e39d7e BINARY_DIR build CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} From f2978475afd78e28232289b19b7bd7b1fbe2d7a2 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Sun, 21 Jul 2019 15:17:53 -0500 Subject: [PATCH 084/107] Update docs * bring homebrew install notes up-to-date * update openkim docs --- doc/src/Build_extras.txt | 18 ++++++---------- doc/src/Examples.txt | 4 +++- doc/src/Install_mac.txt | 43 +++++++++++++------------------------- doc/src/Intro_features.txt | 4 ++-- doc/src/fix_adapt.txt | 3 +-- doc/src/kim_commands.txt | 3 +++ 6 files changed, 30 insertions(+), 45 deletions(-) diff --git a/doc/src/Build_extras.txt b/doc/src/Build_extras.txt index 1d9a7abfcf..e6791de21b 100644 --- a/doc/src/Build_extras.txt +++ b/doc/src/Build_extras.txt @@ -176,19 +176,13 @@ use with LAMMPS. If you want to use the "kim_query"_kim_commands.html command, you also need to have libcurl installed with the matching development headers and the curl-config tool. -Note that in LAMMPS jargon, a KIM model driver is a pair style -(e.g. EAM or Tersoff). A KIM model is a pair style for a particular -element or alloy and set of parameters, e.g. EAM for Cu with a -specific EAM potential file. Also note that when downloading and -installing from source +See "Obtaining KIM Models"_http://openkim.org/doc/usage/obtaining-models to +learn how to install a pre-build binary of the OpenKIM Repository of Models. +See the list of all KIM models here: https://openkim.org/browse/models + +(Also note that when downloading and installing from source the KIM API library with all its models, may take a long time (tens of -minutes to hours) to build. Of course you only need to do that once. - -See the list of KIM model drivers here: -https://openkim.org/browse/model-drivers/alphabetical - -See the list of all KIM models here: -https://openkim.org/browse/models/by-model-drivers +minutes to hours) to build. Of course you only need to do that once.) [CMake build]: diff --git a/doc/src/Examples.txt b/doc/src/Examples.txt index fcf01de383..36d0ac86f9 100644 --- a/doc/src/Examples.txt +++ b/doc/src/Examples.txt @@ -73,7 +73,7 @@ granregion: use of fix wall/region/gran as boundary on granular particles hugoniostat: Hugoniostat shock dynamics hyper: global and local hyperdynamics of diffusion on Pt surface indent: spherical indenter into a 2d solid -kim: use of potentials in Knowledge Base for Interatomic Models (KIM) +kim: use of potentials from the "OpenKIM Repository"_openkim latte: examples for using fix latte for DFTB via the LATTE library meam: MEAM test for SiC and shear (same as shear examples) melt: rapid melt of 3d LJ system @@ -153,3 +153,5 @@ illustrate how to use the command(s) provided in that package. Many of the sub-directories have their own README files which give further instructions. See the "Packages_details"_Packages_details.html doc page for more info on specific USER packages. + +:link(openkim,https://openkim.org) diff --git a/doc/src/Install_mac.txt b/doc/src/Install_mac.txt index 3ab119522c..e277f7e0e4 100644 --- a/doc/src/Install_mac.txt +++ b/doc/src/Install_mac.txt @@ -10,47 +10,34 @@ Documentation"_ld - "LAMMPS Commands"_lc :c Download an executable for Mac :h3 LAMMPS can be downloaded, built, and configured for OS X on a Mac with -"Homebrew"_homebrew. Only four of the LAMMPS packages are unavailable -at this time because of additional needs not yet met: KIM, GPU, -USER-INTEL, USER-ATC. +"Homebrew"_homebrew. The following LAMMPS packages are unavailable at this +time because of additional needs not yet met: GPU, KOKKOS, LATTE, MSCG, +MESSAGE, MPIIO POEMS VORONOI. After installing Homebrew, you can install LAMMPS on your system with the following commands: -% brew tap homebrew/science -% brew install lammps # serial version -% brew install lammps --with-mpi # mpi support :pre +% brew install lammps :pre -This will install the executable "lammps", a python module named -"lammps", and additional resources with all the standard packages. To -get the location of the additional resources type this: - -% brew info lammps :pre - -This command also tells you additional installation options available. -The user-packages are available as options, just install them like -this example for the USER-OMP package: - -% brew install lammps --enable-user-omp :pre - -It is usually best to install LAMMPS with the most up to date source -files, which can be done with the "--HEAD" option: - -% brew install lammps --HEAD :pre - -To re-install the LAMMPS HEAD, run this command occasionally (make sure -to use the desired options). - -% brew install --force lammps --HEAD $\{options\} :pre +This will install the executables "lammps_serial" and "lammps_mpi", as well as +the LAMMPS "doc", "potentials", "tools", "bench", and "examples" directories. Once LAMMPS is installed, you can test the installation with the Lennard-Jones benchmark file: % brew test lammps -v :pre +The LAMMPS binary is built with the "KIM package"_Build_extras#kim which +results in homebrew also installing the `kim-api` binaries when LAMMPS is +installed. In order to use potentials from "openkim.org"_openkim, you can +install the `openkim-models` package + +% brew install openkim-models :pre + If you have problems with the installation you can post issues to "this link"_homebrew. Thanks to Derek Thomas (derekt at cello.t.u-tokyo.ac.jp) for setting up the Homebrew capability. -:link(homebrew,https://github.com/Homebrew/homebrew-science/issues) +:link(homebrew,https://github.com/Homebrew/homebrew-core/issues) +:link(openkim,https://openkim.org) diff --git a/doc/src/Intro_features.txt b/doc/src/Intro_features.txt index 629e8210b7..d133fd8064 100644 --- a/doc/src/Intro_features.txt +++ b/doc/src/Intro_features.txt @@ -92,8 +92,8 @@ commands) implicit solvent potentials: hydrodynamic lubrication, Debye force-field compatibility with common CHARMM, AMBER, DREIDING, \ OPLS, GROMACS, COMPASS options - access to "KIM archive"_http://openkim.org of potentials via \ - "pair kim"_pair_kim.html + access to the "OpenKIM Repository"_http://openkim.org of potentials via \ + "kim_init, kim_interactions, and kim_query"_kim_commands.html commands hybrid potentials: multiple pair, bond, angle, dihedral, improper \ potentials can be used in one simulation overlaid potentials: superposition of multiple pair potentials :ul diff --git a/doc/src/fix_adapt.txt b/doc/src/fix_adapt.txt index 0d862a890d..4f047ec42d 100644 --- a/doc/src/fix_adapt.txt +++ b/doc/src/fix_adapt.txt @@ -149,8 +149,7 @@ meaning of these parameters: "spin/neel"_pair_spin_neel.html: coulombic_cutoff: type global: "table"_pair_table.html: table_cutoff: type pairs: "ufm"_pair_ufm.html: epsilon,sigma: type pairs: -"soft"_pair_soft.html: a: type pairs: -"kim"_pair_kim.html: PARAM_FREE_*:i,j,...: global :tb(c=3,s=:) +"soft"_pair_soft.html: a: type pairs: :tb(c=3,s=:) NOTE: It is easy to add new pairwise potentials and their parameters to this list. All it typically takes is adding an extract() method to diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 7c88fd084a..169f96e6e8 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -116,6 +116,9 @@ See the "current list of KIM PMs and SMs archived in OpenKIM"_https://openkim.or This list is sorted by species and can be filtered to display only IMs for certain species combinations. +See "Obtaining KIM Models"_http://openkim.org/doc/usage/obtaining-models to +learn how to install a pre-build binary of the OpenKIM Repository of Models. + NOTE: It is also possible to locally install IMs not archived in OpenKIM, in which case their names do not have to conform to the KIM ID format. From f5beb418e8e983d6eb32908cb1da18168b0820ca Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Mon, 22 Jul 2019 10:54:53 -0500 Subject: [PATCH 085/107] Put in KIM ID for IFF model in kim_commands usage examples --- doc/src/kim_commands.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 7c88fd084a..dbe0608b5e 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -33,7 +33,7 @@ kim_interactions Si kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 real kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 metal unit_conversion_mode kim_interactions C H O -kim_init Sim_LAMMPS_IFF_OtherInfo_AuthorList_Year_Species__SM_064312669787_000 real +Sim_LAMMPS_IFF_PCFF_HeinzMishraLinEmami_2015Ver1v5_FccmetalsMineralsSolvents Polymers__SM_064312669787_000 real kim_interactions fixed_types kim_query a0 get_lattice_constant_cubic crystal=\["fcc"\] species=\["Al"\] units=\["angstrom"\] :pre From dd4368dd1b471134629486e590a6624a66265c8f Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Tue, 23 Jul 2019 13:40:13 -0500 Subject: [PATCH 086/107] Fix bug in pair_kim.cpp for partialParticleVirial computation --- src/KIM/pair_kim.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index 6251ebb6c7..50eef1de2b 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -826,7 +826,7 @@ void PairKIM::set_argument_pointers() } 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])); + pargs, KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial, &(vatom[0][0])); } if (kimerror) error->all(FLERR,"Unable to set KIM argument pointers"); From be86db9dd9cde416f0136b282c830e9bf231c59a Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Tue, 23 Jul 2019 21:06:02 -0500 Subject: [PATCH 087/107] Update /lib/kim stuff --- lib/kim/Install.py | 11 ++++------- lib/kim/README | 22 ++++++++++------------ 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/lib/kim/Install.py b/lib/kim/Install.py index c3588241c4..de22950639 100644 --- a/lib/kim/Install.py +++ b/lib/kim/Install.py @@ -18,7 +18,7 @@ parser = ArgumentParser(prog='Install.py', # settings thisdir = fullpath('.') -version = "kim-api-2.0.2" +version = "kim-api-2.1.1" # help message @@ -39,11 +39,8 @@ make lib-kim args="-b -a EAM_ErcolessiAdams_1994_Al__MO_324507536345_002" # Ditt make lib-kim args="-b -a everything" # install KIM API lib with all models make lib-kim args="-n -a EAM_Dynamo_Ackland_2003_W__MO_141627196590_005" # only add one model or model driver -See the list of KIM model drivers here: -https://openkim.org/browse/model-drivers/alphabetical - See the list of all KIM models here: -https://openkim.org/browse/models/by-model-drivers +https://openkim.org/browse/models """ pgroup = parser.add_mutually_exclusive_group() @@ -132,7 +129,7 @@ if buildflag: # build kim-api print("Building kim-api ...") - cmd = 'cd "%s/%s/build" && make' % (thisdir, version) + cmd = 'cd "%s/%s/build" && make -j2' % (thisdir, version) txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) if verboseflag: print(txt.decode("UTF-8")) @@ -140,7 +137,7 @@ if buildflag: # install kim-api print("Installing kim-api ...") - cmd = 'cd "%s/%s/build" && make install' % (thisdir, version) + cmd = 'cd "%s/%s/build" && make -j2 install' % (thisdir, version) txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) if verboseflag: print(txt.decode("UTF-8")) diff --git a/lib/kim/README b/lib/kim/README index d3327537b6..3cba4a4597 100644 --- a/lib/kim/README +++ b/lib/kim/README @@ -1,11 +1,11 @@ -This directory contains build settings for the KIM API library which -is required to use the KIM package and its pair_style kim command in a -LAMMPS input script. +This directory contains build settings for the KIM API library which is +required to use the KIM package and its kim_init, kim_interactions, kim_query, +and pair_kim commands in a LAMMPS input script. Information about the KIM project can be found at https://openkim.org. The KIM project is lead by Ellad Tadmor and Ryan Elliott (U Minn). Ryan Elliott is the main developer for the KIM API and he also -maintains the code that implements the pair_style kim command. +maintains the code that implements the KIM commands. You can type "make lib-kim" from the src directory to see help on how to download and build this library via make commands, or you can @@ -13,11 +13,9 @@ do the same thing by typing "python Install.py" from within this directory, or you can do it manually by following the instructions below. -As of KIM API version 2, the KIM package also provides a LAMMPS command -to perform queries through the OpenKIM web API. This feature requires -that the CURL library (libcurl) development package and its configuration -query tool, curl-config, are installed. The provided Makefile.lammps -is set up to automatically detect this. +Use of the kim_query command requires that the CURL library (libcurl) +development package and its configuration query tool, curl-config, are +installed. The provided Makefile.lammps is set up to automatically detect this. ----------------- @@ -40,8 +38,8 @@ $ cmake .. -DCMAKE_INSTALL_PREFIX=${PWD}/../../installed-kim-api-X.Y.Z 3. Build and install the kim-api and model -$ make -$ make install +$ make -j2 +$ make -j2 install 4. Remove source and build files @@ -53,7 +51,7 @@ $ rm -rf kim-api-X.Y.Z.txz desired value) $ source ${PWD}/kim-api-X.Y.Z/bin/kim-api-activate -$ kim-api-collections-management install system Pair_Johnson_Fe__MO_857282754307_002 +$ kim-api-collections-management install system EAM_ErcolessiAdams_1994_Al__MO_324507536345_002 ----------------- From 3bc4a07c74aac582a9e74ce429abb4564e224cfd Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Wed, 24 Jul 2019 11:23:51 -0500 Subject: [PATCH 088/107] Corrections to kim_query in example --- doc/src/kim_commands.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 01df0532b7..6fe7d7ba3e 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -433,7 +433,7 @@ the returned values is determined by the type of query performed. kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal boundary p p p kim_query a0 get_lattice_constant_cubic crystal=\["fcc"\] species=\["Al"\] units=\["angstrom"\] -kim_query alpha get_linear_thermal_expansion_constant_cubic crystal=\["fcc"\] species=\["Al"\] units=\{"1/K"\} temperature=[293.15] temperature_units=["K"] +kim_query alpha get_linear_thermal_expansion_coefficient_cubic crystal=\["fcc"\] species=\["Al"\] units=\["1/K"\] temperature=\[293.15\] temperature_units=\["K"\] variable DeltaT equal 300 lattice fcc $\{a0\}*$\{alpha\}*$\{DeltaT\} ... :pre From 3887a7f3d79559eb47d82e989a71ed1abf6a0320 Mon Sep 17 00:00:00 2001 From: Ellad Tadmor Date: Wed, 24 Jul 2019 12:07:38 -0500 Subject: [PATCH 089/107] Updated KIM ID code for IFF SM --- doc/src/kim_commands.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 6fe7d7ba3e..dd61f6f5cc 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -33,7 +33,7 @@ kim_interactions Si kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 real kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 metal unit_conversion_mode kim_interactions C H O -Sim_LAMMPS_IFF_PCFF_HeinzMishraLinEmami_2015Ver1v5_FccmetalsMineralsSolvents Polymers__SM_064312669787_000 real +Sim_LAMMPS_IFF_PCFF_HeinzMishraLinEmami_2015Ver1v5_FccmetalsMineralsSolvents Polymers__SM_039297821658_000 real kim_interactions fixed_types kim_query a0 get_lattice_constant_cubic crystal=\["fcc"\] species=\["Al"\] units=\["angstrom"\] :pre From b5a066ecd023495b252f3dfab7a8aedce0ac77bc Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Wed, 24 Jul 2019 21:08:08 -0500 Subject: [PATCH 090/107] Better error checking for kim_init log.cite behavior --- src/KIM/kim_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 5fb6748427..83638f3428 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -486,7 +486,7 @@ void KimInit::write_log_cite(char * model_name) if (0 == strncmp("kimcite",fileName,7)) { - if (lmp->citeme) lmp->citeme->add(fileString); + if ((lmp->citeme) && (availableAsString)) lmp->citeme->add(fileString); } } From ca291f1015a1606c3f529ad69f42b98697ae9fb7 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Thu, 25 Jul 2019 11:47:56 -0500 Subject: [PATCH 091/107] Update to kim-api-2.1.1 --- cmake/Modules/Packages/KIM.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 5c0b8e2ee8..1a9dcf83a4 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -21,8 +21,8 @@ if(PKG_KIM) enable_language(Fortran) include(ExternalProject) ExternalProject_Add(kim_build - URL https://s3.openkim.org/kim-api/kim-api-2.1.0.txz - URL_MD5 9ada58e677a545a1987b1ecb98e39d7e + URL https://s3.openkim.org/kim-api/kim-api-2.1.1.txz + URL_MD5 ae0ee413e026c6e93d35692db5966fb4 BINARY_DIR build CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} From fadb40051ba753d6534d7f6d128dc3eb1e00fe69 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Thu, 25 Jul 2019 14:03:35 -0500 Subject: [PATCH 092/107] Update kim_query & clear and update examples/kim --- ....kim.lj.simulator_model => in.kim-ex.melt} | 6 +- examples/kim/in.kim-pm-query.melt | 37 +++++ .../{in.kim.lj.newton-off => in.kim-pm.melt} | 19 +-- examples/kim/in.kim-sm.melt | 36 +++++ examples/kim/in.kim.lj.lmp.newton-off | 35 ----- examples/kim/in.kim.lj.newton-on | 41 ------ ...in.kim.lj.lmp.newton-on => in.lammps.melt} | 4 +- examples/kim/in.query | 12 -- .../log.06Feb2019.in.kim.lj.lmp.newton-off.1 | 55 -------- .../log.06Feb2019.in.kim.lj.lmp.newton-off.4 | 55 -------- .../log.06Feb2019.in.kim.lj.lmp.newton-on.1 | 55 -------- .../log.06Feb2019.in.kim.lj.lmp.newton-on.4 | 55 -------- .../kim/log.06Feb2019.in.kim.lj.newton-off.1 | 59 -------- .../kim/log.06Feb2019.in.kim.lj.newton-off.4 | 65 --------- .../kim/log.06Feb2019.in.kim.lj.newton-on.1 | 59 -------- .../kim/log.06Feb2019.in.kim.lj.newton-on.4 | 65 --------- examples/kim/log.22Mar2019.query.g++.1 | 34 ----- ...og.30Apr2019.kim.VOH.simulator_model.g++.1 | 92 ------------ ....30Apr2019.kim.ex_si.simulator_model.g++.1 | 132 ------------------ ....30Apr2019.kim.ex_si.simulator_model.g++.4 | 132 ------------------ ...log.30Apr2019.kim.lj.simulator_model.g++.1 | 104 -------------- ...log.30Apr2019.kim.lj.simulator_model.g++.4 | 104 -------------- src/KIM/kim_query.cpp | 3 +- 23 files changed, 86 insertions(+), 1173 deletions(-) rename examples/kim/{in.kim.lj.simulator_model => in.kim-ex.melt} (82%) create mode 100644 examples/kim/in.kim-pm-query.melt rename examples/kim/{in.kim.lj.newton-off => in.kim-pm.melt} (52%) create mode 100644 examples/kim/in.kim-sm.melt delete mode 100644 examples/kim/in.kim.lj.lmp.newton-off delete mode 100644 examples/kim/in.kim.lj.newton-on rename examples/kim/{in.kim.lj.lmp.newton-on => in.lammps.melt} (91%) delete mode 100644 examples/kim/in.query delete mode 100644 examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-off.1 delete mode 100644 examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-off.4 delete mode 100644 examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-on.1 delete mode 100644 examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-on.4 delete mode 100644 examples/kim/log.06Feb2019.in.kim.lj.newton-off.1 delete mode 100644 examples/kim/log.06Feb2019.in.kim.lj.newton-off.4 delete mode 100644 examples/kim/log.06Feb2019.in.kim.lj.newton-on.1 delete mode 100644 examples/kim/log.06Feb2019.in.kim.lj.newton-on.4 delete mode 100644 examples/kim/log.22Mar2019.query.g++.1 delete mode 100644 examples/kim/log.30Apr2019.kim.VOH.simulator_model.g++.1 delete mode 100644 examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.1 delete mode 100644 examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.4 delete mode 100644 examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.1 delete mode 100644 examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.4 diff --git a/examples/kim/in.kim.lj.simulator_model b/examples/kim/in.kim-ex.melt similarity index 82% rename from examples/kim/in.kim.lj.simulator_model rename to examples/kim/in.kim-ex.melt index cb7a2e14ed..5cc3dbc61b 100644 --- a/examples/kim/in.kim.lj.simulator_model +++ b/examples/kim/in.kim-ex.melt @@ -14,15 +14,14 @@ variable xx equal 20*$x variable yy equal 20*$y variable zz equal 20*$z -kim_init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu real unit_conversion_mode -newton on +kim_init LennardJones_Ar real lattice fcc 4.4300 region box block 0 ${xx} 0 ${yy} 0 ${zz} create_box 1 box create_atoms 1 box -kim_interactions Au +kim_interactions Ar mass 1 39.95 velocity all create 200.0 232345 loop geom @@ -31,5 +30,6 @@ 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 diff --git a/examples/kim/in.kim-pm-query.melt b/examples/kim/in.kim-pm-query.melt new file mode 100644 index 0000000000..d39dd2d464 --- /dev/null +++ b/examples/kim/in.kim-pm-query.melt @@ -0,0 +1,37 @@ +# 3d Lennard-Jones melt +# +# This example requires that the KIM Portable Model (PM) +# SW_StillingerWeber_1985_Si__MO_405512056662_005 +# is installed. This can be done with the command +# kim-api-collections-management install user SW_StillingerWeber_1985_Si__MO_405512056662_005 +# Or, see https://openkim.org/doc/obtaining-models for alternative options. +# + +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 + +kim_init SW_StillingerWeber_1985_Si__MO_405512056662_005 real +kim_query a0 get_lattice_constant_cubic crystal=["fcc"] species=["Si"] units=["angstrom"] + +lattice fcc ${a0} +region box block 0 ${xx} 0 ${yy} 0 ${zz} +create_box 1 box +create_atoms 1 box + +kim_interactions Si + +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 diff --git a/examples/kim/in.kim.lj.newton-off b/examples/kim/in.kim-pm.melt similarity index 52% rename from examples/kim/in.kim.lj.newton-off rename to examples/kim/in.kim-pm.melt index 82cf5ba602..999cf77180 100644 --- a/examples/kim/in.kim.lj.newton-off +++ b/examples/kim/in.kim-pm.melt @@ -1,9 +1,10 @@ # 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. +# This example requires that the KIM Portable Model (PM) +# SW_StillingerWeber_1985_Si__MO_405512056662_005 +# is installed. This can be done with the command +# kim-api-collections-management install user SW_StillingerWeber_1985_Si__MO_405512056662_005 +# Or, see https://openkim.org/doc/obtaining-models for alternative options. # variable x index 1 @@ -14,20 +15,14 @@ variable xx equal 20*$x variable yy equal 20*$y variable zz equal 20*$z -units metal -atom_style atomic -newton off +kim_init SW_StillingerWeber_1985_Si__MO_405512056662_005 real 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 LennardJones_Ar -pair_coeff * * Ar +kim_interactions Si mass 1 39.95 velocity all create 200.0 232345 loop geom diff --git a/examples/kim/in.kim-sm.melt b/examples/kim/in.kim-sm.melt new file mode 100644 index 0000000000..32f8c6170f --- /dev/null +++ b/examples/kim/in.kim-sm.melt @@ -0,0 +1,36 @@ +# 3d Lennard-Jones melt +# +# This example requires that the KIM Simulator Model (PM) +# Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 +# is installed. This can be done with the command +# kim-api-collections-management install user Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 +# Or, see https://openkim.org/doc/obtaining-models for alternative options. +# + +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 + +kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 real + +lattice fcc 4.4300 +region box block 0 ${xx} 0 ${yy} 0 ${zz} +create_box 1 box +create_atoms 1 box + +kim_interactions O + +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 diff --git a/examples/kim/in.kim.lj.lmp.newton-off b/examples/kim/in.kim.lj.lmp.newton-off deleted file mode 100644 index 197755294a..0000000000 --- a/examples/kim/in.kim.lj.lmp.newton-off +++ /dev/null @@ -1,35 +0,0 @@ -# 3d Lennard-Jones melt - -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 LennardJones_Ar -#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 diff --git a/examples/kim/in.kim.lj.newton-on b/examples/kim/in.kim.lj.newton-on deleted file mode 100644 index 3a95f1dbb0..0000000000 --- a/examples/kim/in.kim.lj.newton-on +++ /dev/null @@ -1,41 +0,0 @@ -# 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 on - -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 LennardJones_Ar -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 diff --git a/examples/kim/in.kim.lj.lmp.newton-on b/examples/kim/in.lammps.melt similarity index 91% rename from examples/kim/in.kim.lj.lmp.newton-on rename to examples/kim/in.lammps.melt index f9f79e2bb2..5792f3a5db 100644 --- a/examples/kim/in.kim.lj.lmp.newton-on +++ b/examples/kim/in.lammps.melt @@ -8,9 +8,7 @@ variable xx equal 20*$x variable yy equal 20*$y variable zz equal 20*$z -units metal -atom_style atomic -newton on +units real lattice fcc 4.4300 region box block 0 ${xx} 0 ${yy} 0 ${zz} diff --git a/examples/kim/in.query b/examples/kim/in.query deleted file mode 100644 index 72e739fb52..0000000000 --- a/examples/kim/in.query +++ /dev/null @@ -1,12 +0,0 @@ - -# example for performing a query to the OpenKIM test database to retrieve -# a parameter to be used in the input. here it requests the aluminium -# lattice constant for a specific test used for a specific model and then -# assigns it to the variable 'latconst' - -kim_init EAM_CubicNaturalSpline_ErcolessiAdams_1994_Al__MO_800509458712_002 metal -info variables out log -kim_query latconst split get_test_result test=TE_156715955670 species=["Al"] prop=structure-cubic-crystal-npt keys=["a","a"] units=["angstrom","angstrom"] -info variables out log -lattice fcc ${latconst_1} -lattice fcc ${latconst_2} diff --git a/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-off.1 b/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-off.1 deleted file mode 100644 index 5925fd750d..0000000000 --- a/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-off.1 +++ /dev/null @@ -1,55 +0,0 @@ -LAMMPS (1 Feb 2019) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:87) - using 1 OpenMP thread(s) per MPI task -Lattice spacing in x,y,z = 4.43 4.43 4.43 -Created orthogonal box = (0 0 0) to (88.6 88.6 88.6) - 1 by 1 by 1 MPI processor grid -Created 32000 atoms - Time spent = 0.004499 secs -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 8.45 - ghost atom cutoff = 8.45 - binsize = 4.225, bins = 21 21 21 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair lj/cut, perpetual - attributes: half, newton off - pair build: half/bin/newtoff - stencil: half/bin/3d/newtoff - bin: standard -Setting up Verlet run ... - Unit style : metal - Current step : 0 - Time step : 0.001 -Per MPI rank memory allocation (min/avg/max) = 20.37 | 20.37 | 20.37 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 6290.8194 0 7118.0584 129712.25 - 100 95.179725 6718.814 0 7112.496 133346.59 -Loop time of 2.92885 on 1 procs for 100 steps with 32000 atoms - -Performance: 2.950 ns/day, 8.136 hours/ns, 34.143 timesteps/s -99.1% CPU use with 1 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 2.5638 | 2.5638 | 2.5638 | 0.0 | 87.54 -Neigh | 0.31935 | 0.31935 | 0.31935 | 0.0 | 10.90 -Comm | 0.006833 | 0.006833 | 0.006833 | 0.0 | 0.23 -Output | 0.000107 | 0.000107 | 0.000107 | 0.0 | 0.00 -Modify | 0.027806 | 0.027806 | 0.027806 | 0.0 | 0.95 -Other | | 0.01091 | | | 0.37 - -Nlocal: 32000 ave 32000 max 32000 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 19911 ave 19911 max 19911 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 2.3705e+06 ave 2.3705e+06 max 2.3705e+06 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 2370499 -Ave neighs/atom = 74.0781 -Neighbor list builds = 3 -Dangerous builds = 0 -Total wall time: 0:00:03 diff --git a/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-off.4 b/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-off.4 deleted file mode 100644 index c1ca108c7b..0000000000 --- a/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-off.4 +++ /dev/null @@ -1,55 +0,0 @@ -LAMMPS (1 Feb 2019) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:87) - using 1 OpenMP thread(s) per MPI task -Lattice spacing in x,y,z = 4.43 4.43 4.43 -Created orthogonal box = (0 0 0) to (88.6 88.6 88.6) - 1 by 2 by 2 MPI processor grid -Created 32000 atoms - Time spent = 0.001039 secs -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 8.45 - ghost atom cutoff = 8.45 - binsize = 4.225, bins = 21 21 21 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair lj/cut, perpetual - attributes: half, newton off - pair build: half/bin/newtoff - stencil: half/bin/3d/newtoff - bin: standard -Setting up Verlet run ... - Unit style : metal - Current step : 0 - Time step : 0.001 -Per MPI rank memory allocation (min/avg/max) = 8.013 | 8.013 | 8.013 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 6290.8194 0 7118.0584 129712.25 - 100 95.179725 6718.814 0 7112.496 133346.59 -Loop time of 0.778581 on 4 procs for 100 steps with 32000 atoms - -Performance: 11.097 ns/day, 2.163 hours/ns, 128.439 timesteps/s -99.8% CPU use with 4 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0.65171 | 0.65891 | 0.67656 | 1.3 | 84.63 -Neigh | 0.07924 | 0.079548 | 0.07997 | 0.1 | 10.22 -Comm | 0.006755 | 0.0069015 | 0.007072 | 0.2 | 0.89 -Output | 4.6e-05 | 9.725e-05 | 0.000203 | 0.0 | 0.01 -Modify | 0.006841 | 0.006941 | 0.007015 | 0.1 | 0.89 -Other | | 0.02618 | | | 3.36 - -Nlocal: 8000 ave 8018 max 7967 min -Histogram: 1 0 0 0 0 0 1 0 0 2 -Nghost: 9131 ave 9164 max 9113 min -Histogram: 2 0 0 1 0 0 0 0 0 1 -Neighs: 630904 ave 632094 max 628209 min -Histogram: 1 0 0 0 0 0 0 1 0 2 - -Total # of neighbors = 2523614 -Ave neighs/atom = 78.8629 -Neighbor list builds = 3 -Dangerous builds = 0 -Total wall time: 0:00:00 diff --git a/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-on.1 b/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-on.1 deleted file mode 100644 index 53555743d7..0000000000 --- a/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-on.1 +++ /dev/null @@ -1,55 +0,0 @@ -LAMMPS (1 Feb 2019) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:87) - using 1 OpenMP thread(s) per MPI task -Lattice spacing in x,y,z = 4.43 4.43 4.43 -Created orthogonal box = (0 0 0) to (88.6 88.6 88.6) - 1 by 1 by 1 MPI processor grid -Created 32000 atoms - Time spent = 0.003479 secs -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 8.45 - ghost atom cutoff = 8.45 - binsize = 4.225, bins = 21 21 21 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair lj/cut, perpetual - attributes: half, newton on - pair build: half/bin/atomonly/newton - stencil: half/bin/3d/newton - bin: standard -Setting up Verlet run ... - Unit style : metal - Current step : 0 - Time step : 0.001 -Per MPI rank memory allocation (min/avg/max) = 19.23 | 19.23 | 19.23 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 6290.8194 0 7118.0584 129712.25 - 100 95.179725 6718.814 0 7112.496 133346.59 -Loop time of 2.17978 on 1 procs for 100 steps with 32000 atoms - -Performance: 3.964 ns/day, 6.055 hours/ns, 45.876 timesteps/s -99.9% CPU use with 1 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 1.9892 | 1.9892 | 1.9892 | 0.0 | 91.26 -Neigh | 0.14506 | 0.14506 | 0.14506 | 0.0 | 6.65 -Comm | 0.011049 | 0.011049 | 0.011049 | 0.0 | 0.51 -Output | 9.1e-05 | 9.1e-05 | 9.1e-05 | 0.0 | 0.00 -Modify | 0.02347 | 0.02347 | 0.02347 | 0.0 | 1.08 -Other | | 0.01094 | | | 0.50 - -Nlocal: 32000 ave 32000 max 32000 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 19911 ave 19911 max 19911 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 2.12688e+06 ave 2.12688e+06 max 2.12688e+06 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 2126875 -Ave neighs/atom = 66.4648 -Neighbor list builds = 3 -Dangerous builds = 0 -Total wall time: 0:00:02 diff --git a/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-on.4 b/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-on.4 deleted file mode 100644 index f0fdf66193..0000000000 --- a/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-on.4 +++ /dev/null @@ -1,55 +0,0 @@ -LAMMPS (1 Feb 2019) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:87) - using 1 OpenMP thread(s) per MPI task -Lattice spacing in x,y,z = 4.43 4.43 4.43 -Created orthogonal box = (0 0 0) to (88.6 88.6 88.6) - 1 by 2 by 2 MPI processor grid -Created 32000 atoms - Time spent = 0.000919 secs -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 8.45 - ghost atom cutoff = 8.45 - binsize = 4.225, bins = 21 21 21 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair lj/cut, perpetual - attributes: half, newton on - pair build: half/bin/atomonly/newton - stencil: half/bin/3d/newton - bin: standard -Setting up Verlet run ... - Unit style : metal - Current step : 0 - Time step : 0.001 -Per MPI rank memory allocation (min/avg/max) = 7.632 | 7.632 | 7.632 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 6290.8194 0 7118.0584 129712.25 - 100 95.179725 6718.814 0 7112.496 133346.59 -Loop time of 0.63515 on 4 procs for 100 steps with 32000 atoms - -Performance: 13.603 ns/day, 1.764 hours/ns, 157.443 timesteps/s -99.8% CPU use with 4 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0.55365 | 0.5566 | 0.55868 | 0.2 | 87.63 -Neigh | 0.041495 | 0.0418 | 0.04211 | 0.1 | 6.58 -Comm | 0.019086 | 0.021075 | 0.023898 | 1.2 | 3.32 -Output | 4.4e-05 | 5.025e-05 | 6e-05 | 0.0 | 0.01 -Modify | 0.009315 | 0.0093595 | 0.009422 | 0.0 | 1.47 -Other | | 0.006263 | | | 0.99 - -Nlocal: 8000 ave 8018 max 7967 min -Histogram: 1 0 0 0 0 0 1 0 0 2 -Nghost: 9131 ave 9164 max 9113 min -Histogram: 2 0 0 1 0 0 0 0 0 1 -Neighs: 531719 ave 533273 max 529395 min -Histogram: 1 0 0 0 1 0 0 0 0 2 - -Total # of neighbors = 2126875 -Ave neighs/atom = 66.4648 -Neighbor list builds = 3 -Dangerous builds = 0 -Total wall time: 0:00:00 diff --git a/examples/kim/log.06Feb2019.in.kim.lj.newton-off.1 b/examples/kim/log.06Feb2019.in.kim.lj.newton-off.1 deleted file mode 100644 index 0ab258fe0d..0000000000 --- a/examples/kim/log.06Feb2019.in.kim.lj.newton-off.1 +++ /dev/null @@ -1,59 +0,0 @@ -LAMMPS (1 Feb 2019) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:87) - using 1 OpenMP thread(s) per MPI task -Lattice spacing in x,y,z = 4.43 4.43 4.43 -Created orthogonal box = (0 0 0) to (88.6 88.6 88.6) - 1 by 1 by 1 MPI processor grid -Created 32000 atoms - Time spent = 0.003446 secs -WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:1097) -WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:1102) -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 8.45 - ghost atom cutoff = 8.45 - binsize = 4.225, bins = 21 21 21 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair kim, perpetual - attributes: full, newton off, cut 8.45 - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Setting up Verlet run ... - Unit style : metal - Current step : 0 - Time step : 0.001 -Per MPI rank memory allocation (min/avg/max) = 28.51 | 28.51 | 28.51 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 6290.8194 0 7118.0584 129712.25 - 100 95.179725 6718.814 0 7112.496 133346.59 -Loop time of 3.01669 on 1 procs for 100 steps with 32000 atoms - -Performance: 2.864 ns/day, 8.380 hours/ns, 33.149 timesteps/s -99.8% CPU use with 1 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 2.6562 | 2.6562 | 2.6562 | 0.0 | 88.05 -Neigh | 0.31903 | 0.31903 | 0.31903 | 0.0 | 10.58 -Comm | 0.00634 | 0.00634 | 0.00634 | 0.0 | 0.21 -Output | 9.1e-05 | 9.1e-05 | 9.1e-05 | 0.0 | 0.00 -Modify | 0.024723 | 0.024723 | 0.024723 | 0.0 | 0.82 -Other | | 0.01032 | | | 0.34 - -Nlocal: 32000 ave 32000 max 32000 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 19911 ave 19911 max 19911 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 0 ave 0 max 0 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 4.25375e+06 ave 4.25375e+06 max 4.25375e+06 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 4253750 -Ave neighs/atom = 132.93 -Neighbor list builds = 3 -Dangerous builds = 0 -Total wall time: 0:00:03 diff --git a/examples/kim/log.06Feb2019.in.kim.lj.newton-off.4 b/examples/kim/log.06Feb2019.in.kim.lj.newton-off.4 deleted file mode 100644 index c17ea6afb7..0000000000 --- a/examples/kim/log.06Feb2019.in.kim.lj.newton-off.4 +++ /dev/null @@ -1,65 +0,0 @@ -LAMMPS (1 Feb 2019) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:87) - using 1 OpenMP thread(s) per MPI task -Lattice spacing in x,y,z = 4.43 4.43 4.43 -Created orthogonal box = (0 0 0) to (88.6 88.6 88.6) - 1 by 2 by 2 MPI processor grid -Created 32000 atoms - Time spent = 0.000921 secs -WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:1097) -WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:1102) -WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:1097) -WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:1102) -WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:1097) -WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:1102) -WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:1097) -WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:1102) -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 8.45 - ghost atom cutoff = 8.45 - binsize = 4.225, bins = 21 21 21 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair kim, perpetual - attributes: full, newton off, cut 8.45 - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Setting up Verlet run ... - Unit style : metal - Current step : 0 - Time step : 0.001 -Per MPI rank memory allocation (min/avg/max) = 10.05 | 10.05 | 10.05 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 6290.8194 0 7118.0584 129712.25 - 100 95.179725 6718.814 0 7112.496 133346.59 -Loop time of 0.890192 on 4 procs for 100 steps with 32000 atoms - -Performance: 9.706 ns/day, 2.473 hours/ns, 112.335 timesteps/s -99.7% CPU use with 4 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0.77867 | 0.77906 | 0.7794 | 0.0 | 87.52 -Neigh | 0.087831 | 0.088176 | 0.088805 | 0.1 | 9.91 -Comm | 0.006358 | 0.0065898 | 0.006815 | 0.3 | 0.74 -Output | 4.9e-05 | 5.975e-05 | 6.8e-05 | 0.0 | 0.01 -Modify | 0.010265 | 0.010429 | 0.010678 | 0.2 | 1.17 -Other | | 0.005874 | | | 0.66 - -Nlocal: 8000 ave 8018 max 7967 min -Histogram: 1 0 0 0 0 0 1 0 0 2 -Nghost: 9131 ave 9164 max 9113 min -Histogram: 2 0 0 1 0 0 0 0 0 1 -Neighs: 0 ave 0 max 0 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -FullNghs: 1.06344e+06 ave 1.06594e+06 max 1.05881e+06 min -Histogram: 1 0 0 0 0 0 1 0 0 2 - -Total # of neighbors = 4253750 -Ave neighs/atom = 132.93 -Neighbor list builds = 3 -Dangerous builds = 0 -Total wall time: 0:00:00 diff --git a/examples/kim/log.06Feb2019.in.kim.lj.newton-on.1 b/examples/kim/log.06Feb2019.in.kim.lj.newton-on.1 deleted file mode 100644 index 59d018e12a..0000000000 --- a/examples/kim/log.06Feb2019.in.kim.lj.newton-on.1 +++ /dev/null @@ -1,59 +0,0 @@ -LAMMPS (1 Feb 2019) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:87) - using 1 OpenMP thread(s) per MPI task -Lattice spacing in x,y,z = 4.43 4.43 4.43 -Created orthogonal box = (0 0 0) to (88.6 88.6 88.6) - 1 by 1 by 1 MPI processor grid -Created 32000 atoms - Time spent = 0.003089 secs -WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:1097) -WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:1102) -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 8.45 - ghost atom cutoff = 8.45 - binsize = 4.225, bins = 21 21 21 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair kim, perpetual - attributes: full, newton off, cut 8.45 - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Setting up Verlet run ... - Unit style : metal - Current step : 0 - Time step : 0.001 -Per MPI rank memory allocation (min/avg/max) = 28.12 | 28.12 | 28.12 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 6290.8194 0 7118.0584 129712.25 - 100 95.179725 6718.814 0 7112.496 133346.59 -Loop time of 3.05849 on 1 procs for 100 steps with 32000 atoms - -Performance: 2.825 ns/day, 8.496 hours/ns, 32.696 timesteps/s -99.6% CPU use with 1 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 2.6786 | 2.6786 | 2.6786 | 0.0 | 87.58 -Neigh | 0.33105 | 0.33105 | 0.33105 | 0.0 | 10.82 -Comm | 0.012602 | 0.012602 | 0.012602 | 0.0 | 0.41 -Output | 9.5e-05 | 9.5e-05 | 9.5e-05 | 0.0 | 0.00 -Modify | 0.024858 | 0.024858 | 0.024858 | 0.0 | 0.81 -Other | | 0.01132 | | | 0.37 - -Nlocal: 32000 ave 32000 max 32000 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 19911 ave 19911 max 19911 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 0 ave 0 max 0 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 4.25375e+06 ave 4.25375e+06 max 4.25375e+06 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 4253750 -Ave neighs/atom = 132.93 -Neighbor list builds = 3 -Dangerous builds = 0 -Total wall time: 0:00:03 diff --git a/examples/kim/log.06Feb2019.in.kim.lj.newton-on.4 b/examples/kim/log.06Feb2019.in.kim.lj.newton-on.4 deleted file mode 100644 index da8c9f0faa..0000000000 --- a/examples/kim/log.06Feb2019.in.kim.lj.newton-on.4 +++ /dev/null @@ -1,65 +0,0 @@ -LAMMPS (1 Feb 2019) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:87) - using 1 OpenMP thread(s) per MPI task -Lattice spacing in x,y,z = 4.43 4.43 4.43 -Created orthogonal box = (0 0 0) to (88.6 88.6 88.6) - 1 by 2 by 2 MPI processor grid -Created 32000 atoms - Time spent = 0.000893 secs -WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:1097) -WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:1102) -WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:1097) -WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:1102) -WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:1097) -WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:1102) -WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:1097) -WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:1102) -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 8.45 - ghost atom cutoff = 8.45 - binsize = 4.225, bins = 21 21 21 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair kim, perpetual - attributes: full, newton off, cut 8.45 - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Setting up Verlet run ... - Unit style : metal - Current step : 0 - Time step : 0.001 -Per MPI rank memory allocation (min/avg/max) = 9.789 | 9.789 | 9.789 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 6290.8194 0 7118.0584 129712.25 - 100 95.179725 6718.814 0 7112.496 133346.59 -Loop time of 0.903182 on 4 procs for 100 steps with 32000 atoms - -Performance: 9.566 ns/day, 2.509 hours/ns, 110.720 timesteps/s -99.6% CPU use with 4 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0.76173 | 0.76349 | 0.76597 | 0.2 | 84.53 -Neigh | 0.088773 | 0.088938 | 0.089074 | 0.0 | 9.85 -Comm | 0.032018 | 0.03452 | 0.03638 | 0.9 | 3.82 -Output | 4e-05 | 4.425e-05 | 5.2e-05 | 0.0 | 0.00 -Modify | 0.009278 | 0.0093917 | 0.009528 | 0.1 | 1.04 -Other | | 0.006797 | | | 0.75 - -Nlocal: 8000 ave 8018 max 7967 min -Histogram: 1 0 0 0 0 0 1 0 0 2 -Nghost: 9131 ave 9164 max 9113 min -Histogram: 2 0 0 1 0 0 0 0 0 1 -Neighs: 0 ave 0 max 0 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -FullNghs: 1.06344e+06 ave 1.06594e+06 max 1.05881e+06 min -Histogram: 1 0 0 0 0 0 1 0 0 2 - -Total # of neighbors = 4253750 -Ave neighs/atom = 132.93 -Neighbor list builds = 3 -Dangerous builds = 0 -Total wall time: 0:00:00 diff --git a/examples/kim/log.22Mar2019.query.g++.1 b/examples/kim/log.22Mar2019.query.g++.1 deleted file mode 100644 index 034bb13bba..0000000000 --- a/examples/kim/log.22Mar2019.query.g++.1 +++ /dev/null @@ -1,34 +0,0 @@ -LAMMPS (28 Feb 2019) - -# example for performing a query to the OpenKIM test database to retrieve -# a parameter to be used in the input. here it requests the aluminium -# lattice constant for a specific test used for a specific model and then -# assigns it to the variable 'latconst' - -units metal -info variables out log - -Info-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info -Printed on Fri Mar 22 20:00:56 2019 - - -Variable information: - -Info-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info - -kim_query latconst get_test_result test=TE_156715955670 species=["Al"] model=MO_800509458712 prop=structure-cubic-crystal-npt keys=["a"] units=["angstrom"] -info variables out log - -Info-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info -Printed on Fri Mar 22 20:00:57 2019 - - -Variable information: -Variable[ 0]: latconst , style = string , def = 4.03208274841 - -Info-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info - -lattice fcc ${latconst} -lattice fcc 4.03208274841 -Lattice spacing in x,y,z = 4.03208 4.03208 4.03208 -Total wall time: 0:00:00 diff --git a/examples/kim/log.30Apr2019.kim.VOH.simulator_model.g++.1 b/examples/kim/log.30Apr2019.kim.VOH.simulator_model.g++.1 deleted file mode 100644 index e9d1f17d76..0000000000 --- a/examples/kim/log.30Apr2019.kim.VOH.simulator_model.g++.1 +++ /dev/null @@ -1,92 +0,0 @@ -LAMMPS (30 Apr 2019) - using 1 OpenMP thread(s) per MPI task -# REAX potential for VOH system -# ..... - -units real -atom_style charge - -kim_style init Sim_LAMMPS_ReaxFF_ChenowethVanDuinPersson_2008_CHOV__SM_429148913211_000 -units real -atom_style charge -neigh_modify one 4000 - -read_data data.VOH - orthogonal box = (0 0 0) to (25 25 25) - 1 by 1 by 1 MPI processor grid - reading atoms ... - 100 atoms - read_data CPU = 0.000217199 secs - -kim_style define H C O V -Using KIM Simulator Model : Sim_LAMMPS_ReaxFF_ChenowethVanDuinPersson_2008_CHOV__SM_429148913211_000 -For Simulator : LAMMPS 28-Feb-2019 -Running on : LAMMPS 30 Apr 2019 -pair_style reax/c /tmp/kim-simulator-model-parameter-file-XXXXXXFRmlac safezone 2.0 mincap 100 -pair_coeff * * /tmp/kim-simulator-model-parameter-file-XXXXXX363kge H C O V -Reading potential file /tmp/kim-simulator-model-parameter-file-XXXXXX363kge with DATE: 2011-02-18 -WARNING: Changed valency_val to valency_boc for X (src/USER-REAXC/reaxc_ffield.cpp:311) -fix reaxqeq all qeq/reax 1 0.0 10.0 1.0e-6 /tmp/kim-simulator-model-parameter-file-XXXXXXzgDl49 - -neighbor 2 bin -neigh_modify every 10 delay 0 check no - -fix 1 all nve -fix 3 all temp/berendsen 500.0 500.0 100.0 - -timestep 0.25 - -#dump 1 all atom 30 dump.reax.voh - -run 300 -Neighbor list info ... - update every 10 steps, delay 0 steps, check no - max neighbors/atom: 4000, page size: 100000 - master list distance cutoff = 12 - ghost atom cutoff = 12 - binsize = 6, bins = 5 5 5 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair reax/c, perpetual - attributes: half, newton off, ghost - pair build: half/bin/newtoff/ghost - stencil: half/ghost/bin/3d/newtoff - bin: standard - (2) fix qeq/reax, perpetual, copy from (1) - attributes: half, newton off, ghost - pair build: copy - stencil: none - bin: none -Per MPI rank memory allocation (min/avg/max) = 25.97 | 25.97 | 25.97 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 0 -10246.825 0 -10246.825 42.256089 - 300 199.45773 -10218.342 0 -10159.482 -66.730725 -Loop time of 1.06721 on 1 procs for 300 steps with 100 atoms - -Performance: 6.072 ns/day, 3.953 hours/ns, 281.107 timesteps/s -98.8% CPU use with 1 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0.93954 | 0.93954 | 0.93954 | 0.0 | 88.04 -Neigh | 0.029087 | 0.029087 | 0.029087 | 0.0 | 2.73 -Comm | 0.0018935 | 0.0018935 | 0.0018935 | 0.0 | 0.18 -Output | 1.8358e-05 | 1.8358e-05 | 1.8358e-05 | 0.0 | 0.00 -Modify | 0.096112 | 0.096112 | 0.096112 | 0.0 | 9.01 -Other | | 0.0005522 | | | 0.05 - -Nlocal: 100 ave 100 max 100 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 608 ave 608 max 608 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 3441 ave 3441 max 3441 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 3441 -Ave neighs/atom = 34.41 -Neighbor list builds = 30 -Dangerous builds not checked - -Please see the log.cite file for references relevant to this simulation - -Total wall time: 0:00:01 diff --git a/examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.1 b/examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.1 deleted file mode 100644 index a6d1c4a955..0000000000 --- a/examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.1 +++ /dev/null @@ -1,132 +0,0 @@ -LAMMPS (30 Apr 2019) - using 1 OpenMP thread(s) per MPI task - -units metal -kim_style init ex_sim_model_Si_mod_tersoff -units metal -newton on - -atom_style atomic -atom_modify map array -boundary p p p - -# temperatures -variable tlo equal 1800.0 -variable thi equal 2400.0 - -# coordination number cutoff - -variable r equal 2.835 - -# minimization parameters - -variable etol equal 1.0e-5 -variable ftol equal 1.0e-5 -variable maxiter equal 100 -variable maxeval equal 100 -variable dmax equal 1.0e-1 - -# diamond unit cell - -variable a equal 5.431 -lattice custom $a a1 1.0 0.0 0.0 a2 0.0 1.0 0.0 a3 0.0 0.0 1.0 basis 0.0 0.0 0.0 basis 0.0 0.5 0.5 basis 0.5 0.0 0.5 basis 0.5 0.5 0.0 basis 0.25 0.25 0.25 basis 0.25 0.75 0.75 basis 0.75 0.25 0.75 basis 0.75 0.75 0.25 -lattice custom 5.431 a1 1.0 0.0 0.0 a2 0.0 1.0 0.0 a3 0.0 0.0 1.0 basis 0.0 0.0 0.0 basis 0.0 0.5 0.5 basis 0.5 0.0 0.5 basis 0.5 0.5 0.0 basis 0.25 0.25 0.25 basis 0.25 0.75 0.75 basis 0.75 0.25 0.75 basis 0.75 0.75 0.25 -Lattice spacing in x,y,z = 5.431 5.431 5.431 - -region myreg block 0 4 0 4 0 4 -create_box 1 myreg -Created orthogonal box = (0 0 0) to (21.724 21.724 21.724) - 1 by 1 by 1 MPI processor grid -create_atoms 1 region myreg -Created 512 atoms - create_atoms CPU = 0.000393867 secs - -mass 1 28.06 - -group Si type 1 -512 atoms in group Si - -velocity all create ${thi} 5287286 mom yes rot yes dist gaussian -velocity all create 2400 5287286 mom yes rot yes dist gaussian - -# make a vacancy - -group del id 300 -1 atoms in group del -delete_atoms group del -Deleted 1 atoms, new total = 511 -kim_style define Si -Using KIM Simulator Model : ex_sim_model_Si_mod_tersoff -For Simulator : LAMMPS 12-Dec-2018 -Running on : LAMMPS 30 Apr 2019 -pair_style tersoff/mod -pair_coeff * * /tmp/kim-simulator-model-parameter-file-XXXXXXVWG8uV Si -Reading potential file /tmp/kim-simulator-model-parameter-file-XXXXXXVWG8uV with DATE: 2013-07-26 - -thermo 10 - -fix 1 all nve -fix 2 all langevin ${thi} ${thi} 0.1 48278 -fix 2 all langevin 2400 ${thi} 0.1 48278 -fix 2 all langevin 2400 2400 0.1 48278 - -timestep 1.0e-3 -neighbor 1.0 bin -neigh_modify every 1 delay 10 check yes - -run 100 -Neighbor list info ... - update every 1 steps, delay 10 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 4.3 - ghost atom cutoff = 4.3 - binsize = 2.15, bins = 11 11 11 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair tersoff/mod, perpetual - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 3.11 | 3.11 | 3.11 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 2397.3877 -2363.0694 0 -2205.0272 15086.224 - 10 1328.4035 -2289.1682 0 -2201.5963 29164.666 - 20 1086.1557 -2254.4447 0 -2182.8424 31906.878 - 30 1528.8439 -2270.2968 0 -2169.5113 21610.528 - 40 1345.227 -2250.3915 0 -2161.7105 22146.886 - 50 1300.3329 -2235.8593 0 -2150.1379 23557.875 - 60 1546.1664 -2241.3019 0 -2139.3744 21648.774 - 70 1662.2896 -2236.2369 0 -2126.6543 23958.738 - 80 1631.7284 -2223.45 0 -2115.8821 28842.194 - 90 1795.3629 -2225.2998 0 -2106.9447 29522.37 - 100 1830.156 -2224.3733 0 -2103.7245 28805.09 -Loop time of 0.201725 on 1 procs for 100 steps with 511 atoms - -Performance: 42.831 ns/day, 0.560 hours/ns, 495.724 timesteps/s -99.3% CPU use with 1 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0.19292 | 0.19292 | 0.19292 | 0.0 | 95.63 -Neigh | 0.0037313 | 0.0037313 | 0.0037313 | 0.0 | 1.85 -Comm | 0.00074744 | 0.00074744 | 0.00074744 | 0.0 | 0.37 -Output | 0.00026727 | 0.00026727 | 0.00026727 | 0.0 | 0.13 -Modify | 0.0036564 | 0.0036564 | 0.0036564 | 0.0 | 1.81 -Other | | 0.0004075 | | | 0.20 - -Nlocal: 511 ave 511 max 511 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 970 ave 970 max 970 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 0 ave 0 max 0 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 9174 ave 9174 max 9174 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 9174 -Ave neighs/atom = 17.953 -Neighbor list builds = 4 -Dangerous builds = 0 - -Total wall time: 0:00:00 diff --git a/examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.4 b/examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.4 deleted file mode 100644 index dcb170aeb6..0000000000 --- a/examples/kim/log.30Apr2019.kim.ex_si.simulator_model.g++.4 +++ /dev/null @@ -1,132 +0,0 @@ -LAMMPS (30 Apr 2019) - using 1 OpenMP thread(s) per MPI task - -units metal -kim_style init ex_sim_model_Si_mod_tersoff -units metal -newton on - -atom_style atomic -atom_modify map array -boundary p p p - -# temperatures -variable tlo equal 1800.0 -variable thi equal 2400.0 - -# coordination number cutoff - -variable r equal 2.835 - -# minimization parameters - -variable etol equal 1.0e-5 -variable ftol equal 1.0e-5 -variable maxiter equal 100 -variable maxeval equal 100 -variable dmax equal 1.0e-1 - -# diamond unit cell - -variable a equal 5.431 -lattice custom $a a1 1.0 0.0 0.0 a2 0.0 1.0 0.0 a3 0.0 0.0 1.0 basis 0.0 0.0 0.0 basis 0.0 0.5 0.5 basis 0.5 0.0 0.5 basis 0.5 0.5 0.0 basis 0.25 0.25 0.25 basis 0.25 0.75 0.75 basis 0.75 0.25 0.75 basis 0.75 0.75 0.25 -lattice custom 5.431 a1 1.0 0.0 0.0 a2 0.0 1.0 0.0 a3 0.0 0.0 1.0 basis 0.0 0.0 0.0 basis 0.0 0.5 0.5 basis 0.5 0.0 0.5 basis 0.5 0.5 0.0 basis 0.25 0.25 0.25 basis 0.25 0.75 0.75 basis 0.75 0.25 0.75 basis 0.75 0.75 0.25 -Lattice spacing in x,y,z = 5.431 5.431 5.431 - -region myreg block 0 4 0 4 0 4 -create_box 1 myreg -Created orthogonal box = (0 0 0) to (21.724 21.724 21.724) - 1 by 2 by 2 MPI processor grid -create_atoms 1 region myreg -Created 512 atoms - create_atoms CPU = 0.102434 secs - -mass 1 28.06 - -group Si type 1 -512 atoms in group Si - -velocity all create ${thi} 5287286 mom yes rot yes dist gaussian -velocity all create 2400 5287286 mom yes rot yes dist gaussian - -# make a vacancy - -group del id 300 -1 atoms in group del -delete_atoms group del -Deleted 1 atoms, new total = 511 -kim_style define Si -Using KIM Simulator Model : ex_sim_model_Si_mod_tersoff -For Simulator : LAMMPS 12-Dec-2018 -Running on : LAMMPS 30 Apr 2019 -pair_style tersoff/mod -pair_coeff * * /tmp/kim-simulator-model-parameter-file-XXXXXXqDlERL Si -Reading potential file /tmp/kim-simulator-model-parameter-file-XXXXXXqDlERL with DATE: 2013-07-26 - -thermo 10 - -fix 1 all nve -fix 2 all langevin ${thi} ${thi} 0.1 48278 -fix 2 all langevin 2400 ${thi} 0.1 48278 -fix 2 all langevin 2400 2400 0.1 48278 - -timestep 1.0e-3 -neighbor 1.0 bin -neigh_modify every 1 delay 10 check yes - -run 100 -Neighbor list info ... - update every 1 steps, delay 10 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 4.3 - ghost atom cutoff = 4.3 - binsize = 2.15, bins = 11 11 11 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair tersoff/mod, perpetual - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 3.082 | 3.082 | 3.082 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 2397.5824 -2363.0694 0 -2205.0143 15087.562 - 10 1298.5003 -2292.5456 0 -2206.945 28361.893 - 20 1114.7065 -2260.7006 0 -2187.2161 30574.077 - 30 1504.9472 -2271.8639 0 -2172.6537 20395.651 - 40 1357.5949 -2248.6066 0 -2159.1103 21779.773 - 50 1351.7212 -2235.0803 0 -2145.9713 23404.844 - 60 1582.4191 -2238.3233 0 -2134.006 21711.26 - 70 1654.3988 -2230.0965 0 -2121.0341 24276.504 - 80 1654.9629 -2218.6654 0 -2109.5658 27571.472 - 90 1815.7206 -2219.2065 0 -2099.5093 28475.757 - 100 1901.1544 -2216.5428 0 -2091.2137 28962.04 -Loop time of 4.36959 on 4 procs for 100 steps with 511 atoms - -Performance: 1.977 ns/day, 12.138 hours/ns, 22.885 timesteps/s -47.8% CPU use with 4 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0.051784 | 0.056551 | 0.064825 | 2.1 | 1.29 -Neigh | 0.00093389 | 0.001028 | 0.0011392 | 0.3 | 0.02 -Comm | 2.8964 | 2.9342 | 3.016 | 2.8 | 67.15 -Output | 0.673 | 0.68159 | 0.69707 | 1.1 | 15.60 -Modify | 0.0011303 | 0.0029655 | 0.0081694 | 5.5 | 0.07 -Other | | 0.6933 | | | 15.87 - -Nlocal: 127.75 ave 134 max 123 min -Histogram: 1 0 0 2 0 0 0 0 0 1 -Nghost: 495 ave 498 max 489 min -Histogram: 1 0 0 0 0 0 0 1 1 1 -Neighs: 0 ave 0 max 0 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -FullNghs: 2302 ave 2443 max 2194 min -Histogram: 1 0 0 2 0 0 0 0 0 1 - -Total # of neighbors = 9208 -Ave neighs/atom = 18.0196 -Neighbor list builds = 4 -Dangerous builds = 0 - -Total wall time: 0:00:05 diff --git a/examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.1 b/examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.1 deleted file mode 100644 index 94aaf1aaef..0000000000 --- a/examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.1 +++ /dev/null @@ -1,104 +0,0 @@ -LAMMPS (30 Apr 2019) - using 1 OpenMP thread(s) per MPI task -# 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 xx equal 20*1 -variable yy equal 20*$y -variable yy equal 20*1 -variable zz equal 20*$z -variable zz equal 20*1 - -units metal -atom_style atomic -newton on - -kim_style init LennardJones_Ar - -lattice fcc 4.4300 -Lattice spacing in x,y,z = 4.43 4.43 4.43 -region box block 0 ${xx} 0 ${yy} 0 ${zz} -region box block 0 20 0 ${yy} 0 ${zz} -region box block 0 20 0 20 0 ${zz} -region box block 0 20 0 20 0 20 -create_box 1 box -Created orthogonal box = (0 0 0) to (88.6 88.6 88.6) - 1 by 1 by 1 MPI processor grid -create_atoms 1 box -Created 32000 atoms - create_atoms CPU = 0.00314307 secs - -#pair_style lj/cut 8.1500 -#pair_coeff 1 1 0.0104 3.4000 - -kim_style define Ar -pair_style kim LennardJones_Ar -WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:980) -WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:985) -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 -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 8.45 - ghost atom cutoff = 8.45 - binsize = 4.225, bins = 21 21 21 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair kim, perpetual - attributes: full, newton off, cut 8.45 - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 28.12 | 28.12 | 28.12 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 6290.8194 0 7118.0584 129712.25 - 100 95.179725 6718.814 0 7112.496 133346.59 -Loop time of 4.91804 on 1 procs for 100 steps with 32000 atoms - -Performance: 1.757 ns/day, 13.661 hours/ns, 20.333 timesteps/s -99.7% CPU use with 1 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 4.3033 | 4.3033 | 4.3033 | 0.0 | 87.50 -Neigh | 0.53176 | 0.53176 | 0.53176 | 0.0 | 10.81 -Comm | 0.024606 | 0.024606 | 0.024606 | 0.0 | 0.50 -Output | 0.00016403 | 0.00016403 | 0.00016403 | 0.0 | 0.00 -Modify | 0.038671 | 0.038671 | 0.038671 | 0.0 | 0.79 -Other | | 0.01951 | | | 0.40 - -Nlocal: 32000 ave 32000 max 32000 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 19911 ave 19911 max 19911 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 0 ave 0 max 0 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 4.25375e+06 ave 4.25375e+06 max 4.25375e+06 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 4253750 -Ave neighs/atom = 132.93 -Neighbor list builds = 3 -Dangerous builds = 0 -Total wall time: 0:00:05 diff --git a/examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.4 b/examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.4 deleted file mode 100644 index 3377f22d02..0000000000 --- a/examples/kim/log.30Apr2019.kim.lj.simulator_model.g++.4 +++ /dev/null @@ -1,104 +0,0 @@ -LAMMPS (30 Apr 2019) - using 1 OpenMP thread(s) per MPI task -# 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 xx equal 20*1 -variable yy equal 20*$y -variable yy equal 20*1 -variable zz equal 20*$z -variable zz equal 20*1 - -units metal -atom_style atomic -newton on - -kim_style init LennardJones_Ar - -lattice fcc 4.4300 -Lattice spacing in x,y,z = 4.43 4.43 4.43 -region box block 0 ${xx} 0 ${yy} 0 ${zz} -region box block 0 20 0 ${yy} 0 ${zz} -region box block 0 20 0 20 0 ${zz} -region box block 0 20 0 20 0 20 -create_box 1 box -Created orthogonal box = (0 0 0) to (88.6 88.6 88.6) - 1 by 2 by 2 MPI processor grid -create_atoms 1 box -Created 32000 atoms - create_atoms CPU = 0.0979962 secs - -#pair_style lj/cut 8.1500 -#pair_coeff 1 1 0.0104 3.4000 - -kim_style define Ar -pair_style kim LennardJones_Ar -WARNING: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero (src/KIM/pair_kim.cpp:980) -WARNING: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero (src/KIM/pair_kim.cpp:985) -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 -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 8.45 - ghost atom cutoff = 8.45 - binsize = 4.225, bins = 21 21 21 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair kim, perpetual - attributes: full, newton off, cut 8.45 - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 9.789 | 9.789 | 9.789 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 6290.8194 0 7118.0584 129712.25 - 100 95.179725 6718.814 0 7112.496 133346.59 -Loop time of 6.29539 on 4 procs for 100 steps with 32000 atoms - -Performance: 1.372 ns/day, 17.487 hours/ns, 15.885 timesteps/s -48.4% CPU use with 4 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 1.9399 | 2.079 | 2.2181 | 9.1 | 33.02 -Neigh | 0.25924 | 0.26632 | 0.2692 | 0.8 | 4.23 -Comm | 2.5011 | 2.6605 | 2.751 | 5.9 | 42.26 -Output | 0.069904 | 0.07097 | 0.071545 | 0.3 | 1.13 -Modify | 0.011383 | 0.012206 | 0.01419 | 1.0 | 0.19 -Other | | 1.206 | | | 19.16 - -Nlocal: 8000 ave 8018 max 7967 min -Histogram: 1 0 0 0 0 0 1 0 0 2 -Nghost: 9131 ave 9164 max 9113 min -Histogram: 2 0 0 1 0 0 0 0 0 1 -Neighs: 0 ave 0 max 0 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -FullNghs: 1.06344e+06 ave 1.06594e+06 max 1.05881e+06 min -Histogram: 1 0 0 0 0 0 1 0 0 2 - -Total # of neighbors = 4253750 -Ave neighs/atom = 132.93 -Neighbor list builds = 3 -Dangerous builds = 0 -Total wall time: 0:00:07 diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index dc8d0544f6..85b865d03f 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -220,8 +220,9 @@ char *do_query(char *qfunction, char * model_name, int narg, char **arg, url += qfunction; std::string query(arg[0]); - query += "&model="; + query += "&model=[\""; query += model_name; + query += "\"]"; for (int i=1; i < narg; ++i) { query += '&'; query += arg[i]; From 60dfa7daf81e056a126dc52e131295aafe97a3d1 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Thu, 25 Jul 2019 18:31:40 -0500 Subject: [PATCH 093/107] doc spelling update --- doc/src/Install_mac.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/Install_mac.txt b/doc/src/Install_mac.txt index e277f7e0e4..773c9ec93a 100644 --- a/doc/src/Install_mac.txt +++ b/doc/src/Install_mac.txt @@ -28,7 +28,7 @@ Lennard-Jones benchmark file: % brew test lammps -v :pre The LAMMPS binary is built with the "KIM package"_Build_extras#kim which -results in homebrew also installing the `kim-api` binaries when LAMMPS is +results in Homebrew also installing the `kim-api` binaries when LAMMPS is installed. In order to use potentials from "openkim.org"_openkim, you can install the `openkim-models` package From 52e175546420c04705ac101f58806a94f5705aba Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 25 Jul 2019 21:20:42 -0400 Subject: [PATCH 094/107] fix spelling errors and false positives --- doc/src/kim_commands.txt | 4 ++-- doc/utils/sphinx-config/false_positives.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index dd61f6f5cc..0bb7de03d6 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -282,7 +282,7 @@ keyword {fixed_types} for models that have a preset fixed mapping (i.e. the mapping between LAMMPS atom types and chemical species is defined by the model and cannot be changed). In the latter case, the user must consult the model documentation to see how many atom types there are and how they -map to the chemcial species. +map to the chemical species. For example, consider an OpenKIM IM that supports Si and C species. If the LAMMPS simulation has four atom types, where the first three are Si, @@ -488,7 +488,7 @@ The citation format for an IM is displayed on its page on "OpenKIM"_https://openkim.org along with the corresponding BibTex file, and is automatically added to the LAMMPS {log.cite} file. -Citing the IM software (KIM infrastucture and specific PM or SM codes) +Citing the IM software (KIM infrastructure and specific PM or SM codes) used in the simulation gives credit to the researchers who developed them and enables open source efforts like OpenKIM to function. diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index e383fddfa9..cf9b823ba3 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -884,6 +884,7 @@ Fogarty Foiles fopenmp forestgreen +formatarg formulae Forschungszentrum Fortran From 47689b4ad36198e7501d5bbd37419d658dce3c3f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 26 Jul 2019 06:03:21 -0400 Subject: [PATCH 095/107] make include files independent of previously included headers. include them first in implementation files. this is to be compliant with upcoming definition of include file policy --- src/KIM/fix_store_kim.cpp | 2 +- src/KIM/fix_store_kim.h | 1 - src/KIM/kim_init.cpp | 2 +- src/KIM/kim_init.h | 1 + src/KIM/kim_interactions.cpp | 2 +- src/KIM/kim_interactions.h | 1 + src/KIM/kim_query.cpp | 2 +- src/KIM/pair_kim.cpp | 2 +- 8 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/KIM/fix_store_kim.cpp b/src/KIM/fix_store_kim.cpp index 1bd924bcfb..16d606d2ed 100644 --- a/src/KIM/fix_store_kim.cpp +++ b/src/KIM/fix_store_kim.cpp @@ -54,8 +54,8 @@ Designed for use with the kim-api-2.0.2 (and newer) package ------------------------------------------------------------------------- */ -#include #include "fix_store_kim.h" +#include extern "C" { #include "KIM_SimulatorModel.h" } diff --git a/src/KIM/fix_store_kim.h b/src/KIM/fix_store_kim.h index 655be83ad0..6baf480993 100644 --- a/src/KIM/fix_store_kim.h +++ b/src/KIM/fix_store_kim.h @@ -63,7 +63,6 @@ FixStyle(STORE/KIM,FixStoreKIM) #ifndef LMP_FIX_STORE_KIM_H #define LMP_FIX_STORE_KIM_H -#include #include "fix.h" namespace LAMMPS_NS { diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 83638f3428..bae286aff6 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -55,11 +55,11 @@ Designed for use with the kim-api-2.1.0 (and newer) package ------------------------------------------------------------------------- */ +#include "kim_init.h" #include #include #include #include -#include "kim_init.h" #include "error.h" #include "atom.h" #include "comm.h" diff --git a/src/KIM/kim_init.h b/src/KIM/kim_init.h index 7c7a24615b..2b5dc520c7 100644 --- a/src/KIM/kim_init.h +++ b/src/KIM/kim_init.h @@ -65,6 +65,7 @@ CommandStyle(kim_init,KimInit) #define LMP_KIM_INIT_H #include "pointers.h" +#include namespace LAMMPS_NS { diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index d0fbb809d2..449b6bcb13 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -55,10 +55,10 @@ Designed for use with the kim-api-2.1.0 (and newer) package ------------------------------------------------------------------------- */ +#include "kim_interactions.h" #include #include #include -#include "kim_interactions.h" #include "error.h" #include "atom.h" #include "comm.h" diff --git a/src/KIM/kim_interactions.h b/src/KIM/kim_interactions.h index 6da1880f84..8172004d53 100644 --- a/src/KIM/kim_interactions.h +++ b/src/KIM/kim_interactions.h @@ -65,6 +65,7 @@ CommandStyle(kim_interactions,KimInteractions) #define LMP_KIM_INTERACTIONS_H #include "pointers.h" +#include namespace LAMMPS_NS { diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index 85b865d03f..6688ed6690 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -54,11 +54,11 @@ Designed for use with the kim-api-2.1.0 (and newer) package ------------------------------------------------------------------------- */ +#include "kim_query.h" #include #include #include #include -#include "kim_query.h" #include "comm.h" #include "error.h" #include "input.h" diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index 50eef1de2b..74b92a3e2b 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -53,13 +53,13 @@ /* ---------------------------------------------------------------------- Designed for use with the kim-api-2.0.2 (and newer) package ------------------------------------------------------------------------- */ +#include "pair_kim.h" #include #include #include // includes from LAMMPS -#include "pair_kim.h" #include "atom.h" #include "comm.h" #include "universe.h" From 010cb0edf304035fafd16b7870dce1a4b05fc7b9 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Fri, 26 Jul 2019 11:10:54 -0500 Subject: [PATCH 096/107] Add warning to cmake if PKG_KIM=ON but DOWNLOAD_KIM not set & KIM is not found This can be a scenario where the user has KIM installed but does not have the environment setup correctly to be found. The config. step should provide some warning of this. Otherwise, it is easy to miss the fact that KIM is being downloaded and built. --- cmake/Modules/Packages/KIM.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 1a9dcf83a4..5987ebbf0a 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -9,6 +9,7 @@ if(PKG_KIM) if(KIM-API_FOUND) set(DOWNLOAD_KIM_DEFAULT OFF) else() + message(WARNING "KIM-API package not found. We will download and build our own") set(DOWNLOAD_KIM_DEFAULT ON) endif() option(DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" ${DOWNLOAD_KIM_DEFAULT}) From 6a5902ec489b49386cf21b9d6fdc5487baa00f33 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Fri, 26 Jul 2019 11:14:46 -0500 Subject: [PATCH 097/107] Update kim_init to use KIM::Collections::GetItemType() A bit of a cleaner solution. Should be no visible change for users. --- src/KIM/kim_init.cpp | 100 ++++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 40 deletions(-) diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index bae286aff6..954a4b0f2c 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -164,21 +164,39 @@ void KimInit::determine_model_type_and_units(char * model_name, KIM_TemperatureUnit temperatureUnit; KIM_TimeUnit timeUnit; int units_accepted; - KIM_Model * kim_MO; + KIM_Collections * kim_Coll; + KIM_CollectionItemType itemType; - get_kim_unit_names(user_units, lengthUnit, energyUnit, - chargeUnit, temperatureUnit, timeUnit, error); - int kim_error = KIM_Model_Create(KIM_NUMBERING_zeroBased, - lengthUnit, - energyUnit, - chargeUnit, - temperatureUnit, - timeUnit, - model_name, - &units_accepted, - &kim_MO); + int kim_error = KIM_Collections_Create(&kim_Coll); + if (kim_error) { + error->all(FLERR,"Unable to access KIM Collections to find Model."); + } + + kim_error = KIM_Collections_GetItemType(kim_Coll, model_name, &itemType); + if (kim_error) { + error->all(FLERR,"KIM Model name not found."); + } + KIM_Collections_Destroy(&kim_Coll); + + if (KIM_CollectionItemType_Equal(itemType, + KIM_COLLECTION_ITEM_TYPE_portableModel)) + { + get_kim_unit_names(user_units, lengthUnit, energyUnit, + chargeUnit, temperatureUnit, timeUnit, error); + KIM_Model * kim_MO; + int kim_error = KIM_Model_Create(KIM_NUMBERING_zeroBased, + lengthUnit, + energyUnit, + chargeUnit, + temperatureUnit, + timeUnit, + model_name, + &units_accepted, + &kim_MO); + + if (kim_error) + error->all(FLERR,"Unable to load KIM Simulator Model."); - if (!kim_error) { // model is an MO model_type = MO; KIM_Model_Destroy(&kim_MO); @@ -213,37 +231,39 @@ void KimInit::determine_model_type_and_units(char * model_name, error->all(FLERR,"KIM Model does not support the requested unit system"); } } + else if (KIM_CollectionItemType_Equal( + itemType, KIM_COLLECTION_ITEM_TYPE_simulatorModel)) { + KIM_SimulatorModel * kim_SM; + kim_error = KIM_SimulatorModel_Create(model_name, &kim_SM); + if (kim_error) + error->all(FLERR,"Unable to load KIM Simulator Model."); + model_type = SM; - KIM_SimulatorModel * kim_SM; - kim_error = KIM_SimulatorModel_Create(model_name, &kim_SM); - if (kim_error) - error->all(FLERR,"KIM model name not found"); - model_type = SM; + int sim_fields; + int sim_lines; + char const * sim_field; + char const * sim_value; + KIM_SimulatorModel_GetNumberOfSimulatorFields(kim_SM, &sim_fields); + KIM_SimulatorModel_CloseTemplateMap(kim_SM); + for (int i=0; i < sim_fields; ++i) { + KIM_SimulatorModel_GetSimulatorFieldMetadata( + kim_SM,i,&sim_lines,&sim_field); - int sim_fields; - int sim_lines; - char const * sim_field; - char const * sim_value; - KIM_SimulatorModel_GetNumberOfSimulatorFields(kim_SM, &sim_fields); - KIM_SimulatorModel_CloseTemplateMap(kim_SM); - for (int i=0; i < sim_fields; ++i) { - KIM_SimulatorModel_GetSimulatorFieldMetadata( - kim_SM,i,&sim_lines,&sim_field); - - if (0 == strcmp(sim_field,"units")) { - KIM_SimulatorModel_GetSimulatorFieldLine(kim_SM,i,0,&sim_value); - int len=strlen(sim_value)+1; - *model_units = new char[len]; strcpy(*model_units,sim_value); - break; + if (0 == strcmp(sim_field,"units")) { + KIM_SimulatorModel_GetSimulatorFieldLine(kim_SM,i,0,&sim_value); + int len=strlen(sim_value)+1; + *model_units = new char[len]; strcpy(*model_units,sim_value); + break; + } } - } - KIM_SimulatorModel_Destroy(&kim_SM); + KIM_SimulatorModel_Destroy(&kim_SM); - if ((! unit_conversion_mode) && (strcmp(*model_units, user_units)!=0)) { - std::string mesg("Incompatible units for KIM Simulator Model, " - "required units = "); - mesg += *model_units; - error->all(FLERR,mesg.c_str()); + if ((! unit_conversion_mode) && (strcmp(*model_units, user_units)!=0)) { + std::string mesg("Incompatible units for KIM Simulator Model, " + "required units = "); + mesg += *model_units; + error->all(FLERR,mesg.c_str()); + } } } From a0abd270b53f58dd99b702ee1fa2691960ee3738 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Mon, 29 Jul 2019 11:41:01 -0500 Subject: [PATCH 098/107] kim_query check for empty query result --- src/KIM/kim_query.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index 6688ed6690..e81e8c5d18 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -130,11 +130,13 @@ void KimQuery::command(int narg, char **arg) // as the first element, and then the error message // that was returned by the web server + char errmsg[1024]; if (0 == strlen(value)) { - char errmsg[1024]; - sprintf(errmsg,"OpenKIM query failed: %s",value+1); - error->all(FLERR,errmsg); + error->all(FLERR,errmsg); + } else if (0 == strcmp(value,"EMPTY")) { + sprintf(errmsg,"OpenKIM query returned no results"); + error->all(FLERR,errmsg); } char **varcmd = new char*[3]; @@ -269,7 +271,11 @@ char *do_query(char *qfunction, char * model_name, int narg, char **arg, if (value[len] == ']') { retval = new char[len]; value[len] = '\0'; - strcpy(retval,value+1); + if (0 == strcmp(value+1, "")) { + strcpy(retval,"EMPTY"); + } + else + strcpy(retval,value+1); } else { retval = new char[len+2]; retval[0] = '\0'; From 2afc498a2b595157ef63c50894c03e5106b57dbc Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Mon, 29 Jul 2019 15:04:15 -0500 Subject: [PATCH 099/107] Add logging to kim_query (compile error at moment) --- src/KIM/kim_query.cpp | 15 ++++++++++++++- src/KIM/kim_query.h | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index e81e8c5d18..e2bee158ed 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -154,14 +154,16 @@ void KimQuery::command(int narg, char **arg) varcmd[0] = const_cast(splitname.str().c_str()); varcmd[2] = const_cast(token.c_str()); input->variable->set(3,varcmd); + echo_var_assign(splitname.str(), varcmd[2]); } } else { varcmd[0] = varname; varcmd[1] = (char *) "string"; varcmd[2] = value; - input->variable->set(3,varcmd); + + echo_var_assign(varname, value); } delete[] varcmd; @@ -297,3 +299,14 @@ char *do_query(char *qfunction, char * model_name, int narg, char **arg, return retval; } #endif + +void KimQuery::echo_var_assign(std::string const & name, + std::string const & value) const +{ + if (comm->me == 0) { + std::string mesg; + mesg = name + " = " + value + "\n"; + if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen); + if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile); + } +} diff --git a/src/KIM/kim_query.h b/src/KIM/kim_query.h index b5433def79..9cffc9ad28 100644 --- a/src/KIM/kim_query.h +++ b/src/KIM/kim_query.h @@ -64,6 +64,7 @@ CommandStyle(kim_query,KimQuery) #define LMP_KIM_QUERY_H #include "pointers.h" +#include namespace LAMMPS_NS { @@ -71,6 +72,9 @@ class KimQuery : protected Pointers { public: KimQuery(class LAMMPS *lmp) : Pointers(lmp) {}; void command(int, char **); + private: + void echo_var_assign(std::string const & name, std::string const & value) + const; }; } From 0f059c56f946b9de88a869401370e6e874fd808c Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Mon, 29 Jul 2019 15:30:46 -0500 Subject: [PATCH 100/107] Add details about installing models to KIM example input --- examples/kim/in.kim-pm-query.melt | 9 +++++++++ examples/kim/in.kim-pm.melt | 9 +++++++++ examples/kim/in.kim-sm.melt | 11 ++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/examples/kim/in.kim-pm-query.melt b/examples/kim/in.kim-pm-query.melt index d39dd2d464..fa04d90436 100644 --- a/examples/kim/in.kim-pm-query.melt +++ b/examples/kim/in.kim-pm-query.melt @@ -4,6 +4,15 @@ # SW_StillingerWeber_1985_Si__MO_405512056662_005 # is installed. This can be done with the command # kim-api-collections-management install user SW_StillingerWeber_1985_Si__MO_405512056662_005 +# If this command does not work, you may need to setup your PATH to find the utility. +# If you installed the kim-api using the LAMMPS CMake build, you can do the following +# (where the current working directory is assumed to be the LAMMPS build directory) +# source ./kim_build-prefix/bin/kim-api-activate +# If you installed the kim-api using the LAMMPS Make build, you can do the following +# (where the current working directory is assumed to be the LAMMPS src directory) +# source ../lib/kim/installed-kim-api-X.Y.Z/bin/kim-api-activate +# (where you should relplace X.Y.Z with the appropriate kim-api version number). +# # Or, see https://openkim.org/doc/obtaining-models for alternative options. # diff --git a/examples/kim/in.kim-pm.melt b/examples/kim/in.kim-pm.melt index 999cf77180..9959a66793 100644 --- a/examples/kim/in.kim-pm.melt +++ b/examples/kim/in.kim-pm.melt @@ -4,6 +4,15 @@ # SW_StillingerWeber_1985_Si__MO_405512056662_005 # is installed. This can be done with the command # kim-api-collections-management install user SW_StillingerWeber_1985_Si__MO_405512056662_005 +# If this command does not work, you may need to setup your PATH to find the utility. +# If you installed the kim-api using the LAMMPS CMake build, you can do the following +# (where the current working directory is assumed to be the LAMMPS build directory) +# source ./kim_build-prefix/bin/kim-api-activate +# If you installed the kim-api using the LAMMPS Make build, you can do the following +# (where the current working directory is assumed to be the LAMMPS src directory) +# source ../lib/kim/installed-kim-api-X.Y.Z/bin/kim-api-activate +# (where you should relplace X.Y.Z with the appropriate kim-api version number). +# # Or, see https://openkim.org/doc/obtaining-models for alternative options. # diff --git a/examples/kim/in.kim-sm.melt b/examples/kim/in.kim-sm.melt index 32f8c6170f..0ee8e9a857 100644 --- a/examples/kim/in.kim-sm.melt +++ b/examples/kim/in.kim-sm.melt @@ -4,7 +4,16 @@ # Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 # is installed. This can be done with the command # kim-api-collections-management install user Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657_000 -# Or, see https://openkim.org/doc/obtaining-models for alternative options. +# If this command does not work, you may need to setup your PATH to find the utility. +# If you installed the kim-api using the LAMMPS CMake build, you can do the following +# (where the current working directory is assumed to be the LAMMPS build directory) +# source ./kim_build-prefix/bin/kim-api-activate +# If you installed the kim-api using the LAMMPS Make build, you can do the following +# (where the current working directory is assumed to be the LAMMPS src directory) +# source ../lib/kim/installed-kim-api-X.Y.Z/bin/kim-api-activate +# (where you should relplace X.Y.Z with the appropriate kim-api version number). +# +# See https://openkim.org/doc/obtaining-models for alternative options. # variable x index 1 From ea4107c4b433082aad60b811588e8e53fc1c1651 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 29 Jul 2019 16:36:57 -0400 Subject: [PATCH 101/107] add write_echo() method to Input class for logging implicit commands where the echo command would send explicit ones --- src/KIM/kim_init.cpp | 14 ++++---------- src/KIM/kim_interactions.cpp | 3 +-- src/KIM/kim_query.cpp | 3 +-- src/input.cpp | 11 +++++++++++ src/input.h | 5 ++--- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 954a4b0f2c..a4272caa01 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -377,8 +377,7 @@ void KimInit::kim_init_log_delimiter(std::string const begin_end) const mesg = "#=== END kim-init ============================================\n\n"; - if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen); - if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile); + input->write_echo(mesg.c_str()); } } @@ -425,8 +424,7 @@ void KimInit::do_variables(char *user_units, char *model_units) mesg += " to "; mesg += to; mesg += ":\n"; - if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen); - if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile); + input->write_echo(mesg.c_str()); } for (int i = 0; i < nunits; i++) { @@ -455,14 +453,10 @@ void KimInit::do_variables(char *user_units, char *model_units) << " internal " << std::setprecision(12) << std::scientific << conversion_factor << std::endl; - if ((screen) && (input->echo_screen)) fputs(mesg.str().c_str(),screen); - if ((logfile) && (input->echo_log)) fputs(mesg.str().c_str(),logfile); + input->write_echo(mesg.str().c_str()); } } - if (comm->me == 0) { - if ((screen) && (input->echo_screen)) fputs("#\n",screen); - if ((logfile) && (input->echo_log)) fputs("#\n",logfile); - } + if (comm->me == 0) input->write_echo("#\n"); } /* ---------------------------------------------------------------------- */ diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index 449b6bcb13..7dbe523033 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -106,8 +106,7 @@ void KimInteractions::kim_interactions_log_delimiter( mesg = "#=== END kim_interactions ====================================\n\n"; - if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen); - if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile); + input->write_echo(mesg.c_str()); } } diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index e2bee158ed..1e699e74b0 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -306,7 +306,6 @@ void KimQuery::echo_var_assign(std::string const & name, if (comm->me == 0) { std::string mesg; mesg = name + " = " + value + "\n"; - if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen); - if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile); + input->write_echo(mesg.c_str()); } } diff --git a/src/input.cpp b/src/input.cpp index 08e3655437..8bf4fc12e1 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -314,6 +314,17 @@ char *Input::one(const char *single) return command; } +/* ---------------------------------------------------------------------- + Send text to active echo file pointers +------------------------------------------------------------------------- */ +void Input::write_echo(const char *txt) +{ + if (me == 0) { + if (echo_screen && screen) fputs(txt,screen); + if (echo_log && logfile) fputs(txt,logfile); + } +} + /* ---------------------------------------------------------------------- parse copy of command line by inserting string terminators strip comment = all chars from # on diff --git a/src/input.h b/src/input.h index dc5a2670d4..b86982cb39 100644 --- a/src/input.h +++ b/src/input.h @@ -25,8 +25,6 @@ class Input : protected Pointers { friend class Info; friend class Error; friend class Deprecated; - friend class KimInit; - friend class KimInteractions; public: int narg; // # of command args @@ -41,7 +39,8 @@ class Input : protected Pointers { void substitute(char *&, char *&, int &, int &, int); // substitute for variables in a string int expand_args(int, char **, int, char **&); // expand args due to wildcard - + void write_echo(const char *); // send text to active echo file pointers + protected: char *command; // ptr to current command int echo_screen; // 0 = no, 1 = yes From 2ffc35297bfc7904051cbc18ec4c6ea7d6599d86 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 29 Jul 2019 16:57:34 -0400 Subject: [PATCH 102/107] make kim_query log of variable setting look more like other KIM log messages this adds BEGIN/END marker comments and echoes the actual command line that the kim_query command implicitly executes --- src/KIM/kim_query.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index 1e699e74b0..cfb26c4d5e 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -305,7 +305,9 @@ void KimQuery::echo_var_assign(std::string const & name, { if (comm->me == 0) { std::string mesg; - mesg = name + " = " + value + "\n"; + mesg = "#=== BEGIN kim_query =========================================\n"; + mesg += "variable " + name + " string " + value + "\n"; + mesg += "#=== END kim_query ===========================================\n"; input->write_echo(mesg.c_str()); } } From c03e9c9711b5eed9ba3e2c589c18af4b5728e7e7 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Mon, 29 Jul 2019 16:11:08 -0500 Subject: [PATCH 103/107] Adjust write_echo() within kim_query --- src/KIM/kim_query.cpp | 23 +++++++++++++++++++++-- src/KIM/kim_query.h | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index cfb26c4d5e..e35afa9a8b 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -139,6 +139,7 @@ void KimQuery::command(int narg, char **arg) error->all(FLERR,errmsg); } + kim_query_log_delimiter("begin"); char **varcmd = new char*[3]; if (split) { int counter = 1; @@ -165,6 +166,7 @@ void KimQuery::command(int narg, char **arg) echo_var_assign(varname, value); } + kim_query_log_delimiter("end"); delete[] varcmd; delete[] value; @@ -300,14 +302,31 @@ char *do_query(char *qfunction, char * model_name, int narg, char **arg, } #endif +/* ---------------------------------------------------------------------- */ + +void KimQuery::kim_query_log_delimiter(std::string const begin_end) const +{ + if (comm->me == 0) { + std::string mesg; + if (begin_end == "begin") + mesg = + "#=== BEGIN kim-query =========================================\n"; + else if (begin_end == "end") + mesg = + "#=== END kim-query ===========================================\n\n"; + + input->write_echo(mesg.c_str()); + } +} + +/* ---------------------------------------------------------------------- */ + void KimQuery::echo_var_assign(std::string const & name, std::string const & value) const { if (comm->me == 0) { std::string mesg; - mesg = "#=== BEGIN kim_query =========================================\n"; mesg += "variable " + name + " string " + value + "\n"; - mesg += "#=== END kim_query ===========================================\n"; input->write_echo(mesg.c_str()); } } diff --git a/src/KIM/kim_query.h b/src/KIM/kim_query.h index 9cffc9ad28..33a37f5131 100644 --- a/src/KIM/kim_query.h +++ b/src/KIM/kim_query.h @@ -73,6 +73,7 @@ class KimQuery : protected Pointers { KimQuery(class LAMMPS *lmp) : Pointers(lmp) {}; void command(int, char **); private: + void kim_query_log_delimiter(std::string const begin_end) const; void echo_var_assign(std::string const & name, std::string const & value) const; }; From 9f276be0e532cee13031b807303cb8ffb5b0d43f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 29 Jul 2019 20:48:47 -0400 Subject: [PATCH 104/107] fix up legacy doc building for final kim doc files --- doc/src/lammps.book | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/lammps.book b/doc/src/lammps.book index 79b410c783..a3ec9c568b 100644 --- a/doc/src/lammps.book +++ b/doc/src/lammps.book @@ -168,7 +168,7 @@ include.html info.html jump.html kim_query.html -kim_style.html +kim_commands.html label.html lattice.html log.html From 90c678849ade82a139852971a5040039485ecfbf Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 29 Jul 2019 21:10:49 -0400 Subject: [PATCH 105/107] replace non-ascii characters with ASCII equivalents --- doc/src/compute.txt | 2 +- doc/src/kim_commands.txt | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/src/compute.txt b/doc/src/compute.txt index 53ed373aa5..0741699e61 100644 --- a/doc/src/compute.txt +++ b/doc/src/compute.txt @@ -177,7 +177,7 @@ compute"_Commands_compute.html doc page are followed by one or more of "angle"_compute_angle.html - energy of each angle sub-style "angle/local"_compute_angle_local.html - theta and energy of each angle "angmom/chunk"_compute_angmom_chunk.html - angular momentum for each chunk -"basal/atom"_compute_basal_atom.html - calculates the hexagonal close-packed “c” lattice vector of each atom +"basal/atom"_compute_basal_atom.html - calculates the hexagonal close-packed "c" lattice vector of each atom "body/local"_compute_body_local.html - attributes of body sub-particles "bond"_compute_bond.html - energy of each bond sub-style "bond/local"_compute_bond_local.html - distance and energy of each bond diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index 0bb7de03d6..93c4e8c4a8 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -258,12 +258,12 @@ variable xyfinal equal xy*$\{_u_distance\} variable xzfinal equal xz*$\{_u_distance\} variable yzfinal equal yz*$\{_u_distance\} change_box all x scale $\{_u_distance\} & -               y scale $\{_u_distance\} & -               z scale $\{_u_distance\} & -               xy final $\{xyfinal\} & -               xz final $\{xzfinal\} & -               yz final $\{yzfinal\} & -               remap :pre + y scale $\{_u_distance\} & + z scale $\{_u_distance\} & + xy final $\{xyfinal\} & + xz final $\{xzfinal\} & + yz final $\{yzfinal\} & + remap :pre NOTE: Unit conversion will only work if the conversion factors are placed in all appropriate places in the input script. It is up to the user to do this From 9004ebc3fe8ebb38b1b64236eb7e95b144a6882e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 29 Jul 2019 21:11:13 -0400 Subject: [PATCH 106/107] one more fixup for compatibility for old PDF build scheme --- doc/src/lammps.book | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/lammps.book b/doc/src/lammps.book index a3ec9c568b..b3808e18dc 100644 --- a/doc/src/lammps.book +++ b/doc/src/lammps.book @@ -42,6 +42,7 @@ Commands_compute.html Commands_pair.html Commands_bond.html Commands_kspace.html +Commands_removed.html Packages.html Packages_standard.html Packages_user.html @@ -167,7 +168,6 @@ if.html include.html info.html jump.html -kim_query.html kim_commands.html label.html lattice.html From c9f3f99ee84f2136acf5cb16c590289de41c4a14 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Mon, 29 Jul 2019 21:48:12 -0500 Subject: [PATCH 107/107] Update to kim-api-2.1.2 --- cmake/Modules/Packages/KIM.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 5987ebbf0a..d9d028f6dc 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -9,7 +9,9 @@ if(PKG_KIM) if(KIM-API_FOUND) set(DOWNLOAD_KIM_DEFAULT OFF) else() - message(WARNING "KIM-API package not found. We will download and build our own") + if (NOT DOWNLOAD_KIM) + message(WARNING "KIM-API package not found. We will download and build our own") + endif() set(DOWNLOAD_KIM_DEFAULT ON) endif() option(DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" ${DOWNLOAD_KIM_DEFAULT}) @@ -22,8 +24,8 @@ if(PKG_KIM) enable_language(Fortran) include(ExternalProject) ExternalProject_Add(kim_build - URL https://s3.openkim.org/kim-api/kim-api-2.1.1.txz - URL_MD5 ae0ee413e026c6e93d35692db5966fb4 + URL https://s3.openkim.org/kim-api/kim-api-2.1.2.txz + URL_MD5 6ac52e14ef52967fc7858220b208cba5 BINARY_DIR build CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}