This example demonstrates using an OpenKIM model installed on your system for an ASE calculation, specifically a static energy calculation of FCC Aluminum using the famous 1994 Ercolessi-Adams EAM potential. The KIM query Python module is used to obtain the lattice constant used for the simulation.
This is what the calculation would look like without OpenKIM. The user is required to specify the lattice constant and obtain their own parameter file:
from ase.calculators.eam import EAM
from ase.lattice.cubic import FaceCenteredCubic
# Define the user-obtained parameter file and lattice constant
model = "potentials/v2_18_Al3Sm_2016.eam.fs"
calc = EAM(potential=model)
a0 = 4.05
# Set up fcc crystal
atoms = FaceCenteredCubic("Al", latticeconstant=a0)
atoms.calc = calc
# Compute energy and stress
print("\nPotential energy:")
print(atoms.get_potential_energy())
Below is the same calculation using OpenKIM. The kim_query Python module is used to automatically obtain the lattice constant.
from ase.calculators.kim import KIM
from ase.lattice.cubic import FaceCenteredCubic
from kim_query import get_lattice_constant_cubic
# Define KIM model and get Al fcc lattice parameter for this potential
model = "EAM_Dynamo_SongMendelev_2021_AlSm__MO_722733117926_000"
calc = KIM(model)
a0 = get_lattice_constant_cubic([model], ["fcc"], ["Al"], ["angstrom"])[0]
# Set up fcc crystal
atoms = FaceCenteredCubic("Al", latticeconstant=a0)
atoms.calc = calc
# Compute energy and stress
print("\nPotential energy:")
print(atoms.get_potential_energy())
The energy is nearly identical, but slightly lower due to the lattice constant being the perfect equilibrium value. See the KIM calculator in ASE documentation for more info.