diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 9ad64a59ed..30c8171f28 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -656,28 +656,34 @@ if(PKG_USER-VTK) endif() if(PKG_KIM) - option(DOWNLOAD_KIM "Download KIM-API v1 from OpenKIM instead of using an already installed one)" OFF) + option(DOWNLOAD_KIM "Download KIM-API v2 from OpenKIM instead of using an already installed one" OFF) if(DOWNLOAD_KIM) - message(STATUS "KIM-API v1 download requested - we will build our own") + message(STATUS "KIM-API v2 download requested - we will build our own") + enable_language(C) + enable_language(Fortran) include(ExternalProject) ExternalProject_Add(kim_build - URL https://github.com/openkim/kim-api/archive/v1.9.5.tar.gz - URL_MD5 9f66efc128da33039e30659f36fc6d00 - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND /configure --prefix= + URL https://s3.openkim.org/kim-api/kim-api-v2-2.0.0.txz + URL_MD5 1ff8f563ad5991f7a2a25b35a13d7308 + BINARY_DIR build + CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} + -DCMAKE_INSTALL_PREFIX= + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ) ExternalProject_get_property(kim_build INSTALL_DIR) - set(KIM_INCLUDE_DIRS ${INSTALL_DIR}/include/kim-api-v1) - set(KIM_LIBRARIES ${INSTALL_DIR}/lib/libkim-api-v1.so) + set(KIM-API-V2_INCLUDE_DIRS ${INSTALL_DIR}/include/kim-api-v2) + set(KIM-API-V2_LDFLAGS ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libkim-api-v2${CMAKE_SHARED_LIBRARY_SUFFIX}) list(APPEND LAMMPS_DEPS kim_build) else() - find_package(KIM) - if(NOT KIM_FOUND) - message(FATAL_ERROR "KIM-API v1 not found, help CMake to find it by setting KIM_LIBRARY and KIM_INCLUDE_DIR, or set DOWNLOAD_KIM=ON to download it") + find_package(KIM-API-V2) + if(NOT KIM-API-V2_FOUND) + message(FATAL_ERROR "KIM-API v2 not found, help CMake to find it by setting PKG_CONFIG_PATH, or set DOWNLOAD_KIM=ON to download it") endif() endif() - list(APPEND LAMMPS_LINK_LIBS ${KIM_LIBRARIES}) - include_directories(${KIM_INCLUDE_DIRS}) + list(APPEND LAMMPS_LINK_LIBS "${KIM-API-V2_LDFLAGS}") + include_directories(${KIM-API-V2_INCLUDE_DIRS}) endif() if(PKG_MESSAGE) diff --git a/cmake/Modules/FindKIM-API-V2.cmake b/cmake/Modules/FindKIM-API-V2.cmake new file mode 100644 index 0000000000..6ca6e068df --- /dev/null +++ b/cmake/Modules/FindKIM-API-V2.cmake @@ -0,0 +1,50 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the Common Development +# and Distribution License Version 1.0 (the "License"). +# +# You can obtain a copy of the license at +# http://www.opensource.org/licenses/CDDL-1.0. See the License for the +# specific language governing permissions and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each file and +# include the License file in a prominent location with the name LICENSE.CDDL. +# If applicable, add the following below this CDDL HEADER, with the fields +# enclosed by brackets "[]" replaced with your own identifying information: +# +# Portions Copyright (c) [yyyy] [name of copyright owner]. All rights reserved. +# +# CDDL HEADER END +# + +# +# Copyright (c) 2013--2018, Regents of the University of Minnesota. +# All rights reserved. +# +# Contributors: +# Richard Berger +# Christoph Junghans +# Ryan S. Elliott +# + +# - Find KIM-API-V2 +# +# sets standard pkg_check_modules variables plus: +# +# KIM-API-V2-CMAKE_C_COMPILER +# KIM-API-V2-CMAKE_CXX_COMPILER +# KIM-API-V2-CMAKE_Fortran_COMPILER +# +find_package(PkgConfig REQUIRED) +include(FindPackageHandleStandardArgs) + +pkg_check_modules(KIM-API-V2 REQUIRED libkim-api-v2>=2.0) + +pkg_get_variable(KIM-API-V2-CMAKE_C_COMPILER libkim-api-v2 CMAKE_C_COMPILER) +pkg_get_variable(KIM-API-V2-CMAKE_CXX_COMPILER libkim-api-v2 CMAKE_CXX_COMPILER) +pkg_get_variable(KIM-API-V2_CMAKE_Fortran_COMPILER libkim-api-v2 CMAKE_Fortran_COMPILER) + +# handle the QUIETLY and REQUIRED arguments and set KIM-API-V2_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(KIM-API-V2 REQUIRED_VARS KIM-API-V2_LIBRARIES) diff --git a/cmake/Modules/FindKIM.cmake b/cmake/Modules/FindKIM.cmake deleted file mode 100644 index a01f817cf6..0000000000 --- a/cmake/Modules/FindKIM.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# - Find kim -# Find the native KIM headers and libraries. -# -# KIM_INCLUDE_DIRS - where to find kim.h, etc. -# KIM_LIBRARIES - List of libraries when using kim. -# KIM_FOUND - True if kim found. -# - -find_path(KIM_INCLUDE_DIR KIM_API.h PATH_SUFFIXES kim-api-v1) - -find_library(KIM_LIBRARY NAMES kim-api-v1) - -set(KIM_LIBRARIES ${KIM_LIBRARY}) -set(KIM_INCLUDE_DIRS ${KIM_INCLUDE_DIR}) - -include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set KIM_FOUND to TRUE -# if all listed variables are TRUE - -find_package_handle_standard_args(KIM DEFAULT_MSG KIM_LIBRARY KIM_INCLUDE_DIR) - -mark_as_advanced(KIM_INCLUDE_DIR KIM_LIBRARY ) diff --git a/doc/src/Build_extras.txt b/doc/src/Build_extras.txt index 09841bd9d4..e7d520747a 100644 --- a/doc/src/Build_extras.txt +++ b/doc/src/Build_extras.txt @@ -191,16 +191,12 @@ package?" page. [CMake build]: --D DOWNLOAD_KIM=value # download OpenKIM API v1 for build, value = no (default) or yes --D KIM_LIBRARY=path # KIM library file (only needed if a custom location) --D KIM_INCLUDE_DIR=path # KIM include directory (only needed if a custom location) :pre +-D DOWNLOAD_KIM=value # download OpenKIM API v2 for build, value = no (default) or yes :pre If DOWNLOAD_KIM is set, the KIM library will be downloaded and built inside the CMake build directory. If the KIM library is already on -your system (in a location CMake cannot find it), KIM_LIBRARY is the -filename (plus path) of the KIM library file, not the directory the -library file is in. KIM_INCLUDE_DIR is the directory the KIM include -file is in. +your system (in a location CMake cannot find it), set the PKG_CONFIG_PATH +environment variable so that libkim-api-v2 can be found. [Traditional make]: @@ -214,8 +210,8 @@ make lib-kim args="-b " # (re-)install KIM API lib with only example models make lib-kim args="-b -a Glue_Ercolessi_Adams_Al__MO_324507536345_001" # ditto plus one model make lib-kim args="-b -a everything" # install KIM API lib with all models make lib-kim args="-n -a EAM_Dynamo_Ackland_W__MO_141627196590_002" # add one model or model driver -make lib-kim args="-p /usr/local/kim-api" # use an existing KIM API installation at the provided location -make lib-kim args="-p /usr/local/kim-api -a EAM_Dynamo_Ackland_W__MO_141627196590_002" # ditto but add one model or driver :pre +make lib-kim args="-p /usr/local" # use an existing KIM API installation at the provided location +make lib-kim args="-p /usr/local -a EAM_Dynamo_Ackland_W__MO_141627196590_002" # ditto but add one model or driver :pre :line diff --git a/doc/src/Errors_messages.txt b/doc/src/Errors_messages.txt index 23a7405f87..fb5003e602 100644 --- a/doc/src/Errors_messages.txt +++ b/doc/src/Errors_messages.txt @@ -6988,12 +6988,6 @@ The atom style defined does not have this attribute. :dd The atom style defined does not have these attributes. :dd -{KIM neighbor iterator exceeded range} :dt - -This should not happen. It likely indicates a bug -in the KIM implementation of the interatomic potential -where it is requesting neighbors incorrectly. :dd - {KOKKOS package does not yet support comm_style tiled} :dt Self-explanatory. :dd @@ -10185,10 +10179,6 @@ valid. :dd Self-explanatory. :dd -{Unrecognized virial argument in pair_style command} :dt - -Only two options are supported: LAMMPSvirial and KIMvirial :dd - {Unsupported mixing rule in kspace_style ewald/disp} :dt Only geometric mixing is supported. :dd diff --git a/doc/src/Packages_details.txt b/doc/src/Packages_details.txt index 7d3d6d13e2..5c98260bd1 100644 --- a/doc/src/Packages_details.txt +++ b/doc/src/Packages_details.txt @@ -346,12 +346,11 @@ system. 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) and James Sethna (Cornell U). +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 in collaboration with Valeriu Smirichinski (U -Minnesota). +developed the pair style. [Install:] @@ -2102,5 +2101,3 @@ src/USER-YAFF/README "pair_style mm3/switch3/coulgauss/long"_pair_mm3_switch3_coulgauss.html "pair_style lj/switch3/coulgauss/long"_pair_lj_switch3_coulgauss.html examples/USER/yaff :ul - - diff --git a/doc/src/fix_adapt.txt b/doc/src/fix_adapt.txt index fe86f49b25..0d862a890d 100644 --- a/doc/src/fix_adapt.txt +++ b/doc/src/fix_adapt.txt @@ -158,12 +158,6 @@ the pair_*.cpp file associated with the potential. Some parameters are global settings for the pair style, e.g. the viscosity setting "mu" for "pair_style lubricate"_pair_lubricate.html. -For "pair_kim"_pair_kim.html, all free parameters supported by the -KIM Model are available (e.g., PARAM_FREE_sigmas provided by the -LennardJones612_Universal__MO_826355984548_001 Model). If the free -parameter corresponds to an array, then the particular array element -to be adapted must be specified (e.g., "PARAM_FREE_sigmas:10", to -adapt the tenth entry of the sigmas array). Other parameters apply to atom type pairs within the pair style, e.g. the prefactor "a" for "pair_style soft"_pair_soft.html. diff --git a/doc/src/pair_kim.txt b/doc/src/pair_kim.txt index e1bde4f10e..67ab0b6c07 100644 --- a/doc/src/pair_kim.txt +++ b/doc/src/pair_kim.txt @@ -10,18 +10,13 @@ pair_style kim command :h3 [Syntax:] -pair_style kim virialmode model printflag :pre +pair_style kim model :pre -virialmode = KIMvirial or LAMMPSvirial model = name of KIM model (potential) -printflag = 1/0 do or do not print KIM descriptor file, optional :ul [Examples:] -pair_style kim KIMvirial model_Ar_P_Morse -pair_coeff * * Ar Ar :pre - -pair_style kim KIMvirial model_Ar_P_Morse 1 +pair_style kim ex_model_Ar_P_LJ pair_coeff * * Ar Ar :pre [Description:] @@ -51,25 +46,19 @@ 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. +See the examples/kim dir for an input script that uses a KIM model (potential) +for Lennard-Jones. Note, for this example input script, the example models +shipped with with kim-api package must be installed. See the "Build +package"_Build_package.html section and the ./lib/kim/README for details +on how to build LAMMSPS with the kim-api and how to install the example models. :line -The argument {virialmode} determines how the global virial is -calculated. If {KIMvirial} is specified, the KIM model performs the -global virial calculation (if it knows how). If {LAMMPSvirial} is -specified, LAMMPS computes the global virial using its fdotr mechanism. - 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. -The argument {printflag} is optional. If it is set to a non-zero -value then a KIM descriptor file is printed when KIM is invoked. This -can be useful for debugging. The default is to not print this file. - 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 @@ -86,18 +75,14 @@ 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. If a mapping value is specified as NULL, the -mapping is not performed. This can only be used when a {kim} -potential is used as part of the {hybrid} pair style. The NULL values -are placeholders for atom types that will be used with other -potentials. +as defined within KIM. :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. This 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 @@ -130,7 +115,7 @@ LAMMPS was built with that package. See the "Build package"_Build_package.html doc page for more info. This current version of pair_style kim is compatible with the -kim-api package version 1.6.0 and higher. +kim-api package version 2.0.0 and higher. [Related commands:] diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 5844dd3454..b76ec11f8d 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -1384,6 +1384,7 @@ libfftw libgcc libgpu libjpeg +libkim liblammps Liblammps liblink diff --git a/examples/kim/in.kim.lj.lmp b/examples/kim/in.kim.lj.lmp.newton-off similarity index 77% rename from examples/kim/in.kim.lj.lmp rename to examples/kim/in.kim.lj.lmp.newton-off index 8879024590..197755294a 100644 --- a/examples/kim/in.kim.lj.lmp +++ b/examples/kim/in.kim.lj.lmp.newton-off @@ -10,6 +10,7 @@ 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} @@ -17,13 +18,12 @@ create_box 1 box create_atoms 1 box pair_style lj/cut 8.1500 -pair_coeff 1 1 0.0031 2.7400 -pair_modify shift yes +pair_coeff 1 1 0.0104 3.4000 -#pair_style kim KIMvirial ex_model_Ne_P_fastLJ -#pair_coeff * * Ne +#pair_style kim LennardJones_Ar +#pair_coeff * * Ar -mass 1 20.18 +mass 1 39.95 velocity all create 200.0 232345 loop geom neighbor 0.3 bin diff --git a/examples/kim/in.kim.lj b/examples/kim/in.kim.lj.lmp.newton-on similarity index 73% rename from examples/kim/in.kim.lj rename to examples/kim/in.kim.lj.lmp.newton-on index f33b258be8..f9f79e2bb2 100644 --- a/examples/kim/in.kim.lj +++ b/examples/kim/in.kim.lj.lmp.newton-on @@ -10,20 +10,20 @@ 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.0031 2.7400 -#pair_modify shift yes +pair_style lj/cut 8.1500 +pair_coeff 1 1 0.0104 3.4000 -pair_style kim KIMvirial ex_model_Ne_P_fastLJ -pair_coeff * * Ne +#pair_style kim LennardJones_Ar +#pair_coeff * * Ar -mass 1 20.18 +mass 1 39.95 velocity all create 200.0 232345 loop geom neighbor 0.3 bin diff --git a/examples/kim/in.kim.lj.newton-off b/examples/kim/in.kim.lj.newton-off new file mode 100644 index 0000000000..82cf5ba602 --- /dev/null +++ b/examples/kim/in.kim.lj.newton-off @@ -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 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 new file mode 100644 index 0000000000..3a95f1dbb0 --- /dev/null +++ b/examples/kim/in.kim.lj.newton-on @@ -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 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/log.06Feb2019.in.kim.lj.lmp.newton-off.1 b/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-off.1 new file mode 100644 index 0000000000..5925fd750d --- /dev/null +++ b/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-off.1 @@ -0,0 +1,55 @@ +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 new file mode 100644 index 0000000000..c1ca108c7b --- /dev/null +++ b/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-off.4 @@ -0,0 +1,55 @@ +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 new file mode 100644 index 0000000000..53555743d7 --- /dev/null +++ b/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-on.1 @@ -0,0 +1,55 @@ +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 new file mode 100644 index 0000000000..f0fdf66193 --- /dev/null +++ b/examples/kim/log.06Feb2019.in.kim.lj.lmp.newton-on.4 @@ -0,0 +1,55 @@ +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 new file mode 100644 index 0000000000..0ab258fe0d --- /dev/null +++ b/examples/kim/log.06Feb2019.in.kim.lj.newton-off.1 @@ -0,0 +1,59 @@ +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 new file mode 100644 index 0000000000..c17ea6afb7 --- /dev/null +++ b/examples/kim/log.06Feb2019.in.kim.lj.newton-off.4 @@ -0,0 +1,65 @@ +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 new file mode 100644 index 0000000000..59d018e12a --- /dev/null +++ b/examples/kim/log.06Feb2019.in.kim.lj.newton-on.1 @@ -0,0 +1,59 @@ +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 new file mode 100644 index 0000000000..da8c9f0faa --- /dev/null +++ b/examples/kim/log.06Feb2019.in.kim.lj.newton-on.4 @@ -0,0 +1,65 @@ +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.28Jun15.kim.lj.lmp.ubuntu.1 b/examples/kim/log.28Jun15.kim.lj.lmp.ubuntu.1 deleted file mode 100644 index efae0587a1..0000000000 --- a/examples/kim/log.28Jun15.kim.lj.lmp.ubuntu.1 +++ /dev/null @@ -1,33 +0,0 @@ -LAMMPS (15 May 2015) -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 -Neighbor list info ... - 1 neighbor list requests - update every 1 steps, delay 0 steps, check yes - master list distance cutoff = 8.45 -Setting up run ... -Memory usage per processor = 9.18789 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 -741.55469 0 85.684388 -34.939092 - 100 108.37517 -362.56658 0 85.694308 3963.7892 -Loop time of 2.95205 on 1 procs for 100 steps with 32000 atoms - -Pair time (%) = 2.52074 (85.3894) -Neigh time (%) = 0.347949 (11.7867) -Comm time (%) = 0.0228171 (0.772925) -Outpt time (%) = 0.000188828 (0.00639649) -Other time (%) = 0.0603588 (2.04464) - -Nlocal: 32000 ave 32000 max 32000 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 20131 ave 20131 max 20131 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 1.88909e+06 ave 1.88909e+06 max 1.88909e+06 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 1889091 -Ave neighs/atom = 59.0341 -Neighbor list builds = 5 -Dangerous builds = 0 diff --git a/examples/kim/log.28Jun15.kim.lj.lmp.ubuntu.4 b/examples/kim/log.28Jun15.kim.lj.lmp.ubuntu.4 deleted file mode 100644 index 12c1c76695..0000000000 --- a/examples/kim/log.28Jun15.kim.lj.lmp.ubuntu.4 +++ /dev/null @@ -1,33 +0,0 @@ -LAMMPS (15 May 2015) -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 -Neighbor list info ... - 1 neighbor list requests - update every 1 steps, delay 0 steps, check yes - master list distance cutoff = 8.45 -Setting up run ... -Memory usage per processor = 4.58461 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 -741.55469 0 85.684388 -34.939092 - 100 108.37517 -362.56658 0 85.694308 3963.7892 -Loop time of 6.15911 on 4 procs for 100 steps with 32000 atoms - -Pair time (%) = 1.76201 (28.6083) -Neigh time (%) = 0.265002 (4.30261) -Comm time (%) = 3.64452 (59.1729) -Outpt time (%) = 0.0169877 (0.275815) -Other time (%) = 0.470582 (7.64042) - -Nlocal: 8000 ave 8010 max 7989 min -Histogram: 1 0 0 0 0 2 0 0 0 1 -Nghost: 9240.25 ave 9249 max 9228 min -Histogram: 1 0 0 0 1 0 0 0 0 2 -Neighs: 472273 ave 473390 max 471652 min -Histogram: 2 0 0 1 0 0 0 0 0 1 - -Total # of neighbors = 1889091 -Ave neighs/atom = 59.0341 -Neighbor list builds = 5 -Dangerous builds = 0 diff --git a/examples/kim/log.28Jun15.kim.lj.ubuntu.1 b/examples/kim/log.28Jun15.kim.lj.ubuntu.1 deleted file mode 100644 index 95284453b1..0000000000 --- a/examples/kim/log.28Jun15.kim.lj.ubuntu.1 +++ /dev/null @@ -1,33 +0,0 @@ -LAMMPS (15 May 2015) -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 -Neighbor list info ... - 1 neighbor list requests - update every 1 steps, delay 0 steps, check yes - master list distance cutoff = 8.45 -Setting up run ... -Memory usage per processor = 9.43789 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 -741.55469 0 85.684388 -34.939092 - 100 108.37517 -362.56658 0 85.694308 3963.7892 -Loop time of 3.79746 on 1 procs for 100 steps with 32000 atoms - -Pair time (%) = 3.18686 (83.9207) -Neigh time (%) = 0.524724 (13.8178) -Comm time (%) = 0.0244031 (0.642616) -Outpt time (%) = 0.000174046 (0.00458321) -Other time (%) = 0.061305 (1.61437) - -Nlocal: 32000 ave 32000 max 32000 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 20131 ave 20131 max 20131 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 2.09236e+06 ave 2.09236e+06 max 2.09236e+06 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 2092355 -Ave neighs/atom = 65.3861 -Neighbor list builds = 5 -Dangerous builds = 0 diff --git a/examples/kim/log.28Jun15.kim.lj.ubuntu.4 b/examples/kim/log.28Jun15.kim.lj.ubuntu.4 deleted file mode 100644 index 7eaf58aad4..0000000000 --- a/examples/kim/log.28Jun15.kim.lj.ubuntu.4 +++ /dev/null @@ -1,33 +0,0 @@ -LAMMPS (15 May 2015) -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 -Neighbor list info ... - 1 neighbor list requests - update every 1 steps, delay 0 steps, check yes - master list distance cutoff = 8.45 -Setting up run ... -Memory usage per processor = 4.70961 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 200 -741.55469 0 85.684388 -34.939092 - 100 108.37517 -362.56658 0 85.694308 3963.7892 -Loop time of 7.25305 on 4 procs for 100 steps with 32000 atoms - -Pair time (%) = 2.52571 (34.8227) -Neigh time (%) = 0.500287 (6.8976) -Comm time (%) = 3.70236 (51.0456) -Outpt time (%) = 0.00146681 (0.0202234) -Other time (%) = 0.523229 (7.21391) - -Nlocal: 8000 ave 8010 max 7989 min -Histogram: 1 0 0 0 0 2 0 0 0 1 -Nghost: 9240.25 ave 9249 max 9228 min -Histogram: 1 0 0 0 1 0 0 0 0 2 -Neighs: 555266 ave 555920 max 554805 min -Histogram: 2 0 0 0 0 1 0 0 0 1 - -Total # of neighbors = 2221065 -Ave neighs/atom = 69.4083 -Neighbor list builds = 5 -Dangerous builds = 0 diff --git a/lib/kim/.gitignore b/lib/kim/.gitignore index c1f57fe64c..bfd4b35d87 100644 --- a/lib/kim/.gitignore +++ b/lib/kim/.gitignore @@ -1,3 +1,2 @@ -/Makefile.KIM_DIR -/Makefile.KIM_Config +/kim-prefix.txt /installed-kim-api-* diff --git a/lib/kim/Install.py b/lib/kim/Install.py index 7031fbd473..e2465eec85 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-v1.9.5" +version = "kim-api-v2-2.0.0" # help message @@ -35,19 +35,15 @@ Syntax from lib dir: python Install.py -b -v version -a kim-name Examples: make lib-kim args="-b" # install KIM API lib with only example models -make lib-kim args="-b -a Glue_Ercolessi_Adams_Al__MO_324507536345_001" # Ditto plus one model +make lib-kim args="-b -a EAM_ErcolessiAdams_1994_Al__MO_324507536345_002" # Ditto plus one model make lib-kim args="-b -a everything" # install KIM API lib with all models -make lib-kim args="-n -a EAM_Dynamo_Ackland_W__MO_141627196590_002" # only add one model or model driver +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/kim-items/model-drivers/alphabetical See the list of all KIM models here: https://openkim.org/kim-items/models/by-model-drivers - -See the list of example KIM models included by default here: -https://openkim.org/kim-api -in the "What is in the KIM API source package?" section """ pgroup = parser.add_mutually_exclusive_group() @@ -94,13 +90,10 @@ url = "https://s3.openkim.org/kim-api/%s.txz" % version if pathflag: # configure LAMMPS to use existing kim-api installation - with open("%s/Makefile.KIM_DIR" % thisdir, 'w') as mkfile: - mkfile.write("KIM_INSTALL_DIR=%s\n\n" % kimdir) - mkfile.write(".DUMMY: print_dir\n\n") - mkfile.write("print_dir:\n") - mkfile.write(" @printf $(KIM_INSTALL_DIR)\n") + with open("%s/kim-prefix.txt" % thisdir, 'w') as pffile: + pffile.write("%s" % kimdir) - print("Created %s/Makefile.KIM_DIR\n using %s" % (thisdir, kimdir)) + print("Created %s/kim-prefix.txt\n using %s" % (thisdir,kimdir)) else: kimdir = os.path.join(os.path.abspath(thisdir), "installed-" + version) if args.nobuild and not os.path.isdir(kimdir): @@ -117,13 +110,10 @@ if buildflag: # configure LAMMPS to use kim-api to be installed - with open("%s/Makefile.KIM_DIR" % thisdir, 'w') as mkfile: - mkfile.write("KIM_INSTALL_DIR=%s\n\n" % kimdir) - mkfile.write(".DUMMY: print_dir\n\n") - mkfile.write("print_dir:\n") - mkfile.write(" @printf $(KIM_INSTALL_DIR)\n") + with open("%s/kim-prefix.txt" % thisdir, 'w') as pffile: + pffile.write("%s" % kimdir) - print("Created %s/Makefile.KIM_DIR\n using %s" % (thisdir, kimdir)) + print("Created %s/kim-prefix.txt\n using %s" % (thisdir,kimdir)) # download entire kim-api tarball @@ -136,12 +126,13 @@ if buildflag: # configure kim-api print("Configuring kim-api ...") - cmd = 'cd "%s/%s"; ./configure --prefix="%s"' % (thisdir, version, kimdir) - subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + cmd = 'cd "%s/%s" && mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX="%s" -DCMAKE_BUILD_TYPE=Release' % (thisdir,version,kimdir) + txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) + if verboseflag: print(txt.decode("UTF-8")) # build kim-api print("Building kim-api ...") - cmd = 'cd "%s/%s"; make' % (thisdir, version) + cmd = 'cd "%s/%s/build" && make' % (thisdir, version) txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) if verboseflag: print(txt.decode("UTF-8")) @@ -149,23 +140,13 @@ if buildflag: # install kim-api print("Installing kim-api ...") - cmd = 'cd "%s/%s"; make install' % (thisdir, version) + cmd = 'cd "%s/%s/build" && make install' % (thisdir, version) txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) if verboseflag: print(txt.decode("UTF-8")) # remove source files - print("Building and installing example Models") - cmd = 'cd "%s/%s/examples"; make model-drivers-all-system' % (thisdir, version) - txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) - if verboseflag: - print(txt.decode("UTF-8")) - cmd = 'cd "%s/%s/examples"; make models-all-system' % (thisdir, version) - txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) - if verboseflag: - print(txt.decode("UTF-8")) - print("Removing kim-api source and build files ...") cmd = 'cd "%s"; rm -rf %s; rm -rf %s.txz' % (thisdir, version, version) subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) @@ -173,7 +154,7 @@ if buildflag: # add all OpenKIM models, if desired if everythingflag: print("Adding all OpenKIM models, this will take a while ...") - cmd = '%s/bin/kim-api-v1-collections-management install system OpenKIM' % (kimdir) + cmd = '%s/bin/kim-api-v2-collections-management install system OpenKIM' % (kimdir) txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) if verboseflag: print(txt.decode("UTF-8")) @@ -181,16 +162,16 @@ if buildflag: # add single OpenKIM model if addflag: - makefile_path = os.path.join(thisdir, "Makefile.KIM_DIR") - if os.path.isfile(makefile_path): - cmd = 'make --no-print-directory -f %s print_dir' % makefile_path - kimdir = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + pf_path = os.path.join(thisdir, "kim-prefix.txt") + if os.path.isfile(pf_path): + cmd = 'cat %s' % pf_path + kimdir = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) if not os.path.isdir(kimdir): sys.exit("\nkim-api is not installed") # download single model - cmd = '%s/bin/kim-api-v1-collections-management install system %s' % (kimdir.decode("UTF-8"), addmodelname) + cmd = '%s/bin/kim-api-v2-collections-management install system %s' % (kimdir.decode("UTF-8"), addmodelname) txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) if verboseflag: print(txt.decode("UTF-8")) diff --git a/lib/kim/Makefile.lammps b/lib/kim/Makefile.lammps index d73891d1e2..7c9fc7c5f7 100644 --- a/lib/kim/Makefile.lammps +++ b/lib/kim/Makefile.lammps @@ -5,8 +5,6 @@ # The KIM API package can be downloaded from https://openkim.org/kim-api # Follow the instructions in the INSTALL file to build and install the # KIM API. Add the openkim.org Models you are interested in using. -# Make sure the directory where the "kim-api-build-conifg" utility is -# located is on the PATH. # # As long as you have followed the KIM API build and install instructions, # there should not be any reason to change this file. @@ -16,17 +14,17 @@ # Settings that the LAMMPS build will import when this package is installed -include ../../lib/kim/Makefile.KIM_DIR - -ifeq ($(wildcard $(KIM_INSTALL_DIR)/bin/kim-api-v1-build-config),) - KIM_CONFIG_HELPER = kim-api-v1-build-config -else - KIM_CONFIG_HELPER = $(KIM_INSTALL_DIR)/bin/kim-api-v1-build-config -endif -ifeq ($(shell $(KIM_CONFIG_HELPER) --version 2> /dev/null),) - $(error $(KIM_CONFIG_HELPER) utility is not available. Something is wrong with your KIM API package setup) +ifeq ($(strip $(shell pkg-config --version)),) + $(error 'pkg-config' not found, but is required to configure the KIM API) endif -kim_SYSINC = $(shell $(KIM_CONFIG_HELPER) --includes) -kim_SYSLIB = $(shell $(KIM_CONFIG_HELPER) --ldlibs) -kim_SYSPATH = $(shell $(KIM_CONFIG_HELPER) --ldflags) +kim_PREFIX := $(shell cat ../../lib/kim/kim-prefix.txt 2> /dev/null) +kim_PREFIX := $(if $(kim_PREFIX),$(kim_PREFIX)/lib/pkgconfig,) +kim_PREFIX := $(if $(shell printf -- "$${PKG_CONFIG_PATH}"),$(kim_PREFIX):$(shell printf -- "$${PKG_CONFIG_PATH}"),$(kim_PREFIX)) + +kim_SYSINC := $(shell export PKG_CONFIG_PATH="$(kim_PREFIX)"; pkg-config --cflags libkim-api-v2 2> /dev/null) +kim_SYSLIB := $(shell export PKG_CONFIG_PATH="$(kim_PREFIX)"; pkg-config --libs libkim-api-v2 2> /dev/null) + +ifeq ($(strip $(kim_SYSINC)),) + $(error 'pkg-config' could not find an installed KIM API library.) +endif diff --git a/lib/kim/README b/lib/kim/README index ce4ea1bdff..0e51a30870 100644 --- a/lib/kim/README +++ b/lib/kim/README @@ -3,10 +3,9 @@ is required to use the KIM package and its pair_style kim command 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) 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 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. 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 @@ -21,33 +20,34 @@ Instructions: 1. Configure lammps for use with the kim-api library installed in this directory # replace X.Y.Z as appropriate here and below -$ printf "KIM_INSTALL_DIR=${PWD}/installed-kim-api-vX.Y.Z\n" > ./Makefile.KIM_DIR +$ printf "${PWD}/installed-kim-api-vX-X.Y.Z" > ./kim-prefix.txt 2. Download and unpack the kim-api -$ wget http://s3.openkim.org/kim-api/kim-api-vX.Y.Z.txz -$ tar zxvf kim-api-vX.Y.Z.txz +$ wget http://s3.openkim.org/kim-api/kim-api-vX-X.Y.Z.txz +$ tar zxvf kim-api-vX-X.Y.Z.txz # configure the kim-api -$ cd kim-api-vX.Y.Z -$ ./configure --prefix=${PWD}/../installed-kim-api-vX.Y.Z +$ cd kim-api-vX-X.Y.Z +$ mkdir build && cd build +$ cmake .. -DCMAKE_INSTALL_PREFIX=${PWD}/../../installed-kim-api-vX-X.Y.Z 3. Build and install the kim-api and model $ make $ make install -$ cd .. 4. Remove source and build files -$ rm -rf kim-api-vX.Y.Z -$ rm -rf kim-api-vX.Y.Z.txz +$ cd ../../ +$ rm -rf kim-api-vX-X.Y.Z +$ rm -rf kim-api-vX-X.Y.Z.txz 5. To add items do the following (replace the kim item name with your desired value) -$ source ${PWD}/kim-api-vX.Y.Z/bin/kim-api-v1-activate -$ kim-api-v1-collections-management install system Pair_Johnson_Fe__MO_857282754307_002 +$ source ${PWD}/kim-api-vX-X.Y.Z/bin/kim-api-vX-activate +$ kim-api-vX-collections-management install system Pair_Johnson_Fe__MO_857282754307_002 ----------------- @@ -59,6 +59,6 @@ $ cd lammpos/src $ make yes-kim $ make g++ (or whatever target you wish) -Note that the Makefile.lammps and Makefile.KIM_DIR files in this directory -are required to allow the LAMMPS build to find the necessary KIM files. -You should not normally need to edit these files. +Note that the Makefile.lammps file in this directory is required to +allow the LAMMPS build to find the necessary KIM files. You should +not normally need to edit these files. diff --git a/src/KIM/README b/src/KIM/README index 496db92cf2..a69206596f 100644 --- a/src/KIM/README +++ b/src/KIM/README @@ -26,5 +26,4 @@ library you can test it using an input file from the examples dir: ./lmp_serial < lammps/examples/kim/in.kim.lj -This pair_style was written by Valeriu Smirichinski and Ryan -S. Elliott (U Minn). +This pair_style was written by Ryan S. Elliott (U Minn). diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index fe638214ba..a4517b848c 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -12,14 +12,45 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing authors: Ryan S. Elliott, - Valeriu Smirichinski, - Ellad Tadmor + Contributing authors: Ryan S. Elliott (UMinn) ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Designed for use with the openkim-api-v1.5.0 package and for use with - the kim-api-v1.6.0 (and newer) package + 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-v2-2.0.0 (and newer) package ------------------------------------------------------------------------- */ #include @@ -38,17 +69,6 @@ #include "domain.h" #include "error.h" -// includes from KIM -#include "KIM_API.h" -#include "KIM_API_status.h" - -#ifndef KIM_API_VERSION_MAJOR -// support v1.5.0 -#define KIM_API_VERSION_MAJOR 1 -#define KIM_API_VERSION_MINOR 5 -#define KIM_API_VERSION_PATCH 0 -#endif - using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ @@ -57,44 +77,47 @@ PairKIM::PairKIM(LAMMPS *lmp) : Pair(lmp), settings_call_count(0), init_style_call_count(0), - kim_modelname(0), - lmps_map_species_to_unique(0), - lmps_unique_elements(0), + kim_modelname(NULL), + lmps_map_species_to_unique(NULL), + lmps_unique_elements(NULL), lmps_num_unique_elements(0), lmps_units(METAL), - pkim(0), - kim_ind_coordinates(-1), - kim_ind_numberOfParticles(-1), - kim_ind_numberContributingParticles(-1), - kim_ind_numberOfSpecies(-1), - kim_ind_particleSpecies(-1), - kim_ind_get_neigh(-1), - kim_ind_neighObject(-1), - kim_ind_cutoff(-1), - kim_ind_energy(-1), - kim_ind_particleEnergy(-1), - kim_ind_forces(-1), - kim_ind_virial(-1), - kim_ind_particleVirial(-1), - kim_particle_codes(0), + 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), + 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_cutoff(0.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(0), - lmps_force_tmp(0), - lmps_stripped_neigh_list(0), - kim_iterator_position(0), - Rij(0) + kim_particleSpecies(NULL), + kim_particleContributing(NULL), + lmps_stripped_neigh_list(NULL), + lmps_stripped_neigh_ptr(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; // BEGIN: initial values that determine the KIM state // (used by kim_free(), etc.) - kim_model_init_ok = false; kim_init_ok = false; + kim_particle_codes_ok = false; // END return; @@ -113,10 +136,23 @@ PairKIM::~PairKIM() 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; + } + // clean up local memory used to support KIM interface memory->destroy(kim_particleSpecies); - memory->destroy(lmps_force_tmp); + 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 @@ -126,8 +162,12 @@ PairKIM::~PairKIM() delete [] lmps_map_species_to_unique; } - // clean up Rij array - memory->destroy(Rij); + // clean up neighborlist pointers + if (neighborLists) + { + delete [] neighborLists; + neighborLists = 0; + } // clean up KIM interface (if necessary) kim_free(); @@ -135,6 +175,16 @@ PairKIM::~PairKIM() return; } +/* ---------------------------------------------------------------------- */ +void PairKIM::set_contributing() +{ + int const nall = atom->nlocal + atom->nghost; + for (int i = 0; i < nall; ++i) + { + kim_particleContributing[i] = ( (i < atom->nlocal) ? 1 : 0 ); + } +} + /* ---------------------------------------------------------------------- */ void PairKIM::compute(int eflag , int vflag) @@ -146,19 +196,31 @@ void PairKIM::compute(int eflag , int vflag) else ev_unset(); - // grow kim_particleSpecies array if necessary + // 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(lmps_force_tmp); + memory->destroy(kim_particleContributing); lmps_maxalloc = atom->nmax; - memory->create(kim_particleSpecies,lmps_maxalloc,"pair:kim_particleSpecies"); - memory->create(lmps_force_tmp,lmps_maxalloc,3,"pair:lmps_force_tmp"); + 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 - // set ielement to valid 0 if lmps_map_species_to_unique[] stores an un-used -1 int *species = atom->type; int nall = atom->nlocal + atom->nghost; @@ -166,57 +228,38 @@ void PairKIM::compute(int eflag , int vflag) for (int i = 0; i < nall; i++) { ielement = lmps_map_species_to_unique[species[i]]; - ielement = MAX(ielement,0); - // @@ this (above line) provides bogus info - // @@ (when lmps_map_species_to_unique[species[i]]==-1) to KIM, but - // @@ I guess this only happens when lmps_hybrid==true, - // @@ and we are sure that iterator mode will - // @@ not use these atoms.... (?) kim_particleSpecies[i] = kim_particle_codes[ielement]; } - // pass current atom pointers to KIM - set_volatiles(); + // Set kim contributing flags + set_contributing(); - pkim->setm_compute_by_index(&kimerror,3*3, - kim_ind_particleEnergy, eflag_atom, - (int) kim_model_has_particleEnergy, - kim_ind_particleVirial, vflag_atom, - (int) kim_model_has_particleVirial, - kim_ind_virial, vflag_global!=0, - no_virial_fdotr_compute); - kim_error(__LINE__,"setm_compute_by_index",kimerror); + // pass current atom pointers to KIM + set_argument_pointers(); + + // set number of particles + lmps_local_tot_num_atoms = (int) nall; // compute via KIM model - kimerror = pkim->model_compute(); - kim_error(__LINE__,"PairKIM::pkim->model_compute() error",kimerror); - // assemble force and particleVirial if needed - if (!lmps_using_newton) comm->reverse_comm_pair(this); + kimerror = KIM_Model_Compute(pkim, pargs); + if (kimerror) error->all(FLERR,"KIM Compute returned error"); - // sum lmps_force_tmp to f if running in hybrid mode - if (lmps_hybrid) { - double **f = atom->f; - for (int i = 0; i < nall; i++) { - f[i][0] += lmps_force_tmp[i][0]; - f[i][1] += lmps_force_tmp[i][1]; - f[i][2] += lmps_force_tmp[i][2]; - } + // compute virial before reverse comm! + if (vflag_global) + { + virial_fdotr_compute(); } - if ((no_virial_fdotr_compute == 1) && (vflag_global)) - { // flip sign and order of virial if KIM is computing it - for (int i = 0; i < 3; ++i) virial[i] = -1.0*virial[i]; - double tmp = virial[3]; - virial[3] = -virial[5]; - virial[4] = -virial[4]; - virial[5] = -tmp; - } - else - { // compute virial via LAMMPS fdotr mechanism - if (vflag_fdotr) virial_fdotr_compute(); + // if newton is off, perform reverse comm + if (!lmps_using_newton) + { + comm->reverse_comm_pair(this); } - if ((kim_model_has_particleVirial) && (vflag_atom)) + 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) @@ -267,10 +310,20 @@ void PairKIM::settings(int narg, char **arg) ++settings_call_count; init_style_call_count = 0; - if (narg < 2) error->all(FLERR,"Illegal pair_style command"); - // arg[0] is the virial handling option: "LAMMPSvirial" or "KIMvirial" - // arg[1] is the KIM Model name - // arg[2] is the print-kim-file flag: 0/1 do-not/do print (default 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-v2."); + } + else + error->all(FLERR,"Illegal pair_style command"); + } + // arg[0] is the KIM Model name + + 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... @@ -288,39 +341,18 @@ void PairKIM::settings(int narg, char **arg) // set lmps_* bool flags set_lmps_flags(); - // set virial handling - if (strcmp(arg[0],"LAMMPSvirial") == 0) - { - no_virial_fdotr_compute = 0; - } - else if (strcmp(arg[0],"KIMvirial") == 0) - { - no_virial_fdotr_compute = 1; - } - else - { - error->all(FLERR,"Unrecognized virial argument in pair_style command"); - } - // set KIM Model name - int nmlen = strlen(arg[1]); + 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[1]); + strcpy(kim_modelname, arg[0]); - // set print_kim_file - if ((2 == narg) || ('0' == *(arg[2]))) - { - print_kim_file = false; - } - else - { - print_kim_file = true; - } + // initialize KIM Model + kim_init(); return; } @@ -341,13 +373,19 @@ void PairKIM::coeff(int narg, char **arg) if (narg != 2 + atom->ntypes) error->all(FLERR,"Incorrect args for pair coefficients"); + // insure I,J args are * * + + 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); // read args that map atom species to KIM elements // lmps_map_species_to_unique[i] = - // which element the Ith atom type is, -1 if NULL + // which element the Ith atom type is // lmps_num_unique_elements = # of unique elements // lmps_unique_elements = list of element names @@ -360,23 +398,20 @@ void PairKIM::coeff(int narg, char **arg) lmps_unique_elements = new char*[atom->ntypes]; for (i = 0; i < atom->ntypes; i++) lmps_unique_elements[i] = 0; + + // Assume all species arguments are valid + // errors will be detected by below lmps_num_unique_elements = 0; for (i = 2; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - if (!lmps_hybrid) - error->all(FLERR,"Invalid args for non-hybrid pair coefficients"); - lmps_map_species_to_unique[i-1] = -1; - continue; - } - 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++; - } + 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; @@ -392,6 +427,35 @@ void PairKIM::coeff(int narg, char **arg) if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); + // 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 kimerror; + int supported; + int code; + kimerror = KIM_Model_GetSpeciesSupportAndCode( + pkim, + KIM_SpeciesName_FromString(lmps_unique_elements[i]), + &supported, + &code); + 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()); + } + } + return; } @@ -408,58 +472,64 @@ void PairKIM::init_style() error->all(FLERR,"PairKIM only works with 3D problems"); int kimerror; - // KIM and Model initialization (only once) - // also sets kim_ind_* and kim_* bool flags - if (!kim_init_ok) - { - kim_init(); - kimerror = pkim->model_init(); - if (kimerror != KIM_STATUS_OK) - kim_error(__LINE__, "KIM API:model_init() failed", kimerror); - else - { - kim_model_init_ok = true; - // allocate enough memory to ensure we are safe - // (by using neighbor->oneatom) - if (kim_model_using_Rij) - memory->create(Rij,3*(neighbor->oneatom),"pair:Rij"); + // 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-1)*(neighbor->oneatom)]); } + } - // request none, half, or full neighbor list - // depending on KIM model requirement + // make sure comm_reverse expects (at most) 9 values when newton is off + if (!lmps_using_newton) comm_reverse_off = 9; - int irequest = neighbor->request(this,instance_me); - if (kim_model_using_cluster) + // request full neighbor + for (int i = 0; i < kim_number_of_neighbor_lists; ++i) { - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->full = 0; - } - else - { - // make sure comm_reverse expects (at most) 9 values when newton is off - if (!lmps_using_newton) comm_reverse_off = 9; + int irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = i; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->full = 1; - if (kim_model_using_half) - { - neighbor->requests[irequest]->half = 1; - neighbor->requests[irequest]->full = 0; - // make sure half lists also include local-ghost pairs - if (lmps_using_newton) neighbor->requests[irequest]->newton = 2; - } - else - { - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->full = 1; - // make sure full lists also include local-ghost pairs - if (lmps_using_newton) neighbor->requests[irequest]->newton = 0; - } + if (modelWillNotRequestNeighborsOfNoncontributingParticles[i]) + { + neighbor->requests[irequest]->ghost = 0; + } + else + { + neighbor->requests[irequest]->ghost = 1; + + } + // always want all owned/ghost pairs + neighbor->requests[irequest]->newton = 2; + // set cutoff + neighbor->requests[irequest]->cut = 1; + neighbor->requests[irequest]->cutoff + = kim_cutoff_values[i] + neighbor->skin; } return; } +/* ---------------------------------------------------------------------- + neighbor callback to inform pair style of neighbor list to use + half or full +------------------------------------------------------------------------- */ + +void PairKIM::init_list(int id, NeighList *ptr) +{ + neighborLists[id] = ptr; +} + /* ---------------------------------------------------------------------- init for one type pair i,j and corresponding j,i ------------------------------------------------------------------------- */ @@ -471,22 +541,7 @@ double PairKIM::init_one(int i, int j) if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); - return kim_global_cutoff; -} - -/* ---------------------------------------------------------------------- */ - -void PairKIM::reinit() -{ - // This is called by fix-adapt - - // Call parent class implementation - Pair::reinit(); - - // Then reinit KIM model - int kimerror; - kimerror = pkim->model_reinit(); - kim_error(__LINE__,"model_reinit unsuccessful", kimerror); + return kim_global_influence_distance; } /* ---------------------------------------------------------------------- */ @@ -495,13 +550,16 @@ int PairKIM::pack_reverse_comm(int n, int first, double *buf) { int i,m,last; double *fp; - if (lmps_hybrid) fp = &(lmps_force_tmp[0][0]); - else fp = &(atom->f[0][0]); + fp = &(atom->f[0][0]); m = 0; last = first + n; - if ((kim_model_has_forces) && ((vflag_atom == 0) || - (!kim_model_has_particleVirial))) + 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++) { @@ -511,8 +569,11 @@ int PairKIM::pack_reverse_comm(int n, int first, double *buf) } return m; } - else if ((kim_model_has_forces) && (vflag_atom == 1) && - (kim_model_has_particleVirial)) + 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++) @@ -530,8 +591,12 @@ int PairKIM::pack_reverse_comm(int n, int first, double *buf) } return m; } - else if ((!kim_model_has_forces) && (vflag_atom == 1) && - (kim_model_has_particleVirial)) + 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++) @@ -555,12 +620,15 @@ void PairKIM::unpack_reverse_comm(int n, int *list, double *buf) { int i,j,m; double *fp; - if (lmps_hybrid) fp = &(lmps_force_tmp[0][0]); - else fp = &(atom->f[0][0]); + fp = &(atom->f[0][0]); m = 0; - if ((kim_model_has_forces) && ((vflag_atom == 0) || - (!kim_model_has_particleVirial))) + 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++) { @@ -570,8 +638,12 @@ void PairKIM::unpack_reverse_comm(int n, int *list, double *buf) fp[3*j+2]+= buf[m++]; } } - else if ((kim_model_has_forces) && (vflag_atom == 1) && - (kim_model_has_particleVirial)) + 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++) @@ -589,8 +661,12 @@ void PairKIM::unpack_reverse_comm(int n, int *list, double *buf) va[j*6+5]+=buf[m++]; } } - else if ((!kim_model_has_forces) && (vflag_atom == 1) && - (kim_model_has_particleVirial)) + 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++) @@ -616,7 +692,7 @@ void PairKIM::unpack_reverse_comm(int n, int *list, double *buf) double PairKIM::memory_usage() { - double bytes = lmps_maxalloc * sizeof(int); + double bytes = 2 * lmps_maxalloc * sizeof(int); return bytes; } @@ -624,45 +700,30 @@ double PairKIM::memory_usage() KIM-specific interface ------------------------------------------------------------------------- */ -void PairKIM::kim_error(int ln, const char* msg, int errcode) +int PairKIM::get_neigh(void const * const dataObject, + int const numberOfNeighborLists, + double const * const cutoffs, + int const neighborListIndex, int const particleNumber, + int * const numberOfNeighbors, + int const ** const neighborsOfParticle) { - if (errcode == KIM_STATUS_OK) return; - KIM_API_model::report_error(ln,(char *) __FILE__, (char *) msg,errcode); - error->all(__FILE__,ln,"Internal KIM error"); + PairKIM const * const Model + = reinterpret_cast(dataObject); - return; -} - -/* ---------------------------------------------------------------------- */ - -int PairKIM::get_neigh(void **kimmdl,int *mode,int *request, - int *atom, int *numnei, int **nei1atom, double **pRij) -{ - KIM_API_model *pkim = (KIM_API_model *) *kimmdl; - - int kimerror; - PairKIM *self = (PairKIM *) pkim->get_sim_buffer(&kimerror); - - if (self->kim_model_using_Rij) { - *pRij = &(self->Rij[0]); - } else { - *pRij = 0; + 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 - // subvert KIM api by using direct access to self->list - // - // get neighObj from KIM API obj - // NeighList * neiobj = (NeighList * ) - // (*pkim).get_data_by_index(self->kim_ind_neighObject, &kimerror); - NeighList * neiobj = self->list; + // initialize numNeigh + *numberOfNeighbors = 0; - // subvert KIM api by using direct acces to self->lmps_local_tot_num_atoms - // - //int * pnAtoms = (int *) - // (*pkim).get_data_by_index(self->kim_ind_numberOfParticles, &kimerror); - //int nAtoms = *pnAtoms; - int nAtoms = self->lmps_local_tot_num_atoms; + NeighList * neiobj = Model->neighborLists[neighborListIndex]; + int nAtoms = Model->lmps_local_tot_num_atoms; int j, jj, inum, *ilist, *numneigh, **firstneigh; inum = neiobj->inum; //# of I atoms neighbors are stored for @@ -670,97 +731,22 @@ int PairKIM::get_neigh(void **kimmdl,int *mode,int *request, numneigh = neiobj->numneigh; // # of J neighbors for each I atom firstneigh = neiobj->firstneigh; // ptr to 1st J int value of each I atom - if (*mode==0){ //iterator mode - if (*request==1) { //increment iterator - if (self->kim_iterator_position < inum) { - *atom = ilist[self->kim_iterator_position]; - *numnei = numneigh[*atom]; + *numberOfNeighbors = numneigh[particleNumber]; - // strip off neighbor mask for molecular systems - if (!self->lmps_using_molecular) - *nei1atom = firstneigh[*atom]; - else - { - int n = *numnei; - int *ptr = firstneigh[*atom]; - int *lmps_stripped_neigh_list = self->lmps_stripped_neigh_list; - for (int i = 0; i < n; i++) - lmps_stripped_neigh_list[i] = *(ptr++) & NEIGHMASK; - *nei1atom = lmps_stripped_neigh_list; - } - - // set Rij if needed - if (self->kim_model_using_Rij) { - double* x = (double *) - (*pkim).get_data_by_index(self->kim_ind_coordinates, - &kimerror); - for (jj=0; jj < *numnei; jj++) { - int i = *atom; - j = (*nei1atom)[jj]; - self->Rij[jj*3 +0] = -x[i*3+0] + x[j*3+0]; - self->Rij[jj*3 +1] = -x[i*3+1] + x[j*3+1]; - self->Rij[jj*3 +2] = -x[i*3+2] + x[j*3+2]; - } - } - - // increment iterator - self->kim_iterator_position++; - - return KIM_STATUS_OK; //successful increment - } else if (self->kim_iterator_position == inum) { - *numnei = 0; - return KIM_STATUS_NEIGH_ITER_PAST_END; //reached end by iterator - } else if (self->kim_iterator_position > inum || inum < 0){ - self->error->one(FLERR, "KIM neighbor iterator exceeded range"); - } - } else if (*request == 0){ //restart iterator - self->kim_iterator_position = 0; - *numnei = 0; - return KIM_STATUS_NEIGH_ITER_INIT_OK; //succsesful restart - } - } else if (*mode == 1){//locator mode - //... - if (*request < inum) { - *atom = *request; - *numnei = numneigh[*atom]; - - // strip off neighbor mask for molecular systems - if (!self->lmps_using_molecular) - *nei1atom = firstneigh[*atom]; - else - { - int n = *numnei; - int *ptr = firstneigh[*atom]; - int *lmps_stripped_neigh_list = self->lmps_stripped_neigh_list; - for (int i = 0; i < n; i++) - lmps_stripped_neigh_list[i] = *(ptr++) & NEIGHMASK; - *nei1atom = lmps_stripped_neigh_list; - } - - // set Rij if needed - if (self->kim_model_using_Rij){ - double* x = (double *) - (*pkim).get_data_by_index(self->kim_ind_coordinates, &kimerror); - for(int jj=0; jj < *numnei; jj++){ - int i = *atom; - int j = (*nei1atom)[jj]; - self->Rij[jj*3 +0] = -x[i*3+0] + x[j*3+0]; - self->Rij[jj*3 +1] = -x[i*3+1] + x[j*3+1]; - self->Rij[jj*3 +2] = -x[i*3+2] + x[j*3+2]; - } - } - return KIM_STATUS_OK; //successful end - } - else if (*request >= nAtoms || inum < 0) - return KIM_STATUS_NEIGH_INVALID_REQUEST; - else if (*request >= inum) { - *atom = *request; - *numnei = 0; - return KIM_STATUS_OK; //successfull but no neighbors in the list - } - } else return KIM_STATUS_NEIGH_INVALID_MODE; //invalid mode - - return -16; //should not get here: unspecified error + // 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; } /* ---------------------------------------------------------------------- */ @@ -769,27 +755,15 @@ void PairKIM::kim_free() { int kimerror; - if (kim_model_init_ok) - { - kimerror = pkim->model_destroy(); - kim_model_init_ok = false; - } if (kim_init_ok) { - pkim->free(&kimerror); - kim_init_ok = false; - } - if (pkim != 0) - { - delete pkim; - pkim = 0; - } - if (kim_particle_codes_ok) - { - delete [] kim_particle_codes; - kim_particle_codes = 0; - kim_particle_codes_ok = false; + 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; } @@ -800,182 +774,165 @@ void PairKIM::kim_init() { 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) + 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) + { + 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(); - // create appropriate KIM descriptor file - char* test_descriptor_string = 0; - // allocate memory for test_descriptor_string and write descriptor file - write_descriptor(&test_descriptor_string); - // print descriptor - if (print_kim_file) + KIM_Model_GetInfluenceDistance(pkim, &kim_global_influence_distance); + KIM_Model_GetNeighborListPointers( + pkim, + &kim_number_of_neighbor_lists, + &kim_cutoff_values, + &modelWillNotRequestNeighborsOfNoncontributingParticles); + if (neighborLists) { - error->message(FLERR, test_descriptor_string); + delete [] neighborLists; + neighborLists = 0; } + neighborLists = new NeighList*[kim_number_of_neighbor_lists]; - // initialize KIM model - pkim = new KIM_API_model(); - kimerror = pkim->string_init(test_descriptor_string, kim_modelname); - if (kimerror != KIM_STATUS_OK) - kim_error(__LINE__,"KIM initialization failed", kimerror); - else - { - kim_init_ok = true; - delete [] test_descriptor_string; - test_descriptor_string = 0; - } + 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)); - // determine kim_model_using_* true/false values - // - // check for half or full list - kim_model_using_half = (pkim->is_half_neighbors(&kimerror)); - // - const char* NBC_method; - kimerror = pkim->get_NBC_method(&NBC_method); - kim_error(__LINE__,"NBC method not set",kimerror); - // check for CLUSTER mode - kim_model_using_cluster = (strcmp(NBC_method,"CLUSTER")==0); - // check if Rij needed for get_neigh - kim_model_using_Rij = ((strcmp(NBC_method,"NEIGH_RVEC_H")==0) || - (strcmp(NBC_method,"NEIGH_RVEC_F")==0)); + kimerror = KIM_ComputeArguments_SetCallbackPointer(pargs, + KIM_COMPUTE_CALLBACK_NAME_GetNeighborList, + KIM_LANGUAGE_NAME_cpp, + reinterpret_cast(get_neigh), + reinterpret_cast(this)); - // get correct index of each variable in kim_api object - pkim->getm_index(&kimerror, 3*13, - "coordinates", &kim_ind_coordinates, 1, - "cutoff", &kim_ind_cutoff, 1, - "numberOfParticles", &kim_ind_numberOfParticles, 1, -#if KIM_API_VERSION_MAJOR == 1 && KIM_API_VERSON_MINOR == 5 - "numberParticleTypes", &kim_ind_numberOfSpecies, 1, - "particleTypes", &kim_ind_particleSpecies, 1, -#else - "numberOfSpecies", &kim_ind_numberOfSpecies, 1, - "particleSpecies", &kim_ind_particleSpecies, 1, -#endif - "numberContributingParticles", &kim_ind_numberContributingParticles, - kim_model_using_half, - "particleEnergy", &kim_ind_particleEnergy, - (int) kim_model_has_particleEnergy, - "energy", &kim_ind_energy, (int) kim_model_has_energy, - "forces", &kim_ind_forces, (int) kim_model_has_forces, - "neighObject", &kim_ind_neighObject, (int) !kim_model_using_cluster, - "get_neigh", &kim_ind_get_neigh, (int) !kim_model_using_cluster, - "particleVirial", &kim_ind_particleVirial, - (int) kim_model_has_particleVirial, - "virial", &kim_ind_virial, no_virial_fdotr_compute); - kim_error(__LINE__,"getm_index",kimerror); - - // setup mapping between LAMMPS unique elements and KIM species codes - 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 kimerror; - kim_particle_codes[i] - = pkim->get_species_code(lmps_unique_elements[i], &kimerror); - kim_error(__LINE__, "create_kim_particle_codes: symbol not found ", - kimerror); - } - - // set pointer values in KIM API object that will not change during run - set_statics(); + if (kimerror) + error->all(FLERR,"Unable to register KIM pointers"); return; } /* ---------------------------------------------------------------------- */ -void PairKIM::set_statics() +void PairKIM::set_argument_pointers() { - // set total number of atoms - lmps_local_tot_num_atoms = (int) (atom->nghost + atom->nlocal); + int kimerror; + kimerror = KIM_ComputeArguments_SetArgumentPointerDouble( + pargs, KIM_COMPUTE_ARGUMENT_NAME_coordinates, &(atom->x[0][0])); - int kimerror; - pkim->setm_data_by_index(&kimerror, 4*6, - kim_ind_numberOfSpecies, 1, (void *) &(atom->ntypes), 1, - kim_ind_cutoff, 1, (void *) &(kim_global_cutoff), 1, - kim_ind_numberOfParticles, 1, (void *) &lmps_local_tot_num_atoms, 1, - kim_ind_numberContributingParticles, 1, (void *) &(atom->nlocal), - (int) kim_model_using_half, - kim_ind_energy, 1, (void *) &(eng_vdwl), (int) kim_model_has_energy, - kim_ind_virial, 1, (void *) &(virial[0]), no_virial_fdotr_compute); - kim_error(__LINE__, "setm_data_by_index", kimerror); - if (!kim_model_using_cluster) - { - kimerror = pkim->set_method_by_index(kim_ind_get_neigh, 1, - (func_ptr) &get_neigh); - kim_error(__LINE__, "set_method_by_index", kimerror); - } + // Set KIM pointer appropriately for particalEnergy + if (KIM_SupportStatus_Equal(kim_model_support_for_particleEnergy, + KIM_SUPPORT_STATUS_required) + && (eflag_atom != 1)) + { + // reallocate per-atom energy array if necessary + if (atom->nmax > maxeatom) + { + maxeatom = atom->nmax; + memory->destroy(eatom); + memory->create(eatom,comm->nthreads*maxeatom,"pair:eatom"); + } + } + if (KIM_SupportStatus_Equal(kim_model_support_for_particleEnergy, + KIM_SUPPORT_STATUS_optional) + && (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)) + { + kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble( + pargs, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, eatom); + } - pkim->set_sim_buffer((void *)this, &kimerror); - kim_error(__LINE__, "set_sim_buffer", kimerror); + // Set KIM pointer appropriately for forces + if (KIM_SupportStatus_Equal(kim_model_support_for_forces, + KIM_SUPPORT_STATUS_notSupported)) + { + kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble( + 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])); + } - return; -} + // Set KIM pointer appropriately for particleVirial + if (KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, + KIM_SUPPORT_STATUS_required) + && (vflag_atom != 1)) + { + // reallocate per-atom virial array if necessary + if (atom->nmax > maxeatom) + { + maxvatom = atom->nmax; + memory->destroy(vatom); + memory->create(vatom,comm->nthreads*maxvatom,6,"pair:vatom"); + } + } + if (KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, + KIM_SUPPORT_STATUS_optional) + && (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)) + { + kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble( + pargs, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, &(vatom[0][0])); + } -/* ---------------------------------------------------------------------- */ + if (kimerror) + { + error->all(FLERR,"Unable to set KIM argument pointers"); + } -void PairKIM::set_volatiles() -{ - int kimerror; - lmps_local_tot_num_atoms = (int) (atom->nghost + atom->nlocal); - intptr_t nall = (intptr_t) lmps_local_tot_num_atoms; - - pkim->setm_data_by_index(&kimerror, 4*2, - kim_ind_coordinates, 3*nall, (void*) &(atom->x[0][0]), 1, - kim_ind_particleSpecies, nall, (void*) kim_particleSpecies, 1); - kim_error(__LINE__, "setm_data_by_index", kimerror); - - if (kim_model_has_particleEnergy && (eflag_atom == 1)) - { - kimerror = pkim->set_data_by_index(kim_ind_particleEnergy, nall, - (void*) eatom); - kim_error(__LINE__, "set_data_by_index", kimerror); - } - - if (kim_model_has_particleVirial && (vflag_atom == 1)) - { - kimerror = pkim->set_data_by_index(kim_ind_particleVirial, 6*nall, - (void*) &(vatom[0][0])); - kim_error(__LINE__, "set_data_by_index", kimerror); - } - - if (kim_model_has_forces) - { - if (lmps_hybrid) - kimerror = pkim->set_data_by_index(kim_ind_forces, nall*3, - (void*) &(lmps_force_tmp[0][0])); - else - kimerror = pkim->set_data_by_index(kim_ind_forces, nall*3, - (void*) &(atom->f[0][0])); - kim_error(__LINE__, "setm_data_by_index", kimerror); - } - - // subvert the KIM api by direct access to this->list in get_neigh - // - //if (!kim_model_using_cluster) - // kimerror = pkim->set_data_by_index(kim_ind_neighObject, 1, - // (void*) this->list); - - if (kim_model_has_particleVirial) - { - if(vflag_atom != 1) { - pkim->set_compute_by_index(kim_ind_particleVirial, KIM_COMPUTE_FALSE, - &kimerror); - } else { - pkim->set_compute_by_index(kim_ind_particleVirial, KIM_COMPUTE_TRUE, - &kimerror); - } - } - - if (no_virial_fdotr_compute == 1) - { - pkim->set_compute_by_index(kim_ind_virial, - ((vflag_global != 1) ? KIM_COMPUTE_FALSE : KIM_COMPUTE_TRUE), - &kimerror); - } - - return; + return; } /* ---------------------------------------------------------------------- */ @@ -985,432 +942,183 @@ void PairKIM::set_lmps_flags() // determint if newton is on or off lmps_using_newton = (force->newton_pair == 1); - // setup lmps_stripped_neigh_list for neighbors of one atom, if needed - lmps_using_molecular = (atom->molecular > 0); - if (lmps_using_molecular) { - memory->destroy(lmps_stripped_neigh_list); - memory->create(lmps_stripped_neigh_list,neighbor->oneatom, - "pair:lmps_stripped_neigh_list"); + // 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 - lmps_hybrid = (force->pair_match("hybrid",0)); - - // support cluster mode if everything is just right - lmps_support_cluster = ((domain->xperiodic == 0 && - domain->yperiodic == 0 && - domain->zperiodic == 0 - ) - && - (comm->nprocs == 1) - ); - // determine unit system and set lmps_units flag - if ((strcmp(update->unit_style,"real")==0)) - lmps_units = REAL; - else if ((strcmp(update->unit_style,"metal")==0)) - lmps_units = METAL; - else if ((strcmp(update->unit_style,"si")==0)) - lmps_units = SI; - else if ((strcmp(update->unit_style,"cgs")==0)) - lmps_units = CGS; - else if ((strcmp(update->unit_style,"electron")==0)) - lmps_units = ELECTRON; - 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"); + 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; } /* ---------------------------------------------------------------------- */ +int PairKIM::check_for_routine_compatibility() +{ + /* Check that we know about all required routines */ + int numberOfModelRoutineNames; + KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames( + &numberOfModelRoutineNames); + for (int i = 0; i < numberOfModelRoutineNames; ++i) + { + KIM_ModelRoutineName modelRoutineName; + KIM_MODEL_ROUTINE_NAME_GetModelRoutineName(i, &modelRoutineName); + + int present; + int required; + int error = KIM_Model_IsRoutinePresent( + pkim, modelRoutineName, &present, &required); + if (error) { return true; } + + if ((present == true) && (required == true)) + { + if (!(KIM_ModelRoutineName_Equal(modelRoutineName, + KIM_MODEL_ROUTINE_NAME_Create) + || KIM_ModelRoutineName_Equal( + modelRoutineName, + KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate) + || KIM_ModelRoutineName_Equal(modelRoutineName, + KIM_MODEL_ROUTINE_NAME_Compute) + || KIM_ModelRoutineName_Equal(modelRoutineName, + KIM_MODEL_ROUTINE_NAME_Refresh) + || KIM_ModelRoutineName_Equal( + modelRoutineName, + KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy) + || KIM_ModelRoutineName_Equal(modelRoutineName, + KIM_MODEL_ROUTINE_NAME_Destroy))) + { return true; } + } + } + + /* everything is good */ + return false; +} + +/* ---------------------------------------------------------------------- */ + void PairKIM::set_kim_model_has_flags() { - KIM_API_model mdl; - - int kimerror; - - // get KIM API object representing the KIM Model only - kimerror = mdl.model_info(kim_modelname); - kim_error(__LINE__,"KIM initialization failed", kimerror); - - // determine if the KIM Model can compute the total energy - mdl.get_index((char*) "energy", &kimerror); - kim_model_has_energy = (kimerror == KIM_STATUS_OK); - if (!kim_model_has_energy) - error->warning(FLERR,"KIM Model does not provide `energy'; " - "Potential energy will be zero"); - - // determine if the KIM Model can compute the forces - mdl.get_index((char*) "forces", &kimerror); - kim_model_has_forces = (kimerror == KIM_STATUS_OK); - if (!kim_model_has_forces) - error->warning(FLERR,"KIM Model does not provide `forces'; " - "Forces will be zero"); - - // determine if the KIM Model can compute the particleEnergy - mdl.get_index((char*) "particleEnergy", &kimerror); - kim_model_has_particleEnergy = (kimerror == KIM_STATUS_OK); - if (!kim_model_has_particleEnergy) - error->warning(FLERR,"KIM Model does not provide `particleEnergy'; " - "energy per atom will be zero"); - - // determine if the KIM Model can compute the particleVerial - mdl.get_index((char*) "particleVirial", &kimerror); - kim_model_has_particleVirial = (kimerror == KIM_STATUS_OK); - mdl.get_index((char*) "process_dEdr", &kimerror); - kim_model_has_particleVirial = kim_model_has_particleVirial || - (kimerror == KIM_STATUS_OK); - if (!kim_model_has_particleVirial) - error->warning(FLERR,"KIM Model does not provide `particleVirial'; " - "virial per atom will be zero"); - - // tear down KIM API object - mdl.free(&kimerror); - // now destructor will do the remaining tear down for mdl - - return; -} - -/* ---------------------------------------------------------------------- */ - -void PairKIM::write_descriptor(char** test_descriptor_string) -{ - // allocate memory - if (*test_descriptor_string != 0) - error->all(FLERR, "Test_descriptor_string already allocated"); - // assuming 75 lines at 100 characters each (should be plenty) - *test_descriptor_string = new char[100*75]; - // initialize - strcpy(*test_descriptor_string, ""); - - // Write Test name and units - strcat(*test_descriptor_string, - "#\n" - "# BEGINNING OF KIM DESCRIPTOR FILE\n" - "#\n" - "# This file is automatically generated from LAMMPS pair_style " - "kim command\n"); - strcat(*test_descriptor_string, - "\n" - "# The call number is (pair_style).(init_style): "); - char tmp_num[100]; - sprintf(tmp_num, "%i.%i\n", settings_call_count, init_style_call_count); - strcat(*test_descriptor_string, tmp_num); - strcat(*test_descriptor_string, - "#\n" - "\n" -#if KIM_API_VERSION_MAJOR == 1 && KIM_API_VERSION_MINOR == 5 -#else - "KIM_API_Version := 1.6.0\n\n" -#endif - "# Base units\n"); - switch (lmps_units) - { - case REAL: - strcat(*test_descriptor_string, - "Unit_length := A\n" - "Unit_energy := kcal/mol\n" - "Unit_charge := e\n" - "Unit_temperature := K\n" - "Unit_time := fs\n\n"); - break; - case METAL: - strcat(*test_descriptor_string, - "Unit_length := A\n" - "Unit_energy := eV\n" - "Unit_charge := e\n" - "Unit_temperature := K\n" - "Unit_time := ps\n\n"); - break; - case SI: - strcat(*test_descriptor_string, - "Unit_length := m\n" - "Unit_energy := J\n" - "Unit_charge := C\n" - "Unit_temperature := K\n" - "Unit_time := s\n\n"); - break; - case CGS: - strcat(*test_descriptor_string, - "Unit_length := cm\n" - "Unit_energy := erg\n" - "Unit_charge := statC\n" - "Unit_temperature := K\n" - "Unit_time := s\n\n"); - break; - case ELECTRON: - strcat(*test_descriptor_string, - "Unit_length := Bohr\n" - "Unit_energy := Hartree\n" - "Unit_charge := e\n" - "Unit_temperature := K\n" - "Unit_time := fs\n\n"); - break; - } - - // Write Supported species section - strcat(*test_descriptor_string, - "\n" -#if KIM_API_VERSION_MAJOR == 1 && KIM_API_VERSON_MINOR == 5 - "SUPPORTED_ATOM/PARTICLES_TYPES:\n" -#else - "PARTICLE_SPECIES:\n" -#endif - "# Symbol/name Type code\n"); - int code=1; - char* tmp_line = 0; - tmp_line = new char[100]; - for (int i=0; i < lmps_num_unique_elements; i++){ - sprintf(tmp_line, "%-24s%-16s%-3i\n", lmps_unique_elements[i], - "spec", code++); - strcat(*test_descriptor_string, tmp_line); - } - delete [] tmp_line; - tmp_line = 0; - strcat(*test_descriptor_string, "\n"); - - // Write conventions section - strcat(*test_descriptor_string, - "\n" - "CONVENTIONS:\n" - "# Name Type\n" - "ZeroBasedLists flag\n"); - // can use iterator or locator neighbor mode, unless in hybrid mode - if (lmps_hybrid) - strcat(*test_descriptor_string, - "Neigh_IterAccess flag\n"); - else - strcat(*test_descriptor_string, - "Neigh_BothAccess flag\n\n"); - - strcat(*test_descriptor_string, - "NEIGH_PURE_H flag\n" - "NEIGH_PURE_F flag\n" - "NEIGH_RVEC_H flag\n" - "NEIGH_RVEC_F flag\n"); - // @@ add code for MI_OPBC_? support ???? - if (lmps_support_cluster) - { - strcat(*test_descriptor_string, - "CLUSTER flag\n\n"); - } - else - { - strcat(*test_descriptor_string, "\n"); - } - - // Write input section - strcat(*test_descriptor_string, - "\n" - "MODEL_INPUT:\n" - "# Name Type Unit Shape\n" - "numberOfParticles integer none []\n" - "numberContributingParticles integer none []\n" -#if KIM_API_VERSION_MAJOR == 1 && KIM_API_VERSON_MINOR == 5 - "numberParticleTypes integer none []\n" - "particleTypes integer none " -#else - "numberOfSpecies integer none []\n" - "particleSpecies integer none " -#endif - "[numberOfParticles]\n" - "coordinates double length " - "[numberOfParticles,3]\n" - "neighObject pointer none []\n" - "get_neigh method none []\n"); - - // Write output section - strcat(*test_descriptor_string, - "\n" - "MODEL_OUPUT:\n" - "# Name Type Unit Shape\n" - "compute method none []\n" - "destroy method none []\n" - "cutoff double length []\n"); - if (!kim_model_has_energy) strcat(*test_descriptor_string,"# "); - strcat(*test_descriptor_string, - "energy double energy []\n"); - if (!kim_model_has_forces) strcat(*test_descriptor_string, "# "); - strcat(*test_descriptor_string, - "forces double force " - "[numberOfParticles,3]\n"); - if (!kim_model_has_particleEnergy) strcat(*test_descriptor_string, "# "); - strcat(*test_descriptor_string, - "particleEnergy double energy " - "[numberOfParticles]\n"); - if (no_virial_fdotr_compute != 1) strcat(*test_descriptor_string, "# "); - strcat(*test_descriptor_string, - "virial double energy [6]\n"); - if (!kim_model_has_particleVirial) strcat(*test_descriptor_string, "# "); - strcat(*test_descriptor_string, - "particleVirial double energy " - "[numberOfParticles,6]\n" - "\n"); - strcat(*test_descriptor_string, - "#\n" - "# END OF KIM DESCRIPTOR FILE\n" - "#\n"); - - return; -} - -void *PairKIM::extract(const char *str, int &dim) -{ - void *paramData; - int kimerror=0; - int ier; - int dummyint; - int isIndexed = 0; - const int MAXLINE = 1024; - int rank; - int validParam = 0; - int numParams; - int *speciesIndex = new int[MAXLINE]; - char *paramStr = new char[MAXLINE]; - char *paramName; - char *indexStr; - char message[MAXLINE]; - int offset; - double* paramPtr; - - // set dim to 0, we will always deal with scalars to circumvent lammps species - // indexing - dim = 0; - - // copy the input str into paramStr for parsing - strcpy(paramStr, str); - // get the name of the parameter (whatever is before ":") - paramName = strtok(paramStr, ":"); - if (0 == strcmp(paramName, str)) - paramName = (char*) str; - else - isIndexed = 1; - - // parse the rest of the string into tokens deliminated by "," and convert - // them to integers, saving them into speciesIndex - int count = -1; - if (isIndexed == 1) + int numberOfComputeArgumentNames; + KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames( + &numberOfComputeArgumentNames); + for (int i = 0; i < numberOfComputeArgumentNames; ++i) { - while((indexStr = strtok(NULL, ",")) != NULL) + KIM_ComputeArgumentName computeArgumentName; + int kimerror = KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName( + i, &computeArgumentName); + KIM_SupportStatus supportStatus; + kimerror = KIM_ComputeArguments_GetArgumentSupportStatus( + pargs, computeArgumentName, &supportStatus); + + if (KIM_ComputeArgumentName_Equal(computeArgumentName, + KIM_COMPUTE_ARGUMENT_NAME_partialEnergy) + ) + kim_model_support_for_energy = supportStatus; + else if (KIM_ComputeArgumentName_Equal( + computeArgumentName, KIM_COMPUTE_ARGUMENT_NAME_partialForces) + ) + kim_model_support_for_forces = supportStatus; + 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) + ) + kim_model_support_for_particleVirial = supportStatus; + else if (KIM_SupportStatus_Equal(supportStatus, KIM_SUPPORT_STATUS_required) + ) { - count++; - ier = sscanf(indexStr, "%d", &speciesIndex[count]); - if (ier != 1) - { - ier = -1; - break; - } + std::stringstream msg; + msg << "KIM Model requires unsupported compute argument: " + << KIM_ComputeArgumentName_ToString(computeArgumentName); + error->all(FLERR, msg.str().c_str()); } } - if (ier == -1) - { - delete [] speciesIndex, speciesIndex = 0; - delete [] paramStr, paramStr = 0; - kim_error(__LINE__,"error in PairKIM::extract(), invalid parameter-indicie format", KIM_STATUS_FAIL); - } - // check to make sure that the requested parameter is a valid free parameter + if (KIM_SupportStatus_Equal(kim_model_support_for_energy, + KIM_SUPPORT_STATUS_notSupported)) + error->warning(FLERR,"KIM Model does not provide `partialEnergy'; " + "Potential energy will be zero"); - kimerror = pkim->get_num_params(&numParams, &dummyint); - kim_error(__LINE__, "get_num_free_params", kimerror); - char **freeParamNames = new char*[numParams]; - for (int k = 0; k < numParams; k++) + if (KIM_SupportStatus_Equal(kim_model_support_for_forces, + KIM_SUPPORT_STATUS_notSupported)) + error->warning(FLERR,"KIM Model does not provide `partialForce'; " + "Forces will be zero"); + + if (KIM_SupportStatus_Equal(kim_model_support_for_particleEnergy, + KIM_SUPPORT_STATUS_notSupported)) + error->warning(FLERR,"KIM Model does not provide `partialParticleEnergy'; " + "energy per atom will be zero"); + + if (KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, + KIM_SUPPORT_STATUS_notSupported)) + error->warning(FLERR,"KIM Model does not provide `partialParticleVirial'; " + "virial per atom will be zero"); + + int numberOfComputeCallbackNames; + KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames( + &numberOfComputeCallbackNames); + for (int i = 0; i < numberOfComputeCallbackNames; ++i) { - kimerror = pkim->get_free_parameter(k, (const char**) &freeParamNames[k]); - kim_error(__LINE__, "get_free_parameter", kimerror); - if (0 == strcmp(paramName, freeParamNames[k])) + KIM_ComputeCallbackName computeCallbackName; + int kimerror = KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName( + i, &computeCallbackName); + KIM_SupportStatus supportStatus; + kimerror = KIM_ComputeArguments_GetCallbackSupportStatus( + pargs, computeCallbackName, &supportStatus); + + if (KIM_SupportStatus_Equal(supportStatus, KIM_SUPPORT_STATUS_required)) { - validParam = 1; - break; + error->all(FLERR,"KIM Model requires unsupported compute callback"); } } - delete [] freeParamNames, freeParamNames = 0; - if (validParam == 0) - { - sprintf(message, "Invalid parameter to adapt: \"%s\" is not a FREE_PARAM", paramName); - delete [] speciesIndex, speciesIndex = 0; - delete [] paramStr, paramStr = 0; - kim_error(__LINE__, message, KIM_STATUS_FAIL); - } - // get the parameter arry from pkim object - paramData = pkim->get_data(paramName, &kimerror); - if (kimerror == KIM_STATUS_FAIL) - { - delete [] speciesIndex, speciesIndex = 0; - delete [] paramStr, paramStr = 0; - } - kim_error(__LINE__,"get_data",kimerror); - - // get rank and shape of parameter - rank = (*pkim).get_rank(paramName, &kimerror); - if (kimerror == KIM_STATUS_FAIL) - { - delete [] speciesIndex, speciesIndex = 0; - delete [] paramStr, paramStr = 0; - } - kim_error(__LINE__,"get_rank",kimerror); - - int *shape = new int[MAXLINE]; - dummyint = (*pkim).get_shape(paramName, shape, &kimerror); - if (kimerror == KIM_STATUS_FAIL) - { - delete [] speciesIndex, speciesIndex = 0; - delete [] paramStr, paramStr = 0; - delete [] shape, shape = 0; - } - kim_error(__LINE__,"get_shape",kimerror); - - delete [] paramStr, paramStr = 0; - // check that number of inputs is rank, and that input indicies are less than - // their respective dimensions in shape - if ((count+1) != rank) - { - sprintf(message, "Number of input indicies not equal to rank of specified parameter (%d)", rank); - kimerror = KIM_STATUS_FAIL; - delete [] speciesIndex, speciesIndex = 0; - delete [] shape, shape = 0; - kim_error(__LINE__,message, kimerror); - } - if (isIndexed == 1) - { - for (int i=0; i <= count; i++) - { - if (shape[i] <= speciesIndex[i] || speciesIndex[i] < 0) - { - kimerror = KIM_STATUS_FAIL; - break; - } - } - } - delete [] shape, shape = 0; - if (kimerror == KIM_STATUS_FAIL) - { - sprintf(message, "One or more parameter indicies out of bounds"); - delete [] speciesIndex, speciesIndex = 0; - kim_error(__LINE__, message, kimerror); - } - - // Cast it to a double - paramPtr = static_cast(paramData); - - // If it is indexed (not just a scalar for the whole model), then get pointer - // corresponding to specified indicies by calculating the adress offset using - // specified indicies and the shape - if (isIndexed == 1) - { - offset = 0; - for (int i = 0; i < (rank-1); i++) - { - offset = (offset + speciesIndex[i]) * shape[i+1]; - } - offset = offset + speciesIndex[(rank - 1)]; - paramPtr = (paramPtr + offset); - } - delete [] speciesIndex, speciesIndex = 0; - - return ((void*) paramPtr); + return; } diff --git a/src/KIM/pair_kim.h b/src/KIM/pair_kim.h index fb4cda8af9..a6f882347d 100644 --- a/src/KIM/pair_kim.h +++ b/src/KIM/pair_kim.h @@ -12,14 +12,45 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing authors: Ryan S. Elliott, - Valeriu Smirichinski, - Ellad Tadmor (U Minn) + Contributing authors: Ryan S. Elliott (UMinn) ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Designed for use with the openkim-api-v1.5.0 package and for use with - the kim-api-v1.6.0 (and newer) package + 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-v2-2.0.0 (and newer) package ------------------------------------------------------------------------- */ #ifdef PAIR_CLASS @@ -34,6 +65,10 @@ PairStyle(kim,PairKIM) // includes from KIM & LAMMPS class KIM_API_model; #include "pair.h" +extern "C" { +#include "KIM_SimulatorHeaders.h" +} +#include namespace LAMMPS_NS { @@ -48,14 +83,13 @@ namespace LAMMPS_NS { 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 void reinit(); virtual int pack_reverse_comm(int, int, double*); virtual void unpack_reverse_comm(int, int*, double*); virtual double memory_usage(); - void *extract(const char *, int &); - private: + 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 @@ -64,12 +98,11 @@ namespace LAMMPS_NS { // values set in settings() char* kim_modelname; - bool print_kim_file; // values set in coeff() // values set in allocate(), called by coeff() - void allocate(); + virtual void allocate(); int* lmps_map_species_to_unique; // values set in coeff(), after calling allocate() @@ -80,74 +113,59 @@ namespace LAMMPS_NS { // values set in set_lmps_flags(), called from init_style() bool lmps_using_newton; bool lmps_using_molecular; - bool lmps_hybrid; // true if running with pair hybrid - bool lmps_support_cluster; // true if running in mode compat. - // with CLUSTER 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_Model * pkim; + KIM_ComputeArguments * pargs; // values set in set_kim_model_has_flags(), called by kim_init() - KIM_API_model* pkim; - bool kim_model_has_energy; - bool kim_model_has_forces; - bool kim_model_has_particleEnergy; - bool kim_model_has_particleVirial; + 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(), after call to string_init(_) + // values set in kim_init() bool kim_init_ok; - bool kim_model_using_half; - bool kim_model_using_cluster; - bool kim_model_using_Rij; - int kim_ind_coordinates; - int kim_ind_numberOfParticles; - int kim_ind_numberContributingParticles; - int kim_ind_numberOfSpecies; - int kim_ind_particleSpecies; - int kim_ind_get_neigh; - int kim_ind_neighObject; - int kim_ind_cutoff; - int kim_ind_energy; - int kim_ind_particleEnergy; - int kim_ind_forces; - int kim_ind_virial; - int kim_ind_particleVirial; + 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(), after calling pkim->model_init() - bool kim_model_init_ok; + // values set in init_style() bool kim_particle_codes_ok; int *kim_particle_codes; - // values set in set_statics(), called at end of kim_init(), - // then again in set_volatiles(), called in compute() - int lmps_local_tot_num_atoms; - double kim_global_cutoff; // KIM Model cutoff value - // values set in compute() int lmps_maxalloc; // max allocated memory value int* kim_particleSpecies; // array of KIM particle species - double** lmps_force_tmp; // temp storage for f, when running in - // hybrid mode needed to avoid resetting - // f to zero in each object + int* kim_particleContributing; // array of KIM particle contributing int* lmps_stripped_neigh_list; // neighbors of one atom, used when LAMMPS // is in molecular mode - - // values used in get_neigh() - int kim_iterator_position; //get_neigh iterator current position - double *Rij; + int** lmps_stripped_neigh_ptr; // pointer into lists // KIM specific helper functions - void kim_error(int, const char *, int); - void kim_init(); - void kim_free(); - void set_statics(); - void set_volatiles(); - void set_lmps_flags(); - void set_kim_model_has_flags(); - void write_descriptor(char** test_descriptor_string); + 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** kimmdl, int* mode, int* request, - int* atom, int* numnei, int** nei1atom, - double** pRij); + 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); }; } @@ -156,81 +174,92 @@ namespace LAMMPS_NS { /* ERROR/WARNING messages: -E: Illegal ... command +E: Unable to set KIM particle species codes and/or contributing -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. +A low-level kim-api error has occurred. -E: Unrecognized virial argument in pair_style command +E: KIM Compute returned error -Only two options are supported: LAMMPSvirial and KIMvirial +The KIM model was unable, for some reason, to complete the computation. + +E: 'KIMvirial' or 'LAMMPSvirial' not supported with kim-api-v2. + +"KIMvirial or "LAMMPSvirial" found on the pair_style line. These keys are not supported kim-api-v2. (The virial computation is always performed by LAMMPS.) Please remove these keys, make sure the KIM model you are using supports kim-api-v2, and rerun. + +E: Illegal pair_style command + +Self-explanatory. E: Incorrect args for pair coefficients -Self-explanatory. Check the input script or data file. +Self-explanatory. -E: Invalid args for non-hybrid pair coefficients +E: create_kim_particle_codes: symbol not found: XX -"NULL" is only supported in pair_coeff calls when using pair hybrid +The KIM model specified does not support the atomic species symbol E: PairKIM only works with 3D problems -This is a current limitation. +Self-explanatory. E: All pair coeffs are not set -All pair coefficients must be set in the data file or by the -pair_coeff command before running a simulation. +Self-explanatory. -E: KIM neighbor iterator exceeded range +E: Unable to destroy Compute Arguments Object -This should not happen. It likely indicates a bug -in the KIM implementation of the interatomic potential -where it is requesting neighbors incorrectly. +A low-level kim-api error has occurred. -E: LAMMPS unit_style lj not supported by KIM models +E: KIM ModelCreate failed -Self-explanatory. Check the input script or data file. +The kim-api was not able to create a model object for the specified model. -E: Unknown unit_style +E: KIM Model did not accept the requested unit system -Self-explanatory. Check the input script or data file. +The KIM Model does not support the specified LAMMPS unit system -W: KIM Model does not provide `energy'; Potential energy will be zero +E: KIM ComputeArgumentsCreate failed -UNDOCUMENTED +A low-level kim-api error has occurred. -W: KIM Model does not provide `forces'; Forces will be zero +E: Unable to register KIM pointers -UNDOCUMENTED +A low-level kim-api error has occurred. -W: KIM Model does not provide `particleEnergy'; energy per atom will be zero +E: Unable to set KIM argument pointers -UNDOCUMENTED +A low-level kim-api error has occurred. -W: KIM Model does not provide `particleVirial'; virial per atom will be zero - -UNDOCUMENTED - -E: Test_descriptor_string already allocated - -This is an internal error. Contact the developers. - -U: KIM Model does not provide 'energy'; Potential energy will be zero +E: pair_kim does not support hybrid Self-explanatory. -U: KIM Model does not provide 'forces'; Forces will be zero +E: LAMMPS unit_style lj not suppored by KIM models Self-explanatory. -U: KIM Model does not provide 'particleEnergy'; energy per atom will be zero +E: KIM Model requires unsupported compute argument: XXX + +A low-level kim-api error has occurred. + +W: KIM Model does not provide `partialEnergy'; Potential energy will be zero Self-explanatory. -U: KIM Model does not provide 'particleVirial'; virial per atom will be zero +W: KIM Model does not provide `partialForce'; Forces will be zero Self-explanatory. +W: KIM Model does not provide `partialParticleEnergy'; energy per atom will be zero + +Self-explanatory. + +W: KIM Model does not provide `partialParticleVirial'; virial per atom will be zero + +Self-explanatory. + +E: KIM Model requires unsupported compute callback + +A low-level kim-api error has occurred. + */