How to fiddle with models on kim-api v.1.9.x

Hello,

I would like to develop/modify my own model contribution, but I don't know
how to do this on kim-api v.1.9.x. I hope someone could instruct me.

I work on my home directory, i.e. I have /home/user/kim-api-v1.x.x
directory where kim-api has been built.

Until kim-api v.1.8.x, developing my own model was simple because I just
had to create a new directory (e.g. Mymodel) in /home/user/kim-api-v1.8.x/src/models
and write mymodel.cpp, mymodel.kim, etc.
When 'make' is done in /home/user/kim-api-v1.8.x, the new directory
(/home/user/kim-api-v1.8.x/src/models/Mymodel) was automatically recognized
and the model was built.

Now, I am having trouble on kim-api v.1.9.x because I don't seem to be
able to do the same thing. First of all, there is no /home/user/kim-api-v1.9.x/src/models
directory. Then I created /home/user/kim-api-v1.9.x/src/models/Mymodel directory and
put my model there, but it was not recognized (nothing happens when 'make' is done).
Therefore I cannot modify my old model contribution or write a new model.
Would somebody help me out?

Regards,
Yoshi

Hi Yoshi,

Thanks for your question. There are multiple ways this can be done.

Probably the simplest way is this:

Put your model code anywhere you like, say,

   /home/user/my-model

edit your model as necessary. When you are ready to build/install it, do this:

The first time:
   $ kim-api-v1-collections-management install user /home/user/my-model

After that:
   $ kim-api-v1-collections-management reinstall /home/user/my-model

Ryan

Dear Ryan,

thank you very much for the advice. Now it works!

I understand, from second time I should do 'reinstall', and each time
I modify the code (say 'mymodel.cpp') I do 'reinstall'. That's OK, but
if I make a mistake leading to a compile error (e.g. typo in the code),
what I must do next (after fixing the code) is 'install user', not
'reinstall'. Is that right?

This may be slightly inconvenient because I want to use the same command
while I work on rewriting the code (and I frequently make mistakes!).
This is not a strong request, but might deserve a thought.

Best,
Yoshi

Hi Yoshi,

Yes that is right. I agree, the scenario you describe is going to be common and not the most convenient. So, let's try a different approach.

(first remove any installed version of your model using the collections management utility.)

In this method, we'll use a "environment variable" collection. I'll assume your model code is located at

   /home/user/my-kim-items/my-model-version2

Fist we'll set the environment variables to tell the kim api to look in the right place (you might want to do this in your .bashrc):

    export KIM\_API\_MODEL\_DRIVERS\_DIR=/home/user/my\-kim\-items     export KIM_API_MODELS_DIR=/home/user/my-kim-items

Next you'll need to do the following (just once)

    cd /home/user/my\-kim\-items     kim-api-v1-build-config --makefile-kim-config > Makefile.KIM_Config

Then you should be able just edit your model code and use make as necessary (no need for a "make install")

For example,

    cd /home/usre/my\-kim\-items/my\-model\-verision2     vi ... # edit code and save
   $ make

That should do it...

Ryan

Hi Ryan,

thanks for the tip! It worked out and now I can simply edit my code and
rebuild it by 'make' command. It's convenient. Thanks!

Best,
Yoshi