Atomic Density

the atomic density function \(g(r)\), often chosen to be a Gaussian or Delta function, that defined the type of density under consideration. For a given central atom \(i\) in the system, the total density function \(\rho_i(\boldsymbol{r})\) around is then defined as \(\rho_i(\boldsymbol{r}) = \sum_{j} g(\boldsymbol{r} - \boldsymbol{r}_{ij})\).

Atomic densities are represented as different child class of rascaline.utils.AtomicDensityBase: rascaline.utils.DeltaDensity, rascaline.utils.GaussianDensity, and rascaline.utils.LodeDensity are provided, and you can implement your own by defining a new class.

class rascaline.utils.AtomicDensityBase

Bases: ABC

Base class representing atomic densities.

abstract compute(positions: float | ndarray) float | ndarray

Compute the atomic density arising from atoms at positions.

Parameters:

positions – positions to evaluate the atomic densities

Returns:

evaluated atomic density

abstract compute_derivative(positions: float | ndarray) float | ndarray

Derivative of the atomic density arising from atoms at positions.

Parameters:

positions – positions to evaluate the derivatives atomic densities

Returns:

evaluated derivative of the atomic density with respect to positions

class rascaline.utils.DeltaDensity

Bases: AtomicDensityBase

Delta atomic densities of the form \(g(r)=\delta(r)\).

compute(positions: float | ndarray) float | ndarray

Compute the atomic density arising from atoms at positions.

Parameters:

positions – positions to evaluate the atomic densities

Returns:

evaluated atomic density

compute_derivative(positions: float | ndarray) float | ndarray

Derivative of the atomic density arising from atoms at positions.

Parameters:

positions – positions to evaluate the derivatives atomic densities

Returns:

evaluated derivative of the atomic density with respect to positions

class rascaline.utils.GaussianDensity(atomic_gaussian_width: float)

Bases: AtomicDensityBase

Gaussian atomic density function.

In rascaline, we use the convention

\[g(r) = \frac{1}{(\pi \sigma^2)^{3/4}}e^{-\frac{r^2}{2\sigma^2}} \,.\]

The prefactor was chosen such that the “L2-norm” of the Gaussian

\[\|g\|^2 = \int \mathrm{d}^3\boldsymbol{r} |g(r)|^2 = 1\,,\]

The derivatives of the Gaussian atomic density with respect to the position is

\[g^\prime(r) = \frac{\partial g(r)}{\partial r} = \frac{-r}{\sigma^2(\pi \sigma^2)^{3/4}}e^{-\frac{r^2}{2\sigma^2}} \,.\]
Parameters:

atomic_gaussian_width – Width of the atom-centered gaussian used to create the atomic density

compute(positions: float | ndarray) float | ndarray

Compute the atomic density arising from atoms at positions.

Parameters:

positions – positions to evaluate the atomic densities

Returns:

evaluated atomic density

compute_derivative(positions: float | ndarray) float | ndarray

Derivative of the atomic density arising from atoms at positions.

Parameters:

positions – positions to evaluate the derivatives atomic densities

Returns:

evaluated derivative of the atomic density with respect to positions

class rascaline.utils.LodeDensity(atomic_gaussian_width: float, potential_exponent: int)

Bases: AtomicDensityBase

Smeared power law density, as used in LODE.

It is defined as

\[g(r) = \frac{1}{\Gamma\left(\frac{p}{2}\right)} \frac{\gamma\left( \frac{p}{2}, \frac{r^2}{2\sigma^2} \right)} {r^p},\]

where \(p\) is the potential exponent, \(\Gamma(z)\) is the Gamma function and \(\gamma(a, x)\) is the incomplete lower Gamma function. However its evaluation at \(r=0\) is problematic because \(g(r)\) is of the form \(0/0\). For practical implementations, it is thus more convenient to rewrite the density as

\[\begin{split}g(r) = \frac{1}{\Gamma(a)}\frac{1}{\left(2 \sigma^2\right)^a} \begin{cases} \frac{1}{a} - \frac{x}{a+1} + \frac{x^2}{2(a+2)} + \mathcal{O}(x^3) & x < 10^{-5} \\ \frac{\gamma(a,x)}{x^a} & x \geq 10^{-5} \end{cases}\end{split}\]

where \(a=p/2\). It is convenient to use the expression for sufficiently small \(x\) since the relative weight of the first neglected term is on the order of \(1/6x^3\). Therefore, the threshold \(x = 10^{-5}\) leads to relative errors on the order of the machine epsilon.

Parameters:
  • atomic_gaussian_width – Width of the atom-centered gaussian used to create the atomic density

  • potential_exponent – Potential exponent of the decorated atom density. Currently only implemented for potential_exponent < 10. Some exponents can be connected to SOAP or physics-based quantities: p=0 uses Gaussian densities as in SOAP, p=1 uses 1/r Coulomb like densities, p=6 uses 1/r^6 dispersion like densities.

compute(positions: float | ndarray) float | ndarray

Compute the atomic density arising from atoms at positions.

Parameters:

positions – positions to evaluate the atomic densities

Returns:

evaluated atomic density

compute_derivative(positions: float | ndarray) float | ndarray

Derivative of the atomic density arising from atoms at positions.

Parameters:

positions – positions to evaluate the derivatives atomic densities

Returns:

evaluated derivative of the atomic density with respect to positions