def test_shape(self):
     """Test whether the rhodots are shaped correctly."""    
     arr = nonadiabatic.deltaPnadmodes(self.Vphi, self.phidot, self.H, 
                                    self.modes, self.modesdot, self.axis)
     result = arr.shape
     actual = self.Vphi.shape
     assert_(result == actual, "Result shape %s, but desired shape is %s"%(str(result), str(actual)))
Exemple #2
0
 def test_shape(self):
     """Test whether the rhodots are shaped correctly."""
     arr = nonadiabatic.deltaPnadmodes(self.Vphi, self.phidot, self.H,
                                       self.modes, self.modesdot, self.axis)
     result = arr.shape
     actual = self.Vphi.shape
     assert_(
         result == actual, "Result shape %s, but desired shape is %s" %
         (str(result), str(actual)))
 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.deltaPnadmodes(Vphi, phidot, H, modes, modesdot, axis)
     assert_almost_equal(arr, np.array([-71.25]))
 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.deltaPnadmodes(Vphi, phidot, H, modes, modesdot, axis)
     desired = np.array([-3.0 +4*1j, -18 + 3*1j]).reshape((2,1))
     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.deltaPnadmodes(Vphi, phidot, H, modes, modesdot, axis)
     desired = np.array([3.884061, 16.1759427]).reshape((2,1))
     assert_almost_equal(arr, desired, decimal=5)
Exemple #6
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.deltaPnadmodes(Vphi, phidot, H, modes, modesdot,
                                       axis)
     assert_almost_equal(arr, np.array([-71.25]))
Exemple #7
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.deltaPnadmodes(Vphi, phidot, H, modes, modesdot,
                                       axis)
     desired = np.array([-3.0 + 4 * 1j, -18 + 3 * 1j]).reshape((2, 1))
     assert_almost_equal(arr, desired)
Exemple #8
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.deltaPnadmodes(Vphi, phidot, H, modes, modesdot,
                                       axis)
     desired = np.array([3.884061, 16.1759427]).reshape((2, 1))
     assert_almost_equal(arr, desired, decimal=5)
 def test_two_by_one_by_one(self):
     """Test results of 2x1x1 calculation."""
     Vphi = np.array([2,3]).reshape((2,1,1))
     phidot = np.array([3,6]).reshape((2,1,1))
     H = np.array([1,2]).reshape((2,1,1))
     
     modes = np.array([10,5]).reshape((2,1,1,1))
     modesdot = np.array([10,5]).reshape((2,1,1,1))
     axis = 2
     
     arr = nonadiabatic.deltaPnadmodes(Vphi, phidot, H, modes, modesdot, axis)
     actual = np.array([-2.22222222222, 138.75]).reshape((2,1,1))
     assert_array_almost_equal(arr, actual)
Exemple #10
0
    def test_two_by_one_by_one(self):
        """Test results of 2x1x1 calculation."""
        Vphi = np.array([2, 3]).reshape((2, 1, 1))
        phidot = np.array([3, 6]).reshape((2, 1, 1))
        H = np.array([1, 2]).reshape((2, 1, 1))

        modes = np.array([10, 5]).reshape((2, 1, 1, 1))
        modesdot = np.array([10, 5]).reshape((2, 1, 1, 1))
        axis = 2

        arr = nonadiabatic.deltaPnadmodes(Vphi, phidot, H, modes, modesdot,
                                          axis)
        actual = np.array([-2.22222222222, 138.75]).reshape((2, 1, 1))
        assert_array_almost_equal(arr, actual)