Skip to main content

OpenKIM material property computations for arbitrary crystal structures as Python classes

Project description

Testing PyPI

This package allows the user to run any OpenKIM Test Drivers written using the kim-tools package locally. A “Test Driver” is a computational protocol that reports one or more material properties using the KIM Properties Framework

List of included Test Drivers:

  • EquilibriumCrystalStructure

  • ElasticConstantsCrystal

  • CrystalStructureAndEnergyVsPressure

Currently, all Test Drivers require the AFLOW software to be installed and in your PATH. See https://kim-tools.readthedocs.io/en/stable/#doc-standalone-installation for installation info.

Basic usage example:

from kimvv import ElasticConstantsCrystal
from ase.build import bulk
from json import dumps

# The Test Driver must be instantiated with an ASE Calculator object
# or a string indicating a KIM model name
elast = ElasticConstantsCrystal('LennardJones_Ar')

# To perform the computation, call the Test Driver object. The first argument
# to most Test Drivers is the crystal structure to perform the compuation on.
# To see the additonal arguments, use .printdoc() to print the docstring
elast.printdoc()

# Let's compute the elastic constants with the "stress-condensed" method.
# The crystal structure can be specified as an Atoms object. Any dependencies
# (e.g. relaxing the crystal structure with EquilibriumCrystalStructure) are
# automatically run.
results = elast(bulk('Ar','fcc',5.0), method="stress-condensed")

# Each Test Driver computes a list of one or more dictionaries, each defining
# a material property in the format specified by the KIM Properties Framework.
# The name of the property is in the "property-id" key. See
# https://openkim.org/properties for the definition of each property.
print(dumps(results, indent=2))

Usage example 2

Getting the anisotropic pressure-volume curve of HCP Ag using a non-KIM ASE Calculator and saving the output files

from kimvv import CrystalStructureAndEnergyVsPressure
from ase.build import bulk
from ase.calculators.emt import EMT
from json import dumps

# The Test Driver must be instantiated with an ASE Calculator object
# or a string indicating a KIM model name
scan = CrystalStructureAndEnergyVsPressure(EMT())

# To perform the computation, call the Test Driver object. The first argument
# to most Test Drivers is the crystal structure to perform the compuation on.
# To see the additonal arguments, use .printdoc() to print the docstring
scan.printdoc()

# The default volume range of 0.25-4.0 will take a long time to scan. Let's
# do a much smaller range
results = scan(
    bulk("Ag", "hcp", 2.92), min_fractional_volume=0.98, max_fractional_volume=1.02
)

# In addition to accessing the results as a Python dictionary, you can save them to
# a file in .edn format. This is especially useful if the Test Driver produces
# auxiliary files, like the pressure scan does. All auxiliary files will be written
# to the parent directory of the path you specified.
scan.write_property_instances_to_file("scan_output/results.edn")

Usage example 3

Querying for all DFT-relaxed structures for a given combination of elements in OpenKIM and relaxing them with your potential

from kimvv import EquilibriumCrystalStructure
from kim_tools import (
  query_crystal_structures,
  get_deduplicated_property_instances
)
from json import dumps
from ase.calculators.lj import LennardJones

# Query for all relaxed Argon reference data in OpenKIM
raw_structs = query_crystal_structures(stoichiometric_species=["Ar"])

# Deduplicate them
unique_structs = get_deduplicated_property_instances(raw_structs, allow_rotation=True)

# Instantiate the Driver with your model
relax = EquilibriumCrystalStructure(LennardJones(sigma=3.4,epsilon=0.0104,rc=8.15))

# Run the Driver with each structure. As this is run, the driver internally accumulates
# Property Instances
for struct in unique_structs:
  relax(struct)

# In addition to returning the Property Instances for the current run, Test Drivers
# accumulate all computed Property Instances. They can be accessed like this:
print(dumps(relax.property_instances, indent=2))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kimvv-0.1.5.tar.gz (41.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kimvv-0.1.5-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

File details

Details for the file kimvv-0.1.5.tar.gz.

File metadata

  • Download URL: kimvv-0.1.5.tar.gz
  • Upload date:
  • Size: 41.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for kimvv-0.1.5.tar.gz
Algorithm Hash digest
SHA256 10f3b8196880c1ca26a03702dbc71833438392d289f51aed10ef63fc3b89b700
MD5 53217a39ec793ee79b571ecf5d1a4ee7
BLAKE2b-256 245856047c6b00e4cb891aee809782888c8a3cd84ff99e27f8d4743f9c2072ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for kimvv-0.1.5.tar.gz:

Publisher: release.yml on openkim/kimvv

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kimvv-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: kimvv-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 42.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for kimvv-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 07260d6ec9acf17f0ba1d8e0f30058d0268a3b4a3c1220c8d4119edcb552dd96
MD5 b7619007934cee2279afec5bba26b0d5
BLAKE2b-256 0e12b741022b7418ad3eef70df497fd71d6ca5116312ff957d5c530ee688b8ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for kimvv-0.1.5-py3-none-any.whl:

Publisher: release.yml on openkim/kimvv

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page