def test_shape(self):
     """Test whether the rhodots are shaped correctly."""    
     arr = nonadiabatic.deltaPnadspectrum(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.deltaPnadspectrum(Vphi, phidot, H, modes, modesdot, axis)
     assert_((not np.iscomplexobj(arr)))
 def test_singlefield(self):
     """Test single field calculation."""
     modes = np.array([[7]])
     modesdot = np.array([[5]])
     Vphi = 3
     phidot = 0.5
     H = 2
     axis=0
     arr = nonadiabatic.deltaPnadspectrum(Vphi, phidot, H, modes, modesdot, axis)
     assert_almost_equal(arr, (-71.25)**2)
 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.deltaPnadspectrum(Vphi, phidot, H, modes, modesdot, axis)
     desired = np.array([358])
     assert_almost_equal(arr, desired)
 def test_two_by_two_by_one(self):
     """Test that 2x2x1 calculation works."""
     Vphi = np.array([5.5,2.3]).reshape((2,1))
     phidot = np.array([2,5]).reshape((2,1))
     modes = np.array([[1/3.0,0.1],[0.1,0.5]]).reshape((2,2,1))
     modesdot = np.array([[0.1,0.2],[0.2,1/7.0]]).reshape((2,2,1))
     axis = 0
     H = np.array([3]).reshape((1,1))
     arr = nonadiabatic.deltaPnadspectrum(Vphi, phidot, H, modes, modesdot, axis)
     desired = np.array([3.884061**2 + 16.1759427**2])
     assert_almost_equal(arr, desired, decimal=4)
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.deltaPnadspectrum(Vphi, phidot, H, modes, modesdot,
                                          axis)
     assert_((not np.iscomplexobj(arr)))
Exemple #7
0
 def test_singlefield(self):
     """Test single field calculation."""
     modes = np.array([[7]])
     modesdot = np.array([[5]])
     Vphi = 3
     phidot = 0.5
     H = 2
     axis = 0
     arr = nonadiabatic.deltaPnadspectrum(Vphi, phidot, H, modes, modesdot,
                                          axis)
     assert_almost_equal(arr, (-71.25)**2)
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.deltaPnadspectrum(Vphi, phidot, H, modes, modesdot,
                                          axis)
     desired = np.array([358])
     assert_almost_equal(arr, desired)
Exemple #9
0
 def test_two_by_two_by_one(self):
     """Test that 2x2x1 calculation works."""
     Vphi = np.array([5.5, 2.3]).reshape((2, 1))
     phidot = np.array([2, 5]).reshape((2, 1))
     modes = np.array([[1 / 3.0, 0.1], [0.1, 0.5]]).reshape((2, 2, 1))
     modesdot = np.array([[0.1, 0.2], [0.2, 1 / 7.0]]).reshape((2, 2, 1))
     axis = 0
     H = np.array([3]).reshape((1, 1))
     arr = nonadiabatic.deltaPnadspectrum(Vphi, phidot, H, modes, modesdot,
                                          axis)
     desired = np.array([3.884061**2 + 16.1759427**2])
     assert_almost_equal(arr, desired, decimal=4)
Exemple #10
0
 def test_shape(self):
     """Test whether the rhodots are shaped correctly."""
     arr = nonadiabatic.deltaPnadspectrum(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)))