Skip to content

Commit 0b47c9a

Browse files
add test lifetime
1 parent aaa93bb commit 0b47c9a

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

tests/test_lifetimes.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import numpy as np
2+
import pytest
3+
from rydstate import RydbergStateSQDTAlkali
4+
from rydstate.angular.angular_ket import AngularKetLS
5+
from rydstate.rydberg.rydberg_sqdt import RydbergStateSQDT
6+
from rydstate.species.sqdt.species_object_sqdt import SpeciesObjectSQDT
7+
8+
9+
# Reference values from NIST Atomic Spectra Database (ASD), Einstein A coefficients:
10+
# H 2p -> 1s: A = 6.2648e8 s^-1
11+
# H 3p -> all lower: A_tot = 1.8971e8 s^-1 (A(3p->1s)=1.6725e8, A(3p->2s)=2.245e7)
12+
# H 3d -> 2p: A = 6.4651e7 s^-1
13+
# Source: https://physics.nist.gov/PhysRefData/ASD/lines_form.html
14+
@pytest.mark.parametrize(
15+
("n", "l", "j", "expected_gamma"),
16+
[
17+
(2, 1, 1.5, 6.2648e8),
18+
(3, 1, 1.5, 1.8971e8),
19+
(3, 2, 2.5, 6.4651e7),
20+
],
21+
)
22+
def test_hydrogen_textbook_lifetimes(n: int, l: int, j: float, expected_gamma: float) -> None:
23+
"""Test that calculated H lifetimes match NIST textbook values within 5%."""
24+
state = RydbergStateSQDTAlkali("H_textbook", n=n, l=l, j=j, m=0.5)
25+
tau = state.get_lifetime(unit="s")
26+
np.testing.assert_allclose(tau, 1 / expected_gamma, rtol=0.05)
27+
28+
29+
def test_bbr_shortens_lifetime() -> None:
30+
"""Test that black body radiation at 300 K shortens the lifetime relative to T=0."""
31+
state = RydbergStateSQDTAlkali("Rb", n=30, l=0, j=0.5, m=0.5)
32+
tau_0 = state.get_lifetime(unit="mus")
33+
tau_300 = state.get_lifetime(300, temperature_unit="K", unit="mus")
34+
assert tau_300 < tau_0
35+
36+
37+
@pytest.mark.parametrize("species_name", SpeciesObjectSQDT.get_available_species())
38+
def test_lifetime_n_scaling(species_name: str) -> None:
39+
"""Test that Rydberg state lifetimes scale as nu^3 (effective quantum number)."""
40+
if species_name in ["Sr87", "Yb171", "Yb173"]:
41+
pytest.skip("No quantum defect data available")
42+
if species_name == "Yb174":
43+
pytest.skip("Quantum defects not correct for low n states")
44+
45+
n1, n2 = 30, 60
46+
species = SpeciesObjectSQDT.from_name(species_name)
47+
s_tot = (species.number_valence_electrons / 2) % 1
48+
f = abs(s_tot - species.i_c_number)
49+
angular = AngularKetLS(l_r=0, s_tot=s_tot, f_tot=f, m=f, species=species)
50+
51+
state1 = RydbergStateSQDT.from_angular_ket(species, angular, n=n1)
52+
state2 = RydbergStateSQDT.from_angular_ket(species, angular, n=n2)
53+
tau1 = state1.get_lifetime(unit="mus")
54+
tau2 = state2.get_lifetime(unit="mus")
55+
nu1 = state1.nu
56+
nu2 = state2.nu
57+
expected_ratio = (nu2 / nu1) ** 3
58+
np.testing.assert_allclose(tau2 / tau1, expected_ratio, rtol=0.05)

0 commit comments

Comments
 (0)