bfit.model

Models used for fitting.

Module Contents

Classes

AtomicGaussianDensity

Gaussian density model for modeling the electronic density of a single atom.

MolecularGaussianDensity

Molecular Atom-Centered Gaussian Density Model.

class bfit.model.AtomicGaussianDensity(points, center=None, num_s=1, num_p=0, normalize=False)[source]

Gaussian density model for modeling the electronic density of a single atom.

Atomic Gaussian density is a linear combination of Gaussian functions of S-type and p-type functions:

\[f(x) := \sum_i c_i e^{-\alpha_i |x - c|^2} + \sum_j d_j |x - c|^2 e^{-\beta_j |x - c|^2}\]

where \(c_i, d_i\) are the coefficients of s-type and p-type Gaussian functions, \(\alpha_i, \beta_j\) are teh exponents of the s-type and p-type Gaussian functions, \(c\) is the center of all Gaussian functions. \(x\) is the real coordinates, can be multi-dimensional.

Construct class representing atomic density modeled as Gaussian functions.

Parameters
  • points (ndarray, (N, D)) – Grid points where N is the number of points and D is the number of dimensions.

  • center (ndarray (D,), optional) – The D-dimensional coordinates of the single center. If None, then the center is the origin of all zeros.

  • num_s (int, optional) – Number of s-type Gaussian basis functions.

  • num_p (int, optional) – Number of p-type Gaussian basis functions.

  • normalize (bool, optional) – Whether to normalize Gaussian basis functions.

property points(self)[source]

Return the grid points.

property radii(self)[source]

Return the distance of grid points from center of Gaussian(s).

property num_s(self)[source]

Return the number of s-type Gaussian basis functions.

property num_p(self)[source]

Return the number of p-type Gaussian basis functions.

property nbasis(self)[source]

Return the total number of Gaussian basis functions.

property natoms(self)[source]

Return the number of basis functions centers.

property prefactor(self)[source]

Obtain list of exponents for the prefactors.

change_numb_s_and_numb_p(self, new_s, new_p)[source]

Change the number of s-type and p-type Gaussians.

Parameters
  • new_s (int) – New number of s-type Gaussians.

  • new_p (int) – New number of p-type Gaussians.

evaluate(self, coeffs, expons, deriv=False)[source]

Compute linear combination of Gaussian basis & its derivatives on the grid points.

\[f(x):= \sum_i c_i e^{-\alpha_i |x - c|^2} + \sum_j d_j |x - c|^2 e^{-\beta_j |x - c|^2}\]

where \(c_i, d_i\) are the coefficients of s-type and p-type Gaussian functions, \(\alpha_i, \beta_j\) are teh exponents of the s-type and p-type Gaussian functions, \(c\) is the center of all Gaussian functions. \(x\) is the real coordinates, can be multi-dimensional.

Parameters
  • coeffs (ndarray(nbasis,)) – The coefficients \(c_i\) of num_s s-type Gaussian basis functions followed by the coefficients \(d_j\) of num_p p-type Gaussian basis functions.

  • expons (ndarray(nbasis,)) – The exponents \(\alpha_i\) of num_s s-type Gaussian basis functions followed by the exponents \(\beta_j\) of num_p p-type Gaussian basis functions.

  • deriv (bool, optional) – Whether to compute derivative of Gaussian basis functions w.r.t. coefficients & exponents.

Returns

  • g (ndarray, (N,)) – The linear combination of Gaussian basis functions evaluated on the grid points.

  • dg (ndarray, (N, 2 * nbasis)) – The derivative of a linear combination of Gaussian basis functions w.r.t. coefficients & exponents, respectively, evaluated on the grid points. Only returned if deriv=True.

class bfit.model.MolecularGaussianDensity(points, coords, basis, normalize=False)[source]

Molecular Atom-Centered Gaussian Density Model.

The Molecular Gaussian Density model is based on multiple centers each associated with a Gaussian density model (s or p-type) of any dimension.

\[f(x) := \sum_j \bigg[ \sum_{i =1}^{M^s_j} c_{ji} e^{-\alpha_{ji} |x - m_j|^2} + \sum_{i=1}^{M_j^p}d_{ji} |x - m_j|^2 e^{-\beta_{ji} |x - m_j|^2} \bigg]\]

where \(c_{ji}, d_{ji}\) are the ith coefficients of s-type and p-type functions of the jth center, \(\alpha_{ji}, \beta_{ji}\) are the ith exponents of S-type and P-type functions of the jth center, \(M_j^s, M_j^p\) is the total number of s-type or p-type Gaussians functions of the jth center respectively, \(m_j\) is the coordinate of the jth center, and \(x\) is the real coordinates of the point. It can be of any dimension.

Construct the MolecularGaussianDensity class.

Parameters
  • points (ndarray, (N, D)) – The grid points, where N is the number of grid points and D is the dimension.

  • coords (ndarray, (M, D)) – The atomic coordinates (M centers) on which Gaussian basis are centered.

  • basis (ndarray, (M, 2)) – The number of S-type & P-type Gaussian basis functions placed on each center.

  • normalize (bool, optional) – Whether to normalize Gaussian basis functions.

property points(self)[source]

Get grid points.

property nbasis(self)[source]

Get the total number of Gaussian basis functions.

property radii(self)[source]

Get the distance of grid points from center of each basis function.

property natoms(self)[source]

Get number of basis functions centers.

property prefactor(self)[source]

Get the pre-factor of Gaussian basis functions to make it normalized.

Only used if attribute normalize is true.

assign_basis_to_center(self, index)[source]

Assign the Gaussian basis function to the atomic center.

Parameters

index (int) – The index of Gaussian basis function.

Returns

index – The index of atomic center.

Return type

int

evaluate(self, coeffs, expons, deriv=False)[source]

Compute linear combination of Gaussian basis & its derivatives on the grid points.

The Molecular Gaussian is defined to be:

\[f(x) := \sum_j \bigg[ \sum_{i =1}^{M^s_j} c_{ji} e^{-\alpha_{ji} |x - m_j|^2} + \sum_{i=1}^{M_j^p}d_{ji} |x - m_j|^2 e^{-\beta_{ji} |x - m_j|^2} \bigg]\]

where \(c_{ji}, d_{ji}\) are the ith coefficients of s-type and p-type functions of the jth center, \(\alpha_{ji}, \beta_{ji}\) are the ith exponents of S-type and P-type functions of the jth center, \(M_j^s, M_j^p\) is the total number of s-type or p-type Gaussians functions of the jth center respectively, \(m_j\) is the coordinate of the jth center, and \(x\) is the real coordinates of the point. It can be of any dimension.

Parameters
  • coeffs (ndarray, (nbasis,)) – The coefficients of num_s s-type Gaussian basis functions followed by the coefficients of num_p p-type Gaussian basis functions for an atom, then repeat for the next atom.

  • expons (ndarray, (nbasis,)) – The exponents of num_s s-type Gaussian basis functions followed by the exponents of num_p p-type Gaussian basis functions for an atom, then repeat for the next atom.

  • deriv (bool, optional) – Whether to compute derivative of Gaussian basis functions w.r.t. coefficients & exponents.

Returns

  • g (ndarray, (N,)) – The linear combination of Gaussian basis functions evaluated on the grid points.

  • dg (ndarray, (N, nbasis)) – The derivative of linear combination of Gaussian basis functions w.r.t. coefficients & exponents, respectively, evaluated on the grid points. Only returned if deriv=True.