def test_scheme4(): ph = Phonon.simple_phonon(Quantity(3.33), Quantity(1), 2) m1 = Mol(Quantity(0), [ph]) m2 = Mol(Quantity(0), [ph]*2) mlist1 = MolList([m1, m2], Quantity(17), 4) mlist2 = MolList([m1, m2], Quantity(17), 3) mpo4 = Mpo(mlist1) assert mpo4.is_hermitian() # for debugging f = mpo4.full_operator() mpo3 = Mpo(mlist2) assert mpo3.is_hermitian() # makeup two states mps4 = Mps() mps4.mol_list = mlist1 mps4.use_dummy_qn = True mps4.append(np.array([1, 0]).reshape((1,2,1))) mps4.append(np.array([0, 1]).reshape((1,2,1))) mps4.append(np.array([0.707, 0.707]).reshape((1,2,1))) mps4.append(np.array([1, 0]).reshape((1,2,1))) mps4.build_empty_qn() e4 = mps4.expectation(mpo4) mps3 = Mps() mps3.mol_list = mlist2 mps3.append(np.array([1, 0]).reshape((1,2,1))) mps3.append(np.array([1, 0]).reshape((1,2,1))) mps3.append(np.array([0, 1]).reshape((1,2,1))) mps3.append(np.array([0.707, 0.707]).reshape((1,2,1))) mps3.append(np.array([1, 0]).reshape((1,2,1))) e3 = mps3.expectation(mpo3) assert pytest.approx(e4) == e3
def test_scheme4(): ph = Phonon.simple_phonon(Quantity(3.33), Quantity(1), 2) m1 = Mol(Quantity(0), [ph]) m2 = Mol(Quantity(0), [ph] * 2) model4 = HolsteinModel([m1, m2], Quantity(17), 4) model3 = HolsteinModel([m1, m2], Quantity(17), 3) mpo4 = Mpo(model4) assert mpo4.is_hermitian() # for debugging f = mpo4.full_operator() mpo3 = Mpo(model3) assert mpo3.is_hermitian() # makeup two states mps4 = Mps() mps4.model = model4 mps4.append(np.array([1, 0]).reshape((1, 2, 1))) mps4.append(np.array([0, 0, 1]).reshape((1, -1, 1))) mps4.append(np.array([0.707, 0.707]).reshape((1, 2, 1))) mps4.append(np.array([1, 0]).reshape((1, 2, 1))) mps4.build_empty_qn() e4 = mps4.expectation(mpo4) mps3 = Mps() mps3.model = model3 mps3.append(np.array([1, 0]).reshape((1, 2, 1))) mps3.append(np.array([1, 0]).reshape((1, 2, 1))) mps3.append(np.array([0, 1]).reshape((1, 2, 1))) mps3.append(np.array([0.707, 0.707]).reshape((1, 2, 1))) mps3.append(np.array([1, 0]).reshape((1, 2, 1))) e3 = mps3.expectation(mpo3) assert pytest.approx(e4) == e3
def test_offset(scheme): ph = Phonon.simple_phonon(Quantity(3.33), Quantity(1), 2) m = Mol(Quantity(0), [ph] * 2) mlist = MolList([m] * 2, Quantity(17), scheme=scheme) mpo1 = Mpo(mlist) assert mpo1.is_hermitian() f1 = mpo1.full_operator() evals1, _ = np.linalg.eigh(f1.asnumpy()) offset = Quantity(0.123) mpo2 = Mpo(mlist, offset=offset) f2 = mpo2.full_operator() evals2, _ = np.linalg.eigh(f2.asnumpy()) assert np.allclose(evals1 - offset.as_au(), evals2)