#!/usr/bin/env python3 """ ASE cohesive energy example test with dependencies """ from ase.build import bulk from ase.calculators.kim import KIM from kim_query import get_lattice_constant_cubic from kim_property import kim_property_create, kim_property_modify, kim_property_dump # Grab the model name from standard input stream (stdin) model = input("Enter a KIM model name:\n") print(model) print() # Query for the fcc lattice constant lattice_constant = get_lattice_constant_cubic([model], ["fcc"], ["Ar"], ["angstrom"])[0] # Set up a primitive FCC Ar unit cell with periodic boundary conditions atoms = bulk('Ar', 'fcc', a=lattice_constant) # Initialize instance of the KIM ASE calculator for the given model and attach to atoms # object calc = KIM(model) atoms.set_calculator(calc) # Compute cohesive energy (and make positive to conform to sign convention in # property definition 'cohesive-potential-energy-cubic-crystal') ecohesive = -atoms.get_potential_energy() # Echo to output print(f"Cohesive energy = {ecohesive} eV/atom") print() # Create a property instance prop_instance = kim_property_create(1, "cohesive-potential-energy-cubic-crystal") # Set all the key-value pairs for this property instance prop_instance = kim_property_modify(prop_instance, 1, "key", "short-name", "source-value", 1, "fcc", "key", "species", "source-value", 1, "Ar", "key", "a", "source-value", lattice_constant, "source-unit", "angstrom", "key", "basis-atom-coordinates", "source-value", "1", "1:3", 0.0, 0.0, 0.0, "key", "basis-atom-coordinates", "source-value", "2", "1:3", 0.0, 0.5, 0.5, "key", "basis-atom-coordinates", "source-value", "3", "1:3", 0.5, 0.0, 0.5, "key", "basis-atom-coordinates", "source-value", "4", "1:3", 0.5, 0.5, 0.0, "key", "space-group", "source-value", "Fm-3m", "key", "cohesive-potential-energy", "source-value", ecohesive, "source-unit", "eV") # Dump the results to results.edn file in 'output' subdir kim_property_dump(prop_instance, "output/results.edn")