Skip to main content
Version: Next

NN

NN Model

Tutorial

Neural Network (NN) Model Overview

The Neural Network (NN) model implements the following 8 feature types, all invariant under translation, rotation, and permutation:

        1. 2-body(2b)
2. 3-body(3b)
3. 2-body Gaussian(2b gauss)
4. 3-body Cosine(3b cos)
5. Moment Tensor Potential(MTP)
6. Spectral Neighbor Analysis Potential(SNAP)
7. DP-Chebyshev(dp1)
8. DP-Gaussian(dp2)

Features (or descriptors) characterize the local atomic environment and must preserve translational, rotational, and permutational symmetry. They are commonly used as inputs to regressors such as linear models and neural networks, which predict atomic energies and forces. Because the features are differentiable functions of spatial coordinates, forces can be calculated as

Fi=dEtotdRi=j,αEjGj,αGj,αRi\mathbf{F}_i = - \frac{d E_{\text{tot}}}{d \mathbf{R}_i} = - \sum_{j,\alpha} \frac{\partial E_j}{\partial G_{j,\alpha}} \frac{\partial G_{j,\alpha}}{\partial \mathbf{R}_i}

where jj indexes neighboring atoms within the cutoff radius and α\alpha indexes the features.

2-b and 3-b features with piecewise cosine functions (feature 1 & 2)

For a given central atom, piecewise cosine functions are used to describe its local environment. The following diagram illustrates the basic idea.

features

We first define piecewise cosine functions for the two-body and three-body features. Given inner and outer cutoffs RinnerR_{\text{inner}} and RouterR_{\text{outer}}, basis order MM, segment width hh, and interatomic distance RijR_{ij} between central atom ii and neighboring atom jj, the basis function is

ϕα(Rij)={12cos(RijRαhπ)+12,RijRα<h0,otherwise\phi_\alpha (R_{ij}) = \begin{cases} \frac{1}{2} \cos\left( \frac{R_{ij} - R_\alpha}{h} \pi \right) + \frac{1}{2} &, |R_{ij} - R_\alpha| < h \\ 0 &, \text{otherwise} \end{cases}

where

Rα=Rinner+(α1)h, α=1,2,...,MR_\alpha = R_{\text{inner}} + (\alpha - 1) h,\ \alpha = 1, 2, ..., M

The two-body feature of central atom ii is

Gα,i=mϕα(Rij)G_{\alpha,i} = \sum_{m} \phi_{\alpha}(R_{ij})

and the three-body feature is

Gαβγ,i=j,kϕα(Rij)ϕβ(Rik)ϕγ(Rjk)G_{\alpha\beta\gamma,i} = \sum_{j,k} \phi_{\alpha}(R_{ij}) \phi_{\beta}(R_{ik}) \phi_{\gamma}(R_{jk})

where m\sum_{m} and m,n\sum_{m,n} denote sums over all atoms within the cutoff radius RouterR_{\text{outer}} of central atom ii, respectively.

These two features are usually used together.

Reference:

Huang, Y., Kang, J., Goddard, W. A. & Wang, L.-W. Density functional theory based neural network force fields from energy decompositions. Phys. Rev. B 99, 064103 (2019)

2-b and 3-b Gaussian feature (feature 3 & 4)

These features were first used in the Behler–Parrinello neural network. Given cutoff radius RcR_c and interatomic distance RijR_{ij} between central atom ii and neighboring atom jj, the cutoff function fcf_c is defined as

fc(Rij)={12cos(πRijRc)+12,Rij<Rc0,otherwisef_c(R_{ij}) = \begin{cases} \frac{1}{2} \cos\left( \frac{\pi R_{ij}}{R_c} \right) + \frac{1}{2} &, R_{ij} < R_c \\ 0 &, \text{otherwise} \end{cases}

The two-body Gaussian feature of central atom ii is defined as

Gi=jie(η(RijRs)2)fc(Rij)G_i = \sum_{j \neq i} e^{(-\eta(R_{ij} - R_s)^2)} f_c(R_{ij})

where η\eta and RsR_s are user-defined parameters.

The three-body Gaussian feature of central atom ii is defined as

Gi=21ζj,ki(1+λcosθijk)ζeη(Rij2+Rik2+Rjk2)fc(Rij)fc(Rik)fc(Rjk)G_i = 2^{1-\zeta} \sum_{j,k \neq i} (1 + \lambda \cos \theta_{ijk})^\zeta e^{-\eta(R_{ij}^2 + R_{ik}^2 + R_{jk}^2)} f_c(R_{ij}) f_c(R_{ik}) f_c(R_{jk})

where

cosθijk=RijRikRijRik\cos \theta_{ijk} = \frac{\mathbf{R}_{ij} \cdot \mathbf{R}_{ik}}{|\mathbf{R}_{ij}| |\mathbf{R}_{ik}|}

η\eta, ζ\zeta, and λ=±1\lambda = \pm 1 are user-defined parameters.

These two features are usually used together.

Reference:

J. Behler and M. Parrinello, Generalized Neural-Network Representation of High Dimensional Potential-Energy Surfaces. Phys. Rev. Lett. 98, 146401 (2007)

Moment Tensor Potential (feature 5)

In MTP, the local environment of central atom ii is defined by

ni=(zi,zj,rij)\mathbf{n}_i = (z_i, z_j, \mathbf{r}_{ij})

where ziz_i is the atom type of the central atom, zjz_j is the atom type of a neighbor, and rij\mathbf{r}_{ij} is the relative coordinate of that neighbor. The energy contribution of each atom is then expanded as

Ei(ni)=αcαBα(ni)E_i(\mathbf{n}_i) = \sum_\alpha c_\alpha B_\alpha(\mathbf{n}_i)

where BαB_\alpha is a user-selected basis function and cαc_\alpha is a parameter to be fitted.

To construct the basis functions, we introduce the moment tensor MμνM_{\mu\nu}:

Mμν(ni)=jfμ(rij,zi,zj)νrijM_{\mu\nu}(\mathbf{n}_i) = \sum_j f_\mu(|\mathbf{r}_{ij}|, z_i, z_j) \bigotimes_\nu \mathbf{r}_{ij}

These moment tensors contain radial and angular components. The radial component can be expanded as

fμ(rij,zi,zj)=βcμ,zi,zj(β)Q(β)(rij)f_\mu(|\mathbf{r}_{ij}|, z_i, z_j) = \sum_\beta c^{(\beta)}_{\mu,z_i,z_j} Q^{(\beta)}(|\mathbf{r}_{ij}|)

where Q(β)(rij)Q^{(\beta)}(|\mathbf{r}_{ij}|) is a radial basis function. Specifically,

Q(β)(rij)={ϕ(β)(rij)(Rcutrij)2,rij<Rcut0,otherwiseQ^{(\beta)}(|\mathbf{r}_{ij}|) = \begin{cases} \phi^{(\beta)}(|\mathbf{r}_{ij}|) (R_{\text{cut}} - |\mathbf{r}_{ij}|)^2 &, |\mathbf{r}_{ij}| < R_{\text{cut}} \\ 0 &, \text{otherwise} \end{cases}

where ϕ(β)\phi^{(\beta)} is a polynomial, such as a Chebyshev polynomial, defined on [Rmin,Rcut][R_{\text{min}}, R_{\text{cut}}].

The angular component is given by νrij\bigotimes_\nu \mathbf{r}_{ij}, the ν\nu-fold tensor product of rij\mathbf{r}_{ij}, and contains the angular information of neighborhood ni\mathbf{n}_i. The value of ν\nu determines the rank of the moment tensor: ν=0\nu=0 gives a constant scalar, ν=1\nu=1 a vector (rank-1 tensor), ν=2\nu=2 a matrix (rank-2 tensor), and so on.

Finally, the level of a moment tensor is defined as

lev(Mμν)=2+4μ+ν\text{lev}(M_{\mu\nu}) = 2 + 4\mu + \nu

This is an empirical formula.

Reference:

I.S. Novikov, etal, The MLIP package: moment tensor potential with MPI and active learning. Mach. Learn.: Sci. Technol, 2, 025002 (2021)

Spectral Neighbor Analysis Potential (feature 6)

SNAP does not use Gaussian basis functions, so it does not calculate distances or kernel functions between two atomic-environment maps. Instead, it first defines a local atomic environment and expands it in spherical harmonics—or on a 4D hypersphere using rotation matrices. A bispectrum is then used to enforce rotational invariance. In this sense, SNAP resembles MTP, but uses a specialized contraction of directional indices to achieve rotational invariance. It is commonly paired with linear regression.

First, the local environment around the neighbors of central atom ii at r\mathbf{r} is defined as a sum of δ\delta functions in three-dimensional space:

ρ(r)=δ(r)+rki<RCfC(rki)ωkδ(rrki)\rho(\mathbf{r}) = \delta(\mathbf{r}) + \sum_{\mathbf{r}_{ki} < R_C} f_C(\mathbf{r}_{ki}) \omega_k \delta(\mathbf{r} - \mathbf{r}_{ki})

where rki\mathbf{r}_{ki} is the position of the kk-th neighbor of atom ii, ωk\omega_k is its weight, and radial function fC(rki)f_C(\mathbf{r}_{ki}) ensures that each neighbor's contribution smoothly approaches zero near cutoff radius RCR_C:

fC(r)=0.5[cos(πrRC)+1]f_C(\mathbf{r}) = 0.5 \left[ \cos\left( \frac{\pi r}{R_C} \right) + 1 \right]

The angular component of this local-environment function can be expanded in spherical harmonics defined for l=0,1,2,...l = 0, 1, 2, ... and m=l,l+1,...,l1,lm = -l, -l+1, ..., l-1, l. A radial distribution is normally represented by a set of radial basis functions. Here, however, radial information r\mathbf{r} is mapped to the 4D hyperspherical function Ummj(θ0,θ,ϕ)U^j_{mm'}(\theta_0,\theta,\phi), where all points (neighboring atoms) lie on a 3D sphere embedded in 4D space and orientation is represented by three angles:

r(xyz)ϕ=arctan(y/x)θ=arccos(z/r)θ0=34πr/rc\mathbf{r} \equiv \begin{pmatrix} x \\ y \\ z \end{pmatrix} \rightarrow \begin{matrix} \phi = \arctan(y/x) \\ \theta = \arccos(z/r) \\ \theta_0 = \frac{3}{4} \pi r / r_c \end{matrix}

The local-environment function can therefore be expanded in these 4D hyperspherical functions Ummj(θ0,θ,ϕ)U^j_{mm'}(\theta_0,\theta,\phi) with coefficients ummju^j_{mm'}:

ρ(r)=j=0,12,1,...m=j,j+1jm=j,j+1jummjUmmj(θ0,θ,ϕ)\rho(\mathbf{r}) = \sum_{j=0,\frac{1}{2},1,...}^\infty \sum_{m=-j,-j+1}^{j} \sum_{m'=-j,-j+1}^{j} u^j_{mm'} U^j_{mm'}(\theta_0,\theta,\phi)

Using the local-environment function above, ummju^j_{mm'} is calculated as

ummj=Ummj(0,0,0)+rki<RCfC(rki)ωkUmmj(θ0(k),θ(k),ϕ(k))u^j_{mm'} = U^j_{mm'}(0,0,0) + \sum_{\mathbf{r}_{ki} < R_C} f_C(\mathbf{r}_{ki}) \omega_k U^j_{mm'}(\theta_0(k),\theta(k),\phi(k))

where kk indexes neighboring atoms and θ0(k),θ(k),ϕ(k)\theta_0(k),\theta(k),\phi(k) are the three angles of the position vector of atom ii's kk-th neighbor. Because of the indices mm and mm', ummju^j_{mm'} is direction dependent. Three such terms can be contracted using

F(j1,j2,j)=m1,m1=j1jm2,m2=j2jm,m=jj(ummj)um1m1j1um2m2j2×Cj1m1j2m2jmCj1m1j2m2jmF(j_1,j_2,j) = \sum_{m_1,m_1'=-j_1}^{j} \sum_{m_2,m_2'=-j_2}^{j} \sum_{m,m'=-j}^{j} (u^{j}_{mm'})^* u^{j_1}_{m_1 m_1'} u^{j_2}_{m_2 m_2'} \times C_{j_1 m_1 j_2 m_2}^{j m} C_{j_1 m_1' j_2 m_2'}^{j m'}

Here, Cj1m1j2m2jmCj1m1j2m2jmC_{j_1 m_1 j_2 m_2}^{j m} C_{j_1 m_1' j_2 m_2'}^{j m} are Clebsch–Gordan coefficients, and the final scalar feature is F(j1,j2,j)F(j_1,j_2,j). Different choices of j1,j2,jj_1,j_2,j produce different features. These features have no radial-function index; instead, they contain three angular-momentum indices because radial-distance information has been transformed into the third angular coordinate on the 3D sphere.

DP-Chebyshev (feature 7)

This feature resembles the DP embedding network and uses Chebyshev polynomials as its basis.

First, S(rij)S(\mathbf{r}_{ij}) is defined as a weighted inverse-distance function:

S(r)=fC(r)rS(\mathbf{r}) = \frac{f_C(\mathbf{r})}{r} fC(r)={1,r<RC212cos(πrRC2RcRC2)+12,RC2r<RC0,r>RCf_C(\mathbf{r}) = \begin{cases} 1 &, r < R_{C_2} \\ \frac{1}{2} \cos\left( \pi \frac{r - R_{C_2}}{R_c - R_{C_2}} \right) + \frac{1}{2} &, R_{C_2} \leq r < R_C \\ 0 &, r > R_C \end{cases}

Here, RC2R_{C_2} is a smooth cutoff parameter that allows the components of ri\mathbf{r}_i to approach zero smoothly at the boundary of the local region defined by RCR_C. This smoothing function is more elaborate than the one used previously. S(rji)S(\mathbf{r}_{ji}) reduces the weight of atoms farther from central atom ii. We then define radial function gM(s)g_M(s) using Chebyshev polynomial CMC_M for the Deep Potential Chebyshev feature:

gM(s)=CM(2RminS1)g_M(s) = C_M(2R_{\min} S - 1)

Here, RminR_{\min} is the minimum input value of rr.

To construct this feature, we first calculate a four-component vector:

TM(k)=rji<RCX^ji(k)S(rji)gM(S(rji))T_M(k) = \sum_{\mathbf{r}_{ji} < R_C} \hat{X}_{ji}(k) S(\mathbf{r}_{ji}) g_M(S(\mathbf{r}_{ji}))

Here, k=0,1,2,3k = 0,1,2,3 indexes the four components: the usual x,y,zx,y,z components plus an SS component:

{xji,yji,zji}{S(rji),x^ji,y^ji,z^ji}\{ x_{ji}, y_{ji}, z_{ji}\} \rightarrow \{ S(\mathbf{r}_{ji}), \hat{x}_{ji}, \hat{y}_{ji}, \hat{z}_{ji} \}

Here, x^ji=xjirji,y^ji=yjirji,z^ji=zjirji\hat{x}_{ji} = \frac{x_{ji}}{r_{ji}}, \hat{y}_{ji} = \frac{y_{ji}}{r_{ji}}, \hat{z}_{ji} = \frac{z_{ji}}{r_{ji}} are the components of the unit vector along rji\mathbf{r}_{ji}.

The component indices of these 4D vectors can then be contracted to obtain a scalar feature:

F(M1,M2)=k=03TM1(k)TM2(k)F(M_1,M_2) = \sum_{k=0}^3 T_{M_1}(k) T_{M_2}(k)

In addition to the Chebyshev order, M1M_1 also encodes the atom type. Therefore, if the maximum Chebyshev order is MM, the number of features is Mntype(Mntype+1)/2M \cdot n_{\text{type}} \cdot (M \cdot n_{\text{type}} + 1) / 2. Different values of MM produce different feature sets.

DP-Gaussian (feature 8)

This feature is similar to DP-Chebyshev, but replaces the Chebyshev polynomials with Gaussian functions whose position and width parameters are specified by the user.

As in DP-Chebyshev, the 4D vector is constructed as follows:

TM(k)=rji<RCX^ji(k)gM(rji)T_M(k) = \sum_{\mathbf{r}_{ji} < R_C} \hat{X}_{ji}(k) g_M(\mathbf{r}_{ji}) X^(0)=S(r),X^(1)=xr,X^(2)=yr,X^(3)=zr\hat{X}(0) = S(\mathbf{r}'), \quad \hat{X}(1) = \frac{x}{r}, \quad \hat{X}(2) = \frac{y}{r}, \quad \hat{X}(3) = \frac{z}{r} gM(r)=fC(r)exp((rrM)ωM)g_M(\mathbf{r}) = f_C(\mathbf{r}) \cdot \exp\left( -\frac{(r - r_M)}{\omega_M} \right) fC(r)=12cos(πrRC)+12f_C(\mathbf{r}) = \frac{1}{2} \cos\left( \frac{\pi r}{R_C} \right) + \frac{1}{2}

The contraction is

F(M1,M2)=k=03TM1(k)TM2(k)F(M_1,M_2) = \sum_{k=0}^3 T_{M_1}(k) T_{M_2}(k)

In addition to the Gaussian-function index, M1M_1 also encodes the atom type. Therefore, if the maximum basis order is MM, the number of features is Mntype(Mntype+1)/2M \cdot n_{\text{type}} \cdot (M \cdot n_{\text{type}} + 1) / 2. Different values of MM produce different feature sets.