@@ -82,7 +82,6 @@ def func(t):
8282
8383
8484@pytest .mark .structure
85- @pytest .mark .dev
8685def test_decoherences ():
8786 """Confirms that the decoherence matrix is building correctly.
8887 """
@@ -126,6 +125,61 @@ def test_decoherences():
126125 err_msg = 'gamma matrix for 2-photon;1 RF not equal' )
127126
128127
128+ @pytest .mark .structure
129+ def test_gamma_mismatching_NLJ ():
130+ """Tests that mismatch handling mechanisms in Cell work as intended with NLJ systems
131+ """
132+
133+ g = rq .A_QState (5 , 0 , 0.5 )
134+ e = rq .A_QState (5 , 1 , 1.5 )
135+ r = rq .A_QState (50 , 2 , 2.5 )
136+
137+ c = rq .Cell ('Rb85' , [g ,e ,r ], gamma_mismatch = 'ground' , gamma_transit = 0 )
138+ lifetimes = np .array ([c .couplings .nodes [n ]['gamma_lifetime' ] for n in c .couplings .nodes ])
139+ dephasings = c .decoherence_matrix ()
140+ # sum of all dephasings to lower states for each state (ie each row) should equal lifetime
141+ mismatches = np .sum (dephasings , axis = 1 )
142+ np .testing .assert_allclose (lifetimes , mismatches ,
143+ err_msg = 'NLJ: ground-mismatch disagreement' )
144+
145+ c = rq .Cell ('Rb85' , [g ,e ,r ], gamma_mismatch = 'all' , gamma_transit = 0 )
146+ lifetimes = np .array ([c .couplings .nodes [n ]['gamma_lifetime' ] for n in c .couplings .nodes ])
147+ dephasings = c .decoherence_matrix ()
148+ # full dephasing rate should be to next lower state only (ie first sub-diagonal)
149+ mismatches = np .diag (dephasings , k = - 1 )
150+ np .testing .assert_allclose (lifetimes [1 :], mismatches ,
151+ err_msg = 'NLJ: all-mismatch disagreement' )
152+
153+
154+ @pytest .mark .structure
155+ def test_gamma_mismatch_groups ():
156+ """Tests that mismatch handling mechanisms in Cell work as intended with HFS systems
157+ """
158+
159+ g = rq .A_QState (5 , 0 , 0.5 , f = 1 , m_f = 'all' )
160+ e = rq .A_QState (5 , 1 , 1.5 , f = 1 , m_f = 'all' )
161+
162+ c = rq .Cell ('Rb87' , [g ,e ], gamma_mismatch = 'none' , gamma_transit = 0 )
163+ dipole_allowed_dephasings_mask = c .decoherence_matrix () != 0.0
164+
165+ c = rq .Cell ('Rb87' , [g ,e ], gamma_mismatch = 'ground' , gamma_transit = 0 )
166+ lifetimes = np .array ([c .couplings .nodes [n ]['gamma_lifetime' ] for n in c .couplings .nodes ])
167+ dephasings = c .decoherence_matrix ()
168+ mismatches = np .sum (dephasings , axis = 1 )
169+ np .testing .assert_allclose (lifetimes , mismatches ,
170+ atol = 1e-7 , # need atol since comparing against 0
171+ err_msg = 'HFS: ground-mismatch disagreement' )
172+
173+ c = rq .Cell ('Rb87' , [g ,e ], gamma_mismatch = 'all' , gamma_transit = 0 )
174+ lifetimes = np .array ([c .couplings .nodes [n ]['gamma_lifetime' ] for n in c .couplings .nodes ])
175+ dephasings = c .decoherence_matrix ()
176+ masked_dephasings = np .where (dipole_allowed_dephasings_mask , dephasings , 0 ) # ensure we don't sum accidental 'new' dephasings
177+ mismatches = np .sum (masked_dephasings , axis = 1 )
178+ np .testing .assert_allclose (lifetimes , mismatches ,
179+ atol = 1e-7 , # need atol since comparing against 0
180+ err_msg = 'HFS: all-mismatch disagreement' )
181+
182+
129183@pytest .mark .structure
130184def test_hyperfine_dipole ():
131185 [g , e1 ] = [A_QState (5 , 0 , 0.5 , m_j = 0.5 ), A_QState (5 , 1 , 1.5 , m_j = 0.5 )]
0 commit comments