grid.basegrid module#
Construct basic grid data structure.
- class grid.basegrid.Grid(points, weights)#
Bases:
objectBasic Grid class for grid information storage.
- get_localgrid(center, radius)#
Create a grid containing points within the given radius of center.
Parameters#
- centerfloat or np.array(M,)
Cartesian coordinates of the center of the local grid.
- radiusfloat
Radius of sphere around the center. When equal to np.inf, the local grid coincides with the whole grid, which can be useful for debugging.
Returns#
- LocalGrid
Instance of LocalGrid.
- integrate(*value_arrays)#
Integrate over the whole grid for given multiple value arrays.
Product of all input arrays will be computed element-wise then integrated on the grid with its weights:
\[\int w(x) \prod_i f_i(x) dx.\]Parameters#
- *value_arraysnp.ndarray of shape (N,)
One or more value arrays to integrate.
Returns#
- float:
The calculated integral over given integrand or function
- moments(orders: int, centers: ndarray, func_vals: ndarray, type_mom: str = 'cartesian', return_orders: bool = False)#
Compute the multipole moment integral of a function over centers.
The Cartesian type moments are:
\[m_{n_x, n_y, n_z} = \int (x - X_c)^{n_x} (y - Y_c)^{n_y} (z - Z_c)^{n_z} f(r) dr,\]where \(\textbf{R}_c = (X_c, Y_c, Z_c)\) is the center of the moment, \(f(r)\) is the function, and \((n_x, n_y, n_z)\) are the Cartesian orders.
The spherical/pure moments with \((l, m)\) parameter are:
\[m_{lm} = \int | \textbf{r} - \textbf{R}_c|^l S_l^m(\theta, \phi) f(\textbf{r}) d\textbf{r},\]where \(S_l^m\) is a regular, real solid harmonic.
The radial moments with \(n\) parameter are:
\[m_n = \int | \textbf{r} - \textbf{R}_c|^{n} f(\textbf{r}) d\textbf{r}\]The radial combined with spherical/pure moments \((n, l, m)\) are:
\[m_{nlm} = \int | \textbf{r} - \textbf{R}_c|^{n+1} S_l^m(\theta, \phi) f(\textbf{r}) d\textbf{r}\]Parameters#
- ordersint
Generates all orders with Horton order depending on the type of the multipole moment type_mom.
- centersndarray(M, 3)
The centers \(\textbf{R}_c\) of the moments to compute from.
- func_valsndarray(N,)
The function \(f\) is evaluated at all \(N\) points on the integration grid.
- type_momstr
The type of multipole moments: “cartesian”, “pure”, “radial” and “pure-radial”.
- return_ordersbool
If true, it will also return a list of size \(L\) of the orders corresponding to each integral/row of the output.
Returns#
- ndarray(L, M), or (ndarray(L, M), list)
Computes the moment integral of the function at the mth center for all orders. If return_orders is true, then this also returns a list that describes what each row/order is, e.g. for Cartesian, [(0, 0, 0), (1, 0, 0) ,…].
- property points#
np.ndarray(N,) or np.ndarray(N, M): Positions of the grid points.
- save(filename)#
Save the points and weights as a npz file.
Parameters#
- filenamestr
The path/name of the .npz file.
- property size#
int: the total number of points on the grid.
- property weights#
np.ndarray(N,): the weights of each grid point.
- class grid.basegrid.LocalGrid(points, weights, center, indices=None)#
Bases:
GridLocal portion of a grid, containing all points within a sphere.
- property center#
np.ndarray(3,): Cartesian coordinates of the center of the local grid.
- property indices#
np.ndarray(N,): Indices of grid points and weights in the parent grid.