JAX-based Interatomic Potential
Project description
JAX-based Interatomic Potential
Description
Jaxip is an optimized Python library on basis of Google JAX that enables development of machine learning inter-atomic potentials for use in computational physics and material science. These potentials are necessary for conducting large-scale molecular dynamics simulations of complex materials with ab initio accuracy.
See documentation for more information.
Features
The design of Jaxip is simple and flexible, which makes it easy to incorporate atomic descriptors and potentials.
It uses automatic differentiation to make defining new descriptors straightforward.
Jaxip is written purely in Python and optimized with just-in-time (JIT) compilation.
It also supports GPU-accelerated computing, which can significantly speed up preprocessing and model training.
Installation
To install Jaxip, run this command in your terminal:
$ pip install jaxip
For machines with an NVIDIA GPU please follow the installation instruction on the documentation.
Examples
Defining an ACSF descriptor
This script demonstrates the process of evaluating an array of atomic-centered symmetry functions (ACSF) for a specific element, which can be utilized to evaluate the descriptor values for any structure. The resulting values can then be used to construct a machine learning potential.
from jaxip.datasets import RunnerDataset
from jaxip.descriptors import ACSF
from jaxip.descriptors.acsf import CutoffFunction, G2, G3
# Read atomic structure dataset (e.g. water molecules)
structures = RunnerDataset('input.data')
structure = structures[0]
print(structure)
# >> Structure(natoms=12, elements=('H', 'O'), dtype=float32)
# Define an ACSF descriptor for hydrogen element
# It includes two radial (G2) and angular (G3) symmetry functions
descriptor = ACSF('H')
cfn = CutoffFunction.from_cutoff_type(r_cutoff=12.0, cutoff_type='tanh')
descriptor.add(G2(cfn, eta=0.5, r_shift=0.0), 'H')
descriptor.add(G3(cfn, eta=0.001, zeta=2.0, lambda0=1.0, r_shift=12.0), 'H', 'O')
print(descriptor)
# >> ACSF(central_element='H', symmetry_functions=2)
values = descriptor(structure)
print("Descriptor values:\n", values)
# >> Descriptor values:
# [[0.01952942 1.1310327 ]
# [0.01952756 1.0431229 ]
# ...
# [0.00228752 0.4144546 ]]
gradient = descriptor.grad(structure, atom_index=0)
print("Descriptor gradient:\n", gradient)
# >> Descriptor gradient:
# [[ 0.0464524 -0.05037863 -0.06146219]
# [-0.10481848 -0.01841717 0.04760207]]
Training an NNP potential
This example illustrates how to quickly create a high-dimensional neural network potential (HDNNP) instance from an in input setting files and train it on input structures. The trained potential can then be used to evaluate the energy and force components for new structures.
from jaxip.datasets import RunnerDataset
from jaxip.potentials import NeuralNetworkPotential
# Read atomic data in RuNNer format
structures = RunnerDataset("input.data")
structure = structures[0]
nnp = NeuralNetworkPotential.from_file("input.nn")
nnp.fit_scaler(structures)
nnp.fit_model(structures)
# nnp.save()
# nnp.load()
total_energy = nnp(structure)
print(total_energy)
# >> -15.386198
forces = nnp.compute_forces(structure)
print(forces)
# >> [[ 1.6445214e-02 -4.1671786e-03 7.6140024e-02]
# [-6.4949177e-02 -4.2048577e-02 5.6018140e-02]
# ...
# [ 7.6149488e-03 -9.5360324e-02 -9.2892153e-03]]
Example files: input.data and input.nn
License
This project is licensed under the GNU General Public License (GPL) version 3 - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jaxip-0.7.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 388e1aaa1c4506c4637b8768e5849238a0f1adeb6cd22a30a22eb24d44f754c5 |
|
MD5 | ee79f082030372acaa6da7742899d401 |
|
BLAKE2b-256 | 3ca8ad7fc8460b643a9273a2991ebbecd05a0237118b11510938bae0f30ae529 |