This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Notebooks · lib/hf/cart2sph

From Cartesian to spherical Gaussians, one shell at a time

The integral kernels in this library work on Cartesian components: a d shell has six (xx, xy, xz, yy, yz, zz) and an f shell ten. Most basis sets are defined on spherical components instead: five d functions and seven f. The sixth Cartesian d combination, xx + yy + zz = r^2, is an s function in disguise, and a spherical basis leaves it out. That is why water in 6-31G* has 19 Cartesian functions and 18 spherical ones.

Each spherical function of a shell is a fixed linear combination of the shell's Cartesian components, with the same radial contraction. Collect the coefficients in a matrix M_l, one row per unit-normalized Cartesian component (PySCF's order) and one column per spherical function:

spherical_m = sum_c M_l[c, m] * unit_c

Then any one-electron matrix goes over as X_sph = M^T X M, and the electron repulsion integrals get one factor of M on each of their four indices. Here M is the block-diagonal matrix for a whole basis, with one M_l block per shell. This module builds M_l and M; lib/hf/transform applies them.

Two constructions. c2s_closed(l) writes the table out by hand for l <= 3, from the textbook real polynomials:

d:  xy, yz, (2z^2 - x^2 - y^2)/2, xz, (x^2 - y^2)
f:  y(3x^2 - y^2), xyz, y(4z^2 - x^2 - y^2), z(2z^2 - 3x^2 - 3y^2),
    x(4z^2 - x^2 - y^2), z(x^2 - y^2), x(x^2 - 3y^2)

A polynomial sum_c a_c x^lx y^ly z^lz becomes a combination of unit components with coefficient a_c sqrt((2lx-1)!! (2ly-1)!! (2lz-1)!!), since a unit component carries the factor Nc = 1/sqrt(...) (see lib/hf/basis). Scaling each column to unit norm gives the numbers in the table. For the f function z(2z^2 - 3x^2 - 3y^2), for example, the squared norm is 60 in units of a unit component's self-overlap, so the zzz entry is 2 sqrt(15) / sqrt(60) = 1 and the xxz entry is -3 sqrt(3) / sqrt(60).

c2s_general(l) works for any l. It sums the general expansion of the real solid harmonics (Helgaker, Jorgensen and Olsen, Molecular Electronic-Structure Theory, eq. 6.4.47) into monomial coefficients, and then scales each column so that M_l^T G M_l = I, where G is the overlap of the unit components of one shell (c2s_unit_gram). The two constructions share no numbers, so their agreement at l <= 3 checks both, and the general one checks lib/hfref/c2s at l = 4.

Order and sign follow PySCF: p stays x, y, z (not m = -1, 0, 1); d is xy, yz, z^2, xz, x^2 - y^2; f and higher run m = -l .. l. The signs of the solid-harmonic expansion match PySCF's for every l checked (0 to 4).

Used with import hf.cart2sph, after import hf.basis.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.

[1]lines 55–344