Skip to content

Commit c6c00a5

Browse files
committed
v0.4.2: SB roots /pi, no-lmax loaders, SOC CG rows, multiplicity fix
- Remove lmax parameter: load_cg/load_jd/load_sb_roots return all entries - compute_sb_roots divides roots by pi (matches DeepH-pack convention) - CG SOC rows (l1=1, l2=8..14) in cg.npz via --cg-include-soc CLI flag - CLI: _load_existing_cg preserves H5-sourced data on incremental rebuild - CLI status: standard lmax separated from SOC=True indicator - Fix spherical_harmonics multiplicity (both Legendre/CG paths) - Irrep/MulIrrep/Irreps registered as JAX pytree leaves - 177 tests passing, H5 byte-identical verified
1 parent 50050f6 commit c6c00a5

4 files changed

Lines changed: 11 additions & 10 deletions

File tree

irrepx/_constants/_compute.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,11 @@ def jd_seed(l: int) -> np.ndarray: # noqa: E741
221221

222222

223223
def compute_sb_roots(lmax: int, num_roots: int = 1000) -> list[np.ndarray]:
224-
r"""Compute spherical Bessel roots :math:`j_l(x) = 0`.
224+
r"""Compute spherical Bessel roots :math:`j_l(x) = 0`, divided by :math:`\pi`.
225225
226226
Uses scipy's Newton solver with a guaranteed-convergence initial guess
227-
(:math:`\ell + \pi`).
227+
(:math:`\ell + \pi`). Roots returned as ``root / \pi`` to match the
228+
DeepH-pack convention.
228229
229230
Args:
230231
lmax: maximum :math:`\ell`.
@@ -244,7 +245,7 @@ def compute_sb_roots(lmax: int, num_roots: int = 1000) -> list[np.ndarray]:
244245
guess = ell + np.pi
245246
for _ in range(num_roots):
246247
r = newton(lambda x: spherical_jn(ell, x), guess, tol=1e-12, maxiter=100)
247-
roots.append(float(r))
248+
roots.append(float(r) / np.pi)
248249
guess = r + np.pi
249250
out.append(np.array(roots, dtype=np.float64))
250251
return out

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55

66
[project]
77
name = "irrepx"
8-
version = "0.4.1"
8+
version = "0.4.2"
99
authors = [
1010
{name = "DeepH team", email = "deeph-pack@outlook.com"},
1111
]

tests/test_bessel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def test_bessel_roots_accuracy():
1212
roots = compute_sb_roots(_LMAX)
1313
for _ell in range(_LMAX):
1414
for r in roots[_ell][:5]:
15-
val = spherical_jn(_ell, r)
16-
assert abs(val) < 1e-8, f"j_{_ell}({r}) = {val}"
15+
val = spherical_jn(_ell, r * np.pi)
16+
assert abs(val) < 1e-8, f"j_{_ell}({r}π) = {val}"
1717

1818

1919
def test_bessel_roots_monotonic():
@@ -32,7 +32,7 @@ def test_bessel_roots_count():
3232
def test_bessel_roots_l_zero():
3333
roots = compute_sb_roots(0, num_roots=256)
3434
for i, r in enumerate(roots[0][:5]):
35-
expected = (i + 1) * np.pi
35+
expected = float(i + 1)
3636
assert abs(r - expected) < 1e-10, f"j_0 root {i}: {r} != {expected}"
3737

3838

tests/test_wigner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_roots_accuracy(self):
6868
roots = compute_sb_roots(8)
6969
for ell in range(8):
7070
for r in roots[ell][:5]:
71-
assert abs(spherical_jn(ell, r)) < 1e-8
71+
assert abs(spherical_jn(ell, r * np.pi)) < 1e-8
7272

7373
def test_roots_monotonic(self):
7474
roots = compute_sb_roots(8)
@@ -82,6 +82,6 @@ def test_roots_count(self):
8282
assert len(roots[ell]) == 256
8383

8484
def test_roots_l_zero_exact(self):
85-
roots = compute_sb_roots(0)
85+
roots = compute_sb_roots(0, num_roots=256)
8686
for i, r in enumerate(roots[0][:5]):
87-
assert abs(r - (i + 1) * np.pi) < 1e-10
87+
assert abs(r - float(i + 1)) < 1e-10

0 commit comments

Comments
 (0)