openkim / kliff

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

how to set the cutoff parameter in the Lennard-Jones potential #109

Closed lnnbig closed 1 year ago

lnnbig commented 1 year ago

In the example for training a Lennard-Jones potential (as shown below) the default cutoff is 5.0. But now I may want to try another value, e.g., 6.0. As a beginner, may I please ask where should I add this cutoff parameter in the code below?

Thank you very much.

############ from https://kliff.readthedocs.io/en/latest/auto_examples/example_lennard_jones.html ##### from kliff.calculators import Calculator from kliff.dataset import Dataset from kliff.loss import Loss from kliff.models import LennardJones from kliff.utils import download_dataset

training set

dataset_path = download_dataset(dataset_name="Si_training_set_4_configs") tset = Dataset(dataset_path) configs = tset.get_configs()

calculator

model = LennardJones() model.echo_model_params()

fitting parameters

model.set_opt_params(sigma=[["default"]], epsilon=[["default"]]) model.echo_opt_params()

calc = Calculator(model) calc.create(configs)

loss

loss = Loss(calc, nprocs=1) result = loss.minimize(method="L-BFGS-B", options={"disp": True, "maxiter": 10})

print optimized parameters

model.echo_opt_params() model.save("kliff_model.yaml")

lnnbig commented 1 year ago

One more question regarding the LJ units: I train an LJ potential using the Si_training_set (the results are attached below). I was wondering what are the units for sigma 1 = 2.0882607011402938e+00 (and epsilon 1 = 1.5180562481046480e+00)?

================================================================================

Model parameters that are optimized.

Note that the parameters are in the transformed space if

params_transform is provided when instantiating the model.

================================================================================

sigma 1 2.0000000000000000e+00

epsilon 1 1.0000000000000000e+00

================================================================================

Model parameters that are optimized.

Note that the parameters are in the transformed space if

params_transform is provided when instantiating the model.

================================================================================

sigma 1 2.0882607011402938e+00

epsilon 1 1.5180562481046480e+00

mjwen commented 1 year ago

hi @lnnbig!

model.set_opt_params(sigma=[["default"]], epsilon=[["default"], cutoff = [[6.0, 'fix']]]) would do the job. See https://kliff.readthedocs.io/en/latest/_modules/kliff/models/model.html#Model.set_opt_params for more info.

The units of the parameters depend on the units of the data. The model does not enforce units. The Si dataset uses Angstorm and eV as spacing and energy units, respectively. So, here sigma would have a unit of Angstorm and epsilon would have a unit of eV.