bfit.grid

Grid module for integration.

Module Contents

Classes

UniformRadialGrid

Uniformly Distributed Radial Grid Class.

ClenshawRadialGrid

Clenshaw-Curtis Radial Grid Class.

CubicGrid

Equally-Spaced 3D Cubic Grid Class.

class bfit.grid.UniformRadialGrid(num_pts, min_radii=0.0, max_radii=100.0, dtype=np.longdouble)[source]

Bases: _BaseRadialGrid

Uniformly Distributed Radial Grid Class.

The grid points are equally-spaced in \([0, K)\) interval, where K is the upper bound on the grid.

Construct the UniformRadialGrid object.

Parameters
  • num_pts (int) – The number of grid points.

  • min_radii (float, optional) – The smallest radial grid point.

  • max_radii (float, optional) – The largest radial grid point.

  • dtype (data-type, optional) – The desired NumPy data-type.

property points(self)[source]

Radial grid points.

integrate(self, arr)[source]

Compute trapezoidal integration of a function evaluated on the radial grid points.

In other words, \(\int f(r) dr\), where :math:’f(r)’ is the integrand.

Parameters

arr (ndarray(N,)) – The integrand evaluated on the \(N\) radial grid points.

Returns

The value of the integral.

Return type

float

class bfit.grid.ClenshawRadialGrid(atomic_number, num_core_pts, num_diffuse_pts, extra_pts=None, include_origin=True, dtype=np.longdouble)[source]

Bases: _BaseRadialGrid

Clenshaw-Curtis Radial Grid Class.

The Clenshaw-Curtis grid places more points closer to the origin of the interval \([0, \inf).\) It is defined as follows. Let \(Z, m, n\) be the atomic number, number of points near the origin, and the number of points far from the origin, respectively.

Then each point \(r_p\) of the Clenshaw radial grid is either

\[\begin{split}\begin{eqnarray} r_p = \frac{1}{2Z} \bigg(1 - \cos\bigg(\frac{\pi p}{400} \bigg)\bigg) & p = 0, 1, \cdots, m - 1 \\ r_p = 25 \bigg(1 - \cos\bigg(\frac{\pi p}{600} \bigg)\bigg) & p = 1, \cdots, n - 1\\ \end{eqnarray}\end{split}\]

Construct ClenshawRadialGrid grid object.

Parameters
  • atomic_number (int) – The atomic number of the atom for which the grid is generated.

  • num_core_pts (int) – The number of points near the origin/core region.

  • num_diffuse_pts (int) – The number of points far from the origin/core region.

  • extra_pts (list) – Additional points to be added to the grid, commonly points far away from origin.

  • include_origin (bool) – If true, then include the origin \(r=0\).

  • dtype (data-type, optional) – The desired NumPy data-type.

property atomic_number(self)[source]

Return the atomic number.

property points(self)[source]

Radial grid points.

integrate(self, arr)[source]

Compute trapezoidal integration of a function evaluated on the radial grid points.

In other words, \(\int f(r) dr\), where :math:’f(r)’ is the integrand.

Parameters

arr (ndarray(N,)) – The integrand evaluated on the \(N\) radial grid points.

Returns

The value of the integral.

Return type

float

class bfit.grid.CubicGrid(origin, axes, shape)[source]

Equally-Spaced 3D Cubic Grid Class.

Construct the CubicGrid object.

Parameters
  • origin (float) – The origin (left-most, down-most) of the 3D cubic grid.

  • axes (ndarray(3, 3)) – The axes that point to the direction of the grid.

  • shape ((int, int, int)) – The number of points in each axes.

property axes(self)[source]

Return the axes/three-directions of the cubic grid.

classmethod from_molecule(cls, atcorenums, atcoords, spacing=0.2, extension=5.0, rotate=True)[source]

Construct a uniform grid given the molecular pseudo-numbers and coordinates.

Parameters
  • atcorenums (np.ndarray, shape (M,)) – Pseudo-number of \(M\) atoms in the molecule.

  • atcoords (np.ndarray, shape (M, 3)) – Cartesian coordinates of \(M\) atoms in the molecule.

  • spacing (float, optional) – Increment between grid points along \(x\), \(y\), and \(z\) direction.

  • extension (float, optional) – The extension of the length of the cube on each side of the molecule.

  • rotate (bool, optional) – When True, the molecule is rotated so the axes of the cube file are aligned with the principle axes of rotation of the molecule. If False, generates axes based on the x,y,z-axis and the spacing parameter, and the origin is defined by the maximum/minimum of the atomic coordinates.

property points(self)[source]

Return cubic grid points.

integrate(self, arr)[source]

Compute the integral of a function evaluated on the grid points based on Riemann sums.

\[\int\int\int f(x, y, z) dx dy dz \approx \sum_i \sum_j \sum_k f(x_i, y_j, z_k) w_{ijk}\]

where :math:’f(r)’ is the integrand, and \(w_{ijk}\) is the weight associated with the (i, j, k)th point.

Parameters

arr (ndarray) – The integrand evaluated on the grid points.

Returns

value – The value of the integral.

Return type

float