def test_prefactor_vacuum(): """test the correct prefactor of 0.5 is calculated for a vacuum state""" Q = np.identity(2) beta = np.zeros([2]) res = prefactor(Means(beta), Covmat(Q)) ex = 1 assert np.allclose(res, ex)
def test_density_matrix_element_no_disp(t): """Test density matrix elements for a state with no displacement""" beta = Beta(np.zeros([6])) Q = Qmat(V) el = t[0] ex = t[1] res = density_matrix_element(Means(beta), Covmat(Q), el[0], el[1]) assert np.allclose(ex, res)
def test_prefactor_TMS(): """test the correct prefactor of 0.5 is calculated for a TMS state""" q = np.fliplr(np.diag([2.0] * 4)) np.fill_diagonal(q, np.sqrt(2)) Q = np.fliplr(q) beta = np.zeros([4]) res = prefactor(Means(beta), Covmat(Q)) ex = 0.5 assert np.allclose(res, ex)
def test_density_matrix_element_vacuum(): """Test density matrix elements for the vacuum""" Q = np.identity(2) beta = np.zeros([2]) el = [[0], [0]] ex = 1 res = density_matrix_element(Means(beta), Covmat(Q), el[0], el[1]) assert np.allclose(ex, res) el = [[1], [1]] # res = density_matrix_element(beta, A, Q, el[0], el[1]) res = density_matrix_element(Means(beta), Covmat(Q), el[0], el[1]) assert np.allclose(0, res) el = [[1], [0]] # res = density_matrix_element(beta, A, Q, el[0], el[1]) res = density_matrix_element(Means(beta), Covmat(Q), el[0], el[1]) assert np.allclose(0, res)
def test_prefactor_with_displacement(): """test the correct prefactor of 0.5 is calculated for a TMS state""" q = np.fliplr(np.diag([2.0] * 4)) np.fill_diagonal(q, np.sqrt(2)) Q = np.fliplr(q) Qinv = np.linalg.inv(Q) vect = 1.2 * np.ones([2]) + 1j * np.ones(2) beta = np.concatenate([vect, vect.conj()]) res = prefactor(Means(beta), Covmat(Q), hbar=2) ex = np.exp(-0.5 * beta @ Qinv @ beta.conj()) / np.sqrt(np.linalg.det(Q)) assert np.allclose(res, ex)
def test_Means(): """test the correct beta is returned""" res = np.arange(4) mu = Beta(res) ex = Means(mu) assert np.allclose(res, ex)