Esempio n. 1
0
 def test_wrong_term_length(self):
     """Test exception raised for wrong terms"""
     with pytest.raises(BoseHubbardError):
         H = bose_hubbard(2, 2, 1, 0.1, 0.2)
         H -= BosonOperator('5^ 5 5^')
         H += BosonOperator('5^ 5')
         extract_onsite_chemical(H)
Esempio n. 2
0
 def test_differing_onsite(self):
     """Test exception raised for differing coefficients"""
     with pytest.raises(BoseHubbardError):
         H = bose_hubbard(2, 2, 1, 0.1, 0.2)
         H -= BosonOperator('5^ 5 5^ 5')
         H += BosonOperator('5^ 5')
         extract_onsite_chemical(H)
Esempio n. 3
0
 def test_incorrect_ladders(self):
     """Test exception raised for wrong ladder operators"""
     with pytest.raises(BoseHubbardError):
         H = bose_hubbard(2, 2, 1, 0.1, 0.2)
         H -= BosonOperator('5^ 5^ 5^ 5^')
         H -= BosonOperator('5 5^ 5 5^')
         extract_onsite_chemical(H)
Esempio n. 4
0
 def test_differing_chemical_potential(self):
     """Test exception raised for differing coefficients"""
     self.logTestName()
     with self.assertRaises(BoseHubbardError):
         H = bose_hubbard(2, 2, 1, 0.1, 0.2)
         H -= BosonOperator('5^ 5')
         extract_onsite_chemical(H)
Esempio n. 5
0
    def test_too_many_terms(self):
        """Test exception raised for wrong number of terms"""
        with pytest.raises(BoseHubbardError):
            H = bose_hubbard(2, 2, 1, 0.1, 0.2)
            H -= BosonOperator('0^ 0^ 0^ 0^')
            extract_onsite_chemical(H)

        with pytest.raises(BoseHubbardError):
            H = bose_hubbard(2, 2, 1, 0.1, 0.2)
            H -= BosonOperator('5^ 5 5^ 5')
            extract_onsite_chemical(H)
Esempio n. 6
0
 def test_both(self):
     """Test case where there is non-zero mu and non-zero U"""
     self.logTestName()
     H = bose_hubbard(2, 2, 1, 0.1, 0.2)
     res = extract_onsite_chemical(H)
     expected = ([[0, 1, 2, 3], 0.1], [[0, 1, 2, 3], 0.2])
     self.assertEqual(res, expected)
Esempio n. 7
0
 def test_both(self):
     """Test case where there is non-zero mu and non-zero U"""
     H = bose_hubbard(2, 2, 1, 0.1, 0.2)
     res = extract_onsite_chemical(H)
     expected = ([[0, 1, 2, 3], 0.1], [[0, 1, 2, 3], 0.2])
     assert res == expected
Esempio n. 8
0
 def test_only_chemical_potential(self):
     """Test case where there is non-zero mu and zero U"""
     H = bose_hubbard(2, 2, 1, 0, 0.2)
     res = extract_onsite_chemical(H)
     expected = ([], [[0, 1, 2, 3], 0.2])
     assert res == expected
Esempio n. 9
0
 def test_only_onsite(self):
     """Test case where there is zero mu and non-zero U"""
     H = bose_hubbard(2, 2, 1, 0.1, 0)
     res = extract_onsite_chemical(H)
     expected = ([[0, 1, 2, 3], 0.1], [])
     self.assertEqual(res, expected)