Inspecting Densities and Descriptors
The PySCF analyzer and descriptor modules expose the electronic ingredients used to construct training data and inspect a mapped model. They evaluate the fixed density and orbitals supplied by a completed calculation.
Analyzer objects
RHFAnalyzer and
UHFAnalyzer bind a molecule, density
matrix, molecular orbitals, and atom-centered grid. They can evaluate and
cache densities, kinetic-energy densities, exchange energy densities, and
related quantities. Their HDF5 representation is useful for separating an
electronic-structure calculation from later descriptor generation.
1#!/usr/bin/env python
2"""Evaluate the descriptor blocks expected by a packaged CIDER model."""
3
4from pyscf import dft, gto
5
6from ciderpress.dft.model_utils import load_cider_model
7from ciderpress.pyscf.analyzers import RHFAnalyzer
8from ciderpress.pyscf.descriptors import get_descriptors
9
10
11def main():
12 mol = gto.M(atom="H 0 0 0; H 0 0 0.74", basis="def2-svp")
13 mf = dft.RKS(mol)
14 mf.xc = "PBE"
15 mf.grids.level = 3
16 mf.conv_tol = 1e-10
17 mf.kernel()
18 if not mf.converged:
19 raise RuntimeError("PBE SCF did not converge")
20
21 model = load_cider_model("CIDER26XCCHEM")
22 analyzer = RHFAnalyzer.from_calc(mf, grids_level=3)
23
24 semilocal = get_descriptors(analyzer, model.settings.sl_settings)
25 nonlocal_density = get_descriptors(analyzer, model.settings.nldf_settings)
26
27 print(f"grid points = {analyzer.grids.weights.size}")
28 print(f"semilocal descriptor shape = {semilocal.shape}")
29 print(f"NLDF descriptor shape = {nonlocal_density.shape}")
30
31
32if __name__ == "__main__":
33 main()
Descriptor arrays
ciderpress.pyscf.descriptors.get_descriptors() evaluates one settings
component at a time. The descriptor array has shape
(nspin, nfeature, ngrid). When orbital selectors are supplied, the
routine also returns feature derivatives with respect to selected occupation
numbers and their corresponding orbital energies.
Use the settings stored in the model being analyzed. They preserve its exact normalizers, exponent parameters, and feature order.
Fixed-density versus self-consistent use
Descriptor extraction evaluates a chosen, fixed density for model analysis, training-data construction, and comparison of feature representations. A self-consistent energy calculation also updates that density through the model potential. The density-generating calculation and the descriptor settings are separate inputs to a fixed-density analysis.
The GPAW descriptor interface obtains plane-wave and PAW quantities from a live, completed GPAW calculator. See GPAW Descriptor Interface for its supported settings, array shapes, PAW behavior, and occupation selectors. Use each backend’s documented point layout and orbital-index convention.