def test_two_by_two_by_one(self): """Test results of 2x2x1 calculation.""" Vphi = np.array([[1, 2], [3, 9]]).reshape((2, 2, 1)) phidot = np.array([[5, 1], [7, 3]]).reshape((2, 2, 1)) H = np.array([[2], [1]]).reshape((2, 1, 1)) arr = nonadiabatic.Pdots(Vphi, phidot, H) actual = np.array([[-310, -16], [-189, -81]]).reshape((2, 2, 1)) assert_array_almost_equal(arr, actual)
def test_two_by_one_by_one(self): """Test results of 2x1x1 calculation.""" Vphi = np.array([5, 10]).reshape((2, 1, 1)) phidot = np.array([3, 6]).reshape((2, 1, 1)) H = np.array([1, 2]).reshape((2, 1, 1)) arr = nonadiabatic.Pdots(Vphi, phidot, H) actual = np.array([-57, -552]).reshape((2, 1, 1)) assert_array_almost_equal(arr, actual)
def test_compare_cs(self): """Compare to result from cs^2 equations.""" cs = nonadiabatic.soundspeeds(self.Vphi, self.phidot, self.H) rhodots = nonadiabatic.rhodots(self.phidot, self.H) prdots = nonadiabatic.Pdots(self.Vphi, self.phidot, self.H) assert_almost_equal(cs, prdots / rhodots)
def test_scalar(self): """Test results of 1x1x1 calculation.""" arr = nonadiabatic.Pdots(3, 0.5, 2) assert_(arr == -6)
def test_shape(self): """Test whether the Pressures are shaped correctly.""" arr = nonadiabatic.Pdots(self.Vphi, self.phidot, self.H) assert_(arr.shape == self.Vphi.shape)