testFermionBasis.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from statefuncs import State, Basis
  2. from phi1234 import Phi1234
  3. from scipy.constants import pi
  4. import numpy as np
  5. from qedstatefuncs import FermionBasis
  6. import unittest
  7. class TestMasslessFermionBasis(unittest.TestCase):
  8. def setUp(self):
  9. self.Emax = 5.
  10. self.fermionBasis = FermionBasis(L=2*pi, Emax=self.Emax, m=0.)
  11. def testNeutral(self):
  12. for state in self.fermionBasis:
  13. self.assertTrue(state.isNeutral())
  14. def testAtRest(self):
  15. for state in self.fermionBasis:
  16. self.assertEqual(state.momentum, 0.)
  17. def testSortedEnergy(self):
  18. lastEnergy = 0
  19. for state in self.fermionBasis:
  20. self.assertLessEqual(lastEnergy, state.energy)
  21. lastEnergy = state.energy
  22. def testLookup(self):
  23. for (index, state) in enumerate(self.fermionBasis):
  24. self.assertEqual(index,self.fermionBasis.lookup(state)[1])
  25. class TestMassiveFermionBasis(unittest.TestCase):
  26. def setUp(self):
  27. self.Emax = 10.
  28. self.fermionBasis = FermionBasis(L=2*pi, Emax=self.Emax, m=4.)
  29. def testNeutral(self):
  30. for state in self.fermionBasis:
  31. self.assertTrue(state.isNeutral())
  32. def testAtRest(self):
  33. for state in self.fermionBasis:
  34. self.assertEqual(state.momentum, 0.)
  35. def testSortedEnergy(self):
  36. lastEnergy = 0
  37. for state in self.fermionBasis:
  38. self.assertLessEqual(lastEnergy, state.energy)
  39. lastEnergy = state.energy
  40. def testLookup(self):
  41. for (index, state) in enumerate(self.fermionBasis):
  42. self.assertEqual(index,self.fermionBasis.lookup(state)[1])