openkim / kliff

KIM-based Learning-Integrated Fitting Framework for interatomic potentials.
https://kliff.readthedocs.io
GNU Lesser General Public License v2.1
34 stars 19 forks source link

Kim model driver for analytical potential #102

Open Rana-Phy opened 1 year ago

Rana-Phy commented 1 year ago

Dear developer, I have a very basic question about fitting analytical potential e.g sw/bop. As a beginner I may not describing my question properly. I hope you will understand and answer. There is a tutorial on Si sw. If I want to fit for SiC, what are the things I need to modify in existing kim model. Further If someone wish to develop an analytical potential for a new system from what will be starting point in Kliff. Are there templates/scripts/command for set/modify initial inputs e.g atom types; before optimization by kliff.

Best regards Rana

mjwen commented 1 year ago

Hi @Rana-Phy

Fitting multispecies SW would be very similar to fitting Si SW. Take the GaN potential here for example, what you need to do is

  1. in line 59 of the Si tutorial, change the model name to SW_BereSerra_2006_GaN__MO_861114678890_001
  2. in line 80 of the same tutorial, set the parameters you want to optimize (and provide the initial guesses). In the Si tutorial, the is one value (Si-Si interaction) for each potential parameter, but for GaN, there will be 3 (Ga-Ga, Ga-N, N-N interactions) for each potential parameter. The initial values can be obtained via model.echo_model_params() as in the tutorial. Alternatively, find it in the SW_GaN.params file on the GaN model page.

To develop a new analytical potential, if the functional form is not on openkim.org yet, there are two ways to do it.

  1. Code your model in KLIFF using Python (here is an example for Lennard-Jones) and use it as usual (here is an example to use the Lennard-Jones)
  2. Directly code your model as a KIM model, and use it in a way as in the Si tutorial

1 might be quicker and easier, which is good to test different functional forms. But if you want to take advantage of the kim-api to use the model in molecular simulation packages like LAMMPS, it should be a KIM model (i.e. you need to go through step 2). I'd suggest doing 1 first to get the final model and then transfer it as a KIM model.

Rana-Phy commented 1 year ago

Dear Dr. @mjwen

Thanks for your reply. I hope I almost get it. Is that mean for AB system, I need to write a *.params file with A-A, A-B, B-B interactions and CMakeLists.txt. Then class KIMModel(Model) will import the initial parameters for fitting.

Best regards, Rana

mjwen commented 1 year ago

For fitting an existing model for AB system, you do not need to explicitly interact with CMakeLists.txt and such.

Take the SW_BereSerra_2006_GaN__MO_861114678890_001 model as an example, when you do model.echo_model_params(), you will be able to see all parameters for A-A, A-B, and B-B interactions. And you just need to use model.set_opt_params(...) to select the parameters you want to optimize.