qstack.spahm.rho.Dmatrix

Wigner d-matrices for real spherical harmonics to symmetrize coefficient vectors.

qstack.spahm.rho.Dmatrix.Dmatrix(xyz, lmax, order='xyz')[source]

Generate real Wigner D-matrices for spatial rotation of spherical harmonics.

Computes rotation matrices D^l for angular momenta l = 0 to lmax, where D^l[m1, m2] transforms spherical harmonics under the specified rotation. The rotation is defined by new axes x’ = xyz[0], y’ = xyz[1], z’ = xyz[2]. The code is generated by mathutils/wigner.py.

Parameters:
  • xyz (numpy ndarray) – 3x3 rotation matrix with rows defining new [x’, y’, z’] axes.

  • lmax (int) – Maximum angular momentum (supports lmax <= 4).

  • order (str) – Ordering convention for l=1 spherical harmonics. Defaults to ‘xyz’.

Returns:

List of numpy ndarrays D[l] where D[l] is the (2l+1) x (2l+1) real Wigner D-matrix for angular momentum l. Note: m1 index is rotated (D is transposed).

Return type:

list

Raises:

NotImplementedError – If lmax > 4.

Note

The matrices are computed using explicit algebraic expressions for each l.

qstack.spahm.rho.Dmatrix.Dmatrix_for_z(z, lmax, order='xyz')[source]

Generate Wigner D-matrices for rotation that aligns z-axis with given vector.

Wrapper function that combines new_xy_axis() and Dmatrix() to compute rotation matrices for a rotation defined only by the target z-direction.

Parameters:
  • z (numpy ndarray) – 3D vector defining the target z-axis direction.

  • lmax (int) – Maximum angular momentum (supports lmax <= 4).

  • order (str) – Ordering convention for l=1 spherical harmonics. Defaults to ‘xyz’.

Returns:

List of Wigner D-matrices for l=0 to lmax.

Return type:

list

qstack.spahm.rho.Dmatrix.c_split(mol, c)[source]

Split coefficient vector by angular momentum quantum number for each atom.

Organizes expansion coefficients into sublists grouped by angular momentum (l) for each atomic basis function.

Parameters:
  • mol (pyscf Mole) – pyscf Mole object.

  • c (numpy ndarray) – 1D array of expansion coefficients.

Returns:

List of [l, coefficients] pairs where l is angular momentum and

coefficients is the subset of c for that angular momentum shell.

Return type:

list

qstack.spahm.rho.Dmatrix.new_xy_axis(z)[source]

Construct orthonormal coordinate system from a given z-axis.

Finds optimal x’ and y’ axes that form a right-handed orthonormal system with the given z’ direction. The algorithm chooses x’ to have maximal component along the original axis with minimal projection onto z’.

Parameters:

z (numpy ndarray) – 3D vector defining the new z-axis direction.

Returns:

3x3 rotation matrix with rows [x’, y’, z’] defining the

new orthonormal coordinate system.

Return type:

numpy ndarray

qstack.spahm.rho.Dmatrix.rotate_c(D, cs)[source]

Rotate coefficient vector using real Wigner D-matrices.

Applies angular momentum rotation to each angular momentum block separately.

Parameters:
  • D (list) – List of Wigner D-matrices (numpy ndarray of shape (2l+1,2l+1) indexed by angular momentum l.

  • cs (list) – List of [l, coefficients] pairs from c_split().

Returns:

1D array of rotated coefficients.

Return type:

numpy ndarray