|
| 1 | +import numpy as np |
| 2 | +import pytest |
| 3 | +from rydstate import BasisSQDTAlkali |
| 4 | +from rydstate.basis.basis_sqdt import BasisSQDTAlkalineLS |
| 5 | + |
| 6 | + |
| 7 | +@pytest.mark.parametrize("species_name", ["Rb", "Na", "H"]) |
| 8 | +def test_alkali_basis(species_name: str) -> None: |
| 9 | + """Test alkali basis creation.""" |
| 10 | + basis = BasisSQDTAlkali(species_name, n_min=1, n_max=20) |
| 11 | + basis.sort_states("n", "l_r") |
| 12 | + lowest_n_state = {"Rb": (4, 2), "Na": (3, 0), "H": (1, 0)}[species_name] |
| 13 | + assert (basis.states[0].n, basis.states[0].l) == lowest_n_state |
| 14 | + assert (basis.states[-1].n, basis.states[-1].l) == (20, 19) |
| 15 | + assert len(basis.states) == {"Rb": 388, "Na": 396, "H": 400}[species_name] |
| 16 | + |
| 17 | + state0 = basis.states[0] |
| 18 | + ov = basis.calc_reduced_overlap(state0) |
| 19 | + compare_ov = np.zeros(len(basis.states)) |
| 20 | + compare_ov[0] = 1.0 |
| 21 | + assert np.allclose(ov, compare_ov, atol=1e-3) |
| 22 | + |
| 23 | + me = basis.calc_reduced_matrix_element(state0, "electric_dipole", unit="e a0") |
| 24 | + assert np.shape(me) == (len(basis.states),) |
| 25 | + assert np.count_nonzero(me) > 0 |
| 26 | + |
| 27 | + basis.filter_states("n", (1, 7)) |
| 28 | + ov_matrix = basis.calc_reduced_overlaps(basis) |
| 29 | + assert np.allclose(ov_matrix, np.eye(len(basis.states)), atol=1e-3) |
| 30 | + |
| 31 | + me_matrix = basis.calc_reduced_matrix_elements(basis, "electric_dipole", unit="e a0") |
| 32 | + assert np.shape(me_matrix) == (len(basis.states), len(basis.states)) |
| 33 | + assert np.count_nonzero(me_matrix) > 0 |
| 34 | + |
| 35 | + |
| 36 | +@pytest.mark.parametrize("species_name", ["Sr88", "Sr87", "Yb174", "Yb171"]) |
| 37 | +def test_alkaline_basis(species_name: str) -> None: |
| 38 | + """Test alkaline basis creation.""" |
| 39 | + basis = BasisSQDTAlkalineLS(species_name, n_min=30, n_max=35) |
| 40 | + basis.sort_states("n", "l_r") |
| 41 | + assert (basis.states[0].n, basis.states[0].l) == (30, 0) |
| 42 | + assert (basis.states[-1].n, basis.states[-1].l) == (35, 34) |
| 43 | + assert len(basis.states) == {"Sr88": 768, "Sr87": 7188, "Yb174": 768, "Yb171": 1524}[species_name] |
| 44 | + |
| 45 | + if species_name in ["Sr87", "Yb171"]: |
| 46 | + pytest.skip("Quantum defects for Sr87 and Yb171 not implemented yet.") |
| 47 | + |
| 48 | + state0 = basis.states[0] |
| 49 | + ov = basis.calc_reduced_overlap(state0) |
| 50 | + compare_ov = np.zeros(len(basis.states)) |
| 51 | + compare_ov[0] = 1.0 |
| 52 | + assert np.allclose(ov, compare_ov, atol=1e-3) |
| 53 | + |
| 54 | + me = basis.calc_reduced_matrix_element(state0, "electric_dipole", unit="e a0") |
| 55 | + assert np.shape(me) == (len(basis.states),) |
| 56 | + assert np.count_nonzero(me) > 0 |
| 57 | + |
| 58 | + basis.filter_states("l_r", (0, 2)) |
| 59 | + ov_matrix = basis.calc_reduced_overlaps(basis) |
| 60 | + assert np.allclose(ov_matrix, np.eye(len(basis.states)), atol=1e-2) |
| 61 | + |
| 62 | + me_matrix = basis.calc_reduced_matrix_elements(basis, "electric_dipole", unit="e a0") |
| 63 | + assert np.shape(me_matrix) == (len(basis.states), len(basis.states)) |
| 64 | + assert np.count_nonzero(me_matrix) > 0 |
0 commit comments