qstack.mathutils.wigner

Wigner D-matrices and spherical harmonic transformations.

qstack.mathutils.wigner.compute_wigner(lmax)[source]

Compute Wigner D matrices for real spherical harmonics up to a maximum angular momentum.

Parameters:

lmax (int) – Maximum angular momentum quantum number.

Returns:

List of Wigner D matrices (sympy.Matrix) for each l from 0 to lmax.

Return type:

list

qstack.mathutils.wigner.get_polynom_Y(l, m)[source]

Rewrite a real spherical harmonic as a polynomial of x, y, z.

Parameters:
  • l (int) – Orbital angular momentum quantum number.

  • m (int) – Magnetic quantum number.

Returns:

Polynomial expression in Cartesian coordinates.

Return type:

sympy.Expr

qstack.mathutils.wigner.print_wigner(D)[source]

Print Wigner D matrices in formatted output.

Parameters:

D (list) – List of Wigner D matrices for each l value.

qstack.mathutils.wigner.product_Y(Y1, Y2)[source]

Compute the product of two spherical harmonics.

Parameters:
  • Y1 (sympy.Expr) – First spherical harmonic polynomial.

  • Y2 (sympy.Expr) – Second spherical harmonic polynomial.

Returns:

A tuple containing: - coefficients (sympy.Matrix): Coefficients of the product. - monomials (list): List of monomial powers.

Return type:

tuple

qstack.mathutils.wigner.real_Y_correct_phase(l, m, theta, phi)[source]

Return real spherical harmonic in Condon–Shortley phase convention.

Note: sympy’s Znm uses a different convention.

Parameters:
  • l (int) – Orbital angular momentum quantum number.

  • m (int) – Magnetic quantum number.

  • theta (sympy.Symbol) – Polar angle.

  • phi (sympy.Symbol) – Azimuthal angle.

Returns:

Real spherical harmonic expression.

Return type:

sympy.Expr

qstack.mathutils.wigner.xyzint_wrapper(knm, integrals_xyz_dict)[source]

Compute xyz integrals with caching.

Computes the integral of x^k * y^n * z^m over the unit sphere. Integral is zero if any power is odd.

Parameters:
  • knm (tuple) – Tuple of three integers (k, n, m) representing powers.

  • integrals_xyz_dict (dict) – Cache dictionary for computed integrals.

Returns:

Integral value, or 0 if any power is odd.

Return type:

float or sympy.Expr