def test_shape(self):
     """Test whether the rhodots are shaped correctly."""    
     arr = nonadiabatic.deltaPspectrum(self.Vphi, self.phidot, self.H, 
                                    self.modes, self.modesdot, self.axis)
     result = arr.shape
     newshape = list(self.phidot.shape)
     del newshape[self.axis]
     actual = tuple(newshape)
     assert_(result == actual, "Result shape %s, but desired shape is %s"%(str(result), str(actual)))
 def test_not_complex(self):
     """Test that returned object is not complex."""
     Vphi = np.array([1,2]).reshape((2,1))
     phidot = np.array([1,1]).reshape((2,1))
     H = np.array([1]).reshape((1,1))
     modes = np.array([[1, 1j],[-1j, 3-1j]]).reshape((2,2,1))
     modesdot = np.array([[1, -1j],[1j, 3+1j]]).reshape((2,2,1))
     axis=0
     arr = nonadiabatic.deltaPspectrum(Vphi, phidot, H, modes, modesdot, axis)
     assert_((not np.iscomplexobj(arr)))
 def test_imaginary(self):
     """Test calculation with complex values."""
     Vphi = np.array([1,2]).reshape((2,1))
     phidot = np.array([1,1]).reshape((2,1))
     H = np.array([1]).reshape((1,1))
     modes = np.array([[1, 1j],[-1j, 3-1j]]).reshape((2,2,1))
     modesdot = np.array([[1, -1j],[1j, 3+1j]]).reshape((2,2,1))
     axis=0
     arr = nonadiabatic.deltaPspectrum(Vphi, phidot, H, modes, modesdot, axis)
     desired = np.array([54])
     assert_almost_equal(arr, desired)
 def test_two_by_two_by_one(self):
     """Test that 2x2x1 calculation works."""
     Vphi = np.array([1,2]).reshape((2,1))
     phidot = np.array([7,9]).reshape((2,1))
     modes = np.array([[1,3],[2,5]]).reshape((2,2,1))
     modesdot = np.array([[1,3],[2,5]]).reshape((2,2,1))
     axis = 0
     H = np.array([2]).reshape((1,1))
     arr = nonadiabatic.deltaPspectrum(Vphi, phidot, H, modes, modesdot, axis)
     desired = np.array([6405**2 + 16909**2])
     assert_almost_equal(arr, desired)
 def test_singlefield(self):
     """Test single field calculation."""
     modes = np.array([[7]])
     modesdot = np.array([[3]])
     Vphi = 3
     phidot = 1.7
     H = 0.5
     axis=0
     actual = (0.5**2*1.7*3-0.5**3*1.7**2*1.7*7-21)**2
     arr = nonadiabatic.deltaPspectrum(Vphi, phidot, H, modes, modesdot, axis)
     assert_almost_equal(arr, actual)
Exemple #6
0
 def test_not_complex(self):
     """Test that returned object is not complex."""
     Vphi = np.array([1, 2]).reshape((2, 1))
     phidot = np.array([1, 1]).reshape((2, 1))
     H = np.array([1]).reshape((1, 1))
     modes = np.array([[1, 1j], [-1j, 3 - 1j]]).reshape((2, 2, 1))
     modesdot = np.array([[1, -1j], [1j, 3 + 1j]]).reshape((2, 2, 1))
     axis = 0
     arr = nonadiabatic.deltaPspectrum(Vphi, phidot, H, modes, modesdot,
                                       axis)
     assert_((not np.iscomplexobj(arr)))
Exemple #7
0
 def test_shape(self):
     """Test whether the rhodots are shaped correctly."""
     arr = nonadiabatic.deltaPspectrum(self.Vphi, self.phidot, self.H,
                                       self.modes, self.modesdot, self.axis)
     result = arr.shape
     newshape = list(self.phidot.shape)
     del newshape[self.axis]
     actual = tuple(newshape)
     assert_(
         result == actual, "Result shape %s, but desired shape is %s" %
         (str(result), str(actual)))
Exemple #8
0
 def test_imaginary(self):
     """Test calculation with complex values."""
     Vphi = np.array([1, 2]).reshape((2, 1))
     phidot = np.array([1, 1]).reshape((2, 1))
     H = np.array([1]).reshape((1, 1))
     modes = np.array([[1, 1j], [-1j, 3 - 1j]]).reshape((2, 2, 1))
     modesdot = np.array([[1, -1j], [1j, 3 + 1j]]).reshape((2, 2, 1))
     axis = 0
     arr = nonadiabatic.deltaPspectrum(Vphi, phidot, H, modes, modesdot,
                                       axis)
     desired = np.array([54])
     assert_almost_equal(arr, desired)
Exemple #9
0
 def test_two_by_two_by_one(self):
     """Test that 2x2x1 calculation works."""
     Vphi = np.array([1, 2]).reshape((2, 1))
     phidot = np.array([7, 9]).reshape((2, 1))
     modes = np.array([[1, 3], [2, 5]]).reshape((2, 2, 1))
     modesdot = np.array([[1, 3], [2, 5]]).reshape((2, 2, 1))
     axis = 0
     H = np.array([2]).reshape((1, 1))
     arr = nonadiabatic.deltaPspectrum(Vphi, phidot, H, modes, modesdot,
                                       axis)
     desired = np.array([6405**2 + 16909**2])
     assert_almost_equal(arr, desired)
Exemple #10
0
 def test_singlefield(self):
     """Test single field calculation."""
     modes = np.array([[7]])
     modesdot = np.array([[3]])
     Vphi = 3
     phidot = 1.7
     H = 0.5
     axis = 0
     actual = (0.5**2 * 1.7 * 3 - 0.5**3 * 1.7**2 * 1.7 * 7 - 21)**2
     arr = nonadiabatic.deltaPspectrum(Vphi, phidot, H, modes, modesdot,
                                       axis)
     assert_almost_equal(arr, actual)