Minimal model and driver template files for kim-api-v2

Hi Ryan,

Thanks for the fix! I tried that, not still successful, but seems to have made a progress. Now it says:

ERROR: ‘KIMvirial’ or ‘LAMMPSvirial’ not supported with kim-api-v2. (…/pair_kim.cpp:316)

Last command: pair_style kim KIMvirial LennardJones612_UniversalShifted__MO_959249795837_003

This is the log file:

LAMMPS (22 Aug 2018)

3d Lennard-Jones melt

variable x index 1

variable y index 1

variable z index 1

variable xx equal 10*$x

variable xx equal 10*1

variable yy equal 10*$y

variable yy equal 10*1

variable zz equal 10*$z

variable zz equal 10*1

units metal

atom_style atomic

lattice fcc 1.5

Lattice spacing in x,y,z = 1.5 1.5 1.5

region box block 0 {xx} 0 {yy} 0 ${zz}

region box block 0 10 0 {yy} 0 {zz}

region box block 0 10 0 10 0 ${zz}

region box block 0 10 0 10 0 10

create_box 1 box

Created orthogonal box = (0 0 0) to (15 15 15)

1 by 1 by 1 MPI processor grid

create_atoms 1 box

Created 4000 atoms

Time spent = 0.000463009 secs

mass 1 1.0

velocity all create 1.44 87287 loop geom

#pair_style kim KIMvirial toy_parameterized_model

pair_style kim KIMvirial LennardJones612_UniversalShifted__MO_959249795837_003

ERROR: ‘KIMvirial’ or ‘LAMMPSvirial’ not supported with kim-api-v2. (…/pair_kim.cpp:316)

Last command: pair_style kim KIMvirial LennardJones612_UniversalShifted__MO_959249795837_003

Regards,
Alireza

Right,

Just remove the KIMvirial argument from the "pair_style kim" line of the lammps input file.

Ryan

Good! That was fixed. I cannot install my toy_model_driver and toy_parametrized_model though. I get:

vagrant@vagrant-ubuntu-trusty-64:~$ kim-api-v2-collections-management install user ./toy_model_driver

CMake Error: The source directory “/tmp/kim-api-v2-build-4TQfZD02oU/item-source” does not appear to contain CMakeLists.txt.

Specify --help for usage, or press the help button on the CMake GUI.

Aborting!

vagrant@vagrant-ubuntu-trusty-64:~$ cd toy_model_driver/

vagrant@vagrant-ubuntu-trusty-64:~/toy_model_driver$ ls

cutoffs.F90 gaussian.F90 Makefile neuralnetwork.f90 toy_model_driver.F90

vagrant@vagrant-ubuntu-trusty-64:~/toy_model_driver$ make

Makefile:32: *** kim-api-v2-build-config utility is not available. Something is wrong with your KIM API package setup. Stop.

vagrant@vagrant-ubuntu-trusty-64:~/toy_model_driver$ cd …/

vagrant@vagrant-ubuntu-trusty-64:~$ kim-api-v2-collections-management install user ./toy_parameterized_model

CMake Error: The source directory “/tmp/kim-api-v2-build-ex3ScogE2P/item-source” does not appear to contain CMakeLists.txt.

Specify --help for usage, or press the help button on the CMake GUI.

Aborting!

I suspect the Makefile inside the toy_model_driver folder should also change. Currently it has this content:

load all basic KIM make configuration

KIM_API_BUILD_CONFIG = kim-api-v2-build-config

ifeq ((shell (KIM_API_BUILD_CONFIG) --version 2> /dev/null),)

(error (KIM_API_BUILD_CONFIG) utility is not available. Something is wrong with your KIM API package setup)

endif

include (shell (KIM_API_BUILD_CONFIG) --master-config)

set model driver specific details

MODEL_DRIVER_NAME := toy_model_driver

MODEL_DRIVER_CREATE_FUNCTION_NAME := model_driver_create

MODEL_DRIVER_CREATE_FUNCTION_LANG := fortran

LOCALOBJ = cutoffs.o gaussian.o neuralnetwork.o toy_model_driver.o

LOCALCLEAN =

APPEND to compiler option flag lists

#FFLAGS = -c

#CFLAGS +=

#CXXFLAGS +=

#LDFLAGS +=

#LDLIBS +=

load remaining KIM make configuration

include (KIM_DIR)/(builddir)/Makefile.ModelDriver

Regards,
Alireza

Hi Alireza,

OK, yes.

You should replace the Makefile with a CMakeLists.txt file. I've attached the necessary files for the driver and model. (I think these should just work for you as is....)

Ryan

CMakeLists.txt-driver (667 Bytes)

CMakeLists.txt-model (470 Bytes)

Hi Ryan,

Thank you so much! That worked very well. I will soon push the neural network model driver to the Amp repository, and write installation instructions.

It seems that every time I login to the virtual box, I need to do “source ‘${HOME}/local/bin/kim-api-v2-activate’” in order to have kim-api-v2-collections-management available. I might have missed a step in installation though!

Lastly, I would like to reinstall the kim-api-v2 just to refresh what the minimal lines of installation are for the user. I am not sure how I can uninstall the kim-api-v2 entirely though?

Regards,
Alireza

Hi Ryan,

Thank you so much! That worked very well. I will soon push the neural
network model driver to the Amp repository, and write installation
instructions.

It seems that every time I login to the virtual box, I need to do "source
'${HOME}/local/bin/kim-api-v2-activate'" in order to
have kim-api-v2-collections-management available. I might have missed a
step in installation though!

No, you didn't miss anything. You either need to "activate" for every shell. Or you should add appropriate values to your configuration files so that your default environment is setup correctly. You can read the activate script to see what needs to be set or just source the activate script from your configuration script.

Lastly, I would like to reinstall the kim-api-v2 just to refresh what the
minimal lines of installation are for the user. I am not sure how I can
uninstall the kim-api-v2 entirely though?

If you set the CMAKE_INSTALL_PREFIX to "${HOME}/local" (and you have not installed anything other software to that location) then you can just delete that directory:

rm \-rf "{HOME}/local"

Cheers,

Ryan

Thanks Ryan! Before documenting the installation instruction for the user, I am now reinstalling kim-api-v2 and lammps-kim-v2-update to find the minimal steps that the user will need. This time I am surprisingly getting an error when I do “make mpi” to install lammps as below:

vagrant@vagrant-ubuntu-trusty-64:~/lammps/src$ make lib-kim args="-p ${HOME}/local/lib/kim-api-v2"

Installing lib kim

Created /home/vagrant/lammps/lib/kim/Makefile.KIM_DIR

using /home/vagrant/local/lib/kim-api-v2

vagrant@vagrant-ubuntu-trusty-64:~/lammps/src$ make yes-kim

Installing package kim

vagrant@vagrant-ubuntu-trusty-64:~/lammps/src$ make mpi

make[1]: Entering directory `/home/vagrant/lammps/src’

Gathering installed package information (may take a little while)

make[1]: Leaving directory `/home/vagrant/lammps/src’

Compiling LAMMPS for machine mpi

make[1]: Entering directory `/home/vagrant/lammps/src/Obj_mpi’

make[1]: Leaving directory `/home/vagrant/lammps/src/Obj_mpi’

make[1]: Entering directory `/home/vagrant/lammps/src/Obj_mpi’

mpicxx -g -O3 -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I/home/vagrant/local/include/kim-api-v2 -I/home/vagrant/local/lib/kim-api-v2/mod -c …/main.cpp

mpicxx -g -O3 -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I/home/vagrant/local/include/kim-api-v2 -I/home/vagrant/local/lib/kim-api-v2/mod -c …/pair_kim.cpp

…/pair_kim.cpp: In member function ‘virtual void LAMMPS_NS::PairKIM::kim_init()’:

…/pair_kim.cpp:738:25: error: expected type-specifier

reinterpret_cast<KIM::func *>(get_neigh),

^

…/pair_kim.cpp:738:25: error: expected ‘>’

…/pair_kim.cpp:738:25: error: expected ‘(’

…/pair_kim.cpp:738:25: error: ‘func’ is not a member of ‘KIM’

…/pair_kim.cpp:738:36: error: expected primary-expression before ‘>’ token

reinterpret_cast<KIM::func *>(get_neigh),

^

make[1]: *** [pair_kim.o] Error 1

make[1]: Leaving directory `/home/vagrant/lammps/src/Obj_mpi’

make: *** [mpi] Error 2

Has anything been changed upstream, or I have missed one step of installation?

Regards,
Alireza

Hi Ryan,

I did a second try this time with cmake according to the instructions here (https://github.com/ellio167/lammps/tree/kim-v2-update/cmake#other-packages). Again the same error happened, so this seems to be a bug in the code. I am surprised though why it was not an issue last time I installed lammps?!

/home/vagrant/lammps/src/KIM/pair_kim.cpp: In member function ‘virtual void LAMMPS_NS::PairKIM::kim_init()’:

/home/vagrant/lammps/src/KIM/pair_kim.cpp:738:25: error: expected type-specifier

reinterpret_cast<KIM::func *>(get_neigh),

^

/home/vagrant/lammps/src/KIM/pair_kim.cpp:738:25: error: expected ‘>’

/home/vagrant/lammps/src/KIM/pair_kim.cpp:738:25: error: expected ‘(’

/home/vagrant/lammps/src/KIM/pair_kim.cpp:738:25: error: ‘func’ is not a member of ‘KIM’

/home/vagrant/lammps/src/KIM/pair_kim.cpp:738:36: error: expected primary-expression before ‘>’ token

reinterpret_cast<KIM::func *>(get_neigh),

^

make[2]: *** [CMakeFiles/lmp.dir/home/vagrant/lammps/src/KIM/pair_kim.cpp.o] Error 1

make[1]: *** [CMakeFiles/lmp.dir/all] Error 2

make: *** [all] Error 2

Regards,
Alireza

I think we figured out the problem. The bug is just a single “<KIM::func *>” left over from the past and has not been updated to “<KIM::Function *>”.

Thanks again Ryan!

Regards,
Alireza

Hey there,

Looks like the files are not accessible now. Would you re-upload them? Also, what’s the best way to learn to code a model for kim using cpp?

Jay

Hello Jay,

Thanks for your message. We're in the final stretch for a new beta release of the KIM API V2 and should release it later this week. I'll respond more fully to your question once we get past that milestone.

Thanks for your patience!

Cheers,

Ryan

Hey Ryan,

Thanks for your reply. I’m asking about the latest v1 release, not v2. Is there a cpp template for that?

Jay

Hi Jay,

Ah. OK. The best example we have for C++ in v1 is the EAM_Dynamo driver

https://openkim.org/dev-kim-item/EAM_Dynamo__MD_120291908751_004

Howerver, this was written in a way that aimed to give the c++ compiler maximum information about how variables are used (const correctness, and such). This resulted in rather cumbersome code (and not so much actual performance gain). So, it is not an ideal template.

Anyway, our whole system will be converting over to the kim-api-v2 release in the very near future. We'll be converting over to the next beta release. We are confident enough in the state of the upcoming release that were going to use it in production even before we finalize the documentation and make the official v2 release.

So, unless you have a really good reason, I would plan to work with v2.

Cheers,

Ryan

Hi Ryan,

Good to hear from you. I’m aiming to write a quick Openkim model for my model, not a full-blown model driver. Therefore, I would think v1 is sufficient?

Also, after the release of v2 do you have any idea the time is needed for the api to be supported by the major simulators? I’m looking at LAMMPS in particular. If there is no definite timeline I think it would be good to just stick with v1 for now since I’m just going to create a quick simple model for testing?

Jay

Hi Jay,

I see. Yes, then it might be good to work with v1 for now. I would say that the simplist thing would be to work with the c template, but compile them as c++. You would just need to surround the declaration of the functions using extern c.

extern "C"
{
int model_init(void* km);
}

The rest should just work as is.

Ryan

Hi Ryan,

Good to hear from you. I'm aiming to write a quick Openkim model for my model, not a full-blown model driver. Therefore, I would think v1 is sufficient?

Also, after the release of v2 do you have any idea the time is needed for the api to be supported by the major simulators? I'm looking at LAMMPS in particular. If there is no definite timeline I think it would be good to just stick with v1 for now since I'm just going to create a quick simple model for testing?

I do not know about major simulators (although it is my impression that LAMMPS is ready), but a minor one (Asap + ASE) is already prepared for V2. I will merge the OpenKIM v2 branch into master, test and release very soon after the first OpenKIM v2 release - as soon as they convert their infrastructure and make models available.

Best regards

Jakob