Projector¶
A crucial step in NeuralXC is the creation of machine learning features \(c_\alpha\) by projecting the density \(n(\mathbf r)\) onto a set of basis functions \(\psi_{\alpha}(\mathbf r)\)
Here, \(\alpha\) summarizes the quantum numbers \(n,l,m\). In practice, this integration is either performed on a grid, or, if both density matrix and projection basis can be expressed in terms of Gaussian type orbitals (GTO), analytically.
For grid integrations, NeuralXC distinguishes between three dimensional euclidean grids
and radial grids
with integration weights \(w_i\). For euclidean grids, NeuralXC automatically assumes periodic boundary conditions. Radial grids are only supported for finite systems.
If the density can be expressed in terms of GTOs \(\phi(\mathbf r)\) with density matrix \(\rho_{\mu\nu}\)
then the projection can be computed analytically as
NeuralXC takes advantage of this to avoid grid computations when working with PySCF cite{pyscf}.
Beyond the type of integration methods, Projectors are defined by their radial basis functions (the angular part is always given by spherical harmonics).
These can either be polynomials
or GTOs.
For polynomial basis functions the user needs to specify the number of radial functions \(n\), the number of spherical shells \(l\) (this is the maximum angular momentum \(l_\text {max}\) plus one) and an outer cutoff \(r_o\) in the configuration file. Basis sets can either be specified on a per-element basis or a single, species independent, basis set can be used across elements.
For GTO basis functions, the user can either provide a basis-set name (same nomenclature as used by PySCF) such as “6-311G*” or a path pointing to a file containing a NWChem cite{nwchem} formatted basis definition (see Basis Set Exchange cite{bse}). If the projection is done on a grid (as opposed to analytically) the Gaussians should be localized to have finite support
We have introduced two parameters that can be tuned by the user to control the localization of the basis functions. \(\sigma\) (default: 2.0) controls the effective cutoff radius as a function of the Gaussian exponent \(\kappa\) and the angular momentum \(l\). \(\gamma\) (default: 1.0) allows the user to re-scale the Gaussian functions.
The type of radial basis to be used can be specified in the configuration file using the keyword
projector
ortho
Polynomial basisgaussian
GTO basis
In addition, the grid (or lack thereof) has to be specified through the keyword
grid
euclidean
Euclidean gridradial
Radial gridanalytical
Perform integrals analytically
Base classes and inheritance¶
All real space projectors are either derived from EuclideanProjector or RadialProjector. The former implements density projections on a euclidean grid with periodic boundary conditions. The latter can be used for projections on flexible grids for which grid coordinates and integration weights are explicitly provided (as e.g. in PySCF). Both of these projector types inherit from the BaseProjector class.
-
class
neuralxc.projector.projector.
BaseProjector
¶ -
get_basis_rep
(rho, positions, species, **kwargs)¶ Calculates the basis representation for a given real space density
Parameters: - rho (np.ndarray float (npoints) or (xpoints, ypoints, zpoints)) – Electron density in real space
- positions (np.ndarray float (natoms, 3)) – atomic positions
- species (list string) – atomic species (chem. symbols)
Returns: c – Basis representation, dict keys correspond to atomic species.
Return type: dict of np.ndarrays
-
-
class
neuralxc.projector.projector.
EuclideanProjector
(unitcell, grid, basis_instructions, **kwargs)¶ -
__init__
(unitcell, grid, basis_instructions, **kwargs)¶ Projector on euclidean grid with periodic bounday conditions
Parameters: - unitcell (numpy.ndarray float (3,3)) – Unitcell in bohr
- grid (numpy.ndarray float (3)) – Grid points per unitcell
- basis_instructions (dict) – Instructions that define basis
-
-
class
neuralxc.projector.projector.
RadialProjector
(grid_coords, grid_weights, basis_instructions, **kwargs)¶ -
__init__
(grid_coords, grid_weights, basis_instructions, **kwargs)¶ Projector for generalized grid (as provided by e.g. PySCF). More flexible than euclidean grid as only grid point coordinates and their integration weights need to be provided, however does not support periodic boundary conditions. Special use case: Radial grids, as used by all-electron codes.
Parameters: - grid_coords (numpy.ndarray (npoints, 3)) – Coordinates of radial grid points
- grid_weights (numpy.ndarray (npoints)) – Grid weights for integration
- basis_instructions (dict) – Instructions that defines basis
-
Radial basis¶
Starting from from these definitions, NeuralXC implements two projectors that differ in their radial basis functionals. OrthoProjector implements an orthonormal polynomial basis whereas GaussianProjector uses Gaussian type orbitals similar to those used in quantum chemistry codes. Both projectors come in a euclidean and radial version.
-
class
neuralxc.projector.polynomial.
OrthoRadialProjector
(grid_coords, grid_weights, basis_instructions, **kwargs)¶ _registry_name: ‘ortho_radial’
-
class
neuralxc.projector.gaussian.
GaussianRadialProjector
(grid_coords, grid_weights, basis_instructions, **kwargs)¶ _registry_name: ‘gaussian_radial’
PySCF projector¶
If GTO orbitals in both projection and DFT calculation, projection integrals can be computed analytically. For this purpoes we have implemented a projector that works with PySCF. Future version of NeuralXC will implement a more general density matrix projector class that works with other gto codes as well.
-
class
neuralxc.projector.pyscf.
PySCFProjector
(mol, basis_instructions, **kwargs)¶ _registry_name: ‘pyscf’ -
__init__
(mol, basis_instructions, **kwargs)¶ Projector class specific to usage with PySCF. Instead of working with electron density on real space grid, density matrix is projected using analytical integrals.
Parameters: - mol (pyscf.gto.M) – Contains information about atoms and GTO basis
- basis_instructions (dict) –
- Basis instructions containing following values:
- spec_agnostic, bool (False)
- Use same basis for every atomic species?
- operator, {‘delta’, ‘rij’} (‘delta’)
- Operator in overlap integral used for projection, delta means standard 3-center overalp, rij with coulomb kernel.
- delta, bool (False)
- Use delta density (atomic density subracted)
- basis, str
- Either name of PySCF basis (e.g. ccpvdz-jkfit) or file containing basis.
-
get_basis_rep
(dm, **kwargs)¶ Project density matrix dm onto set of basis functions and return the projection coefficients (coeff)
-