def test_setattr_standard_constructor(self):
        '''Testing overidden __setattr__ function in FCSSolver which changes __cache_is_stale flag.'''
        srl_solver = utils.setup_srl_solver(1., 1.)
        self.assertTrue(srl_solver._FCSSolver__cache_is_stale
                        )  # check __cache_is_stale is True on initialization

        # change of variable in srl_solver.__watch_variables should trigger stale cache
        srl_solver._FCSSolver__cache_is_stale = False
        self.assertFalse(srl_solver._FCSSolver__cache_is_stale)
        srl_solver.L = utils.reduced_srl_liouvillian(2., 2.)
        self.assertTrue(srl_solver._FCSSolver__cache_is_stale)

        srl_solver._FCSSolver__cache_is_stale = False
        self.assertFalse(srl_solver._FCSSolver__cache_is_stale)
        srl_solver.jump_op = np.array([[0, 0], [1, 0]])
        self.assertTrue(srl_solver._FCSSolver__cache_is_stale)

        srl_solver._FCSSolver__cache_is_stale = False
        self.assertFalse(srl_solver._FCSSolver__cache_is_stale)
        srl_solver.pops = np.array([1, 0])
        self.assertTrue(srl_solver._FCSSolver__cache_is_stale)

        # variables not in srl_solver.__watch_variables shouldn't trigger stale cache
        srl_solver._FCSSolver__cache_is_stale = False
        self.assertFalse(srl_solver._FCSSolver__cache_is_stale)
        srl_solver.H = 8
        self.assertFalse(srl_solver._FCSSolver__cache_is_stale)
Beispiel #2
0
 def test_setattr_standard_constructor(self):
     '''Testing overidden __setattr__ function in FCSSolver which changes __cache_is_stale flag.'''
     srl_solver = utils.setup_srl_solver(1., 1.)
     self.assertTrue(srl_solver._FCSSolver__cache_is_stale) # check __cache_is_stale is True on initialization
     
     # change of variable in srl_solver.__watch_variables should trigger stale cache
     srl_solver._FCSSolver__cache_is_stale = False
     self.assertFalse(srl_solver._FCSSolver__cache_is_stale)
     srl_solver.L = utils.reduced_srl_liouvillian(2., 2.)
     self.assertTrue(srl_solver._FCSSolver__cache_is_stale)
     
     srl_solver._FCSSolver__cache_is_stale = False
     self.assertFalse(srl_solver._FCSSolver__cache_is_stale)
     srl_solver.jump_op = np.array([[0,0],[1,0]])
     self.assertTrue(srl_solver._FCSSolver__cache_is_stale)
     
     srl_solver._FCSSolver__cache_is_stale = False
     self.assertFalse(srl_solver._FCSSolver__cache_is_stale)
     srl_solver.pops = np.array([1,0])
     self.assertTrue(srl_solver._FCSSolver__cache_is_stale)
     
     # variables not in srl_solver.__watch_variables shouldn't trigger stale cache
     srl_solver._FCSSolver__cache_is_stale = False
     self.assertFalse(srl_solver._FCSSolver__cache_is_stale)
     srl_solver.H = 8
     self.assertFalse(srl_solver._FCSSolver__cache_is_stale)
 def test_reduce_dim_SRL(self):
     '''Functionality test of dimension reduction of Liouvillian for a two level system'''
     Gamma_L = 1.
     Gamma_R = 2.
     ls = utils.setup_srl_system(Gamma_L, Gamma_R, True)
     npt.assert_allclose(ls.liouvillian(),
                         utils.reduced_srl_liouvillian(Gamma_L, Gamma_R))
Beispiel #4
0
 def test_standard_constructor(self):
     '''Test FCSSolver __init__ method initializes main attributes properly.'''
     Gamma_L = 1.; Gamma_R = 1.
     solver = utils.setup_srl_solver(Gamma_L, Gamma_R)
     npt.assert_allclose(solver.L, utils.reduced_srl_liouvillian(Gamma_L, Gamma_R))
     npt.assert_allclose(solver.jump_op, np.array([[0,1],[0,0]]))
     npt.assert_allclose(solver.pops, np.array([1,1]))
     self.assertFalse(solver.from_hilbert_space)
Beispiel #5
0
 def test_from_hilbert_space_constructor(self):
     '''Test secondary 'constructor' initializes main attributes properly.'''
     Gamma_L = 1.; Gamma_R = 1.
     solver = utils.setup_srl_solver_from_hilbert_space(Gamma_L, Gamma_R)
     npt.assert_allclose(solver.L, utils.reduced_srl_liouvillian(Gamma_L, Gamma_R))
     npt.assert_allclose(solver.jump_op, np.array([[0,1],[0,0]]))
     npt.assert_allclose(solver.pops, np.array([1,1]))
     self.assertTrue(solver.from_hilbert_space)
Beispiel #6
0
 def test_finite_freq_F2_srl(self):
     '''Functionality test for second order Fano factor using SRL model with an array of frequencies.'''
     Gamma_R = 0.5; Gamma_L = 1.
     freq = np.linspace(0,10,100)
     srl_liouvillian = utils.reduced_srl_liouvillian(Gamma_L, Gamma_R)
     srl_jump_op = np.array([[0, Gamma_R],[0, 0]])
     expected_F2 = utils.finite_freq_F2(freq, srl_liouvillian, srl_jump_op)
     srl_solver = utils.setup_srl_solver_from_hilbert_space(Gamma_L, Gamma_R)
     npt.assert_allclose(expected_F2, srl_solver.second_order_fano_factor(freq))
 def test_standard_constructor(self):
     '''Test FCSSolver __init__ method initializes main attributes properly.'''
     Gamma_L = 1.
     Gamma_R = 1.
     solver = utils.setup_srl_solver(Gamma_L, Gamma_R)
     npt.assert_allclose(solver.L,
                         utils.reduced_srl_liouvillian(Gamma_L, Gamma_R))
     npt.assert_allclose(solver.jump_op, np.array([[0, 1], [0, 0]]))
     npt.assert_allclose(solver.pops, np.array([1, 1]))
     self.assertFalse(solver.from_hilbert_space)
 def test_from_hilbert_space_constructor(self):
     '''Test secondary 'constructor' initializes main attributes properly.'''
     Gamma_L = 1.
     Gamma_R = 1.
     solver = utils.setup_srl_solver_from_hilbert_space(Gamma_L, Gamma_R)
     npt.assert_allclose(solver.L,
                         utils.reduced_srl_liouvillian(Gamma_L, Gamma_R))
     npt.assert_allclose(solver.jump_op, np.array([[0, 1], [0, 0]]))
     npt.assert_allclose(solver.pops, np.array([1, 1]))
     self.assertTrue(solver.from_hilbert_space)
 def test_finite_freq_F2_srl(self):
     '''Functionality test for second order Fano factor using SRL model with an array of frequencies.'''
     Gamma_R = 0.5
     Gamma_L = 1.
     freq = np.linspace(0, 10, 100)
     srl_liouvillian = utils.reduced_srl_liouvillian(Gamma_L, Gamma_R)
     srl_jump_op = np.array([[0, Gamma_R], [0, 0]])
     expected_F2 = utils.finite_freq_F2(freq, srl_liouvillian, srl_jump_op)
     srl_solver = utils.setup_srl_solver_from_hilbert_space(
         Gamma_L, Gamma_R)
     npt.assert_allclose(expected_F2,
                         srl_solver.second_order_fano_factor(freq))
 def test_reduce_dim_SRL(self):
     '''Functionality test of dimension reduction of Liouvillian for a two level system'''
     Gamma_L = 1.
     Gamma_R = 2.
     ls = utils.setup_srl_system(Gamma_L, Gamma_R, True)
     npt.assert_allclose(ls.liouvillian(), utils.reduced_srl_liouvillian(Gamma_L, Gamma_R))