Changing model parameters in ASE

Hi all,

I am interested in modifying the parameters of a KIM model - e.g. “SW_StillingerWeber_1985_Si__MO_405512056662_005” - and performing some calculations using ASE within a Jupyter notebook.

Using the KimPy interface I can create a kimpy.model.Model object, with which I can see the number, type and value of the different parameters, and I can also set their values within this object.

My question is, how can I feed these changes to the parameters through to an ASE calculator?

Apologies if this is a simple question / if this is the wrong way to approach this problem, but I am still fairly new to OpenKIM !

Thanks in advance,
Iain

Hi Iain,

Efforts are already underway: https://gitlab.com/ase/ase/-/merge_requests/2267. We’re still hashing out the interface, but if you check out the latest commit on our fork, you can do something like this:

import pprint

from ase import Atoms
from ase.calculators.kim import KIM

pp = pprint.PrettyPrinter(indent=4)

calc = KIM("SW_StillingerWeber_1985_Si__MO_405512056662_005")

# Print summary of model parameters, including their length and how they're indexed
pp.pprint(calc.parameters_metadata())
print()

atoms = Atoms("Si" * 2, positions=[[0, 0, 0], [0, 0, 2.1]])
atoms.calc = calc

energy_orig = atoms.get_potential_energy()
print(f"Energy with original parameters = {energy_orig} eV")

# Now double the parameter A
A_orig = calc.get_parameters(A=[0])['A'][1][0]
A_modified = 2 * A_orig

calc.set_parameters(A=[0, A_modified])

energy_modified = atoms.get_potential_energy()
print(f"Energy with modified parameters = {energy_modified} eV")

Dan